admin pages, mysql optimizations, menu fixes
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 28 Apr 2005 12:35:57 +0000 (12:35 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:48 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-604

htdocs.net/admin.php [new file with mode: 0644]
htdocs.net/groupe/edit.php
include/xnet/page.inc.php
templates/xnet/admin.tpl [new file with mode: 0644]
upgrade/0.9.6/00_xnet.sql

diff --git a/htdocs.net/admin.php b/htdocs.net/admin.php
new file mode 100644 (file)
index 0000000..f8a928e
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+    require 'xnet.inc.php';
+    new_admin_page('xnet/admin.tpl');
+    $page->useMenu();
+
+    if (Get::has('del')) {
+        $res = $globals->xdb->query('SELECT id, nom, mail_domain FROM groupex.asso WHERE diminutif={?}', Get::get('del'));
+        list($id, $nom, $domain) = $res->fetchOneRow();
+        $page->assign('nom', $nom);
+        if ($id && Post::has('del')) {
+            $globals->xdb->query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
+            $page->trig('membres supprimés');
+
+            if ($domain) {
+                $globals->xdb->query('DELETE FROM  virtual_domains WHERE domain={?}', $domain);
+                $globals->xdb->query('DELETE FROM  virtual, virtual_redirect
+                                            USING  virtual INNER JOIN virtual_redirect USING (vid)
+                                            WHERE  alias LIKE {?}', '%@'.$domain);
+                $page->trig('suppression des alias mails');
+
+                require_once('lists.inc.php');
+                $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $domain);
+                if ($listes = $client->get_lists()) {
+                    foreach ($listes as $l) {
+                        $client->delete_list($l['list'], true);
+                    }
+                    $page->trig('mail lists surpprimées');
+                }
+            }
+            
+            $globals->xdb->query('DELETE FROM groupex.asso WHERE id={?}', $id);
+            $page->trig("Groupe $nom supprimé");
+            Get::kill('del');
+        }
+        if (!$id) {
+            Get::kill('del');
+        }
+    }
+
+    if (Post::has('diminutif')) {
+        $globals->xdb->query('INSERT INTO groupex.asso (id,diminutif) VALUES(NULL,{?})', Post::get('diminutif'));
+        header('Location: '.Post::get('diminutif').'/edit.php');
+    }
+
+    $res = $globals->xdb->query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
+    $page->assign('assos', $res->fetchAllAssoc());
+    
+    $page->run();
+?>
index 8d18421..bdb6d0c 100644 (file)
@@ -12,6 +12,7 @@
                   Post::get('nom'), Post::get('diminutif'), Post::get('cat'), Post::getInt('dom'),
                   Post::get('descr'), Post::get('site'), Post::get('mail'), Post::get('resp'),
                   Post::get('forum'), Post::get('mail_domain'), Post::has('ax'), $globals->asso('id'));
+            $globals->xdb->execute('INSERT INTO virtual_domains (domain) VALUES({?})', Post::get('mail_domain'));
         } else {
             $globals->xdb->execute(
                 "UPDATE  groupex.asso
index 6d83970..cf5c653 100644 (file)
@@ -62,6 +62,9 @@ class XnetPage extends PlatalPage
         $sub['accueil']           = 'index.php';
         $sub['liste des groupes'] = 'plan.php';
         if (logged()) {
+            if (has_perms()) {
+                $sub['admin X.net'] = 'admin.php';
+            }
             $sub['déconnexion']   = 'deconnexion.php';
         }
         $menu["Menu Principal"]   = $sub;
@@ -69,7 +72,7 @@ class XnetPage extends PlatalPage
         if (logged() && (is_member() || may_update())) {
             $sub = array();
             $dim = $globals->asso('diminutif');
-            $sub['accueil'] = "$dim/asso.php";
+            $sub['présentation'] = "$dim/asso.php";
             $sub['annuaire du groupe'] = "$dim/annuaire.php";
             if ($globals->asso('mail_domain')) {
                 $sub['listes de diffusion'] = "$dim/listes.php";
@@ -84,10 +87,11 @@ class XnetPage extends PlatalPage
         if (logged() && may_update()) {
             $sub = array();
             $sub['modifier l\'acceuil'] = "$dim/edit.php";
-            $sub['envoyer un mail']     = "$dim/mail.php";
-            $sub['créer une liste']     = "$dim/listes-create.php";
-            $sub['créer un alias']      = "$dim/alias-create.php";
-
+            if ($globals->asso('mail_domain')) {
+                $sub['envoyer un mail']     = "$dim/mail.php";
+                $sub['créer une liste']     = "$dim/listes-create.php";
+                $sub['créer un alias']      = "$dim/alias-create.php";
+            }
             $menu['Administrer Groupe'] = $sub;
         }
 
diff --git a/templates/xnet/admin.tpl b/templates/xnet/admin.tpl
new file mode 100644 (file)
index 0000000..90c6ffb
--- /dev/null
@@ -0,0 +1,60 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 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                *
+ ***************************************************************************}
+
+{if $smarty.get.del}
+
+<h1>Suppression du groupe {$nom}</h1>
+
+<form action="?del={$smarty.request.del}" method="post">
+  <div class="center">
+    <input type="submit" name="del" value="Oui, je veux supprimer ce groupe" />
+  </div>
+</form>
+
+{else}
+
+<h1>Ajouter un groupe</h1>
+
+<form action="{$smarty.server.PHP_SELF}" method="post">
+  <p class="descr">
+  Pour ajouter un groupe, choisir ici le diminutif qu'il va utiliser,
+  tu seras ensuite redirigé vers une page te permettant d'éditer le groupe :
+  </p>
+  <div class="center">
+    <input type="text" name="diminutif" value="{$smarty.request.diminutif}" />
+    <input type="submit" name="del" value="Ajouter" />
+  </div>
+</form>
+
+
+<h1>Administration des groupes X.net</h1>
+
+<table cellspacing="0" cellpadding="0">
+  {foreach from=$assos item=a key=i name=all}
+  {if $i is even}<tr>{/if}
+    <td><a href='?del={$a.diminutif}'><img src='{rel}/images/del.png' alt='delete' /></a></td>
+    <td><a href='{rel}/{$a.diminutif}/edit.php'>{$a.nom}</a></td>
+    {if $i is odd || $smarty.foreach.all.last}</tr>{/if}
+  {/foreach}
+</table>
+
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index afb1edf..0e1e997 100644 (file)
@@ -1,3 +1,15 @@
 update groupex.asso set nom=replace(nom, '<small>', '');
 update groupex.asso set nom=replace(nom, '</small>', '');
+
 alter table groupex.asso drop column m_list;
+alter table groupex.asso change column nom nom CHAR(255) not null;
+alter table groupex.asso change column diminutif diminutif CHAR(64) not null;
+alter table groupex.asso change column site site CHAR(255) not null;
+alter table groupex.asso change column mail mail CHAR(255) not null;
+alter table groupex.asso change column resp resp CHAR(255) not null;
+alter table groupex.asso change column forum forum CHAR(255) not null;
+alter table groupex.asso change column mail_domain mail_domain CHAR(255) not null;
+alter table groupex.asso add unique index (diminutif);
+
+alter table groupex.membres change column uid uid int not null;
+