From: x2001corpet Date: Sun, 1 Oct 2006 13:35:24 +0000 (+0000) Subject: titre different pour le sujet du mail et le titre dans le mail X-Git-Tag: xorg/0.9.11~28 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=e6f0208d23a2691a2e55a900326eb1b9af9346e6;p=platal.git titre different pour le sujet du mail et le titre dans le mail git-svn-id: svn+ssh://murphy/home/svn/platal/branches/platal-0.9.11@941 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index b7bba9c..5d81fa3 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -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(); } diff --git a/modules/events.php b/modules/events.php index 7c96566..895ef13 100644 --- a/modules/events.php +++ b/modules/events.php @@ -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(); diff --git a/templates/newsletter/edit.tpl b/templates/newsletter/edit.tpl index b19bfa3..0758901 100644 --- a/templates/newsletter/edit.tpl +++ b/templates/newsletter/edit.tpl @@ -48,6 +48,14 @@ + Titre du mail + + + + + + + Titre