}
$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'));
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);
'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'),
);
}
$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);
+ }
}
?>
<a href="admin/geoloc/dynamap">Dynamap</a>
</td>
</tr>
+ <tr class="impair">
+ <td>
+ <strong>Wiki :</strong>
+ <a href="admin/wiki">Pages et permissions</a>
+ </td>
+ </tr>
</table>
{* vim:set et sw=2 sts=2 sws=2: *}
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<h1>Pages wiki du site</h1>
+
+<form action="admin/wiki/update" method="post">
+<table class="bicol">
+ <tr>
+ <th>
+ page
+ </th>
+ <th>
+ lecture
+ </th>
+ <th>
+ écriture
+ </th>
+ <th class="action">
+ action
+ </th>
+ </tr>
+{foreach from=$wiki_pages item=perm key=page}
+ <tr class="{cycle values="impair,pair"}">
+ <td>
+ <a href="{$page|replace:'.':'/'}">{$page}</a> <a href="{$page|replace:'.':'/'}?action=edit" class="indice">{icon name=date_edit title='éditer'}</a>
+ </td>
+ <td class="center">
+ {$perm.read}
+ </td>
+ <td class="center">
+ {$perm.edit}
+ </td>
+ <td class="action">
+ <input type="checkbox" name="{$page|replace:'.':'/'}"/>
+ </td>
+ </tr>
+{/foreach}
+ <tr>
+ <td>
+ Attribue les permissions aux pages cochées :
+ </td>
+ <td>
+ <select name="read">
+ <option value=""> - </option>
+ {html_options options=$perms_opts}
+ </select>
+ </td>
+ <td>
+ <select name="edit">
+ <option value=""> - </option>
+ {html_options options=$perms_opts}
+ </select>
+ </td>
+ <td class="option">
+ <input type="submit" value="ok"/>
+ </td>
+ </tr>
+</table>
+</form>
+{* vim:set et sw=2 sts=2 sws=2: *}