Add a new marketing on users who have no valid redirection
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 1 Aug 2006 15:48:28 +0000 (15:48 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 1 Aug 2006 15:48:28 +0000 (15:48 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@770 839d8a87-29fc-0310-9880-83ba4fa771e5

include/search/classes.inc.php
modules/marketing.php
templates/include/minifiche.tpl
templates/marketing/broken.tpl [new file with mode: 0644]

index 9ed011c..57f1d7d 100644 (file)
@@ -35,7 +35,8 @@ $globals->search->result_fields = '
                 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
                 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
                 es.label AS secteur, ef.fonction_fr AS fonction,
-                IF(n.nat=\'\',n.pays,n.nat) AS nat, n.a2 AS iso3166,';
+                IF(n.nat=\'\',n.pays,n.nat) AS nat, n.a2 AS iso3166,
+        COUNT(em.email) > 0 AS actif,';
 // hide private information if not logged
 if (S::logged()) 
        $globals->search->result_fields .='
@@ -64,7 +65,8 @@ $globals->search->result_where_statement = '
                 LEFT JOIN  geoloc_pays    AS n   ON (u.nationalite = n.a2)
                 LEFT JOIN  adresses       AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
                 LEFT JOIN  geoloc_pays    AS gp  ON (adr.country = gp.a2)
-                LEFT JOIN  geoloc_region  AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)';
+                LEFT JOIN  geoloc_region  AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)
+                LEFT JOIN  emails         AS em  ON (em.uid = u.user_id AND em.flags = \'active\')';
 
 // }}}
 // {{{ function display_lines()
index 68541b0..b9e4710 100644 (file)
@@ -32,6 +32,7 @@ class MarketingModule extends PLModule
 
             'marketing/private'    => $this->make_hook('private',    AUTH_MDP, 'admin'),
             'marketing/public'     => $this->make_hook('public',     AUTH_COOKIE),
+            'marketing/broken'     => $this->make_hook('broken',     AUTH_COOKIE),
         );
     }
 
@@ -158,6 +159,42 @@ class MarketingModule extends PLModule
         }
     }
 
+    function handler_broken(&$page, $uid = null)
+    {
+        $page->changeTpl('marketing/broken.tpl');
+
+        if (is_null($uid)) {
+            return;
+        }
+
+        $res = Xdb::query("SELECT  u.nom, u.prenom, u.promo, a.alias AS forlife
+                             FROM  auth_user_md5 AS u
+                       INNER JOIN  aliases       AS a ON a.id = u.user_id
+                            WHERE  u.user_id = {?}", S::i('uid'));
+        if (!$res->numRows()) {
+            return;
+        }
+        $user = $res->fetchOneAssoc();
+        $page->assign('user', $user);
+
+        $email = trim(Post::v('mail'));
+        if (Post::has('valide') && strlen($email) > 0) {
+            require_once('diogenes/diogenes.hermes.inc.php');
+            $mailer = new HermesMailer();
+            $mailer->setFrom(S::v('bestalias') . '@polytechnique.org');
+            $mailer->addTo('resetpass@polytechnique.org');
+            $mailer->setSubject("Proposition d'adresse mail pour " . $user['forlife']);
+
+            $message = S::v('nom') . ' ' . S::v('prenom') . ' (X' . S::v('promo') . ') '
+                     . 'propose l\'adresse suivante pour un camarade qui n\'a plus de '
+                     . 'redirections actives :' . "\n\n"
+                     . '* ' . $user['forlife'] . ' => ' . $email . "\n";
+            $mailer->setTxtBody(wordwrap($message, 78));
+            $mailer->send();
+            $page->assign('sent', true);
+        }
+    }
+
     function handler_promo(&$page, $promo = null)
     {
         $page->changeTpl('marketing/promo.tpl');
index f02c3e3..8ec3227 100644 (file)
@@ -87,7 +87,7 @@
 
   <div class="long">
   {if $c.wasinscrit}
-    {if $c.web || $c.mobile || $c.countrytxt || $c.city || $c.region || $c.entreprise || $c.freetext}
+    {if $c.web || $c.mobile || $c.countrytxt || $c.city || $c.region || $c.entreprise || $c.freetext || (!$c.dcd && !$c.actif )}
     <table cellspacing="0" cellpadding="0">
       {if $c.web}
       <tr>
         <td class="rt">{$c.freetext|nl2br}</td>
       </tr>
       {/if}
+      {if !$c.dcd && !$c.actif && $c.wasinscrit}
+      <tr>
+        <td class="smaller" colspan="2">
+          Ce camarade n'a plus d'adresse redirection valide.
+          <a href="marketing/broken/{$c.user_id}">
+            Si tu en connais une, <strong>n'hésite pas à nous la transmettre</strong>
+          </a>
+        </td>
+      </tr>
+      {/if}
     </table>
     {/if}
   {/if}
diff --git a/templates/marketing/broken.tpl b/templates/marketing/broken.tpl
new file mode 100644 (file)
index 0000000..4fd9ee0
--- /dev/null
@@ -0,0 +1,67 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2006 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+
+{if $sent}
+
+<p>
+  Merci de nous avoir communiqué cette information !
+</p>
+
+{elseif $user}
+
+<h1>
+  Recherche d'adresses pour {$user.nom} {$user.prenom} (X{$user.promo})
+</h1>
+
+<p>
+  Avec le temps toutes les adresses de redirection de notre camarade sont devenues invalides et produisent
+  des erreurs lorsqu'on lui envoie un mail. Nous sommes donc à la recherche d'adresses valides où nous pourrions
+  contacter ce camarade.
+</p>
+<p>
+  Les adresses emails qui tu pourras nous donner ne seront pas ajouter directement aux redirections de {$user.prenom}.
+</p>
+<p>
+  Merci de participer à cette recherche.
+</p>
+
+<form method="post" action="{$platal->path}">
+  <table class="bicol" summary="Fiche camarade">
+    <tr class="impair"><td>Nom :</td><td>{$user.nom}</td></tr>
+    <tr class="pair"><td>Prénom :</td><td>{$user.prenom}</td></tr>
+    <tr class="impair"><td>Promo :</td><td>{$user.promo}</td></tr>
+    <tr class="pair">
+      <td>Adresse email :</td>
+      <td>
+        <input type="text" name="mail" size="30" maxlength="50" />
+      </td>
+    </tr>
+  </table>
+  <div class="center">
+    <input type="submit" name="valide" value="Valider" />
+  </div>
+</form>
+{/if}
+
+
+{* vim:set et sw=2 sts=2 sws=2: *}