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