Merge a protocole independent version of spoolgen in Banana itself
[banana.git] / banana / banana.inc.php.in
index 0b3c77c..df1768b 100644 (file)
@@ -45,6 +45,7 @@ class Banana
     static public $msgshow_mimeparts = array('multipart/report', 'multipart/mixed', 'text/html', 'text/plain', 'text/enriched', 'text', 'message');
     static public $msgshow_xface     = true;
     static public $msgshow_wrap      = 78;
+    static public $msgshow_externalimages = false;
     static public $msgshow_withthread = true;
 
     /** Match an url
@@ -444,6 +445,49 @@ class Banana
     }
 
     /**************************************************************************/
+    /* Spoolgen functions                                                     */
+    /**************************************************************************/
+
+    private function checkErrors()
+    {
+        if (Banana::$protocole->lastErrno()) {
+            echo "\nL'erreur suivante s'est produite : "
+                . Banana::$protocole->lastErrno() . " "
+                . Banana::$protocole->lastError() . "\n";
+            return false;
+        }
+        return true;
+    } 
+
+    static public function createAllSpool(array $protos)
+    {
+        foreach ($protos as $proto) {
+            $banana = new Banana(array(), $proto);
+
+            if (!$banana->checkErrors()) {
+                continue;
+            }
+            $groups = Banana::$protocole->getBoxList();
+            if (!$banana->checkErrors()) {
+                continue;
+            }
+
+            print "** $proto **\n";
+            foreach (array_keys($groups) as $g) {
+                print "Generating spool for $g : ";
+                Banana::$group = $g;
+                $spool = $banana->loadSpool($g);
+                if (!$banana->checkErrors()) {
+                    break;
+                }
+                print "done.\n";
+                unset($spool);
+            }
+            print "\n";
+        }
+    }
+
+    /**************************************************************************/
     /* Private functions                                                      */
     /**************************************************************************/
 
@@ -455,6 +499,10 @@ class Banana
             if ($group == @$_SESSION['banana_group'] && isset($_SESSION['banana_spool'])) {
                 Banana::$spool = unserialize($_SESSION['banana_spool']);
                 $clean = @(Banana::$profile['lastnews'] != $_SESSION['banana_lastnews']);
+            } else {
+                unset($_SESSION['banana_message']);
+                unset($_SESSION['banana_artid']);
+                unset($_SESSION['banana_showhdr']);
             }
             BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup'] || $clean);
             $_SESSION['banana_group'] = $group;