X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=b7bba9c734ed28dbff41f1c352193302bcc02382;hb=c46ec4752db88dbde3f792a278f350c922cd211d;hp=06d3e54fcbdddb81c264556f1227d21bb2383c3a;hpb=cab0809050d58f8484608e91f7555ebd69dcb451;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 06d3e54..b7bba9c 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -22,10 +22,9 @@ // {{{ requires + defines require_once("xorg.misc.inc.php"); -require_once("diogenes/diogenes.misc.inc.php"); if (isset($page)) { - $page->addCssLink('css/nl.css'); + $page->addCssLink('nl.css'); } define('FEMME', 1); @@ -58,7 +57,11 @@ class NewsLetter $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(); $this->_id = $nl['id']; @@ -88,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); } // }}} @@ -231,15 +234,16 @@ class NewsLetter // }}} // {{{ function toHtml() - function toHtml($prenom,$nom,$sexe,$body=false) + function toHtml($prenom, $nom, $sexe, $body=false, $urlprefix = false) { + $u = $urlprefix ? 'nl/show/'.$this->_id : ''; $res = '
'.$this->title().'
'; $head = $this->head(); $head = str_replace('', $sexe ? 'Chère' : 'Cher', $head); $head = str_replace('', $prenom, $head); $head = str_replace('', $nom, $head); - $head = enriched_to_text($head,true); + $head = enriched_to_text($head, true); if($head) { $res .= "
$head
"; @@ -248,9 +252,9 @@ class NewsLetter $i = 1; $res .= ""; foreach ($this->_arts as $cid=>$arts) { - $res .= "
$i. {$this->_cats[$cid]}"; + $res .= "
$i. {$this->_cats[$cid]}"; foreach ($arts as $art) { - $res .= "  - ".htmlentities($art->title()).""; + $res .= "  - ".htmlentities($art->title()).""; } $res .= '
'; $i ++; @@ -260,7 +264,7 @@ class NewsLetter $res .= "

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

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

Revenir au sommaire

"; + $res .= "

Revenir au sommaire

"; } }