Fixes vim mode line.
[banana.git] / banana / nntp.inc.php
index 6245803..1076a57 100644 (file)
@@ -26,14 +26,16 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
         $url = parse_url(Banana::$nntp_host);
         if ($url['scheme'] == 'nntps' || $url['scheme'] == 'snntp') {
             $url['host'] = 'ssl://' . $url['host'];
-        }
-        if (!isset($url['port'])) {
+            if (!isset($url['port'])) {
+                $url['port'] = 563;
+            }
+        } else if (!isset($url['port'])) {
             $url['port'] = 119;
         }
         parent::__construct($url['host'], $url['port']);
         if (isset($url['user'])) {
             $this->authinfo($url['user'], $url['pass']);
-        }      
+        }
     }
 
     /** Return the descript;ion of the current box
@@ -76,10 +78,10 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
                     if (!is_utf8($desc)) {
                         $desc = utf8_encode($desc);
                     }
-                    $this->boxes[$group] = array('desc' => $desc);           
+                    $this->boxes[$group] = array('desc' => $desc);
                 } else {
                     $this->boxes[$group] = array('desc' => null);
-                }    
+                }
             }
             ksort($this->boxes);
         }
@@ -87,7 +89,25 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
             foreach ($this->boxes as $group=>&$desc) {
                 list($msgnum, $first, $last, $groupname) = $this->group($group);
                 $this->ingroup = $group;
-                $new = count($this->newnews($group, $since));
+                $new = $this->newnews($group, $since);
+                if (!is_array($new)) {
+                    $new = 0;
+                } else {
+                    $c = count($new);
+                    if ($c > 0 && function_exists('hook_listReadMessages')) {
+                        $msgs = hook_listReadMessages($group);
+                        if (is_array($msgs)) {
+                            foreach ($msgs as $msg) {
+                                if (is_numeric($msg)) {
+                                    $c--;
+                                } else if (in_array($msg, $new)) {
+                                    $c--;
+                                }
+                            }
+                        }
+                    }
+                    $new = $c;
+                }
                 $desc['msgnum'] = $msgnum;
                 $desc['unread'] = $new;
             }
@@ -209,7 +229,7 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
 
     /** Send the message
      */
-    public function send(BananaMessage &$message)
+    public function send(BananaMessage $message)
     {
         $sources = $message->get(true);
         return $this->post($sources);
@@ -217,7 +237,7 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
 
     /** Cancel the message
      */
-    public function cancel(BananaMessage &$message)
+    public function cancel(BananaMessage $message)
     {
         $headers = Array('From' => Banana::$profile['From'],
                          'Newsgroups' => Banana::$group,
@@ -253,5 +273,5 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
     }
 }
 
-// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
+// vim:set et sw=4 sts=4 ts=4 fenc=utf-8:
 ?>