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
37 function getDescription()
39 return _("Set simple individual page permissions.");
42 function run($dbi, $argstr, &$request, $basepage)
44 if ($request->getArg('action') != 'browse') {
45 if ($request->getArg('action') != _("PhpWikiAdministration/SetAclSimple")) {
46 return $this->disabled(_("Plugin not run: not in browse mode"));
49 if (!ENABLE_PAGEPERM) {
50 return $this->disabled("ENABLE_PAGEPERM = false");
53 $args = $this->getArgs($argstr, $request);
55 $this->preSelectS($args, $request);
57 $p = $request->getArg('p');
58 $post_args = $request->getArg('admin_setacl');
60 if ($p && !$request->isPost())
63 $pages = $this->_list;
64 $header = HTML::fieldset();
65 if ($p && $request->isPost() &&
66 (!empty($post_args['aclliberal']) || !empty($post_args['aclrestricted']))
68 // without individual PagePermissions:
69 if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
70 $request->_notAuthorized(WIKIAUTH_ADMIN);
71 $this->disabled("! user->isAdmin");
73 if (!empty($post_args['aclliberal'])) {
74 return $this->setaclPages($request, array_keys($p), $this->liberalPerms());
75 } elseif (!empty($post_args['aclrestricted'])) {
76 return $this->setaclPages($request, array_keys($p), $this->restrictedPerms());
80 // List all pages to select from.
81 $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
83 $pagelist = new PageList_Selectable($args['info'],
85 array('types' => array(
87 => new _PageList_Column_acl('acl', _("ACL")))));
89 $pagelist->addPageList($pages);
90 $button_label_liberal = _("Set Liberal Access Rights");
91 $button_label_restrictive = _("Set Restrictive Access Rights");
92 $header = $this->setaclForm($header, $pages);
93 $header->pushContent(HTML::legend(_("Select the pages where to change access rights")));
95 $buttons = HTML::p(Button('submit:admin_setacl[aclliberal]', $button_label_liberal, 'wikiadmin'),
96 Button('submit:admin_setacl[aclrestricted]', $button_label_restrictive, 'wikiadmin'));
97 $header->pushContent($buttons);
99 return HTML::form(array('action' => $request->getPostURL(),
102 $pagelist->getContent(),
103 HiddenInputs($request->getArgs(),
105 array('admin_setacl')),
108 : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
112 * acces rights where everyone can edit
113 * _EVERY: view edit list create;
114 * _ADMIN: remove purge dump change;
115 * _OWNER: remove purge dump change;
118 function liberalPerms()
121 $perm = array('view' => array(ACL_EVERY => true),
122 'edit' => array(ACL_EVERY => true),
123 'create' => array(ACL_EVERY => true),
124 'list' => array(ACL_EVERY => true),
125 'remove' => array(ACL_ADMIN => true,
127 'purge' => array(ACL_ADMIN => true,
129 'dump' => array(ACL_ADMIN => true,
131 'change' => array(ACL_ADMIN => true,
137 * acces rights where only authenticated users can see pages
138 * _AUTHENTICATED: view edit list create;
139 * _ADMIN: remove purge dump change;
140 * _OWNER: remove purge dump change;
141 * _EVERY: -view -edit -list -create;
144 function restrictedPerms()
147 $perm = array('view' => array(ACL_AUTHENTICATED => true,
149 'edit' => array(ACL_AUTHENTICATED => true,
151 'create' => array(ACL_AUTHENTICATED => true,
153 'list' => array(ACL_AUTHENTICATED => true,
155 'remove' => array(ACL_ADMIN => true,
157 'purge' => array(ACL_ADMIN => true,
159 'dump' => array(ACL_ADMIN => true,
161 'change' => array(ACL_ADMIN => true,
166 function setaclForm(&$header, $pagehash)
170 foreach ($pagehash as $name => $checked) {
171 if ($checked) $pages[] = $name;
174 $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br());
183 // c-hanging-comment-ender-p: nil
184 // indent-tabs-mode: nil