fa7d6c7b |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2007 Polytechnique.org * |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
22 | require_once 'banana/banana.inc.php'; |
23 | require_once 'banana/hooks.inc.php'; |
24 | |
fa7d6c7b |
25 | class MLBanana extends Banana |
26 | { |
27 | static public $listname; |
28 | static public $domain; |
29 | |
b2bffbe6 |
30 | function __construct($forlife, $params = null) |
fa7d6c7b |
31 | { |
9fc2d0d2 |
32 | global $globals; |
580d1c7d |
33 | Banana::$spool_root = $globals->banana->spool_root; |
fa7d6c7b |
34 | Banana::$spool_boxlist = false; |
35 | Banana::$msgedit_canattach = true; |
d3f26be9 |
36 | Banana::$debug_mbox = ($globals->debug & 1); |
37 | Banana::$mbox_helper = $globals->banana->mbox_helper; |
1515e65a |
38 | if (S::has_perms()) { |
39 | Banana::$msgshow_mimeparts[] = 'source'; |
40 | } |
fa7d6c7b |
41 | array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail'); |
6544d0e1 |
42 | if (!S::v('core_rss_hash')) { |
43 | Banana::$feed_active = false; |
44 | } |
ea626742 |
45 | |
fa7d6c7b |
46 | MLBanana::$listname = $params['listname']; |
47 | MLBanana::$domain = $params['domain']; |
48 | $params['group'] = $params['listname'] . '@' . $params['domain']; |
49 | parent::__construct($params, 'MLArchive'); |
50 | } |
51 | |
52 | public function run() |
53 | { |
54 | global $platal, $globals; |
55 | |
315fa6ae |
56 | $nom = S::v('prenom') . ' ' . S::v('nom'); |
57 | $mail = S::v('bestalias') . '@' . $globals->mail->domain; |
58 | $sig = $nom . ' (' . S::v('promo') . ')'; |
59 | Banana::$msgedit_headers['X-Org-Mail'] = S::v('forlife') . '@' . $globals->mail->domain; |
60 | |
61 | // Build user profile |
2d967f8c |
62 | Banana::$profile['headers']['From'] = "$nom <$mail>"; |
315fa6ae |
63 | Banana::$profile['headers']['Organization'] = 'Utilisateur de Polytechnique.org'; |
2d967f8c |
64 | Banana::$profile['signature'] = $sig; |
315fa6ae |
65 | |
66 | // Page design |
c93959a9 |
67 | Banana::$page->killPage('forums'); |
fa7d6c7b |
68 | Banana::$page->killPage('subscribe'); |
69 | |
70 | // Run Banana |
71 | return parent::run(); |
72 | } |
73 | } |
74 | |
75 | require_once('banana/mbox.inc.php'); |
76 | |
77 | class BananaMLArchive extends BananaMBox |
78 | { |
79 | public function name() |
80 | { |
81 | return 'MLArchives'; |
82 | } |
83 | |
5760f76b |
84 | public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false) |
85 | { |
86 | global $globals; |
87 | $spool = $globals->lists->spool . '/'; |
88 | $list = glob($spool . '*.mbox', GLOB_ONLYDIR); |
89 | if ($list === false) { |
90 | return array(); |
91 | } |
92 | $groups = array(); |
93 | foreach ($list as $path) { |
94 | $path = substr($path, strlen($spool)); |
95 | $path = substr($path, 0, -5); |
96 | list($domain, $listname) = explode($globals->lists->vhost_sep, $path, 2); |
97 | $group = $listname . '@' . $domain; |
98 | $groups[$group] = array('desc' => null, 'msgnum' => null, 'unread' => null); |
99 | } |
100 | return $groups; |
101 | } |
102 | |
fa7d6c7b |
103 | public function filename() |
104 | { |
5760f76b |
105 | if (MLBanana::$listname) { |
106 | $listname = MLBanana::$listname; |
107 | $domain = MLBanana::$domain; |
108 | } else { |
109 | list($listname, $domain) = explode('@', Banana::$group); |
110 | } |
111 | return $domain . '_' . $listname; |
fa7d6c7b |
112 | } |
113 | |
3e949cf9 |
114 | protected function getFileName() |
fa7d6c7b |
115 | { |
116 | global $globals; |
117 | $base = $globals->lists->spool; |
5760f76b |
118 | if (MLBanana::$listname) { |
119 | $listname = MLBanana::$listname; |
120 | $domain = MLBanana::$domain; |
121 | } else { |
122 | list($listname, $domain) = explode('@', Banana::$group); |
123 | } |
124 | $file = $domain . $globals->lists->vhost_sep . $listname . '.mbox'; |
fa7d6c7b |
125 | return "$base/$file/$file"; |
126 | } |
127 | } |
128 | |
a7de4ef7 |
129 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
fa7d6c7b |
130 | ?> |