Bye xorg.misc.inc.php
[platal.git] / include / newsletter.inc.php
index 0ab9899..9e1a59b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -31,7 +31,7 @@ class NewsLetter extends MassMailer
 
     function __construct($id = null)
     {
-        parent::__construct('newsletter/nl.tpl', 'nl.css', 'nl/show', 'newsletter', 'newsletter_ins');
+        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'");
@@ -223,18 +223,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 = "<h2 class='xorg_nl'><a id='art{$this->_aid}'></a>".pl_entities($this->title()).'</h2>';
         $body  = MiniWiki::WikiToHTML($this->_body);
@@ -246,6 +252,11 @@ class NLArticle
             $art .= "<div class='app'>$app</div>";
         }
         $art  .= "</div>\n";
+        if (!is_null($hash) && !is_null($login)) {
+            $art = str_replace('%HASH%', "$hash/$login", $art);
+        } else {
+            $art = str_replace('%HASH%', '', $art);
+        }
 
         return $art;
     }