<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'banana/banana.inc.php';
+require_once dirname(__FILE__) . '/../../banana/banana/banana.inc.php';
+require_once dirname(__FILE__) . '/../../banana/banana/message.func.inc.php';
function hook_formatDisplayHeader($_header, $_text, $in_spool = false)
{
$addresses = preg_split("/ *, */", $_text);
$text = '';
foreach ($addresses as $address) {
- $address = BananaMessage::formatFrom(trim($address));
+ $address = BananaMessage::formatFrom(trim($address), Banana::$message->getHeaderValue('subject'));
if ($_header == 'from') {
if ($id = Banana::$message->getHeaderValue('x-org-id')) {
return $address . ' <a href="profile/' . $id . '" class="popup2" title="' . $id . '">'
. '<img src="images/icons/user_suit.gif" title="fiche" alt="" /></a>';
} else {
return $address;
- }
+ }
}
if (!empty($text)) {
$text .= ', ';
} else {
$group = '';
}
- return '/rss/' . $group . S::v('forlife') . '/' . S::v('core_rss_hash') . '/rss.xml';
+ return '/rss/' . $group . S::v('hruid') . '/' . S::user()->token . '/rss.xml';
}
function hook_platalMessageLink($params)
return $base . '/' . $params['page'];
}
if (@$params['action'] == 'subscribe') {
- return $base . '/subscription';
+ return $base . '/subscribe';
}
-
+
if (!isset($params['group'])) {
return $base;
}
$base .= '/' . $params['group'];
} else if (Banana::$protocole->name() == 'NNTP' && $xnet) {
if ($feed) {
- return 'http://www.polytechnique.org/banana' . hook_platalRSS(@$params['group']);
- }
- $base = $globals->baseurl . '/' . $platal->ns . 'forum';
+ return $globals->baseurl . '/banana' . hook_platalRSS(@$params['group']);
+ }
+ $base = $globals->baseurl . '/' . $platal->ns . 'forum';
} else if (Banana::$protocole->name() == 'MLArchives') {
- $base = $globals->baseurl . '/' . $platal->ns . 'lists/archives';
if ($feed) {
- return $base . hook_platalRSS(MLBanana::$listname);
+ return $globals->baseurl . '/' . $platal->ns . hook_platalRSS(MLBanana::$listname);
+ } elseif (php_sapi_name() == 'cli') {
+ $base = "http://listes.polytechnique.org/archives/" . str_replace('@', '_', $params['group']);
+ } else {
+ $base = $globals->baseurl . '/' . $platal->ns . 'lists/archives/' . MLBanana::$listname;
}
- $base .= '/' . MLBanana::$listname;
}
$base = $base . hook_platalMessageLink($params);
if (@$params['action'] == 'showext') {
}
}
+function hook_hasXFace($headers)
+{
+ return isset($headers['x-org-id']) || isset($headers['x-org-mail']);
+}
+
+function hook_getXFace($headers)
+{
+ $login = null;
+ foreach (array('x-org-id', 'x-org-mail') as $key) {
+ if (isset($headers[$key])) {
+ $login = $headers[$key];
+ break;
+ }
+ }
+ if (is_null($login)) {
+ // No login, fallback to default handler
+ return false;
+ }
+ if (isset($headers['x-face'])) {
+ $user = User::getSilent($login);
+ $res = XDB::query("SELECT pf.uid
+ FROM forum_profiles AS pf
+ WHERE pf.uid = {?} AND FIND_IN_SET('xface', pf.flags)",
+ $user->id());
+ if ($res->numRows()) {
+ // User wants his xface to be showed, fallback to default handler
+ return false;
+ }
+ }
+ global $globals;
+ http_redirect($global->baseurl . '/photo/' . $login);
+}
+
function hook_makeJs($src)
{
- global $page;
- $page->addJsLink("$src.js");
+ Platal::page()->addJsLink("$src.js");
return ' ';
}
+function make_Organization()
+{
+ global $globals;
+ $perms = S::v('perms');
+ $group = $globals->asso('nom');
+ if (S::admin()) {
+ return "Administrateur de Polytechnique.org";
+ } else if ($group && $perms->hasFlag('groupadmin')) {
+ return "Animateur de $group";
+ } else if ($group && $perms->hasFlag('groupmember')) {
+ return "Membre de $group";
+ }
+ return "Utilisateur de Polytechnique.org";
+}
+
function get_banana_params(array &$get, $group = null, $action = null, $artid = null)
{
+ if ($group == 'forums') {
+ $group = null;
+ } else if ($group == 'thread') {
+ $group = S::v('banana_group');
+ } else if ($group == 'message') {
+ $action = 'read';
+ $group = S::v('banana_group');
+ $artid = S::i('banana_artid');
+ } else if ($action == 'message') {
+ $action = 'read';
+ $artid = S::i('banana_artid');
+ } else if ($group == 'subscribe' || $group == 'subscription') {
+ $group = null;
+ $action = null;
+ $get['action'] = 'subscribe';
+ } else if ($group == 'profile') {
+ $group = null;
+ $action = null;
+ $get['action'] = 'profile';
+ }
if (!is_null($group)) {
$get['group'] = $group;
}
if (!is_null($action)) {
if ($action == 'new') {
- $get['action'] = 'new';
+ $get['action'] = 'new';
} elseif (!is_null($artid)) {
- $get['artid'] = $artid;
+ $get['artid'] = $artid;
if ($action == 'reply') {
$get['action'] = 'new';
} elseif ($action == 'cancel') {
} elseif ($action) {
$get['part'] = str_replace('.', '/', $action);
}
- if (Get::v('action') == 'showext') {
- $get['action'] = 'showext';
- }
+ if (Get::v('action') == 'showext') {
+ $get['action'] = 'showext';
+ }
}
}
}
-function run_banana(&$page, $class, array $args)
+class PlatalBananaPage extends BananaPage
{
- $banana = new $class(S::v('forlife'), $args);
+ protected $handler;
+ protected $base;
+
+ public function __construct()
+ {
+ global $platal;
+ Banana::$withtabs = false;
+ $this->handler = 'BananaHandler';
+ $this->base = $platal->pl_self(0);
+ parent::__construct();
+ }
+
+ protected function prepare()
+ {
+ $tpl = parent::prepare();
+ global $wiz;
+ $wiz = new PlWizard('Banana', PlPage::getCoreTpl('plwizard.tpl'), true, false);
+ foreach ($this->pages as $name=>&$mpage) {
+ $wiz->addPage($this->handler, $mpage['text'], $name);
+ }
+ $wiz->apply(Platal::page(), $this->base, $this->page);
+ return $tpl;
+ }
+}
+
+class BananaHandler
+{
+ public function __construct(PlWizard $wiz)
+ {
+ }
+
+ public function template()
+ {
+ return 'banana/index.tpl';
+ }
+
+ public function prepare(PlPage $page, $id)
+ {
+ }
+
+ public function success() { }
+
+ public function process(&$success)
+ {
+ return PlWizard::CURRENT_PAGE;
+ }
+}
+
+function run_banana($page, $class, array $args)
+{
+ $user = S::user();
+ $banana = new $class($user, $args);
$page->assign('banana', $banana->run());
$page->addCssInline($banana->css());
$page->addCssLink('banana.css');
$bt = $banana->backtrace();
if ($bt) {
new PlBacktrace(Banana::$protocole->name(), $banana->backtrace(), 'response', 'time');
- }
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: