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
20 * along with PhpWiki; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
38 return _("WikiAdminSetAclSimple");
41 function getDescription() {
42 return _("Set simple individual page permissions.");
45 function run($dbi, $argstr, &$request, $basepage) {
46 if ($request->getArg('action') != 'browse')
47 if ($request->getArg('action') != _("PhpWikiAdministration/SetAclSimple"))
48 return $this->disabled("(action != 'browse')");
50 return $this->disabled("ENABLE_PAGEPERM = false");
52 $args = $this->getArgs($argstr, $request);
54 $this->preSelectS($args, $request);
56 $p = $request->getArg('p');
57 $post_args = $request->getArg('admin_setacl');
59 if ($p && !$request->isPost())
62 $pages = $this->_list;
63 $header = HTML::fieldset();
64 if ($p && $request->isPost() &&
65 (!empty($post_args['aclliberal']) || !empty($post_args['aclrestricted']))) {
66 // without individual PagePermissions:
67 if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
68 $request->_notAuthorized(WIKIAUTH_ADMIN);
69 $this->disabled("! user->isAdmin");
71 if (!empty($post_args['aclliberal'])) {
72 return $this->setaclPages($request, array_keys($p), $this->liberalPerms());
73 } else if (!empty($post_args['aclrestricted'])) {
74 return $this->setaclPages($request, array_keys($p), $this->restrictedPerms());
78 // List all pages to select from.
79 $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
81 $pagelist = new PageList_Selectable($args['info'],
83 array('types' => array(
85 => new _PageList_Column_acl('acl', _("ACL")))));
87 $pagelist->addPageList($pages);
88 $button_label_liberal = _("Set Liberal Access Rights");
89 $button_label_restrictive = _("Set Restrictive Access Rights");
90 $header = $this->setaclForm($header, $pages);
91 $header->pushContent(HTML::legend(_("Select the pages where to change access rights")));
93 $buttons = HTML::p(Button('submit:admin_setacl[aclliberal]', $button_label_liberal, 'wikiadmin'),
94 Button('submit:admin_setacl[aclrestricted]', $button_label_restrictive, 'wikiadmin'));
95 $header->pushContent($buttons);
97 return HTML::form(array('action' => $request->getPostURL(),
100 $pagelist->getContent(),
101 HiddenInputs($request->getArgs(),
103 array('admin_setacl')),
106 : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
110 * acces rights where everyone can edit
111 * _EVERY: view edit list create;
112 * _ADMIN: remove purge dump change;
113 * _OWNER: remove purge dump change;
116 function liberalPerms() {
118 $perm = array('view' => array(ACL_EVERY => true),
119 'edit' => array(ACL_EVERY => true),
120 'create' => array(ACL_EVERY => true),
121 'list' => array(ACL_EVERY => true),
122 'remove' => array(ACL_ADMIN => true,
124 'purge' => array(ACL_ADMIN => true,
126 'dump' => array(ACL_ADMIN => true,
128 'change' => array(ACL_ADMIN => true,
134 * acces rights where only authenticated users can see pages
135 * _AUTHENTICATED: view edit list create;
136 * _ADMIN: remove purge dump change;
137 * _OWNER: remove purge dump change;
138 * _EVERY: -view -edit -list -create;
141 function restrictedPerms() {
143 $perm = array('view' => array(ACL_AUTHENTICATED => true,
145 'edit' => array(ACL_AUTHENTICATED => true,
147 'create' => array(ACL_AUTHENTICATED => true,
149 'list' => array(ACL_AUTHENTICATED => true,
151 'remove' => array(ACL_ADMIN => true,
153 'purge' => array(ACL_ADMIN => true,
155 'dump' => array(ACL_ADMIN => true,
157 'change' => array(ACL_ADMIN => true,
162 function setaclForm(&$header, $pagehash) {
165 foreach ($pagehash as $name => $checked) {
166 if ($checked) $pages[] = $name;
169 $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ',$pages)), HTML::br());
178 // c-hanging-comment-ender-p: nil
179 // indent-tabs-mode: nil