subscription system
authorx99bachelart <x99bachelart>
Fri, 12 Sep 2003 16:17:22 +0000 (16:17 +0000)
committerx99bachelart <x99bachelart>
Fri, 12 Sep 2003 16:17:22 +0000 (16:17 +0000)
include/groups.inc.php
index.php
locales/fr.inc.php

index 871867e..4c5e647 100644 (file)
@@ -20,26 +20,43 @@ class groups {
    * @param $_nntp RESOURCE handle to NNTP socket
    */
 
-  function groups(&$_nntp) {
+  function groups(&$_nntp,$_type=0) {
+    global $profile;
     $desc=$_nntp->xgtitle();
-    $list=$_nntp->liste();
+    if ($_type==1) {
+      $list=$_nntp->newgroups($profile['lastnews']);
+    } else {
+      $list=$_nntp->liste();
+    }
     if (!$list) {
-      $this="list";
+      $this->overview=array();
       return false;
     }
     if (isset($desc)) {
       foreach ($desc as $g=>$d) {
-        $this->overview[$g][0]=$d;
-        $this->overview[$g][1]=$list[$g][0];
+        if ((($_type==0) and (in_array($g,$profile['subscribe']) or !count($profile['subscribe'])))
+          or (($_type==1) and in_array($g,array_keys($list)))
+          or ($_type==2)) {
+          $this->overview[$g][0]=$d;
+          $this->overview[$g][1]=$list[$g][0];
+        }
       }
       foreach (array_diff(array_keys($list),array_keys($desc)) as $g) {
-        $this->overview[$g][0]="-";
-        $this->overview[$g][1]=$list[$g][0];
+        if ((($_type==0) and (in_array($g,$profile['subscribe']) or !count($profile['subscribe'])))
+          or (($_type==1) and in_array($g,array_keys($list)))
+          or ($_type==2)) {
+          $this->overview[$g][0]="-";
+          $this->overview[$g][1]=$list[$g][0];
+        }
       }
     } else {
       foreach ($list as $g=>$l) {
-        $this->overview[$g][0]="-";
-        $this->overview[$g][1]=$l[0];
+        if ((($_type==0) and (in_array($g,$profile['subscribe']) or !count($profile['subscribe'])))
+          or (($_type==1) and in_array($g,array_keys($list)))
+          or ($_type==2)) {
+          $this->overview[$g][0]="-";
+          $this->overview[$g][1]=$l[0];
+        }
       }
     }
     return true;
index ea3a699..0286da1 100644 (file)
--- a/index.php
+++ b/index.php
@@ -30,8 +30,8 @@ if ($news['user']!="anonymous") {
     exit;
   }
 }
-$groups = new groups($nntp);
-
+$groups = new groups($nntp,0);
+$newgroups = new groups($nntp,1);
 ?>
 
 <div class="<?php echo $css["title"];?>">
@@ -92,6 +92,47 @@ foreach ($groups->overview as $g => $d) {
 ?>
 </table>
 <?php
+if (count($newgroups->overview) and count($profile['subscribe'])) {
+?>
+<p class="normal">
+<?php echo $locale['index']['newgroupstext']; ?>
+</p>
+<table class="<?php echo $css["bicol"];?>" cellspacing="0" cellpadding="2" 
+  summary="<?php echo $locale['index']['summary'];?>">
+  <tr>
+    <th>
+      <?php echo $locale['index']['total'];?>
+    </th>
+    <th>
+      <?php echo $locale['index']['name'];?>
+    </th>
+    <th>
+      <?php echo $locale['index']['description'];?>
+    </th>
+  </tr>
+<?php
+  $pair = true;
+  foreach ($newgroups->overview as $g => $d) {
+    $pair = !$pair;
+    $groupinfo = $nntp->group($g);
+?>
+  <tr class="<?php echo ($pair?$css["pair"]:$css["impair"]);?>" >
+    <td class="<?php echo $css["total"]; ?>">
+      <?php echo $groupinfo[0]; ?>
+    </td>
+    <td class="<?php echo $css["group"]; ?>">
+      <?php echo "<a href=\"thread.php?group=$g\">$g</a>";?>
+    </td>
+    <td class="<?php echo $css["description"]; ?>">
+      <?php echo $d[0];?>
+    </td>
+  </tr>
+<?php
+  } //foreach
+?>
+</table>
+<?php
+} // new newsgroups ?
 
 displayshortcuts();
 
index 98b2f3d..ad0a956 100644 (file)
@@ -28,6 +28,16 @@ $locale['index'] = array(
   'unread' => "Nouveaux",
   'name' => "Nom",
   'description' => "Description",
+  'newgroupstext' => "Les forums suivants ont été créés depuis ton dernier passage :"
+);
+
+$locale['subscribe'] = array(
+  'title' => "Abonnements",
+  'summary' => "Liste des forums",
+  'total' => "Total",
+  'subscribed' => "Abonné",
+  'name' => "Nom",
+  'description' => "Description",
 );
 
 $locale['article'] = array(