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 | function hook_makeLink($params) |
26 | { |
27 | global $globals, $platal; |
3e949cf9 |
28 | $base = $globals->baseurl . '/' . $platal->ns . 'lists/archives/' . MLBanana::$listname; |
fa7d6c7b |
29 | return $base . hook_platalMessageLink($params); |
30 | } |
31 | |
32 | class MLBanana extends Banana |
33 | { |
34 | static public $listname; |
35 | static public $domain; |
36 | |
37 | function __construct($params = null) |
38 | { |
39 | Banana::$spool_boxlist = false; |
40 | Banana::$msgedit_canattach = true; |
41 | array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail'); |
315fa6ae |
42 | |
fa7d6c7b |
43 | MLBanana::$listname = $params['listname']; |
44 | MLBanana::$domain = $params['domain']; |
45 | $params['group'] = $params['listname'] . '@' . $params['domain']; |
46 | parent::__construct($params, 'MLArchive'); |
47 | } |
48 | |
49 | public function run() |
50 | { |
51 | global $platal, $globals; |
52 | |
315fa6ae |
53 | $nom = S::v('prenom') . ' ' . S::v('nom'); |
54 | $mail = S::v('bestalias') . '@' . $globals->mail->domain; |
55 | $sig = $nom . ' (' . S::v('promo') . ')'; |
56 | Banana::$msgedit_headers['X-Org-Mail'] = S::v('forlife') . '@' . $globals->mail->domain; |
57 | |
58 | // Build user profile |
59 | Banana::$profile['headers']['From'] = utf8_encode("$nom <$mail>"); |
60 | Banana::$profile['headers']['Organization'] = 'Utilisateur de Polytechnique.org'; |
61 | Banana::$profile['signature'] = utf8_encode($sig); |
62 | |
63 | // Page design |
c93959a9 |
64 | Banana::$page->killPage('forums'); |
fa7d6c7b |
65 | Banana::$page->killPage('subscribe'); |
66 | |
67 | // Run Banana |
68 | return parent::run(); |
69 | } |
70 | } |
71 | |
72 | require_once('banana/mbox.inc.php'); |
73 | |
74 | class BananaMLArchive extends BananaMBox |
75 | { |
76 | public function name() |
77 | { |
78 | return 'MLArchives'; |
79 | } |
80 | |
5760f76b |
81 | public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false) |
82 | { |
83 | global $globals; |
84 | $spool = $globals->lists->spool . '/'; |
85 | $list = glob($spool . '*.mbox', GLOB_ONLYDIR); |
86 | if ($list === false) { |
87 | return array(); |
88 | } |
89 | $groups = array(); |
90 | foreach ($list as $path) { |
91 | $path = substr($path, strlen($spool)); |
92 | $path = substr($path, 0, -5); |
93 | list($domain, $listname) = explode($globals->lists->vhost_sep, $path, 2); |
94 | $group = $listname . '@' . $domain; |
95 | $groups[$group] = array('desc' => null, 'msgnum' => null, 'unread' => null); |
96 | } |
97 | return $groups; |
98 | } |
99 | |
fa7d6c7b |
100 | public function filename() |
101 | { |
5760f76b |
102 | if (MLBanana::$listname) { |
103 | $listname = MLBanana::$listname; |
104 | $domain = MLBanana::$domain; |
105 | } else { |
106 | list($listname, $domain) = explode('@', Banana::$group); |
107 | } |
108 | return $domain . '_' . $listname; |
fa7d6c7b |
109 | } |
110 | |
3e949cf9 |
111 | protected function getFileName() |
fa7d6c7b |
112 | { |
113 | global $globals; |
114 | $base = $globals->lists->spool; |
5760f76b |
115 | if (MLBanana::$listname) { |
116 | $listname = MLBanana::$listname; |
117 | $domain = MLBanana::$domain; |
118 | } else { |
119 | list($listname, $domain) = explode('@', Banana::$group); |
120 | } |
121 | $file = $domain . $globals->lists->vhost_sep . $listname . '.mbox'; |
fa7d6c7b |
122 | return "$base/$file/$file"; |
123 | } |
124 | } |
125 | |
126 | ?> |