From: x2000habouzit Date: Tue, 4 Jan 2005 16:47:17 +0000 (+0000) Subject: godferdom X-Git-Tag: 1.8~331 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=1dd3e06ac6843fe01960aad47c1b3695a1666782;p=banana.git godferdom --- diff --git a/include/banana.inc.php.in b/include/banana.inc.php.in index 766830c..1411566 100644 --- a/include/banana.inc.php.in +++ b/include/banana.inc.php.in @@ -8,8 +8,6 @@ ********************************************************************************/ require_once("include/misc.inc.php"); -require_once("include/groups.inc.php"); -require_once("include/format.inc.php"); require_once("include/error.inc.php"); class Banana @@ -33,11 +31,13 @@ class Banana var $host = 'news://localhost:119/'; var $profile = Array( 'name' => 'Anonymous '', 'org' => '', - 'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'lang' => 'fr', 'subscribe' => array()); + 'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'locale' => 'fr_FR', 'subscribe' => array()); var $nntp; - var $spool; + var $groups; + var $newgroups; var $post; + var $spool; function Banana() { @@ -49,6 +49,70 @@ class Banana $this->nntp = new nntp($this->host); } + /**************************************************************************/ + /* actions */ + /**************************************************************************/ + + function action_listGroups() + { + $this->newGroup(BANANA_GROUP_SUB); + + $cuts = displayshortcuts(); + $res = '

'._b_('Les forums de Banana').'

'.$cuts.$this->groups->to_html(); + if (count($this->newgroups->overview)) { + $res .= '

'._b_('Les forums suivants ont été créés depuis ton dernier passage :').'

'; + $res .= $this->newgroups->to_html(); + } + + $this->nntp->quit(); + return $res.$cuts; + } + + function action_showThread($group, $first) + { + $this->newSpool($group, $this->profile['display'], $this->profile['lastnews']); + + if ($first > count($this->spool->overview)) { + $first = count($this->spool->overview); + } + + $first = $first - ($first % $this->tmax) + 1; + + $cuts = displayshortcuts($first); + + $res = '

'.$group.'

'.$cuts; + $res .= $this->spool->to_html($first, $first+$this->tmax); + + $this->nntp->quit(); + + return $res.$cuts; + } + + function action_showArticle($group, $id) + { + $this->newSpool($group, $this->profile['display'], $this->profile['lastnews']); + $this->newPost($id); + if (!$this->post) { + if ($this->nntp->lasterrorcode == "423") { + $this->spool->delid($id); + } + $this->nntp->quit(); + return displayshortcuts().'

'._b_('Impossible d\'accéder au message. Le message a peut-être été annulé').'

'; + } + + $cuts = displayshortcuts(); + $res = '

'._b_('Message').'

'.$cuts; + $res .= $this->post->to_html(); + + $this->nntp->quit(); + + return $res.$cuts; + } + + /**************************************************************************/ + /* */ + /**************************************************************************/ + function newSpool($group, $disp=0, $since='') { require_once('include/spool.inc.php'); $this->spool = new BananaSpool($group, $disp, $since); @@ -61,6 +125,19 @@ class Banana $this->post = new BananaPost($id); } + function newGroup() + { + require_once("include/groups.inc.php"); + $this->groups = new BananaGroups(BANANA_GROUP_SUB); + if ($this->groups->type == BANANA_GROUP_SUB) { + $this->newgroups = new BananaGroups(BANANA_GROUP_NEW); + } + } + + /**************************************************************************/ + /* */ + /**************************************************************************/ + function _setupProfile() { if (function_exists('hook_getprofile')) { @@ -69,7 +146,7 @@ class Banana session_start(); } - setlocale(LC_ALL, $this->profile['locale']); + setlocale(LC_ALL, $this->profile['locale']); } }