X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fnewsletter.inc.php;h=9e1a59bc3f0fbc6edc04046e6b86ecd56109cd8a;hb=f70f2bcdc077c220e40ecebaf569e097f6028743;hp=386ef1661833a7474babeb2bf901c55ccf3d9e37;hpb=fc9d9368a4c8781f26a34a8f28523073d645f508;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 386ef16..9e1a59b 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1,6 +1,6 @@ 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 @@ -76,7 +76,7 @@ class NewsLetter extends MassMailer XDB::execute('UPDATE newsletter SET date={?},titre={?},titre_mail={?},head={?},short_name={?} WHERE id={?}', $this->_date, $this->_title, $this->_title_mail, $this->_head, $this->_shortname,$this->_id); } - + public function getArt($aid) { foreach ($this->_arts as $key=>$artlist) { @@ -104,7 +104,7 @@ class NewsLetter extends MassMailer $this->_arts['a'.$a->_aid] = $a; } } - + public function delArticle($aid) { XDB::execute('DELETE FROM newsletter_art WHERE id={?} AND aid={?}', $this->_id, $aid); @@ -121,7 +121,7 @@ class NewsLetter extends MassMailer protected function setSent() { XDB::execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); - } + } static public function subscriptionState($uid = null) { @@ -130,8 +130,8 @@ class NewsLetter extends MassMailer FROM newsletter_ins WHERE user_id={?}", $user); return $res->fetchOneCell(); - } - + } + static public function unsubscribe($uid = null) { $user = is_null($uid) ? S::v('uid') : $uid; @@ -181,7 +181,7 @@ class NewsLetter extends MassMailer class NLArticle { // {{{ properties - + var $_aid; var $_cid; var $_pos; @@ -191,7 +191,7 @@ class NLArticle // }}} // {{{ constructor - + function __construct($title='', $body='', $append='', $aid=-1, $cid=0, $pos=0) { $this->_body = $body; @@ -210,43 +210,54 @@ class NLArticle // }}} // {{{ function body() - + public function body() { return trim($this->_body); } - + // }}} // {{{ function append() - + public function append() { return trim($this->_append); } // }}} // {{{ function toText() - public function toText() + public function toText($hash = null, $login = null) { $title = '*'.$this->title().'*'; - $body = enriched_to_text($this->_body,false,true); - $app = enriched_to_text($this->_append,false,false,4); - return trim("$title\n\n$body\n\n$app")."\n"; + $body = MiniWiki::WikiToText($this->_body, true); + $app = MiniWiki::WikiToText($this->_append,false,4); + $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 = enriched_to_text($this->_body,true); - $app = enriched_to_text($this->_append,true); - + $body = MiniWiki::WikiToHTML($this->_body); + $app = MiniWiki::WikiToHTML($this->_append); + $art = "$title\n"; $art .= "
\n$body\n"; if ($app) { $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; } @@ -255,7 +266,7 @@ class NLArticle public function check() { - $text = enriched_to_text($this->_body); + $text = MiniWiki::WikiToText($this->_body); $arr = explode("\n",wordwrap($text,68)); $c = 0; foreach ($arr as $line) {