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: <<WikiAdminAclDelete >> or called via WikiAdminSelect
28 * Author: Marc-Etienne Vargenau, Alcatel-Lucent
32 require_once 'lib/PageList.php';
33 require_once 'lib/plugin/WikiAdminSelect.php';
35 class WikiPlugin_WikiAdminDeleteAcl
36 extends WikiPlugin_WikiAdminSelect
40 return _("WikiDeleteAcl");
43 function getDescription()
45 return _("Delete page permissions.");
48 function deleteaclPages(&$request, $pages)
50 $result = HTML::div();
52 $dbi =& $request->_dbi;
53 $perm = new PagePermission('');
55 foreach ($pages as $pagename) {
56 // check if unchanged? we need a deep array_equal
57 $page = $dbi->getPage($pagename);
58 $oldperm = getPagePermissions($page);
59 setPagePermissions($page, $perm);
60 $result->setAttr('class', 'feedback');
61 $result->pushContent(HTML::p(fmt("ACL deleted for page ā%sā", $pagename)));
62 $current = $page->getCurrentRevision();
63 $version = $current->getVersion();
64 $meta = $current->_data;
65 $text = $current->getPackedContent();
66 $meta['summary'] = sprintf(_("ACL deleted for page ā%sā"), $pagename);
67 $meta['is_minor_edit'] = 1;
68 $meta['author'] = $request->_user->UserName();
69 unset($meta['mtime']); // force new date
70 $page->save($text, $version + 1, $meta);
75 $result->setAttr('class', 'feedback');
77 $result->pushContent(HTML::p(fmt("%d pages have been changed.", $count)));
80 $result->setAttr('class', 'error');
81 $result->pushContent(HTML::p(_("No pages changed.")));
86 function run($dbi, $argstr, &$request, $basepage)
88 if ($request->getArg('action') != 'browse') {
89 if ($request->getArg('action') != _("PhpWikiAdministration/AdminAclDelete")) {
90 return $this->disabled(_("Plugin not run: not in browse mode"));
93 if (!ENABLE_PAGEPERM) {
94 return $this->disabled("ENABLE_PAGEPERM = false");
97 $args = $this->getArgs($argstr, $request);
99 $this->preSelectS($args, $request);
101 $p = $request->getArg('p');
102 $post_args = $request->getArg('admin_deleteacl');
104 if ($p && !$request->isPost())
106 elseif ($this->_list)
107 $pages = $this->_list;
108 $header = HTML::fieldset();
109 if ($p && $request->isPost()) {
110 if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
111 $request->_notAuthorized(WIKIAUTH_ADMIN);
112 $this->disabled("! user->isAdmin");
114 return $this->deleteaclPages($request, array_keys($p));
117 // List all pages to select from.
118 $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
120 $pagelist = new PageList_Selectable($args['info'],
122 array('types' => array(
124 => new _PageList_Column_acl('acl', _("ACL")))));
126 $pagelist->addPageList($pages);
127 $button_label_delete_acl = _("Delete ACL");
128 $header = $this->deleteaclForm($header, $pages);
129 $header->pushContent(HTML::legend(_("Select the pages where to delete access rights")));
131 $buttons = HTML::p(Button('submit:admin_deleteacl', $button_label_delete_acl, 'wikiadmin'));
132 $header->pushContent($buttons);
134 return HTML::form(array('action' => $request->getPostURL(),
137 $pagelist->getContent(),
138 HiddenInputs($request->getArgs(),
140 array('admin_deleteacl')),
143 : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
146 function deleteaclForm(&$header, $pagehash)
150 foreach ($pagehash as $name => $checked) {
151 if ($checked) $pages[] = $name;
154 $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br());
163 // c-hanging-comment-ender-p: nil
164 // indent-tabs-mode: nil