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; |
81e9c63f |
36 | Banana::$debug_mbox = ($globals->debug & DEBUG_BT); |
37 | Banana::$debug_smarty = ($globals->debug & DEBUG_SMARTY); |
d3f26be9 |
38 | Banana::$mbox_helper = $globals->banana->mbox_helper; |
831ff3e3 |
39 | Banana::$feed_updateOnDemand = true; |
1515e65a |
40 | if (S::has_perms()) { |
41 | Banana::$msgshow_mimeparts[] = 'source'; |
eaf30d86 |
42 | } |
fa7d6c7b |
43 | array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail'); |
6544d0e1 |
44 | if (!S::v('core_rss_hash')) { |
45 | Banana::$feed_active = false; |
46 | } |
ea626742 |
47 | |
fa7d6c7b |
48 | MLBanana::$listname = $params['listname']; |
49 | MLBanana::$domain = $params['domain']; |
50 | $params['group'] = $params['listname'] . '@' . $params['domain']; |
51 | parent::__construct($params, 'MLArchive'); |
52 | } |
53 | |
54 | public function run() |
55 | { |
56 | global $platal, $globals; |
57 | |
315fa6ae |
58 | $nom = S::v('prenom') . ' ' . S::v('nom'); |
59 | $mail = S::v('bestalias') . '@' . $globals->mail->domain; |
60 | $sig = $nom . ' (' . S::v('promo') . ')'; |
61 | Banana::$msgedit_headers['X-Org-Mail'] = S::v('forlife') . '@' . $globals->mail->domain; |
62 | |
63 | // Build user profile |
2d967f8c |
64 | Banana::$profile['headers']['From'] = "$nom <$mail>"; |
437a98e0 |
65 | Banana::$profile['headers']['Organization'] = make_Organization(); |
2d967f8c |
66 | Banana::$profile['signature'] = $sig; |
eaf30d86 |
67 | |
315fa6ae |
68 | // Page design |
c93959a9 |
69 | Banana::$page->killPage('forums'); |
eaf30d86 |
70 | Banana::$page->killPage('subscribe'); |
fa7d6c7b |
71 | |
72 | // Run Banana |
73 | return parent::run(); |
74 | } |
75 | } |
76 | |
77 | require_once('banana/mbox.inc.php'); |
78 | |
79 | class BananaMLArchive extends BananaMBox |
80 | { |
81 | public function name() |
82 | { |
83 | return 'MLArchives'; |
84 | } |
85 | |
5760f76b |
86 | public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false) |
87 | { |
88 | global $globals; |
89 | $spool = $globals->lists->spool . '/'; |
dee14597 |
90 | $list = glob($spool . '*.mbox/*.mbox'); |
5760f76b |
91 | if ($list === false) { |
92 | return array(); |
93 | } |
94 | $groups = array(); |
95 | foreach ($list as $path) { |
dee14597 |
96 | $path = substr($path, strpos($path, 'mbox/') + 5); |
5760f76b |
97 | $path = substr($path, 0, -5); |
98 | list($domain, $listname) = explode($globals->lists->vhost_sep, $path, 2); |
99 | $group = $listname . '@' . $domain; |
100 | $groups[$group] = array('desc' => null, 'msgnum' => null, 'unread' => null); |
101 | } |
102 | return $groups; |
103 | } |
104 | |
fa7d6c7b |
105 | public function filename() |
106 | { |
5760f76b |
107 | if (MLBanana::$listname) { |
108 | $listname = MLBanana::$listname; |
109 | $domain = MLBanana::$domain; |
110 | } else { |
111 | list($listname, $domain) = explode('@', Banana::$group); |
112 | } |
113 | return $domain . '_' . $listname; |
fa7d6c7b |
114 | } |
115 | |
3e949cf9 |
116 | protected function getFileName() |
fa7d6c7b |
117 | { |
118 | global $globals; |
119 | $base = $globals->lists->spool; |
5760f76b |
120 | if (MLBanana::$listname) { |
121 | $listname = MLBanana::$listname; |
122 | $domain = MLBanana::$domain; |
123 | } else { |
124 | list($listname, $domain) = explode('@', Banana::$group); |
125 | } |
126 | $file = $domain . $globals->lists->vhost_sep . $listname . '.mbox'; |
fa7d6c7b |
127 | return "$base/$file/$file"; |
128 | } |
129 | } |
130 | |
a7de4ef7 |
131 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
fa7d6c7b |
132 | ?> |