X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=c58844e478cc7e09e5b16cc10f710f8d0d95072d;hb=1f58ccb1e75eca08fbd04971d617ea372bc77b5a;hp=1c58f0a42fd5b78cbd6165a7d54ddfcd3072a396;hpb=b71f7275d0abe31614da74e05524ac08033bbe18;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 1c58f0a..c58844e 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1,6 +1,6 @@ numRows() != 1) { + throw new MailNotFound(); + } $nl = $res->fetchOneAssoc(); $this->_id = $nl['id']; @@ -223,18 +226,24 @@ class NLArticle // }}} // {{{ function toText() - public function toText() + public function toText($hash = null, $login = null) { $title = '*'.$this->title().'*'; $body = MiniWiki::WikiToText($this->_body, true); $app = MiniWiki::WikiToText($this->_append,false,4); - return trim("$title\n\n$body\n\n$app")."\n"; + $text = trim("$title\n\n$body\n\n$app")."\n"; + if (!is_null($hash) && !is_null($login)) { + $text = str_replace('%HASH%', "$hash/$login", $text); + } else { + $text = str_replace('%HASH%', '', $text); + } + return $text; } // }}} // {{{ function toHtml() - public function toHtml() + public function toHtml($hash = null, $login = null) { $title = "

".pl_entities($this->title()).'

'; $body = MiniWiki::WikiToHTML($this->_body); @@ -246,6 +255,11 @@ class NLArticle $art .= "
$app
"; } $art .= "\n"; + if (!is_null($hash) && !is_null($login)) { + $art = str_replace('%HASH%', "$hash/$login", $art); + } else { + $art = str_replace('%HASH%', '', $art); + } return $art; }