From: <var...@us...> - 2012-11-14 17:38:55
|
Revision: 8462 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8462&view=rev Author: vargenau Date: 2012-11-14 17:38:49 +0000 (Wed, 14 Nov 2012) Log Message: ----------- Add action DeleteAcl Added Paths: ----------- trunk/lib/plugin/WikiAdminDeleteAcl.php Added: trunk/lib/plugin/WikiAdminDeleteAcl.php =================================================================== --- trunk/lib/plugin/WikiAdminDeleteAcl.php (rev 0) +++ trunk/lib/plugin/WikiAdminDeleteAcl.php 2012-11-14 17:38:49 UTC (rev 8462) @@ -0,0 +1,167 @@ +<?php + +/* + * Copyright 2004 $ThePhpWikiProgrammingTeam + * Copyright 2009-2010 Marc-Etienne Vargenau, Alcatel-Lucent + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * Set simple individual PagePermissions + * + * Usage: <<WikiAdminAclDelete >> or called via WikiAdminSelect + * Author: Marc-Etienne Vargenau, Alcatel-Lucent + * + */ + +require_once 'lib/PageList.php'; +require_once 'lib/plugin/WikiAdminSelect.php'; + +class WikiPlugin_WikiAdminDeleteAcl + extends WikiPlugin_WikiAdminSelect +{ + function getName() + { + return _("WikiDeleteAcl"); + } + + function getDescription() + { + return _("Delete page permissions."); + } + + function deleteaclPages(&$request, $pages) + { + $result = HTML::div(); + $count = 0; + $dbi =& $request->_dbi; + $perm = new PagePermission(''); + $perm->sanify(); + foreach ($pages as $pagename) { + // check if unchanged? we need a deep array_equal + $page = $dbi->getPage($pagename); + $oldperm = getPagePermissions($page); + setPagePermissions($page, $perm); + $result->setAttr('class', 'feedback'); + $result->pushContent(HTML::p(fmt("ACL deleted for page '%s'", $pagename))); + $current = $page->getCurrentRevision(); + $version = $current->getVersion(); + $meta = $current->_data; + $text = $current->getPackedContent(); + $meta['summary'] = sprintf(_("ACL deleted for page '%s'."), $pagename); + $meta['is_minor_edit'] = 1; + $meta['author'] = $request->_user->UserName(); + unset($meta['mtime']); // force new date + $page->save($text, $version + 1, $meta); + $count++; + } + if ($count) { + $dbi->touch(); + $result->setAttr('class', 'feedback'); + if ($count > 1) { + $result->pushContent(HTML::p(fmt("%d pages have been changed.", $count))); + } + } else { + $result->setAttr('class', 'error'); + $result->pushContent(HTML::p(_("No pages changed."))); + } + return $result; + } + + function run($dbi, $argstr, &$request, $basepage) + { + if ($request->getArg('action') != 'browse') { + if ($request->getArg('action') != _("PhpWikiAdministration/AdminAclDelete")) { + return $this->disabled(_("Plugin not run: not in browse mode")); + } + } + if (!ENABLE_PAGEPERM) { + return $this->disabled("ENABLE_PAGEPERM = false"); + } + + $args = $this->getArgs($argstr, $request); + $this->_args = $args; + $this->preSelectS($args, $request); + + $p = $request->getArg('p'); + $post_args = $request->getArg('admin_deleteacl'); + $pages = array(); + if ($p && !$request->isPost()) + $pages = $p; + elseif ($this->_list) + $pages = $this->_list; + $header = HTML::fieldset(); + if ($p && $request->isPost()) { + if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { + $request->_notAuthorized(WIKIAUTH_ADMIN); + $this->disabled("! user->isAdmin"); + } + return $this->deleteaclPages($request, array_keys($p)); + } + if (empty($pages)) { + // List all pages to select from. + $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); + } + $pagelist = new PageList_Selectable($args['info'], + $args['exclude'], + array('types' => array( + 'acl' + => new _PageList_Column_acl('acl', _("ACL"))))); + + $pagelist->addPageList($pages); + $button_label_delete_acl = _("Delete ACL"); + $header = $this->deleteaclForm($header, $pages); + $header->pushContent(HTML::legend(_("Select the pages where to delete access rights"))); + + $buttons = HTML::p(Button('submit:admin_deleteacl', $button_label_delete_acl, 'wikiadmin')); + $header->pushContent($buttons); + + return HTML::form(array('action' => $request->getPostURL(), + 'method' => 'post'), + $header, + $pagelist->getContent(), + HiddenInputs($request->getArgs(), + false, + array('admin_deleteacl')), + ENABLE_PAGEPERM + ? '' + : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))); + } + + function deleteaclForm(&$header, $pagehash) + { + + $pages = array(); + foreach ($pagehash as $name => $checked) { + if ($checked) $pages[] = $name; + } + + $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br()); + return $header; + } +} + + + +// Local Variables: +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil +// End: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-09-12 14:18:15
|
Revision: 9075 http://sourceforge.net/p/phpwiki/code/9075 Author: vargenau Date: 2014-09-12 14:18:12 +0000 (Fri, 12 Sep 2014) Log Message: ----------- Remove useless code Modified Paths: -------------- trunk/lib/plugin/WikiAdminDeleteAcl.php Modified: trunk/lib/plugin/WikiAdminDeleteAcl.php =================================================================== --- trunk/lib/plugin/WikiAdminDeleteAcl.php 2014-09-12 12:48:30 UTC (rev 9074) +++ trunk/lib/plugin/WikiAdminDeleteAcl.php 2014-09-12 14:18:12 UTC (rev 9075) @@ -119,9 +119,7 @@ $pagelist->addPageList($pages); $button_label_delete_acl = _("Delete ACL"); - $header = $this->deleteaclForm($header, $pages); $header->pushContent(HTML::legend(_("Select the pages where to delete access rights"))); - $buttons = HTML::p(Button('submit:admin_deleteacl', $button_label_delete_acl, 'wikiadmin')); $header->pushContent($buttons); @@ -136,18 +134,6 @@ ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))); } - - function deleteaclForm(&$header, $pagehash) - { - - $pages = array(); - foreach ($pagehash as $name => $checked) { - if ($checked) $pages[] = $name; - } - - $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::samp(join(', ', $pages)), HTML::br()); - return $header; - } } // Local Variables: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-12-09 13:08:43
|
Revision: 10751 http://sourceforge.net/p/phpwiki/code/10751 Author: vargenau Date: 2021-12-09 13:08:42 +0000 (Thu, 09 Dec 2021) Log Message: ----------- WikiAdminDeleteAcl plugin: remove unused variable Modified Paths: -------------- trunk/lib/plugin/WikiAdminDeleteAcl.php Modified: trunk/lib/plugin/WikiAdminDeleteAcl.php =================================================================== --- trunk/lib/plugin/WikiAdminDeleteAcl.php 2021-12-08 18:47:39 UTC (rev 10750) +++ trunk/lib/plugin/WikiAdminDeleteAcl.php 2021-12-09 13:08:42 UTC (rev 10751) @@ -42,11 +42,11 @@ return _("Delete page permissions."); } - private function deleteaclPages(&$request, $pages) + private function deleteaclPages($request, $pages) { $result = HTML::div(); $count = 0; - $dbi =& $request->_dbi; + $dbi = $request->_dbi; $perm = new PagePermission(''); $perm->sanify(); foreach ($pages as $pagename) { @@ -102,7 +102,6 @@ $this->preSelectS($args, $request); $p = $request->getArg('p'); - $post_args = $request->getArg('admin_deleteacl'); $pages = array(); if ($p && !$request->isPost()) $pages = $p; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |