From 3aec1c213ff4bc67300f938dde79a10b44285f31 Mon Sep 17 00:00:00 2001 From: x2001corpet Date: Thu, 27 Jul 2006 07:55:34 +0000 Subject: [PATCH] page admin pour le wiki git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@670 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/wiki.php | 4 +-- include/wiki.inc.php | 5 +++ modules/admin.php | 42 +++++++++++++++++++++++++ templates/admin/index.tpl | 6 ++++ templates/admin/wiki.tpl | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 templates/admin/wiki.tpl diff --git a/htdocs/wiki.php b/htdocs/wiki.php index 33697b1..5c65266 100644 --- a/htdocs/wiki.php +++ b/htdocs/wiki.php @@ -92,9 +92,7 @@ if (Env::v('action')) { } $page->assign('perms', $perms); -$page->assign('perms_opts', - array('public' => 'Public', 'logged' => 'Connecté', - 'mdp' => 'Authentifié', 'admin' => 'Admin')); +$page->assign('perms_opts', wiki_perms_options()); $page->assign('canedit', wiki_may_have_perms($perms[1])); $page->assign('has_perms', wiki_may_have_perms('admin')); diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 6ad7cbc..40dc108 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -46,6 +46,11 @@ function wiki_clear_all_cache() system('rm -f '.wiki_work_dir().'/cache_*'); } +function wiki_perms_options() { + return array('public' => 'Public', 'logged' => 'Connecté', + 'mdp' => 'Authentifié', 'admin' => 'Admin'); +} + function wiki_get_perms($n) { $file = wiki_work_dir().'/'.str_replace('/', '.', $n); diff --git a/modules/admin.php b/modules/admin.php index 4a311ad..83eebdf 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -53,6 +53,7 @@ class AdminModule extends PLModule 'admin/trombino' => $this->make_hook('trombino', AUTH_MDP, 'admin'), 'admin/user' => $this->make_hook('user', AUTH_MDP, 'admin'), 'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin'), + 'admin/wiki' => $this->make_hook('wiki', AUTH_MDP, 'admin'), ); } @@ -864,6 +865,47 @@ class AdminModule extends PLModule $page->assign('grades', $res); } } + function handler_wiki(&$page, $action='list') { + require_once 'wiki.inc.php'; + + // update wiki perms + if ($action == 'update') { + $perms_read = Post::v('read'); + $perms_edot = Post::v('edit'); + if ($perms_read || $perms_edit) { + foreach ($_POST as $wiki_page => $val) if ($val == 'on') { + $wiki_page = str_replace('_', '/', $wiki_page); + if (!$perms_read || !$perms_edit) + list($perms0, $perms1) = wiki_get_perms($wiki_page); + if ($perms_read) + $perms0 = $perms_read; + if ($perms_edit) + $perms1 = $perms_edit; + wiki_set_perms($wiki_page, $perms0, $perms1); + } + } + } + + $perms = wiki_perms_options(); + + // list wiki pages and their perms + $wiki_pages = array(); + $dir = wiki_work_dir(); + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') { + list($read,$edit) = wiki_get_perms($file); + $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]); + } + closedir($dh); + } + } + ksort($wiki_pages); + + $page->changeTpl('admin/wiki.tpl'); + $page->assign('wiki_pages', $wiki_pages); + $page->assign('perms_opts', $perms); + } } ?> diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 8ed4f97..6515294 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -124,6 +124,12 @@ Dynamap + + + Wiki :   + Pages et permissions + + {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/admin/wiki.tpl b/templates/admin/wiki.tpl new file mode 100644 index 0000000..fb8fa6b --- /dev/null +++ b/templates/admin/wiki.tpl @@ -0,0 +1,79 @@ +{**************************************************************************} +{* *} +{* 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 *} +{* *} +{**************************************************************************} + +

Pages wiki du site

+ +
+ + + + + + + +{foreach from=$wiki_pages item=perm key=page} + + + + + + +{/foreach} + + + + + + +
+ page + + lecture + + écriture + + action +
+ {$page} {icon name=date_edit title='éditer'} + + {$perm.read} + + {$perm.edit} + + +
+ Attribue les permissions aux pages cochées : + + + + + + +
+
+{* vim:set et sw=2 sts=2 sws=2: *} -- 2.1.4