2 /********************************************************************************
3 * include/groups.inc.php : class for group lists
4 * ------------------------
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
10 /** class for group lists
13 define ( 'BANANA_GROUP_ALL', 0 );
14 define ( 'BANANA_GROUP_SUB', 1 );
15 define ( 'BANANA_GROUP_NEW', 2 );
19 var $overview = Array();
28 function BananaGroups($_type = BANANA_GROUP_SUB
) {
32 $desc = $banana->nntp
->xgtitle();
34 if ($_type == BANANA_GROUP_NEW
) {
35 $list = $banana->nntp
->newgroups($banana->profile
['lastnews']);
37 $list = $banana->nntp
->liste();
38 if ($_type == BANANA_GROUP_SUB
) {
40 foreach ($banana->profile
['subscribe'] as $g) {
41 if (isset($list[$g])) {
42 $mylist[$g] = $list[$g];
49 foreach ($list as $g=>$l) {
50 $this->overview
[$g][0] = isset($desc[$g]) ?
$desc[$g] : '-';
51 $this->overview
[$g][1] = $l[0];
53 ksort($this->overview
);
55 if (empty($this->overview
) && $_type == BANANA_GROUP_SUB
) {
56 $this = new BananaGroups(BANANA_GROUP_ALL
);
61 * @param date INTEGER date of last update
63 function update($_date) {
65 $serverdate = $banana->nntp
->date();
66 if (!$serverdate) $serverdate=time();
67 $newlist = $banana->nntp
->newgroups($_date);
68 if (!$newlist) return false
;
69 $this->date
= $serverdate;
70 foreach (array_keys($newlist) as $g) {
71 $groupstat = $banana->nntp
->group($g);
72 $groupdesc = $banana->nntp
->xgtitle($g);
73 $this->overview
[$g][0]=($groupdesc?
$groupdesc:"-");
74 $this->overview
[$g][1]=$groupstat[0];
79 function to_html($show_form = false
)
82 if (empty($this->overview
)) {
86 $html = '<table class="bicol banana_group" cellspacing="0" cellpadding="2">'."\n";
87 $html .= '<tr><th>'._b_('Total').'</th><th>';
89 $html .= _b_('Abo.').'</th><th>';
90 } elseif ($this->type
== BANANA_GROUP_SUB
) {
91 $html .= _b_('Nouveaux').'</th><th>';
93 $html .= _b_('Nom').'</th><th>'._b_('Description').'</th></tr>'."\n";
96 foreach ($this->overview
as $g => $d) {
98 $ginfo = $banana->nntp
->group($g);
99 $new = count($banana->nntp
->newnews($banana->profile
['lastnews'],$g));
101 $html .= '<tr class="'.($b ?
'pair' : 'impair').'">'."\n";
102 $html .= "<td class='all'>{$ginfo[0]}</td>";
104 $html .= '<td class="new"><input type="checkbox" name="subscribe[]" value="'.$g.'"';
105 if (in_array($g, $banana->profile
['subscribe'])) {
106 $html .= ' checked="checked"';
109 } elseif ($this->type
== BANANA_GROUP_SUB
) {
110 $html .= '<td class="new">'.($new ?
$new : '-').'</td>';
112 $html .= "<td class='grp'><a href='?group=$g'>$g</a></td><td class='dsc'>{$d[0]}</td></tr>";
118 return '<form method="post" action="?"><div class="center"><input type="submit" /></div>'
119 .$html.'<div class="center"><input type="submit" /></div></form>';