X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fbanana%2Fml.inc.php;h=9a3174f413f47859ee486724130e7899e3c28b11;hb=24cfa984cc0d84c3b636891f792e3e50559fb42b;hp=1c0e0683c5673a3cfae141b5bba054241cd710cb;hpb=c93959a97a1a0649660fc3b309713b6e480b1b4d;p=platal.git diff --git a/include/banana/ml.inc.php b/include/banana/ml.inc.php index 1c0e068..9a3174f 100644 --- a/include/banana/ml.inc.php +++ b/include/banana/ml.inc.php @@ -1,6 +1,6 @@ baseurl . $platal->ns . '/lists/archives/' . MLBanana::$listname; - return $base . hook_platalMessageLink($params); + public function __construct() + { + parent::__construct(); + global $platal; + $this->handler = 'BananaMLHandler'; + $this->base = $platal->pl_self(1); + } +} + +class BananaMLHandler extends BananaHandler +{ + public function template() + { + return 'lists/archives.tpl'; + } } class MLBanana extends Banana { static public $listname; static public $domain; + private $user; - function __construct($params = null) + function __construct(User &$user, $params = null) { + global $globals; + $this->user = &$user; + + Banana::$spool_root = $globals->banana->spool_root; Banana::$spool_boxlist = false; Banana::$msgedit_canattach = true; + Banana::$debug_mbox = ($globals->debug & DEBUG_BT); + Banana::$debug_smarty = ($globals->debug & DEBUG_SMARTY); + Banana::$mbox_helper = $globals->banana->mbox_helper; + Banana::$feed_updateOnDemand = true; + if (S::has_perms()) { + Banana::$msgshow_mimeparts[] = 'source'; + } array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail'); - + if (!S::v('core_rss_hash')) { + Banana::$feed_active = false; + } + MLBanana::$listname = $params['listname']; MLBanana::$domain = $params['domain']; $params['group'] = $params['listname'] . '@' . $params['domain']; - parent::__construct($params, 'MLArchive'); + parent::__construct($params, 'MLArchive', 'PlatalBananaMLPage'); } public function run() { global $platal, $globals; + $nom = S::v('prenom') . ' ' . S::v('nom'); + $mail = $this->user->bestEmail(); + $sig = $nom . ' (' . S::v('promo') . ')'; + Banana::$msgedit_headers['X-Org-Mail'] = $this->user->forlifeEmail(); + + // Tree color + $req = XDB::query("SELECT tree_unread, tree_read + FROM {$globals->banana->table_prefix}profils + WHERE uid={?}", S::i('uid')); + if (!(list($unread, $read) = $req->fetchOneRow())) { + $unread = 'o'; + $read = 'dg'; + } + Banana::$tree_unread = $unread; + Banana::$tree_read = $read; + + // Build user profile + Banana::$profile['headers']['From'] = "$nom <$mail>"; + Banana::$profile['headers']['Organization'] = make_Organization(); + Banana::$profile['signature'] = $sig; + + // Page design Banana::$page->killPage('forums'); - Banana::$page->killPage('subscribe'); + Banana::$page->killPage('subscribe'); // Run Banana return parent::run(); @@ -67,18 +116,50 @@ class BananaMLArchive extends BananaMBox return 'MLArchives'; } + public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false) + { + global $globals; + $spool = $globals->lists->spool . '/'; + $list = glob($spool . '*.mbox/*.mbox'); + if ($list === false) { + return array(); + } + $groups = array(); + foreach ($list as $path) { + $path = substr($path, strpos($path, 'mbox/') + 5); + $path = substr($path, 0, -5); + list($domain, $listname) = explode($globals->lists->vhost_sep, $path, 2); + $group = $listname . '@' . $domain; + $groups[$group] = array('desc' => null, 'msgnum' => null, 'unread' => null); + } + return $groups; + } + public function filename() { - return MLBanana::$domain . '_' . MLBanana::$listname; + if (MLBanana::$listname) { + $listname = MLBanana::$listname; + $domain = MLBanana::$domain; + } else { + list($listname, $domain) = explode('@', Banana::$group); + } + return $domain . '_' . $listname; } - protected function getFileName($box) + protected function getFileName() { global $globals; $base = $globals->lists->spool; - $file = MLBanana::$domain . $globals->lists->vhost_sep . MLBanana::$listname . '.mbox'; + if (MLBanana::$listname) { + $listname = MLBanana::$listname; + $domain = MLBanana::$domain; + } else { + list($listname, $domain) = explode('@', Banana::$group); + } + $file = $domain . $globals->lists->vhost_sep . $listname . '.mbox'; return "$base/$file/$file"; } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>