make prepare_client take a page as an argument, useful for xnet.
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 15 Jul 2006 13:02:14 +0000 (13:02 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 15 Jul 2006 13:02:14 +0000 (13:02 +0000)
implement a XnetLists class that is not more than a subtle variation on the List one.

it just wors \o/

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@492 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs.net/groupe/listes-admin.php [deleted file]
htdocs.net/groupe/listes-archives.php [deleted file]
htdocs.net/groupe/listes-check.php [deleted file]
htdocs.net/groupe/listes-delete.php [deleted file]
htdocs.net/groupe/listes-members.php [deleted file]
htdocs.net/groupe/listes-moderate.php [deleted file]
htdocs.net/groupe/listes-options.php [deleted file]
htdocs.net/groupe/listes-soptions.php [deleted file]
htdocs.net/index.php
modules/lists.php
modules/xnetlists.php [new file with mode: 0644]

diff --git a/htdocs.net/groupe/listes-admin.php b/htdocs.net/groupe/listes-admin.php
deleted file mode 100644 (file)
index 8e1aa9e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('listes.php');
-$liste  = strtolower(Env::get('liste'));
-$domain = $globals->asso('mail_domain');
-
-new_group_page('listes/admin.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/admin.php');
-
-?>
diff --git a/htdocs.net/groupe/listes-archives.php b/htdocs.net/groupe/listes-archives.php
deleted file mode 100644 (file)
index ba01d0c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('listes.php');
-$liste  = strtolower(Env::get('liste'));
-$domain = $globals->asso('mail_domain');
-
-new_group_page('listes/archives.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/archives.php');
-
-?>
diff --git a/htdocs.net/groupe/listes-check.php b/htdocs.net/groupe/listes-check.php
deleted file mode 100644 (file)
index 7962154..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('index.php');
-$liste = strtolower(Env::get('liste'));
-
-new_groupadmin_page('listes/check.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/check.php');
-
-?>
diff --git a/htdocs.net/groupe/listes-delete.php b/htdocs.net/groupe/listes-delete.php
deleted file mode 100644 (file)
index 031b469..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('listes.php');
-$liste = strtolower(Env::get('liste'));
-
-new_group_page('listes/delete.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/delete.php');
-
-?>
diff --git a/htdocs.net/groupe/listes-members.php b/htdocs.net/groupe/listes-members.php
deleted file mode 100644 (file)
index 06ca91f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('listes.php');
-$liste = strtolower(Env::get('liste'));
-
-new_group_page('listes/members.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/members.php');
-
-?>
diff --git a/htdocs.net/groupe/listes-moderate.php b/htdocs.net/groupe/listes-moderate.php
deleted file mode 100644 (file)
index 2ed5009..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('listes.php');
-$liste  = strtolower(Env::get('liste'));
-$domain = $globals->asso('mail_domain');
-
-if (preg_match("!(?:[a-z0-9]+\\.)?{".$globals->asso('mail_domain')."}_(.*)!", $liste, $matches)) {
-    redirect("{$_SERVER['PHP_SELF']}?liste={$matches[1]}");
-}
-
-new_group_page('listes/moderate.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/moderate.php');
-
-?>
diff --git a/htdocs.net/groupe/listes-options.php b/htdocs.net/groupe/listes-options.php
deleted file mode 100644 (file)
index d1174cb..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('listes.php');
-$liste = strtolower(Env::get('liste'));
-
-new_group_page('listes/options.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/options.php');
-
-?>
diff --git a/htdocs.net/groupe/listes-soptions.php b/htdocs.net/groupe/listes-soptions.php
deleted file mode 100644 (file)
index 2eb4b43..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xnet.inc.php';
-if (!Env::has('liste')) redirect('listes.php');
-$liste = strtolower(Env::get('liste'));
-
-new_groupadmin_page('listes/soptions.tpl');
-$page->assign('force_list_super', may_update());
-
-require_once('lists.inc.php');
-$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
-require(dirname(dirname(dirname(__FILE__))).'/htdocs/listes/soptions.php');
-
-?>
index 8ee3c5d..cf5079d 100644 (file)
@@ -24,7 +24,7 @@ require 'xnet.inc.php';
 require_once dirname(__FILE__).'/../classes/Xnet.php';
 require_once dirname(__FILE__).'/../classes/PLModule.php';
 
-$platal = new Xnet('xnet', 'xnetgrp');
+$platal = new Xnet('xnet', 'xnetgrp', 'xnetlists');
 $platal->run();
 
 ?>
index 5d445e6..2f74ea6 100644 (file)
@@ -43,7 +43,7 @@ class ListsModule extends PLModule
         );
     }
 
-    function prepare_client()
+    function prepare_client(&$page)
     {
         require_once 'lists.inc.php';
 
@@ -54,7 +54,7 @@ class ListsModule extends PLModule
     {
         global $globals;
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/index.tpl');
         $page->assign('xorg_title','Polytechnique.org - Listes de diffusion');
@@ -171,7 +171,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/members.tpl');
 
@@ -232,7 +232,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/trombi.tpl');
 
@@ -269,7 +269,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/archives.tpl');
 
@@ -313,7 +313,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/moderate.tpl');
 
@@ -414,7 +414,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/admin.tpl');
 
@@ -494,7 +494,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/options.tpl');
 
@@ -547,7 +547,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/delete.tpl');
 
@@ -577,7 +577,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/soptions.tpl');
 
@@ -605,7 +605,7 @@ class ListsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $this->prepare_client();
+        $this->prepare_client($page);
 
         $page->changeTpl('listes/check.tpl');
 
diff --git a/modules/xnetlists.php b/modules/xnetlists.php
new file mode 100644 (file)
index 0000000..08a0aee
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once dirname(__FILE__).'/lists.php';
+
+class XnetListsModule extends ListsModule
+{
+    var $client;
+
+    function handlers()
+    {
+        return array(
+            'grp/lists'           => $this->make_hook('lists',     AUTH_MDP),
+            'grp/lists/create'    => $this->make_hook('create',    AUTH_MDP),
+
+            'grp/lists/members'   => $this->make_hook('members',   AUTH_COOKIE),
+            'grp/lists/trombi'    => $this->make_hook('trombi',    AUTH_COOKIE),
+            'grp/lists/archives'  => $this->make_hook('archives',  AUTH_COOKIE),
+
+            'grp/lists/moderate'  => $this->make_hook('moderate',  AUTH_MDP),
+            'grp/lists/admin'     => $this->make_hook('admin',     AUTH_MDP),
+            'grp/lists/options'   => $this->make_hook('options',   AUTH_MDP),
+            'grp/lists/delete'    => $this->make_hook('delete',    AUTH_MDP),
+
+            'grp/lists/soptions'  => $this->make_hook('soptions',  AUTH_MDP),
+            'grp/lists/check'     => $this->make_hook('check',     AUTH_MDP),
+
+            /* hack: lists uses that */
+            'profile' => $this->make_hook('profile', AUTH_PUBLIC),
+        );
+    }
+
+    function prepare_client(&$page)
+    {
+        global $globals;
+
+        require_once 'lists.inc.php';
+
+        $this->client =& lists_xmlrpc(Session::getInt('uid'),
+                                      Session::get('password'),
+                                      $globals->asso('mail_domain'));
+
+        $page->useMenu();
+        $page->assign('asso', $globals->asso());
+        $page->setType($globals->asso('cat'));
+    }
+
+    function handler_profile(&$page, $user = null)
+    {
+        redirect('https://www.polytechnique.org/profile/'.$user);
+    }
+}
+
+?>