Fixes deprecated features in PHP 5.3.x.
[banana.git] / banana / nntp.inc.php
index 6f5d245..f352292 100644 (file)
@@ -14,7 +14,6 @@ require_once dirname(__FILE__) . '/protocoleinterface.inc.php';
 
 class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
 {
-    private $description = null;
     private $ingroup = null;
 
     private $mode = null;
@@ -31,10 +30,8 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
         if (!isset($url['port'])) {
             $url['port'] = 119;
         }
-        if (!isset($url['user'])) {
-            parent::__construct($url['host'], $url['port']);
-        } else {
-            parent::__construct($url['host'], $url['port'], 120, false);
+        parent::__construct($url['host'], $url['port']);
+        if (isset($url['user'])) {
             $this->authinfo($url['user'], $url['pass']);
         }      
     }
@@ -43,14 +40,11 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
      */
     public function getDescription()
     {
-        if ($this->description) {
-            return $this->description;
-        }
         $descs = $this->xgtitle(Banana::$group);
         if (isset($descs[Banana::$group])) {
-            $this->description = $descs[Banana::$group];
+            return trim(utf8_encode($descs[Banana::$group]));
         }
-        return $this->description;
+        return null;
     }
 
     /** Return the list of the boxes
@@ -67,7 +61,11 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
             } else {
                 $list = $this->listGroups();
                 if ($mode == Banana::BOXES_SUB) {
-                    $sub = array_flip(Banana::$profile['subscribe']);
+                    if (is_array(Banana::$profile['subscribe'])) {
+                        $sub = array_flip(Banana::$profile['subscribe']);
+                    } else {
+                        $sub = array();
+                    }
                     $list = array_intersect_key($list, $sub);
                 }
             }
@@ -78,10 +76,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);
         }
@@ -157,10 +155,11 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
         $messages = array();
         foreach ($msg_headers as $header) {
             $headers = $this->xhdr($header, $firstid, $lastid);
-            array_walk($headers, array('BananaMimePart', 'decodeHeader'));
             $header  = strtolower($header);
             if ($header == 'date') {
                 $headers = array_map('strtotime', $headers);
+            } else {
+                array_walk($headers, array('BananaMimePart', 'decodeHeader'));
             }
             foreach ($headers as $id=>&$value) {
                 if (!isset($messages[$id])) {
@@ -210,7 +209,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);
@@ -218,7 +217,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,