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 * Delete 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
38 function getDescription()
40 return _("Delete page permissions.");
43 private function deleteaclPages(&$request, $pages)
45 $result = HTML::div();
47 $dbi =& $request->_dbi;
48 $perm = new PagePermission('');
50 foreach ($pages as $pagename) {
51 // check if unchanged? we need a deep array_equal
52 $page = $dbi->getPage($pagename);
53 setPagePermissions($page, $perm);
54 $result->setAttr('class', 'feedback');
55 $result->pushContent(HTML::p(fmt("ACL deleted for page ā%sā", $pagename)));
56 $current = $page->getCurrentRevision();
57 $version = $current->getVersion();
58 $meta = $current->_data;
59 $text = $current->getPackedContent();
60 $meta['summary'] = sprintf(_("ACL deleted for page ā%sā"), $pagename);
61 $meta['is_minor_edit'] = 1;
62 $meta['author'] = $request->_user->UserName();
63 unset($meta['mtime']); // force new date
64 $page->save($text, $version + 1, $meta);
69 $result->setAttr('class', 'feedback');
71 $result->pushContent(HTML::p(fmt("%d pages have been changed.", $count)));
74 $result->setAttr('class', 'error');
75 $result->pushContent(HTML::p(_("No pages changed.")));
82 * @param string $argstr
83 * @param WikiRequest $request
84 * @param string $basepage
87 function run($dbi, $argstr, &$request, $basepage)
89 if ($request->getArg('action') != 'browse') {
90 if ($request->getArg('action') != __("PhpWikiAdministration")."/".__("AdminDeleteAcl")) {
91 return $this->disabled(_("Plugin not run: not in browse mode"));
94 if (!ENABLE_PAGEPERM) {
95 return $this->disabled("ENABLE_PAGEPERM = false");
98 $args = $this->getArgs($argstr, $request);
100 $this->preSelectS($args, $request);
102 $p = $request->getArg('p');
103 $post_args = $request->getArg('admin_deleteacl');
105 if ($p && !$request->isPost())
107 elseif ($this->_list)
108 $pages = $this->_list;
109 $header = HTML::fieldset();
110 if ($p && $request->isPost()) {
111 if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
112 $request->_notAuthorized(WIKIAUTH_ADMIN);
113 $this->disabled("! user->isAdmin");
115 return $this->deleteaclPages($request, array_keys($p));
118 // List all pages to select from.
119 $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
121 $pagelist = new PageList_Selectable($args['info'],
123 array('types' => array(
125 => new _PageList_Column_acl('acl', _("ACL")))));
127 $pagelist->addPageList($pages);
128 $button_label_delete_acl = _("Delete ACL");
129 $header->pushContent(HTML::legend(_("Select the pages where to delete access rights")));
130 $buttons = HTML::p(Button('submit:admin_deleteacl', $button_label_delete_acl, 'wikiadmin'));
131 $header->pushContent($buttons);
133 return HTML::form(array('action' => $request->getPostURL(),
136 $pagelist->getContent(),
137 HiddenInputs($request->getArgs(),
139 array('admin_deleteacl')),
142 : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
150 // c-hanging-comment-ender-p: nil
151 // indent-tabs-mode: nil