X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fbanana%2Fhooks.inc.php;h=f881814f377ecc13664987e539642a7e4b4acf38;hb=bc0276a2d79d88a56656514fe24bd427c0ef3b88;hp=f5f608ae3edb495eae1348a80fc4d7d63b561c9d;hpb=eb5632361d837d1d4f813d4f77e52d6702a0d523;p=platal.git diff --git a/include/banana/hooks.inc.php b/include/banana/hooks.inc.php index f5f608a..f881814 100644 --- a/include/banana/hooks.inc.php +++ b/include/banana/hooks.inc.php @@ -1,6 +1,6 @@ token . '/rss.xml'; } function hook_platalMessageLink($params) @@ -177,20 +178,25 @@ function hook_hasXFace($headers) 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; } } @@ -301,7 +307,7 @@ class PlatalBananaPage extends BananaPage class BananaHandler { - public function __construct(PlWizard &$wiz) + public function __construct(PlWizard $wiz) { } @@ -310,7 +316,7 @@ class BananaHandler return 'banana/index.tpl'; } - public function prepare(PlPage &$page, $id) + public function prepare(PlPage $page, $id) { } @@ -322,9 +328,10 @@ class BananaHandler } } -function run_banana(&$page, $class, array $args) +function run_banana($page, $class, array $args) { - $banana = new $class(S::user(), $args); + $user = S::user(); + $banana = new $class($user, $args); $page->assign('banana', $banana->run()); $page->addCssInline($banana->css()); $page->addCssLink('banana.css');