Adapt spoolgen
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 15 Jan 2007 11:08:14 +0000 (11:08 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 15 Jan 2007 11:08:14 +0000 (11:08 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1340 839d8a87-29fc-0310-9880-83ba4fa771e5

bin/banana.spoolgen.php
bin/connect.db.inc.php
include/banana/ml.inc.php

index ce5d27c..7c05f62 100755 (executable)
@@ -9,36 +9,9 @@
  ********************************************************************************/
 
 require_once 'connect.db.inc.php';
-require_once dirname(__FILE__).'/../modules/banana/banana.inc.php';
+require_once dirname(__FILE__).'/../include/banana/ml.inc.php';
 
-class MyBanana extends Banana
-{
-    function MyBanana()
-    {
-        global $globals;
-        $this->host = "http://{$globals->banana->web_user}:{$globals->banana->web_pass}@{$globals->banana->server}:{$globals->banana->port}/";
-        parent::Banana();
-    }
-
-    function createAllSpool()
-    {
-        $this->_require('groups');
-        $this->_require('spool');
-        $this->_require('misc');
-
-        $groups = new BananaGroups(BANANA_GROUP_ALL);
-
-        foreach (array_keys($groups->overview) as $g) {
-            print "Generating spool for $g : ";
-            $spool = new BananaSpool($g);
-            print "done.\n";
-            unset($spool);
-        }
-        $this->nntp->quit();
-    }
-}
-
-$banana = new MyBanana();
-$banana->createAllSpool();
+Banana::$nntp_host = "news://{$globals->banana->web_user}:{$globals->banana->web_pass}@{$globals->banana->server}:{$globals->banana->port}/";
+Banana::createAllSpool(array('NNTP', 'MLArchive'));
 system("chown -R www-data:www-data /var/spool/banana");
 ?>
index d8059e3..0fc5ac6 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-ini_set('include_path','/usr/share/php:'.dirname(__FILE__).'/../include');
+ini_set('include_path',dirname(__FILE__).'/../include:/usr/share/php');
 
 require_once('xorg.inc.php');
 require_once('xorg.misc.inc.php');
index 2ae418b..97e43aa 100644 (file)
@@ -78,16 +78,47 @@ class BananaMLArchive extends BananaMBox
         return 'MLArchives';
     }
 
+    public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false)
+    {
+        global $globals;
+        $spool = $globals->lists->spool . '/';
+        $list = glob($spool . '*.mbox', GLOB_ONLYDIR);
+        if ($list === false) {
+            return array();
+        }
+        $groups = array();
+        foreach ($list as $path) {
+            $path = substr($path, strlen($spool));
+            $path = substr($path, 0, -5);
+            list($domain, $listname) = explode($globals->lists->vhost_sep, $path, 2);
+            $group = $listname . '@' . $domain;
+            $groups[$group] = array('desc' => null, 'msgnum' => null, 'unread' => null);
+        }
+        return $groups;
+    }
+
     public function filename()
     {
-        return MLBanana::$domain . '_' . MLBanana::$listname;
+        if (MLBanana::$listname) {
+            $listname = MLBanana::$listname;
+            $domain   = MLBanana::$domain;
+        } else {
+            list($listname, $domain) = explode('@', Banana::$group);
+        }
+        return $domain . '_' . $listname;
     }
 
     protected function getFileName()
     {
         global $globals;
         $base = $globals->lists->spool;
-        $file = MLBanana::$domain . $globals->lists->vhost_sep . MLBanana::$listname . '.mbox';
+        if (MLBanana::$listname) {
+            $listname = MLBanana::$listname;
+            $domain   = MLBanana::$domain;
+        } else {
+            list($listname, $domain) = explode('@', Banana::$group);
+        }
+        $file = $domain . $globals->lists->vhost_sep . $listname . '.mbox';
         return "$base/$file/$file";
     }
 }