2 /***************************************************************************
3 * Copyright (C) 2003-2007 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once 'banana/banana.inc.php';
23 require_once 'banana/hooks.inc.php';
25 function hook_checkcancel($_headers)
27 return ($_headers['x-org-id'] == S
::v('forlife') or S
::has_perms());
30 function hook_makeLink($params)
32 global $platal, $globals;
33 $base = $globals->baseurl
. '/' . $platal->ns
. 'lists/moderate/' . ModerationBanana
::$listname . '?';
35 foreach ($params as $key=>$value) {
36 if ($key == 'artid') {
39 if ($key == 'group') {
42 if ($key == 'action' && $value != 'showext') {
48 $get .= $key . '=' . $value;
53 class ModerationBanana
extends Banana
55 static public $listname;
56 static public $domain;
57 static public $client;
59 function __construct($forlife, $params = null
)
62 ModerationBanana
::$client = $params['client'];
63 ModerationBanana
::$listname = $params['listname'];
64 ModerationBanana
::$domain = isset($params['domain']) ?
$params['domain'] : $globals->mail
->domain
;
65 $params['group'] = ModerationBanana
::$listname . '@' . ModerationBanana
::$domain;
66 Banana
::$spool_root = $globals->banana
->spool_root
;
67 Banana
::$spool_boxlist = false
;
68 Banana
::$msgshow_withthread = false
;
69 Banana
::$withtabs = false
;
70 Banana
::$msgshow_externalimages = false
;
71 Banana
::$msgshow_mimeparts[] = 'source';
72 Banana
::$feed_active = false
;
73 Banana
::$debug_smarty = ($globals->debug
& DEBUG_SMARTY
);
74 array_push(Banana
::$msgparse_headers, 'x-org-id', 'x-org-mail');
75 parent
::__construct($params, 'MLInterface', 'ModerationPage');
79 require_once('banana/page.inc.php');
81 class ModerationPage
extends BananaPage
83 protected function prepare()
85 $this->killPage('subscribe');
86 $this->killPage('forums');
87 $this->assign('noactions', true
);
88 return parent
::prepare();
91 public function trig($msg)
101 require_once('banana/protocoleinterface.inc.php');
102 require_once('banana/message.inc.php');
104 class BananaMLInterface
implements BananaProtocoleInterface
106 private $infos; //(list, addr, host, desc, info, diff, ins, priv, sub, own, nbsub)
107 private $helds; //(id, sender, size, subj, date)
109 public function __construct()
111 $this->infos
= ModerationBanana
::$client->get_members(ModerationBanana
::$listname);
112 $this->infos
= $this->infos
[0];
114 $mods = ModerationBanana
::$client->get_pending_ops(ModerationBanana
::$listname);
115 $this->helds
= $mods[1];
118 public function isValid()
120 return !is_null(ModerationBanana
::$client);
123 public function lastErrNo()
128 public function lastError()
133 public function getDescription()
135 return $this->infos
['desc'];
138 public function getBoxList($mode = Banana
::BOXES_ALL
, $since = 0, $withstats = false
)
140 return array(Banana
::$group => Array(
141 'desc' => $this->infos
['desc'],
142 'msgnum' => count($this->helds
),
143 'unread' => count($this->helds
)));
146 public function &getMessage($id)
149 $msg = ModerationBanana
::$client->get_pending_mail(ModerationBanana
::$listname, $id, 1);
151 $message = new BananaMessage(html_entity_decode($msg));
156 public function getMessageSource($id)
158 return ModerationBanana
::$client->get_pending_mail(ModerationBanana
::$listname, $id, 1);
161 public function getIndexes()
164 foreach ($this->helds
as &$desc) {
165 $ids[] = intval($desc['id']);
168 return array(count($ids), min($ids), max($ids));
171 public function &getMessageHeaders($firstid, $lastid, array $msg_headers = array())
173 $conv = array('from' => 'sender', 'subject' => 'subj', 'date' => 'stamp', 'message-id' => 'id');
175 foreach ($msg_headers as $hdr) {
176 $hdr = strtolower($hdr);
177 $mlhdr = isset($conv[$hdr]) ?
$conv[$hdr] : $hdr;
178 foreach ($this->helds
as &$desc) {
179 $id = intval($desc['id']);
180 if (!isset($headers[$id])) {
181 $headers[$id] = array();
183 if ($mlhdr == 'id') {
184 $headers[$id][$hdr] = $desc['stamp'] . '$' . $desc['id'] . '@' . Banana
::$group;
186 $headers[$id][$hdr] = isset($desc[$mlhdr]) ?
banana_html_entity_decode($desc[$mlhdr]) : null
;
193 public function updateSpool(array &$messages) { }
195 public function getNewIndexes($since)
198 foreach ($this->helds
as &$desc) {
199 if ($desc['stamp'] > $since) {
200 $ids[] = intval($desc['id']);
207 public function canSend()
212 public function canCancel()
217 public function requestedHeaders()
222 public function send(BananaMessage
&$message)
227 public function cancel(BananaMessage
&$message)
232 public function name()
234 return 'MLModeration';
237 public function filename()
239 return ModerationBanana
::$domain . '_' . ModerationBanana
::$listname;
242 public function backtrace()
248 // vim:set et sw=4 sts=4 ts=4 enc=utf-8: