4 * Copyright 2004 $ThePhpWikiProgrammingTeam
5 * Copyright 2009-2010 Marc-Etienne Vargenau, Alcatel-Lucent
7 * This file is part of PhpWiki.
9 * PhpWiki is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * PhpWiki is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Set simple individual PagePermissions
27 * Usage: <<WikiAdminSetAclSimple >> or called via WikiAdminSelect
28 * Author: Marc-Etienne Vargenau, Alcatel-Lucent
32 require_once 'lib/plugin/WikiAdminSetAcl.php';
34 class WikiPlugin_WikiAdminSetAclSimple
35 extends WikiPlugin_WikiAdminSetAcl
39 return _("WikiAdminSetAclSimple");
42 function getDescription()
44 return _("Set simple individual page permissions.");
47 function run($dbi, $argstr, &$request, $basepage)
49 if ($request->getArg('action') != 'browse') {
50 if ($request->getArg('action') != _("PhpWikiAdministration/SetAclSimple")) {
51 return $this->disabled(_("Plugin not run: not in browse mode"));
54 if (!ENABLE_PAGEPERM) {
55 return $this->disabled("ENABLE_PAGEPERM = false");
58 $args = $this->getArgs($argstr, $request);
60 $this->preSelectS($args, $request);
62 $p = $request->getArg('p');
63 $post_args = $request->getArg('admin_setacl');
65 if ($p && !$request->isPost())
68 $pages = $this->_list;
69 $header = HTML::fieldset();
70 if ($p && $request->isPost() &&
71 (!empty($post_args['aclliberal']) || !empty($post_args['aclrestricted']))
73 // without individual PagePermissions:
74 if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
75 $request->_notAuthorized(WIKIAUTH_ADMIN);
76 $this->disabled("! user->isAdmin");
78 if (!empty($post_args['aclliberal'])) {
79 return $this->setaclPages($request, array_keys($p), $this->liberalPerms());
80 } elseif (!empty($post_args['aclrestricted'])) {
81 return $this->setaclPages($request, array_keys($p), $this->restrictedPerms());
85 // List all pages to select from.
86 $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
88 $pagelist = new PageList_Selectable($args['info'],
90 array('types' => array(
92 => new _PageList_Column_acl('acl', _("ACL")))));
94 $pagelist->addPageList($pages);
95 $button_label_liberal = _("Set Liberal Access Rights");
96 $button_label_restrictive = _("Set Restrictive Access Rights");
97 $header = $this->setaclForm($header, $pages);
98 $header->pushContent(HTML::legend(_("Select the pages where to change access rights")));
100 $buttons = HTML::p(Button('submit:admin_setacl[aclliberal]', $button_label_liberal, 'wikiadmin'),
101 Button('submit:admin_setacl[aclrestricted]', $button_label_restrictive, 'wikiadmin'));
102 $header->pushContent($buttons);
104 return HTML::form(array('action' => $request->getPostURL(),
107 $pagelist->getContent(),
108 HiddenInputs($request->getArgs(),
110 array('admin_setacl')),
113 : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
117 * acces rights where everyone can edit
118 * _EVERY: view edit list create;
119 * _ADMIN: remove purge dump change;
120 * _OWNER: remove purge dump change;
123 function liberalPerms()
126 $perm = array('view' => array(ACL_EVERY => true),
127 'edit' => array(ACL_EVERY => true),
128 'create' => array(ACL_EVERY => true),
129 'list' => array(ACL_EVERY => true),
130 'remove' => array(ACL_ADMIN => true,
132 'purge' => array(ACL_ADMIN => true,
134 'dump' => array(ACL_ADMIN => true,
136 'change' => array(ACL_ADMIN => true,
142 * acces rights where only authenticated users can see pages
143 * _AUTHENTICATED: view edit list create;
144 * _ADMIN: remove purge dump change;
145 * _OWNER: remove purge dump change;
146 * _EVERY: -view -edit -list -create;
149 function restrictedPerms()
152 $perm = array('view' => array(ACL_AUTHENTICATED => true,
154 'edit' => array(ACL_AUTHENTICATED => true,
156 'create' => array(ACL_AUTHENTICATED => true,
158 'list' => array(ACL_AUTHENTICATED => true,
160 'remove' => array(ACL_ADMIN => true,
162 'purge' => array(ACL_ADMIN => true,
164 'dump' => array(ACL_ADMIN => true,
166 'change' => array(ACL_ADMIN => true,
171 function setaclForm(&$header, $pagehash)
175 foreach ($pagehash as $name => $checked) {
176 if ($checked) $pages[] = $name;
179 $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br());
190 // c-hanging-comment-ender-p: nil
191 // indent-tabs-mode: nil