2 /***************************************************************************
3 * Copyright (C) 2003-2008 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/message.func.inc.php';
24 require_once 'banana/hooks.inc.php';
26 function hook_checkcancel($_headers)
28 return ($_headers['x-org-id'] == S
::v('forlife') or S
::has_perms());
31 function hook_makeLink($params)
33 global $platal, $globals;
34 $base = $globals->baseurl
. '/' . $platal->ns
. 'lists/moderate/' . ModerationBanana
::$listname . '?';
36 foreach ($params as $key=>$value) {
37 if ($key == 'artid') {
40 if ($key == 'group') {
43 if ($key == 'action' && $value != 'showext') {
49 $get .= $key . '=' . $value;
54 class ModerationBanana
extends Banana
56 static public $listname;
57 static public $domain;
58 static public $client;
60 function __construct($forlife, $params = null
)
62 ini_set('memory_limit', '128M');
65 ModerationBanana
::$client = $params['client'];
66 ModerationBanana
::$listname = $params['listname'];
67 ModerationBanana
::$domain = isset($params['domain']) ?
$params['domain'] : $globals->mail
->domain
;
68 $params['group'] = ModerationBanana
::$listname . '@' . ModerationBanana
::$domain;
69 Banana
::$spool_root = $globals->banana
->spool_root
;
70 Banana
::$spool_boxlist = false
;
71 Banana
::$msgshow_withthread = false
;
72 Banana
::$withtabs = false
;
73 Banana
::$msgshow_externalimages = false
;
74 Banana
::$msgshow_mimeparts[] = 'source';
75 Banana
::$feed_active = false
;
76 Banana
::$debug_smarty = ($globals->debug
& DEBUG_SMARTY
);
77 array_push(Banana
::$msgparse_headers, 'x-org-id', 'x-org-mail');
78 parent
::__construct($params, 'MLInterface', 'ModerationPage');
82 class ModerationPage
extends BananaPage
84 protected function prepare()
86 $this->killPage('subscribe');
87 $this->killPage('forums');
88 $this->assign('noactions', true
);
89 return parent
::prepare();
92 public function trig($msg)
96 $page->trigError($msg);
102 class BananaMLInterface
implements BananaProtocoleInterface
104 private $infos; //(list, addr, host, desc, info, diff, ins, priv, sub, own, nbsub)
105 private $helds; //(id, sender, size, subj, date)
107 public function __construct()
109 $this->infos
= ModerationBanana
::$client->get_members(ModerationBanana
::$listname);
110 $this->infos
= $this->infos
[0];
112 $mods = ModerationBanana
::$client->get_pending_ops(ModerationBanana
::$listname);
113 $this->helds
= $mods[1];
116 public function isValid()
118 return !is_null(ModerationBanana
::$client);
121 public function lastErrNo()
126 public function lastError()
131 public function getDescription()
133 return $this->infos
['desc'];
136 public function getBoxList($mode = Banana
::BOXES_ALL
, $since = 0, $withstats = false
)
138 return array(Banana
::$group => Array(
139 'desc' => $this->infos
['desc'],
140 'msgnum' => count($this->helds
),
141 'unread' => count($this->helds
)));
144 public function &getMessage($id)
147 $msg = ModerationBanana
::$client->get_pending_mail(ModerationBanana
::$listname, $id, 1);
149 $message = new BananaMessage(html_entity_decode($msg));
154 public function getMessageSource($id)
156 return ModerationBanana
::$client->get_pending_mail(ModerationBanana
::$listname, $id, 1);
159 public function getIndexes()
162 foreach ($this->helds
as &$desc) {
163 $ids[] = intval($desc['id']);
166 return array(count($ids), min($ids), max($ids));
169 public function &getMessageHeaders($firstid, $lastid, array $msg_headers = array())
171 $conv = array('from' => 'sender', 'subject' => 'subj', 'date' => 'stamp', 'message-id' => 'id');
173 foreach ($msg_headers as $hdr) {
174 $hdr = strtolower($hdr);
175 $mlhdr = isset($conv[$hdr]) ?
$conv[$hdr] : $hdr;
176 foreach ($this->helds
as &$desc) {
177 $id = intval($desc['id']);
178 if (!isset($headers[$id])) {
179 $headers[$id] = array();
181 if ($mlhdr == 'id') {
182 $headers[$id][$hdr] = $desc['stamp'] . '$' . $desc['id'] . '@' . Banana
::$group;
184 $headers[$id][$hdr] = isset($desc[$mlhdr]) ?
banana_html_entity_decode($desc[$mlhdr]) : null
;
191 public function updateSpool(array &$messages) { }
193 public function getNewIndexes($since)
196 foreach ($this->helds
as &$desc) {
197 if ($desc['stamp'] > $since) {
198 $ids[] = intval($desc['id']);
205 public function canSend()
210 public function canCancel()
215 public function requestedHeaders()
220 public function send(BananaMessage
&$message)
225 public function cancel(BananaMessage
&$message)
230 public function name()
232 return 'MLModeration';
235 public function filename()
237 return ModerationBanana
::$domain . '_' . ModerationBanana
::$listname;
240 public function backtrace()
246 // vim:set et sw=4 sts=4 ts=4 enc=utf-8: