X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=a60ecb39a2da343e608e66b32af4b2444aae36f0;hb=ad6ca77d8c628ace020c2da968dd0f7665620717;hp=b7bba9c734ed28dbff41f1c352193302bcc02382;hpb=6795ed86cd992c35a28c7a98c39d83ea8250279e;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index b7bba9c..a60ecb3 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -49,41 +49,41 @@ class NewsLetter function NewsLetter($id=null) { - if (isset($id)) { - if ($id == 'last') { - $res = XDB::query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); + if (isset($id)) { + if ($id == 'last') { + $res = XDB::query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); $id = $res->fetchOneCell(); - } - $res = XDB::query("SELECT * FROM newsletter WHERE id={?}", $id); - } else { - $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); + } + $res = XDB::query("SELECT * FROM newsletter WHERE id={?}", $id); + } else { + $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); if (!$res->numRows()) { insert_new_nl(); } $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); } - $nl = $res->fetchOneAssoc(); + $nl = $res->fetchOneAssoc(); - $this->_id = $nl['id']; - $this->_date = $nl['date']; - $this->_title = $nl['titre']; - $this->_head = $nl['head']; + $this->_id = $nl['id']; + $this->_date = $nl['date']; + $this->_title = $nl['titre']; + $this->_head = $nl['head']; - $res = XDB::iterRow("SELECT cid,titre FROM newsletter_cat ORDER BY pos"); - while (list($cid, $title) = $res->next()) { - $this->_cats[$cid] = $title; - } - - $res = XDB::iterRow( + $res = XDB::iterRow("SELECT cid,titre FROM newsletter_cat ORDER BY pos"); + 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 INNER JOIN newsletter AS n USING(id) LEFT JOIN newsletter_cat AS c ON(a.cid=c.cid) WHERE a.id={?} ORDER BY c.pos,a.pos", $this->_id); - while (list($title, $body, $append, $aid, $cid, $pos) = $res->next()) { - $this->_arts[$cid]["a$aid"] = new NLArticle($title, $body, $append, $aid, $cid, $pos); - } + while (list($title, $body, $append, $aid, $cid, $pos) = $res->next()) { + $this->_arts[$cid]["a$aid"] = new NLArticle($title, $body, $append, $aid, $cid, $pos); + } } // }}} @@ -91,7 +91,7 @@ class NewsLetter function setSent() { - XDB::execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); + XDB::execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); } // }}} @@ -99,7 +99,7 @@ class NewsLetter function save() { - XDB::execute('UPDATE newsletter SET date={?},titre={?},head={?} WHERE id={?}', + XDB::execute('UPDATE newsletter SET date={?},titre={?},head={?} WHERE id={?}', $this->_date, $this->_title, $this->_head, $this->_id); } @@ -120,12 +120,12 @@ class NewsLetter 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; } // }}} @@ -133,21 +133,21 @@ class NewsLetter function saveArticle(&$a) { - if ($a->_aid>=0) { - XDB::execute('REPLACE INTO newsletter_art (id,aid,cid,pos,title,body,append) + 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->_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; - } + $this->_arts['a'.$a->_aid] = $a; + } } // }}} @@ -155,10 +155,10 @@ class NewsLetter 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"]); + } } // }}} @@ -167,24 +167,24 @@ class NewsLetter function footer($html) { global $globals; - $url = $globals->baseurl; - - if ($html) { - return '