titre different pour le sujet du mail et le titre dans le mail
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 1 Oct 2006 13:35:24 +0000 (13:35 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 1 Oct 2006 13:35:24 +0000 (13:35 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/branches/platal-0.9.11@941 839d8a87-29fc-0310-9880-83ba4fa771e5

include/newsletter.inc.php
modules/events.php
templates/newsletter/edit.tpl

index b7bba9c..5d81fa3 100644 (file)
@@ -40,6 +40,7 @@ class NewsLetter
     var $_id;
     var $_date;
     var $_title;
+    var $_titleMail;
     var $_head;
     var $_cats = Array();
     var $_arts = Array();
@@ -67,6 +68,12 @@ class NewsLetter
        $this->_id    = $nl['id'];
        $this->_date  = $nl['date'];
        $this->_title = $nl['titre'];
+       if (($coupure = strpos($this->_title, '§|§')) !== false) {
+               $this->_titleMail = substr($this->_title, 0, $coupure);
+               $this->_title = substr($this->_title, $coupure + 3);
+       } else {
+               $this->_titleMail = $this->_title;
+       }
        $this->_head  = $nl['head'];
 
        $res = XDB::iterRow("SELECT cid,titre FROM newsletter_cat ORDER BY pos");
@@ -99,15 +106,24 @@ class NewsLetter
 
     function save()
     {
+       $title = $this->_title;
+       if ($this->_titleMail != $title && $this->_titleMail) {
+               $title = $this->_titleMail.'§|§'.$this->_title;
+       }
        XDB::execute('UPDATE newsletter SET date={?},titre={?},head={?} WHERE id={?}',
-                     $this->_date, $this->_title, $this->_head, $this->_id);
+                     $this->_date, $title, $this->_head, $this->_id);
     }
 
     // }}}
     // {{{ function title()
 
-    function title()
-    { return $this->_title; }
+    function title($email = false)
+    {
+                       if ($email) {
+                               return $this->_titleMail;
+                       }
+                       return $this->_title;
+               }
 
     // }}}
     // {{{ function head()
@@ -321,7 +337,7 @@ EOF;
 
        $mailer = new HermesMailer();
        $mailer->setFrom($globals->newsletter->from);
-       $mailer->setSubject($this->title());
+       $mailer->setSubject($this->title(true));
        $mailer->addTo("\"$prenom $nom\" <$login@{$globals->mail->domain}>");
         if (!empty($globals->newsletter->replyto)) {
             $mailer->addHeader('Reply-To',$globals->newsletter->replyto);
@@ -443,13 +459,13 @@ function insert_new_nl()
 
 function get_nl_slist()
 {
-    $res = XDB::query("SELECT id,date,titre FROM newsletter ORDER BY date DESC");
+    $res = XDB::query("SELECT id,date,IF(LOCATE('§|§',titre),LEFT(titre, LOCATE('§|§',titre)-1),titre) AS titre FROM newsletter ORDER BY date DESC");
     return $res->fetchAllAssoc();
 }
 
 function get_nl_list()
 {
-    $res = XDB::query("SELECT id,date,titre FROM newsletter WHERE bits!='new' ORDER BY date DESC");
+    $res = XDB::query("SELECT id,date,IF(LOCATE('§|§',titre),LEFT(titre, LOCATE('§|§',titre)-1),titre) AS titre FROM newsletter WHERE bits!='new' ORDER BY date DESC");
     return $res->fetchAllAssoc();
 }
 
index 7c96566..895ef13 100644 (file)
@@ -376,6 +376,7 @@ class EventsModule extends PLModule
         
         if($aid == 'update') {
             $nl->_title = Post::v('title');
+            $nl->_titleMail = Post::v('titleMail');
             $nl->_date  = Post::v('date');
             $nl->_head  = Post::v('head');
             $nl->save();
index b19bfa3..0758901 100644 (file)
     </tr>
     <tr>
       <td class='titre'>
+        Titre du mail
+      </td>
+      <td>
+        <input type='text' size='60' name='titleMail' value="{$nl->title(true)}" />
+      </td>
+    </tr>
+    <tr>
+      <td class='titre'>
         Titre
       </td>
       <td>