| 1 | <?php |
| 2 | /******************************************************************************** |
| 3 | * include/groups.inc.php : class for group lists |
| 4 | * ------------------------ |
| 5 | * |
| 6 | * This file is part of the banana distribution |
| 7 | * Copyright: See COPYING files that comes with this distribution |
| 8 | ********************************************************************************/ |
| 9 | |
| 10 | /** class for group lists |
| 11 | */ |
| 12 | |
| 13 | class groups { |
| 14 | /** group list */ |
| 15 | var $overview; |
| 16 | /** last update */ |
| 17 | var $date; |
| 18 | |
| 19 | /** constructor |
| 20 | * @param $_nntp RESOURCE handle to NNTP socket |
| 21 | */ |
| 22 | |
| 23 | function groups(&$_nntp) { |
| 24 | $desc=$_nntp->xgtitle(); |
| 25 | $list=$_nntp->liste(); |
| 26 | if (!$list) { |
| 27 | $this="list"; |
| 28 | return false; |
| 29 | } |
| 30 | if (isset($desc)) { |
| 31 | foreach ($desc as $g=>$d) { |
| 32 | $this->overview[$g][0]=$d; |
| 33 | $this->overview[$g][1]=$list[$g][0]; |
| 34 | } |
| 35 | foreach (array_diff(array_keys($list),array_keys($desc)) as $g) { |
| 36 | $this->overview[$g][0]="-"; |
| 37 | $this->overview[$g][1]=$list[$g][0]; |
| 38 | } |
| 39 | } else { |
| 40 | foreach ($list as $g=>$l) { |
| 41 | $this->overview[$g][0]="-"; |
| 42 | $this->overview[$g][1]=$l[0]; |
| 43 | } |
| 44 | } |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | /** updates overview |
| 49 | * @param $_nntp RESOURCE handle to NNTP socket |
| 50 | * @param date INTEGER date of last update |
| 51 | */ |
| 52 | function update(&$_nntp,$_date) { |
| 53 | $serverdate = $_nntp->date(); |
| 54 | if (!$serverdate) $serverdate=time(); |
| 55 | $newlist = $_nntp->newgroups($_date); |
| 56 | if (!$newlist) return false; |
| 57 | $this->date = $serverdate; |
| 58 | foreach (array_keys($newlist) as $g) { |
| 59 | $groupstat = $_nntp->group($g); |
| 60 | $groupdesc = $_nntp->xgtitle($g); |
| 61 | $this->overview[$g][0]=($groupdesc?$groupdesc:"-"); |
| 62 | $this->overview[$g][1]=$groupstat[0]; |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | ?> |