| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2010 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/hooks.inc.php'; |
| 23 | |
| 24 | class PlatalBananaMLPage extends PlatalBananaPage |
| 25 | { |
| 26 | public function __construct() |
| 27 | { |
| 28 | parent::__construct(); |
| 29 | global $platal; |
| 30 | $this->handler = 'BananaMLHandler'; |
| 31 | $this->base = $platal->pl_self(1); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | class BananaMLHandler extends BananaHandler |
| 36 | { |
| 37 | public function template() |
| 38 | { |
| 39 | return 'lists/archives.tpl'; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | class MLBanana extends Banana |
| 44 | { |
| 45 | static public $listname; |
| 46 | static public $domain; |
| 47 | private $user; |
| 48 | |
| 49 | function __construct(User &$user, $params = null) |
| 50 | { |
| 51 | global $globals; |
| 52 | $this->user = &$user; |
| 53 | |
| 54 | Banana::$spool_root = $globals->banana->spool_root; |
| 55 | Banana::$spool_boxlist = false; |
| 56 | Banana::$msgedit_canattach = true; |
| 57 | Banana::$debug_mbox = ($globals->debug & DEBUG_BT); |
| 58 | Banana::$debug_smarty = ($globals->debug & DEBUG_SMARTY); |
| 59 | Banana::$mbox_helper = $globals->banana->mbox_helper; |
| 60 | Banana::$feed_updateOnDemand = true; |
| 61 | if (S::admin()) { |
| 62 | Banana::$msgshow_mimeparts[] = 'source'; |
| 63 | } |
| 64 | array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail'); |
| 65 | Banana::$feed_active = S::hasAuthToken(); |
| 66 | |
| 67 | MLBanana::$listname = $params['listname']; |
| 68 | MLBanana::$domain = $params['domain']; |
| 69 | $params['group'] = $params['listname'] . '@' . $params['domain']; |
| 70 | parent::__construct($params, 'MLArchive', 'PlatalBananaMLPage'); |
| 71 | } |
| 72 | |
| 73 | public function run() |
| 74 | { |
| 75 | global $platal, $globals; |
| 76 | |
| 77 | $nom = S::v('prenom') . ' ' . S::v('nom'); |
| 78 | $mail = $this->user->bestEmail(); |
| 79 | $sig = $nom . ' (' . S::v('promo') . ')'; |
| 80 | Banana::$msgedit_headers['X-Org-Mail'] = $this->user->forlifeEmail(); |
| 81 | |
| 82 | // Tree color |
| 83 | $req = XDB::query('SELECT tree_unread, tree_read |
| 84 | FROM forum_profiles |
| 85 | WHERE uid= {?}', $this->user->id()); |
| 86 | if (!(list($unread, $read) = $req->fetchOneRow())) { |
| 87 | $unread = 'o'; |
| 88 | $read = 'dg'; |
| 89 | } |
| 90 | Banana::$tree_unread = $unread; |
| 91 | Banana::$tree_read = $read; |
| 92 | |
| 93 | // Build user profile |
| 94 | Banana::$profile['headers']['From'] = "$nom <$mail>"; |
| 95 | Banana::$profile['headers']['Organization'] = make_Organization(); |
| 96 | Banana::$profile['signature'] = $sig; |
| 97 | |
| 98 | // Page design |
| 99 | Banana::$page->killPage('forums'); |
| 100 | Banana::$page->killPage('subscribe'); |
| 101 | |
| 102 | // Run Banana |
| 103 | return parent::run(); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | require_once dirname(__FILE__) . '/../../banana/banana/mbox.inc.php'; |
| 108 | |
| 109 | class BananaMLArchive extends BananaMBox |
| 110 | { |
| 111 | public function name() |
| 112 | { |
| 113 | return 'MLArchives'; |
| 114 | } |
| 115 | |
| 116 | public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false) |
| 117 | { |
| 118 | global $globals; |
| 119 | $spool = $globals->lists->spool . '/'; |
| 120 | $list = glob($spool . '*.mbox/*.mbox'); |
| 121 | if ($list === false) { |
| 122 | return array(); |
| 123 | } |
| 124 | $groups = array(); |
| 125 | foreach ($list as $path) { |
| 126 | $path = substr($path, strpos($path, 'mbox/') + 5); |
| 127 | $path = substr($path, 0, -5); |
| 128 | list($domain, $listname) = explode($globals->lists->vhost_sep, $path, 2); |
| 129 | $group = $listname . '@' . $domain; |
| 130 | $groups[$group] = array('desc' => null, 'msgnum' => null, 'unread' => null); |
| 131 | } |
| 132 | return $groups; |
| 133 | } |
| 134 | |
| 135 | public function filename() |
| 136 | { |
| 137 | if (MLBanana::$listname) { |
| 138 | $listname = MLBanana::$listname; |
| 139 | $domain = MLBanana::$domain; |
| 140 | } else { |
| 141 | list($listname, $domain) = explode('@', Banana::$group); |
| 142 | } |
| 143 | return $domain . '_' . $listname; |
| 144 | } |
| 145 | |
| 146 | protected function getFileName() |
| 147 | { |
| 148 | global $globals; |
| 149 | $base = $globals->lists->spool; |
| 150 | if (MLBanana::$listname) { |
| 151 | $listname = MLBanana::$listname; |
| 152 | $domain = MLBanana::$domain; |
| 153 | } else { |
| 154 | list($listname, $domain) = explode('@', Banana::$group); |
| 155 | } |
| 156 | $file = $domain . $globals->lists->vhost_sep . $listname . '.mbox'; |
| 157 | return "$base/$file/$file"; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
| 162 | ?> |