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
) {
34 if (empty($this->overview
) && $_type == BANANA_GROUP_SUB
) {
35 $this->type
= BANANA_GROUP_ALL
;
46 $desc = $banana->nntp
->xgtitle();
47 if ($this->type
== BANANA_GROUP_NEW
) {
48 $list = $banana->nntp
->newgroups($banana->profile
['lastnews']);
50 $list = $banana->nntp
->liste();
51 if ($this->type
== BANANA_GROUP_SUB
) {
53 foreach ($banana->profile
['subscribe'] as $g) {
54 if (isset($list[$g])) {
55 $mylist[$g] = $list[$g];
62 foreach ($list as $g=>$l) {
63 $this->overview
[$g][0] = isset($desc[$g]) ?
$desc[$g] : '-';
64 $this->overview
[$g][1] = $l[0];
66 ksort($this->overview
);
70 * @param date INTEGER date of last update
72 function update($_date) {
74 $serverdate = $banana->nntp
->date();
75 if (!$serverdate) $serverdate=time();
76 $newlist = $banana->nntp
->newgroups($_date);
77 if (!$newlist) return false
;
78 $this->date
= $serverdate;
79 foreach (array_keys($newlist) as $g) {
80 $groupstat = $banana->nntp
->group($g);
81 $groupdesc = $banana->nntp
->xgtitle($g);
82 $this->overview
[$g][0]=($groupdesc?
$groupdesc:"-");
83 $this->overview
[$g][1]=$groupstat[0];
88 function to_html($show_form = false
)
91 if (empty($this->overview
)) {
95 $html = '<table class="bicol banana_group" cellspacing="0" cellpadding="2">'."\n";
96 $html .= '<tr><th>'._b_('Total').'</th><th>';
98 $html .= _b_('Abo.').'</th><th>';
99 } elseif ($this->type
== BANANA_GROUP_SUB
) {
100 $html .= _b_('Nouveaux').'</th><th>';
102 $html .= _b_('Nom').'</th><th>'._b_('Description').'</th></tr>'."\n";
105 foreach ($this->overview
as $g => $d) {
107 $ginfo = $banana->nntp
->group($g);
108 $new = count($banana->nntp
->newnews($banana->profile
['lastnews'],$g));
110 $html .= '<tr class="'.($b ?
'pair' : 'impair').'">'."\n";
111 $html .= "<td class='all'>{$ginfo[0]}</td>";
113 $html .= '<td class="new"><input type="checkbox" name="subscribe[]" value="'.$g.'"';
114 if (in_array($g, $banana->profile
['subscribe'])) {
115 $html .= ' checked="checked"';
118 } elseif ($this->type
== BANANA_GROUP_SUB
) {
119 $html .= '<td class="new">'.($new ?
$new : '-').'</td>';
121 $html .= '<td class="grp">' . makeHREF(Array('group' => $g), $g) . '</td><td class="dsc">' . $d[0] . '</td></tr>';
127 return '<form method="post" action="' . htmlentities(makeLink(Array())) . '">'
128 . '<div class="center"><input type="submit" value="Valider" name="validsubs" /></div>'
129 . $html . '<div class="center"><input type="submit" value="Valider" name="validsubs" /></div></form>';
136 // vim:set et sw=4 sts=4 ts=4