bugfix (spool)
[banana.git] / include / spool.inc.php
index 314267d..3d54680 100644 (file)
@@ -87,7 +87,7 @@ class spool {
          // remove expired messages
          $msgids=array_flip($this->ids);
          for ($id=min(array_keys($this->overview)); $id<$first; $id++) { 
-               $this->delid[$id];
+               $this->delid($id);
          }
          $this->ids=array_flip($msgids);
          $first=max(array_keys($this->overview))+1;
@@ -107,24 +107,36 @@ class spool {
         "$first-$last"));
       $refs = $_nntp->xhdr("References","$first-$last");
 #      $this->date=$nntp->date;
-      if ($this->ids) {
+      if (isset($this->ids)) {
         $this->ids=array_merge($this->ids,array_flip($msgids));
       } else {
         $this->ids=array_flip($msgids);
       }
 
       foreach ($msgids as $id=>$msgid) {
-        $msg = new spoolhead($dates[$id],$subjects[$id],$froms[$id],
-          (isset($this->overview[$id]->desc)?
-          $this->overview[$id]->desc+1:1));
+        if (isset($this->overview[$id])) {
+          $msg = $this->overview[$id];
+          $msg->desc++;
+        } else {
+          $msg = new spoolhead($dates[$id],$subjects[$id],$froms[$id],1);
+        }
         $refs[$id]=str_replace("><","> <",$refs[$id]);
         $msgrefs=preg_split("/( |\t)/",strtr($refs[$id],$this->ids));
         $parents=preg_grep("/^\d+$/",$msgrefs);
         $msg->parent=array_pop($parents);
         $p = $msg->parent;
         while ($p) {
-          $this->overview[$p]->desc++;
-          $p = $this->overview[$p]->parent;
+          if (isset($this->overview[$p])) {
+            $this->overview[$p]->desc++;
+            if (isset($this->overview[$p]->parent)) {
+              $p = $this->overview[$p]->parent;
+            } else {
+              $p = false;
+            }
+          } else {
+            $this->overview[$p] = new spoolhead($dates[$p],$subjects[$p],$froms[$p],1);
+            $p = false; 
+          }
         }
         if ($msg->parent!="") 
           $this->overview[$msg->parent]->children[]=$id;
@@ -158,7 +170,8 @@ class spool {
         switch ($_display) {
           case 1:
             foreach ($this->overview as $i=>$p) {
-              if (!isset($this->overview[$i]->parent) && 
+              if (isset($this->overview[$i]) &&
+              !isset($this->overview[$i]->parent) && 
               ($this->overview[$i]->descunread==0)) {
                 $this->killdesc($i);
               }
@@ -246,6 +259,7 @@ class spool {
 
   function disp_desc($_id,$_index="",$_first=0,$_last=0,$_ref="",
   $_pfx_node="", $_pfx_end="",$_head=true) {
+    global $css;
     $debug = false;
     $spfx_f = '<img src="img/k1.gif" height="21" width="9" alt="o" />'; 
     $spfx_n = '<img src="img/k2.gif" height="21" width="9" alt="*" />'; 
@@ -259,18 +273,18 @@ class spool {
     
     if (!sizeof($this->overview[$_id]->children) && ($_index<=$_last)
     && ($_index>=$_first)) {
-      echo '<tr class="'.($_index%2?"pair":"impair")."\">\n";
-      echo "<td class=\"date\">"
+      echo '<tr class="'.($_index%2?$css["pair"]:$css["impair"])."\">\n";
+      echo "<td class=\"{$css['date']}\">"
         .formatSpoolHeader("date",$this->overview[$_id]->date,$_id,
         $this->group,($_index==$_ref),$this->overview[$_id]->isread)
         ." </td>\n";
-      echo "<td class=\"subject\"><div class=\"tree\">"
+      echo "<td class=\"{$css['subject']}\"><div class=\"{$css['tree']}\">"
         .$_pfx_node.($_head?$spfx_f:$spfx_s)."</div>"
         .formatSpoolHeader("subject",$this->overview[$_id]->subject,$_id,
         $this->group,($_index==$_ref),$this->overview[$_id]->isread)
         .($debug?" $_id $_index ".
         $this->overview[$_id]->desc." ".$this->overview[$_id]->descunread." ":"")." </td>\n";
-      echo "<td class=\"author\">"
+      echo "<td class=\"{$css['author']}\">"
         .formatSpoolHeader("from",$this->overview[$_id]->from,$_id,
         $this->group,($_index==$_ref),$this->overview[$_id]->isread)
         ." </td>\n</tr>";
@@ -278,18 +292,18 @@ class spool {
     } 
     $children = $this->overview[$_id]->children;
     if (($_index<=$_last) && ($_index>=$_first)) {
-      echo '<tr class="'.($_index%2?"pair":"impair")."\">\n";
-      echo "<td class=\"date\">"
+      echo '<tr class="'.($_index%2?$css["pair"]:$css["impair"])."\">\n";
+      echo "<td class=\"{$css['date']}\">"
          .formatSpoolHeader("date",$this->overview[$_id]->date,$_id,
          $this->group,($_index==$_ref),$this->overview[$_id]->isread)
          ." </td>\n";
-      echo "<td class=\"subject\"><div class=\"tree\">"
+      echo "<td class=\"{$css['subject']}\"><div class=\"{$css['tree']}\">"
         .$_pfx_node.$spfx_n."</div>"
         .formatSpoolHeader("subject",$this->overview[$_id]->subject,$_id,
         $this->group,($_index==$_ref),$this->overview[$_id]->isread)
         .($debug?" $_id $_index ".
         $this->overview[$_id]->desc." ".$this->overview[$_id]->descunread." ":"")." </td>\n";
-      echo "<td class=\"author\">"
+      echo "<td class=\"{$css['author']}\">"
         .formatSpoolHeader("from",$this->overview[$_id]->from,$_id,
         $this->group,($_index==$_ref),$this->overview[$_id]->isread)
         ." </td>\n</tr>";
@@ -317,6 +331,7 @@ class spool {
    */
 
   function disp($_first=0,$_last=0,$_ref="") {
+    global $css;
     $index=1;
     if (sizeof($this->overview)) {
       foreach ($this->overview as $id=>$msg) {
@@ -326,7 +341,7 @@ class spool {
         }
       }
     } else {
-     echo "<tr class=\"pair\">\n";
+     echo "<tr class=\"{$css['pair']}\">\n";
      echo "\t<td colspan=\"3\">\n";
      echo "\t\tNo post in this newsgroup\n";
      echo "\t</td>\n";