X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=9e1a59bc3f0fbc6edc04046e6b86ecd56109cd8a;hb=9466051012a24391af2b769a4c281ed5588105bc;hp=482a61d14acde0b83cd94066b13470a4b1de796f;hpb=8269d2d652f539cd06117bac1e51f4e2182520b4;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 482a61d..9e1a59b 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1,6 +1,6 @@ addCssLink('nl.css'); -} - -define('FEMME', 1); -define('HOMME', 0); - -// }}} // {{{ class NewsLetter -class NewsLetter +class NewsLetter extends MassMailer { - // {{{ properties - - var $_id; - var $_shortname; - var $_date; - var $_title; - var $_title_mail; - var $_head; - var $_cats = Array(); - var $_arts = Array(); + public $_date; + public $_cats = Array(); + public $_arts = Array(); - // }}} - // {{{ constructor - - function NewsLetter($id=null) + function __construct($id = null) { + parent::__construct('newsletter/nl.mail.tpl', 'nl.css', 'nl/show', 'newsletter', 'newsletter_ins'); if (isset($id)) { if ($id == 'last') { $res = XDB::query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); @@ -60,7 +41,7 @@ class NewsLetter } else { $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); if (!$res->numRows()) { - insert_new_nl(); + Newsletter::create(); } $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); } @@ -77,7 +58,7 @@ class NewsLetter while (list($cid, $title) = $res->next()) { $this->_cats[$cid] = $title; } - + $res = XDB::iterRow( "SELECT a.title,a.body,a.append,a.aid,a.cid,a.pos FROM newsletter_art AS a @@ -90,269 +71,108 @@ class NewsLetter } } - // }}} - // {{{ function setSent() - - function setSent() - { - XDB::execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); - } - - // }}} - // {{{ function save() - - function save() + public function save() { XDB::execute('UPDATE newsletter SET date={?},titre={?},titre_mail={?},head={?},short_name={?} WHERE id={?}', $this->_date, $this->_title, $this->_title_mail, $this->_head, $this->_shortname,$this->_id); } - // }}} - // {{{ function id() - - function id() - { - return is_null($this->_shortname) ? $this->_id : $this->_shortname; - } - - // }}} - // {{{ function title() - - function title($mail = false) { - if ($mail) { - return $this->_title_mail; - } - return $this->_title; - } - - // }}} - // {{{ function head() - - function head() - { return $this->_head; } - - // }}} - // {{{ function getArt() - - function getArt($aid) + public function getArt($aid) { - foreach ($this->_arts as $key=>$artlist) { - if (isset($artlist["a$aid"])) { + foreach ($this->_arts as $key=>$artlist) { + if (isset($artlist["a$aid"])) { return $artlist["a$aid"]; } + } + return null; } - return null; - } - - // }}} - // {{{ function saveArticle() - function saveArticle(&$a) + public function saveArticle(&$a) { - if ($a->_aid>=0) { - XDB::execute('REPLACE INTO newsletter_art (id,aid,cid,pos,title,body,append) - VALUES ({?},{?},{?},{?},{?},{?},{?})', - $this->_id, $a->_aid, $a->_cid, $a->_pos, - $a->_title, $a->_body, $a->_append); - $this->_arts['a'.$a->_aid] = $a; - } else { - XDB::execute( - 'INSERT INTO newsletter_art - SELECT {?},MAX(aid)+1,{?},'.($a->_pos ? intval($a->_pos) : 'MAX(pos)+1').',{?},{?},{?} - FROM newsletter_art AS a - WHERE a.id={?}', - $this->_id, $a->_cid, $a->_title, $a->_body, $a->_append, $this->_id); - $this->_arts['a'.$a->_aid] = $a; - } + if ($a->_aid>=0) { + XDB::execute('REPLACE INTO newsletter_art (id,aid,cid,pos,title,body,append) + VALUES ({?},{?},{?},{?},{?},{?},{?})', + $this->_id, $a->_aid, $a->_cid, $a->_pos, + $a->_title, $a->_body, $a->_append); + $this->_arts['a'.$a->_aid] = $a; + } else { + XDB::execute('INSERT INTO newsletter_art + SELECT {?},MAX(aid)+1,{?},'.($a->_pos ? intval($a->_pos) : 'MAX(pos)+1').',{?},{?},{?} + FROM newsletter_art AS a + WHERE a.id={?}', + $this->_id, $a->_cid, $a->_title, $a->_body, $a->_append, $this->_id); + $this->_arts['a'.$a->_aid] = $a; + } } - // }}} - // {{{ function delArticle() - - function delArticle($aid) + public function delArticle($aid) { - XDB::execute('DELETE FROM newsletter_art WHERE id={?} AND aid={?}', $this->_id, $aid); - foreach ($this->_arts as $key=>$art) { - unset($this->_arts[$key]["a$aid"]); - } + XDB::execute('DELETE FROM newsletter_art WHERE id={?} AND aid={?}', $this->_id, $aid); + foreach ($this->_arts as $key=>$art) { + unset($this->_arts[$key]["a$aid"]); + } } - // }}} - // {{{ function footer - - function footer($html) + protected function assignData(&$smarty) { - global $globals; - $url = 'https://www.polytechnique.org'; - - if ($html) { - return '