X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fbanana.inc.php;h=4f009f88d175ea1062ef13c53bebd6de30f63c73;hb=7e6495d42e104f9d85561ba58f0bf4d1eb7fce94;hp=8cef0d0289af468f440430e428e262620bc08d04;hpb=4475197cd74c1190b520bfa0ac1ad293ffc524ff;p=platal.git diff --git a/include/banana.inc.php b/include/banana.inc.php index 8cef0d0..4f009f8 100644 --- a/include/banana.inc.php +++ b/include/banana.inc.php @@ -1,6 +1,6 @@ fiche]"; +function hook_formatDisplayHeader($_header, $_text) { + global $globals, $banana; + if ($_header == 'from') { + $id = $banana->post->headers['x-org-id']; + $_text = formatFrom($_text); + return $_text . ' ' + . 'fiche' + . ''; } } -function hook_headerTranslate($hdr) { - if ($hdr == 'x-org-id') { - return 'Identité'; +function hook_checkcancel($_headers) { + return ($_headers['x-org-id'] == Session::get('forlife') or has_perms()); +} + +function hook_makeLink($params) { + global $globals; + $base = $globals->baseurl . '/banana'; + if ($params['subscribe'] == 1) { + return $base . '/subscription'; + } + if (isset($params['xface'])) { + return $base . '/xface/' . strtr(base64_encode($params['xface']), '+/', '.:'); + } + + if (!isset($params['group'])) { + return $base; + } + $base .= '/' . $params['group']; + + if (isset($params['first'])) { + return $base . '/from/' . $params['first']; + } + if (isset($params['artid'])) { + if ($params['action'] == 'new') { + $base .= '/reply'; + } elseif ($params['action'] == 'cancel') { + $base .= '/cancel'; + } else { + $base .= '/read'; + } + return $base . '/' . $params['artid']; + } + + if ($params['action'] == 'new') { + return $base . '/new'; } + return $base; } -function hook_checkcancel($_headers) { - return ($_headers['x-org-id'] == Session::get('forlife') or has_perms()); +function hook_makeImg($img, $alt, $height, $width) +{ + global $globals; + $url = $globals->baseurl . '/images/banana/' . $img . '.gif'; + + if (!is_null($width)) { + $width = ' width="' . $width . '"'; + } + if (!is_null($height)) { + $height = ' height="' . $height . '"'; + } + + return '' . $alt . ''; +} + +function hook_getSubject(&$subject) +{ + if (preg_match('!(.*\S)\s*\[=> ([^\]\s]+)\]!', $subject, $matches)) { + $subject = $matches[1]; + global $banana; + if ($banana->state['group'] == $matches[2]) { + return ' [=> ' . $matches[2] . ']'; + } else { + return ' [=> ' . makeHREF(Array('group' => $matches[2]), $matches[2]) . ']'; + } + } + return null; } class PlatalBanana extends Banana @@ -71,14 +134,14 @@ class PlatalBanana extends Banana $globals->xdb->execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid); } - $req = $globals->xdb->query( - "SELECT nom + $req = $globals->xdb->query(" + SELECT nom FROM {$globals->banana->table_prefix}abos LEFT JOIN {$globals->banana->table_prefix}list ON list.fid=abos.fid WHERE uid={?}", $uid); $this->profile['subscribe'] = $req->fetchColumn(); - array_splice($this->show_hdr, count($this->show_hdr) - 2, 0, 'x-org-id'); + array_splice($this->show_hdr, count($this->show_hdr) - 2, 0); array_splice($this->parse_hdr, count($this->parse_hdr) - 2, 0, 'x-org-id'); $this->host = 'news://web_'.Session::get('forlife') @@ -87,16 +150,16 @@ class PlatalBanana extends Banana parent::Banana(); } - function run() + function run($params = null) { global $banana, $globals; - if (Get::get('banana') == 'updateall') { + if (Get::get('banana') == 'updateall' + || (!is_null($params) && isset($params['banana']) && $params['banana'] == 'updateall')) { $globals->xdb->execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), Session::getInt('uid')); $_SESSION['banana_last'] = time(); - redirect($_SERVER['PHP_SELF']); } - return Banana::run('PlatalBanana'); + return Banana::run('PlatalBanana', $params); } function action_saveSubs()