cc6a2ee78a4acd6107d23832098b6fef37f87f58
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 $globals, $platal;
33 $base = $globals->baseurl
. $platal->ns
. '/lists/archives/' . MLBanana
::$listname;
34 return $base . hook_platalMessageLink($params);
37 class MLBanana
extends Banana
39 static public $listname;
40 static public $domain;
42 function __construct($params = null
)
44 Banana
::$spool_boxlist = false
;
45 Banana
::$msgedit_canattach = true
;
46 array_push(Banana
::$msgparse_headers, 'x-org-id', 'x-org-mail');
48 MLBanana
::$listname = $params['listname'];
49 MLBanana
::$domain = $params['domain'];
50 $params['group'] = $params['listname'] . '@' . $params['domain'];
51 parent
::__construct($params, 'MLArchive');
56 global $platal, $globals;
58 /* // Update last unread time
60 if (!is_null($this->params) && isset($this->params['updateall'])) {
61 $time = intval($this->params['updateall']);
62 $_SESSION['banana_last'] = $time;
65 // Get user profile from SQL
66 $req = XDB::query("SELECT nom, mail, sig,
67 FIND_IN_SET('threads',flags), FIND_IN_SET('automaj',flags)
68 FROM {$globals->banana->table_prefix}profils
69 WHERE uid={?}", S::i('uid'));
70 if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
71 $nom = S::v('prenom')." ".S::v('nom');
72 $mail = S::v('forlife')."@polytechnique.org";
73 $sig = $nom." (".S::v('promo').")";
84 FROM {$globals->banana->table_prefix}abos
85 LEFT JOIN {$globals->banana->table_prefix}list ON list.fid=abos.fid
86 WHERE uid={?}", S::i('uid'));
87 Banana::$profile['headers']['From'] = utf8_encode("$nom <$mail>");
88 Banana::$profile['headers']['Organization'] = 'Utilisateur de Polytechnique.org';
89 Banana::$profile['signature'] = utf8_encode($sig);
90 Banana::$profile['display'] = $disp;
91 Banana::$profile['autoup'] = $maj;
92 Banana::$profile['lastnews'] = S::v('banana_last');
93 Banana::$profile['subscribe'] = $req->fetchColumn();
95 // Update the "unread limit"
96 if (!is_null($time)) {
97 XDB::execute("UPDATE auth_user_quick
98 SET banana_last = FROM_UNIXTIME({?})
103 // Register custom Banana links and tabs
104 if (!Banana::$profile['autoup']) {
105 Banana::$page->registerAction('<a href=\'javascript:dynpostkv("'
106 . $platal->path . '", "updateall", ' . time() . ')\'>'
107 . 'Marquer tous les messages comme lus'
108 . '</a>', array('forums', 'thread', 'message'));
110 Banana::$page->registerPage('profile', utf8_encode('Préférences'), null);
111 */ Banana
::$page->killPage('forums');
112 Banana
::$page->killPage('subscribe');
115 return parent
::run();
119 require_once('banana/mbox.inc.php');
121 class BananaMLArchive
extends BananaMBox
123 public function name()
128 public function filename()
130 return MLBanana
::$domain . '_' . MLBanana
::$listname;
133 protected function getFileName($box)
136 $base = $globals->lists
->spool
;
137 $file = MLBanana
::$domain . $globals->lists
->vhost_sep
. MLBanana
::$listname . '.mbox';
138 return "$base/$file/$file";