X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=06d3e54fcbdddb81c264556f1227d21bb2383c3a;hb=cab0809050d58f8484608e91f7555ebd69dcb451;hp=9e960d37c5df73c0594d600372130ae2cd72c092;hpb=575dd9be519a557c47e1288eaa15b1e1446dd058;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 9e960d3..06d3e54 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1,6 +1,6 @@ xdb->query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); + $res = XDB::query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); $id = $res->fetchOneCell(); } - $res = $globals->xdb->query("SELECT * FROM newsletter WHERE id={?}", $id); + $res = XDB::query("SELECT * FROM newsletter WHERE id={?}", $id); } else { - $res = $globals->xdb->query("SELECT * FROM newsletter WHERE bits='new'"); + $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); } $nl = $res->fetchOneAssoc(); @@ -68,12 +66,12 @@ class NewsLetter $this->_title = $nl['titre']; $this->_head = $nl['head']; - $res = $globals->xdb->iterRow("SELECT cid,titre FROM newsletter_cat ORDER BY pos"); + $res = XDB::iterRow("SELECT cid,titre FROM newsletter_cat ORDER BY pos"); while (list($cid, $title) = $res->next()) { $this->_cats[$cid] = $title; } - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT a.title,a.body,a.append,a.aid,a.cid,a.pos FROM newsletter_art AS a INNER JOIN newsletter AS n USING(id) @@ -90,8 +88,7 @@ class NewsLetter function setSent() { - global $globals; - $globals->xdb->execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); + XDB::execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); } // }}} @@ -99,9 +96,8 @@ class NewsLetter function save() { - global $globals; - $globals->xdb->execute('UPDATE newsletter SET date={?},titre={?},head={?} WHERE id={?}', - $this->_date, $this->_title, $this->_head, $this->_id); + XDB::execute('UPDATE newsletter SET date={?},titre={?},head={?} WHERE id={?}', + $this->_date, $this->_title, $this->_head, $this->_id); } // }}} @@ -134,15 +130,14 @@ class NewsLetter function saveArticle(&$a) { - global $globals; if ($a->_aid>=0) { - $globals->xdb->execute('REPLACE INTO newsletter_art (id,aid,cid,pos,title,body,append) + 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 { - $globals->xdb->execute( + XDB::execute( 'INSERT INTO newsletter_art SELECT {?},MAX(aid)+1,{?},'.($a->_pos ? intval($a->_pos) : 'MAX(pos)+1').',{?},{?},{?} FROM newsletter_art AS a @@ -157,8 +152,7 @@ class NewsLetter function delArticle($aid) { - global $globals; - $globals->xdb->execute('DELETE FROM newsletter_art WHERE id={?} AND aid={?}', $this->_id, $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"]); } @@ -175,18 +169,18 @@ class NewsLetter if ($html) { return '
Cette lettre est envoyée à tous les Polytechniciens sur Internet par l\'intermédiaire de Polytechnique.org.
' . '
' - . "[archives | " - . "écrire dans la NL | " - . "ne plus recevoir]" + . "[archives | " + . "écrire dans la NL | " + . "ne plus recevoir]" . '
'; } else { return "\n\n--------------------------------------------------------------------\n" . "Cette lettre est envoyée à tous les Polytechniciens sur Internet par\n" . "l'intermédiaire de Polytechnique.org.\n" . "\n" - . "archives : [$url/newsletter/]\n" - . "écrire : [$url/newsletter/submit.php]\n" - . "ne plus recevoir: [$url/newsletter/?out=1]\n"; + . "archives : [$url/nl]\n" + . "écrire : [$url/nl/submit]\n" + . "ne plus recevoir: [$url/nl/out]\n"; } } @@ -252,6 +246,7 @@ class NewsLetter } $i = 1; + $res .= ""; foreach ($this->_arts as $cid=>$arts) { $res .= "
$i. {$this->_cats[$cid]}"; foreach ($arts as $art) { @@ -264,7 +259,8 @@ class NewsLetter foreach ($this->_arts as $cid=>$arts) { $res .= "

".$this->_cats[$cid].'

'; foreach($arts as $art) { - $res .= $art->toHtml(); + $res .= $art->toHtml(); + $res .= "

Revenir au sommaire

"; } } @@ -438,43 +434,37 @@ class NLArticle function insert_new_nl() { - global $globals; - $globals->xdb->execute("INSERT INTO newsletter SET bits='new',date=NOW(),titre='to be continued'"); + XDB::execute("INSERT INTO newsletter SET bits='new',date=NOW(),titre='to be continued'"); } function get_nl_slist() { - global $globals; - $res = $globals->xdb->query("SELECT id,date,titre FROM newsletter ORDER BY date DESC"); + $res = XDB::query("SELECT id,date,titre FROM newsletter ORDER BY date DESC"); return $res->fetchAllAssoc(); } function get_nl_list() { - global $globals; - $res = $globals->xdb->query("SELECT id,date,titre FROM newsletter WHERE bits!='new' ORDER BY date DESC"); + $res = XDB::query("SELECT id,date,titre FROM newsletter WHERE bits!='new' ORDER BY date DESC"); return $res->fetchAllAssoc(); } function get_nl_state() { - global $globals; - $res = $globals->xdb->query('SELECT 1 FROM newsletter_ins WHERE user_id={?}', Session::getInt('uid')); + $res = XDB::query('SELECT 1 FROM newsletter_ins WHERE user_id={?}', S::v('uid')); return $res->fetchOneCell(); } function unsubscribe_nl() { - global $globals; - $globals->xdb->execute('DELETE FROM newsletter_ins WHERE user_id={?}', Session::getInt('uid')); + XDB::execute('DELETE FROM newsletter_ins WHERE user_id={?}', S::v('uid')); } function subscribe_nl($uid=-1) { - global $globals; - $user = ($uid == -1) ? Session::getInt('uid') : $uid; - $globals->xdb->execute('REPLACE INTO newsletter_ins (user_id,last) - VALUES ({?}, 0)', $user); + $user = ($uid == -1) ? S::v('uid') : $uid; + XDB::execute('REPLACE INTO newsletter_ins (user_id,last) + VALUES ({?}, 0)', $user); } function justify($text,$n)