<?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)
{
} 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)
function hook_getXFace($headers)
{
- $login = @$headers['x-org-id'];
- if (!$login) {
- @list($login, ) = explode('@', $headers['x-org-mail']);
+ $login = null;
+ foreach (array('x-org-id', 'x-org-mail') as $key) {
+ if (isset($headers[$key])) {
+ $login = $headers[$key];
+ break;
+ }
}
- if (!$login) {
+ if (is_null($login)) {
+ // No login, fallback to default handler
return false;
}
if (isset($headers['x-face'])) {
- $res = XDB::query("SELECT p.uid
- FROM forums.profils AS p
- INNER JOIN aliases AS a ON (p.uid = a.id)
- WHERE FIND_IN_SET('xface', p.flags) AND a.alias = {?}",
- $login);
+ $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;
}
}
function hook_makeJs($src)
{
- global $page;
- $page->addJsLink("$src.js");
+ Platal::page()->addJsLink("$src.js");
return ' ';
}
global $globals;
$perms = S::v('perms');
$group = $globals->asso('nom');
- if (S::has_perms()) {
+ if (S::admin()) {
return "Administrateur de Polytechnique.org";
} else if ($group && $perms->hasFlag('groupadmin')) {
return "Animateur de $group";
$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;
class PlatalBananaPage extends BananaPage
{
+ 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, $page;
- $wiz = new PlWizard('Banana', 'core/plwizard.tpl', true, false);
+ global $wiz;
+ $wiz = new PlWizard('Banana', PlPage::getCoreTpl('plwizard.tpl'), true, false);
foreach ($this->pages as $name=>&$mpage) {
- if ($text == 'profile') {
- $wiz->addPage('BananaProfile', $mpage['text'], $name);
- } else {
- $wiz->addPage('BananaHandler', $mpage['text'], $name);
- }
+ $wiz->addPage($this->handler, $mpage['text'], $name);
}
- $wiz->apply($page, 'banana', $this->page);
+ $wiz->apply(Platal::page(), $this->base, $this->page);
return $tpl;
}
}
class BananaHandler
{
- public function __construct(PlWizard &$wiz)
+ public function __construct(PlWizard $wiz)
{
}
return 'banana/index.tpl';
}
- public function prepare(PlatalPage &$page, $id)
+ public function prepare(PlPage $page, $id)
{
}
- public function process()
+ public function success() { }
+
+ public function process(&$success)
{
return PlWizard::CURRENT_PAGE;
}
}
-function run_banana(&$page, $class, array $args)
+function run_banana($page, $class, array $args)
{
- $banana = new $class(S::v('forlife'), $args);
+ $user = S::user();
+ $banana = new $class($user, $args);
$page->assign('banana', $banana->run());
$page->addCssInline($banana->css());
$page->addCssLink('banana.css');