tpl.mailer goes into xorg
authorx2000habouzit <x2000habouzit>
Mon, 22 Nov 2004 07:40:16 +0000 (07:40 +0000)
committerx2000habouzit <x2000habouzit>
Mon, 22 Nov 2004 07:40:16 +0000 (07:40 +0000)
12 files changed:
htdocs/admin/newsletter_pattecassee.php
htdocs/inscription/step3.php
htdocs/inscription/step4.php
htdocs/marketing/relance.php
htdocs/marketing/utilisateurs_marketing.php
include/user.func.inc.php
include/validations/aliases.inc.php
include/validations/epouses.inc.php
include/validations/evts.inc.php
include/validations/listes.inc.php
include/validations/photos.inc.php
include/xorg.mailer.inc.php [moved from include/tpl.mailer.inc.php with 76% similarity]

index c561a5d..f9fb888 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: newsletter_pattecassee.php,v 1.5 2004-09-02 23:33:56 x2000bedo Exp $
+        $Id: newsletter_pattecassee.php,v 1.6 2004-11-22 07:40:16 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -36,7 +36,7 @@ function valide_email($str) {
 
 }
 
-require("tpl.mailer.inc.php");
+require("xorg.mailer.inc.php");
 
 if (array_key_exists('email', $_GET) && array_key_exists('action', $_GET)) {
     $email = valide_email($_GET['email']);
@@ -48,7 +48,7 @@ if (array_key_exists('email', $_GET) && array_key_exists('action', $_GET)) {
        INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie')
        WHERE e.email='$email'");
        
-    $mailer = new TplMailer('templates/mails/pattecasser.nl.tpl');
+    $mailer = new XOrgMailer('templates/mails/pattecasser.nl.tpl');
     $mailer->assign('email', $email);
     
     if (list($dest) = mysql_fetch_row($sel)) {
index 546a4fc..8ff49c6 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: step3.php,v 1.4 2004-11-21 23:35:31 x2000habouzit Exp $
+        $Id: step3.php,v 1.5 2004-11-22 07:40:16 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -73,8 +73,8 @@ $globals->db->query("UPDATE auth_user_md5 SET last_known_email='{$_REQUEST['emai
 if(isset($_REQUEST['envoidirect']))
     $globals->db->query("UPDATE envoidirect SET date_succes=NOW() WHERE uid='{$_REQUEST['envoidirect']}'");
 
-require("tpl.mailer.inc.php");
-$mymail = new TplMailer('inscrire.mail.tpl');
+require("xorg.mailer.inc.php");
+$mymail = new XOrgMailer('inscrire.mail.tpl');
 $mymail->assign('forlife',$forlife);
 $mymail->assign('lemail',$_REQUEST['email']);
 $mymail->assign('pass_clair',$pass_clair);
index 5af0e05..7007851 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: step4.php,v 1.16 2004-11-21 23:35:31 x2000habouzit Exp $
+        $Id: step4.php,v 1.17 2004-11-22 07:40:16 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
 new_skinned_page('inscription/step4.tpl', AUTH_PUBLIC);
 
 require("user.func.inc.php");
-require('tpl.mailer.inc.php');
+require('xorg.mailer.inc.php');
 
 define("ERROR_REF", 1);
 define("ERROR_ALREADY_SUBSCRIBED", 2);
@@ -106,7 +106,7 @@ if (!empty($_REQUEST['ref'])) {
                            INNER JOIN  aliases     AS a ON ( a.id = e.sender AND a.type='a_vie' )
                                  WHERE  e.matricule = '$matricule'");
     while (list($sender_usern, $sender_date) = mysql_fetch_row($res)) {
-        $mymail = new TplMailer('marketing.thanks.tpl');
+        $mymail = new XOrgMailer('marketing.thanks.tpl');
         $mymail->assign('to', $sender_usern);
         $mymail->assign('prenom', $prenom);
         $mymail->assign('nom',$nom);
@@ -134,7 +134,7 @@ if (!empty($_REQUEST['ref'])) {
     $globals->db->query("insert into user_changes ($uid)");
 
     // envoi du mail à l'inscrit
-    $mymail = new TplMailer('inscription.reussie.tpl');
+    $mymail = new XOrgMailer('inscription.reussie.tpl');
     $mymail->assign('forlife', $forlife);
     $mymail->assign('prenom', $prenom);
     $mymail->send();
index 13f69ff..2e5c637 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: relance.php,v 1.5 2004-11-21 23:35:32 x2000habouzit Exp $
+        $Id: relance.php,v 1.6 2004-11-22 07:40:17 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -27,7 +27,7 @@ new_admin_page('marketing/relance.tpl');
 
 /* une relance a été demandée - on envoit les mails correspondants */
 if (isset($_POST["relancer"]) && isset($_POST["relancer"]) != "") {
-    require("tpl.mailer.inc.php");
+    require("xorg.mailer.inc.php");
     
     
     $res=$globals->db->query("SELECT COUNT(*) FROM auth_user_md5");
@@ -47,7 +47,7 @@ if (isset($_POST["relancer"]) && isset($_POST["relancer"]) != "") {
             $lpass = md5($nveau_pass);
             $fdate = substr($ldate, 8, 2)."/".substr($ldate, 5, 2)."/".substr($ldate, 0, 4);
             
-            $mymail = new TplMailer('marketing.relance.tpl');
+            $mymail = new XOrgMailer('marketing.relance.tpl');
             $mymail->assign('nbdix',$nbdix);
             $mymail->assign('fdate',$fdate);
             $mymail->assign('lusername',$lusername);
index b5f7ca7..fd346a8 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: utilisateurs_marketing.php,v 1.11 2004-11-21 23:35:32 x2000habouzit Exp $
+        $Id: utilisateurs_marketing.php,v 1.12 2004-11-22 07:40:17 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
@@ -100,8 +100,8 @@ switch ($_REQUEST["submit"]) {
        // pas d'erreur pour l'insert
 
        // envoi du mail à l'utilisateur
-       require('tpl.mailer.inc.php');
-       $mymail = new TplMailer('marketing.utilisateur.tpl');
+       require('xorg.mailer.inc.php');
+       $mymail = new XOrgMailer('marketing.utilisateur.tpl');
 
        $mymail->assign('from', $_REQUEST["from"]);
        $mymail->assign('to', stripslashes($_REQUEST["mail"]));
index 32b39b0..1552bab 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: user.func.inc.php,v 1.4 2004-11-18 17:39:10 x2000habouzit Exp $
+    $Id: user.func.inc.php,v 1.5 2004-11-22 07:40:17 x2000habouzit Exp $
  ***************************************************************************/
 
-
+// {{{ function user_clear_all_subs()
 /** kills the inscription of a user.
  * we still keep his birthdate, adresses, and personnal stuff
  * kills the entreprises, mentor, emails and lists subscription stuff
  */
-function user_clear_all_subs($user_id, $really_del=true) {
+function user_clear_all_subs($user_id, $really_del=true)
+{
     // keep datas in : aliases, adresses, applis_ins, binets_ins, contacts, groupesx_ins, homonymes, identification_ax, photo
     // delete in     : auth_user_md5, auth_user_quick, competences_ins, emails, entreprises, langues_ins, mentor,
     //                 mentor_pays, mentor_secteurs, newsletter_ins, perte_pass, requests, user_changes, virtual_redirect, watch_sub
@@ -38,7 +39,7 @@ function user_clear_all_subs($user_id, $really_del=true) {
     list($alias) = mysql_fetch_row($res);
     mysql_free_result($res);
 
-    if($really_del) {
+    if ($really_del) {
        $globals->db->query("delete from emails where uid=$uid");
        $globals->db->query("delete from newsletter_ins where user_id=$uid");
     }
@@ -64,14 +65,18 @@ function user_clear_all_subs($user_id, $really_del=true) {
     $client = new xmlrpc_client("http://{$_SESSION['uid']}:{$_SESSION['password']}@localhost:4949/polytechnique.org");
     $client->kill($alias, $really_del);
 }
+
+// }}}
+// {{{ function inscription_forum_promo()
+
 /** inscrit l'uid donnée au forum promo 
  * @param $uid UID
  * @param $promo promo
  * @return la reponse MySQL
  * @see step4.php
  */
-function inscription_forum_promo($uid,$promo) {
+function inscription_forum_promo($uid,$promo)
+{
     global $globals;
     // récupération de l'id du forum promo
     $result=$globals->db->query("SELECT fid FROM forums.list WHERE nom='xorg.promo.x$promo'");
@@ -81,8 +86,8 @@ function inscription_forum_promo($uid,$promo) {
        $req_id=$globals->db->query("SELECT count(*) FROM auth_user_md5 WHERE promo='$promo'");
        list($effid) = mysql_fetch_row($req_id);
        if (5*$effau>$effid) { // + de 20% d'inscrits
-           require_once("tpl.mailer.inc.php");
-           $mymail = new TplMailer('forums.promo.tpl');
+           require_once("xorg.mailer.inc.php");
+           $mymail = new XOrgMailer('forums.promo.tpl');
            $mymail->assign('promo', $promo);
            $mymail->send();
        }
@@ -96,12 +101,16 @@ function inscription_forum_promo($uid,$promo) {
     return $res;
 } 
 
+// }}}
+// {{{ function inscription_forums()
+
 /** inscrit UID aux forums par défaut
  * @param $uid UID
  * @return la reponse MySQL globale
  * @see step4.php
  */
-function inscription_forums($uid) {
+function inscription_forums($uid)
+{
     global $globals;
     $res = true;
     $cible = array('xorg.general','xorg.pa.emploi','xorg.pa.divers','xorg.pa.logements');
@@ -114,6 +123,8 @@ function inscription_forums($uid) {
     return $res;
 }
 
+// }}}
+// {{{ function inscription_listes_base()
 
 /** inscrit l'uid donnée à la promo
  * @param $uid UID
@@ -122,7 +133,8 @@ function inscription_forums($uid) {
  * @see admin/RegisterNewUser.php
  * @see step4.php
  */
-function inscription_listes_base($uid,$pass,$promo) {
+function inscription_listes_base($uid,$pass,$promo)
+{
     require_once('xml-rpc-client.inc.php');
     require_once('newsletter.inc.php');
     global $globals;
@@ -132,4 +144,7 @@ function inscription_listes_base($uid,$pass,$promo) {
     subscribe_nl();
 }
 
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
index 8a0e3fe..b1ada27 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: aliases.inc.php,v 1.1 2004-11-22 07:24:56 x2000habouzit Exp $
+    $Id: aliases.inc.php,v 1.2 2004-11-22 07:40:18 x2000habouzit Exp $
  ***************************************************************************/
 
 // {{{ class AliasReq
@@ -89,8 +89,8 @@ class AliasReq extends Validate
             return false;
         }
 
-        require_once("tpl.mailer.inc.php");
-        $mymail = new TplMailer('valid.alias.tpl');
+        require_once("xorg.mailer.inc.php");
+        $mymail = new XOrgMailer('valid.alias.tpl');
         $mymail->assign('alias', $this->alias);
         $mymail->assign('bestalias', $this->bestalias);
 
index 9f0002d..76dd6e4 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: epouses.inc.php,v 1.1 2004-11-22 07:24:56 x2000habouzit Exp $
+    $Id: epouses.inc.php,v 1.2 2004-11-22 07:40:18 x2000habouzit Exp $
  ***************************************************************************/
 
 // {{{ class EpouseReq
@@ -86,8 +86,8 @@ class EpouseReq extends Validate
             return false;
         }
 
-        require_once("tpl.mailer.inc.php");
-        $mymail = new TplMailer('valid.epouses.tpl');
+        require_once("xorg.mailer.inc.php");
+        $mymail = new XOrgMailer('valid.epouses.tpl');
         $mymail->assign('forlife', $this->forlife);
 
         if ($_REQUEST['submit']=="Accepter") {
index 5231d92..55831e7 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: evts.inc.php,v 1.1 2004-11-22 07:24:56 x2000habouzit Exp $
+    $Id: evts.inc.php,v 1.2 2004-11-22 07:40:18 x2000habouzit Exp $
  ***************************************************************************/
 
 // {{{ class EvtReq
@@ -85,8 +85,8 @@ class EvtReq extends Validate
     {
         global $globals;
         if (isset($_POST['action'])) {
-            require("tpl.mailer.inc.php");
-            $mymail = new TplMailer('valid.evts.tpl');
+            require("xorg.mailer.inc.php");
+            $mymail = new XOrgMailer('valid.evts.tpl');
             $mymail->assign('bestalias',$this->bestalias);
             $mymail->assign('titre',$this->titre);
 
index 5b1737e..eb0e9df 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: listes.inc.php,v 1.1 2004-11-22 07:24:56 x2000habouzit Exp $
+    $Id: listes.inc.php,v 1.2 2004-11-22 07:40:18 x2000habouzit Exp $
  ***************************************************************************/
 
 // {{{ class ListeReq
@@ -89,8 +89,8 @@ class ListeReq extends Validate
             return false;
         }
 
-        require_once("tpl.mailer.inc.php");
-        $mymail = new TplMailer('valid.liste.tpl');
+        require_once("xorg.mailer.inc.php");
+        $mymail = new XOrgMailer('valid.liste.tpl');
         $mymail->assign('alias', $this->liste);
         $mymail->assign('bestalias', $this->bestalias);
         $mymail->assign('motif', stripslashes($_REQUEST['motif']));
index ec55ba8..fa5c932 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: photos.inc.php,v 1.1 2004-11-22 07:24:56 x2000habouzit Exp $
+    $Id: photos.inc.php,v 1.2 2004-11-22 07:40:18 x2000habouzit Exp $
  ***************************************************************************/
 
 // {{{ class PhotoReq
@@ -119,8 +119,8 @@ class PhotoReq extends Validate
             return false;
         }
         
-        require_once("tpl.mailer.inc.php");
-        $mymail = new TplMailer('valid.photos.tpl');
+        require_once("xorg.mailer.inc.php");
+        $mymail = new XOrgMailer('valid.photos.tpl');
         $mymail->assign('bestalias', $this->bestalias);
 
         if ($_REQUEST['submit']=="Accepter") {
similarity index 76%
rename from include/tpl.mailer.inc.php
rename to include/xorg.mailer.inc.php
index d00547b..3961c9a 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: tpl.mailer.inc.php,v 1.5 2004-11-16 20:59:06 x2000habouzit Exp $
+    $Id: xorg.mailer.inc.php,v 1.1 2004-11-22 07:40:17 x2000habouzit Exp $
  ***************************************************************************/
 
 require_once("diogenes.hermes.inc.php");
 require_once("Smarty.class.php");
 
+// {{{ class XOrgMailer
+
 /** Classe de mail avec corps en templates.
  */
-class TplMailer extends Smarty {
+class XOrgMailer extends Smarty
+{
+    // {{{ properties
+    
     /** Directory used to store mails_templates.
      * Smarty::template_dir subdir used to sotre the mails templates.
      * The body of the message is taken from a tsmarty template
@@ -45,8 +50,12 @@ class TplMailer extends Smarty {
     var $_bcc = Array();
     /** stores the subject of the mail */
     var $_subject;
+
+    // }}}
+    // {{{ constructor
     
-    function TplMailer($tpl) {
+    function TplMailer($tpl)
+    {
         global $globals;
         $this->_tpl = $tpl;
         $this->caching=false;
@@ -64,7 +73,11 @@ class TplMailer extends Smarty {
         $this->register_function('subject', 'set_subject');
     }
 
-    function send() {
+    // }}}
+    // {{{ function send()
+
+    function send()
+    {
         // do not try to optimize, in the templates, some function can modify our object, then we
         // have to fetch in the first time, and only then send the mail.
         $body = $this->fetch($this->mail_dir."/".$this->_tpl);
@@ -72,51 +85,94 @@ class TplMailer extends Smarty {
        $mailer->setFrom($this->_from);
        $mailer->addTo(implode(',',$this->_to));
        $mailer->setSubject($this->_subject);
-       if (!empty($this->_cc)) $mailer->addCc(implode(',',$this->_cc));
-       if (!empty($this->_bcc)) $mailer->addBcc(implode(',',$this->_bcc));
+       if (!empty($this->_cc)) {
+            $mailer->addCc(implode(',',$this->_cc));
+        }
+       if (!empty($this->_bcc)) {
+            $mailer->addBcc(implode(',',$this->_bcc));
+        }
         $mailer->setTxtBody($body);
         $mailer->send();
     }
+
+    // }}}
 }
 
+// }}}
+// {{{ function mail_format()
+
 /** used to remove the empty lines due to {from ...}, {to ...} ... functions */
-function mail_format($output, &$smarty) {
+function mail_format($output, &$smarty)
+{
     return wordwrap("\n".trim($output)."\n",75);
 }
 
-function format_addr(&$params) {
-    if(isset($params['full']))
+// }}}
+// {{{ function format_addr()
+
+function format_addr(&$params)
+{
+    if (isset($params['full'])) {
         return $params['full'];
-    if(empty($params['text']))
+    } elseif (empty($params['text'])) {
         return $params['addr'];
-    else
+    } else {
         return $params['text'].' <'.$params['addr'].'>';
+    }
 }
 
+// }}}
+// {{{ function set_from()
+
 /** template function : from.
  * {from full=...} for an already formatted address
  * {from addr=... [text=...]} else
  */
-function set_from($params, &$smarty) { $smarty->_from  = format_addr($params); }
+function set_from($params, &$smarty)
+{ $smarty->_from = format_addr($params); }
+
+// }}}
+// {{{ function set_to()
+
 /** template function : to.
  * {to full=...} for an already formatted address
  * {to addr=... [text=...]} else
  */
-function set_to($params, &$smarty)   { $smarty->_to[]  = format_addr($params); }
+function set_to($params, &$smarty)
+{ $smarty->_to[] = format_addr($params); }
+
+// }}}
+// {{{ function set_cc()
+
 /** template function : cc.
  * {cc full=...} for an already formatted address
  * {cc addr=... [text=...]} else
  */
-function set_cc($params, &$smarty)   { $smarty->_cc[]  = format_addr($params); }
+function set_cc($params, &$smarty)
+{ $smarty->_cc[] = format_addr($params); }
+
+// }}}
+// {{{ function set_bcc()
+
 /** template function : bcc.
  * {bcc full=...} for an already formatted address
  * {bcc addr=... [text=...]} else
  */
-function set_bcc($params, &$smarty)  { $smarty->_bcc[] = format_addr($params); }
+function set_bcc($params, &$smarty)
+{ $smarty->_bcc[] = format_addr($params); }
+
+// }}}
+// {{{ function set_subject()
+
 /** template function : subject.
  * {subject text=...} 
  */
-function set_subject($params, &$smarty) {
+function set_subject($params, &$smarty)
+{
     $smarty->_subject = $params['text'];
 }
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>