From ccf28a1b1a242ff3e34ecf1b4b7e103ddee25d7d Mon Sep 17 00:00:00 2001 From: vargenau Date: Fri, 13 Aug 2010 13:34:26 +0000 Subject: [PATCH] New plugin: WikiAdminSetAclSimple git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@7644 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/IniConfig.php | 4 + lib/main.php | 10 +- lib/plugin/WikiAdminSetAclSimple.php | 181 +++++++++++++++++++++ pgsrc/Help%2FPagePermissions | 4 +- pgsrc/Help%2FWikiAdminSetAclSimplePlugin | 52 ++++++ pgsrc/PhpWikiAdministration | 9 +- pgsrc/PhpWikiAdministration%2FSetAcl | 6 +- pgsrc/PhpWikiAdministration%2FSetAclSimple | 18 ++ pgsrc/SetGlobalAccessRights | 14 ++ pgsrc/SetGlobalAccessRightsSimple | 14 ++ themes/gforge/pgsrc/PhpWikiAdministration | 9 +- themes/gforge/templates/actionbar.tmpl | 2 +- 12 files changed, 313 insertions(+), 10 deletions(-) create mode 100644 lib/plugin/WikiAdminSetAclSimple.php create mode 100644 pgsrc/Help%2FWikiAdminSetAclSimplePlugin create mode 100644 pgsrc/PhpWikiAdministration%2FSetAclSimple create mode 100644 pgsrc/SetGlobalAccessRights create mode 100644 pgsrc/SetGlobalAccessRightsSimple diff --git a/lib/IniConfig.php b/lib/IniConfig.php index c43e8a069..0cf00eb84 100644 --- a/lib/IniConfig.php +++ b/lib/IniConfig.php @@ -700,6 +700,7 @@ function fixup_static_configs($file) { $AllAllowedPlugins[] = 'WikiAdminRename'; $AllAllowedPlugins[] = 'WikiAdminSearchReplace'; $AllAllowedPlugins[] = 'WikiAdminSetAcl'; + $AllAllowedPlugins[] = 'WikiAdminSetAclSimple'; $AllAllowedPlugins[] = 'WikiAdminUtils'; $AllAllowedPlugins[] = 'WikicreoleTable'; $AllAllowedPlugins[] = 'WikiForm'; @@ -763,9 +764,12 @@ function fixup_static_configs($file) { $AllActionPages[] = 'PhpWikiAdministration/Rename'; $AllActionPages[] = 'PhpWikiAdministration/SearchReplace'; $AllActionPages[] = 'PhpWikiAdministration/SetAcl'; + $AllActionPages[] = 'PhpWikiAdministration/SetAclSimple'; $AllActionPages[] = 'RecentChangesMyPages'; $AllActionPages[] = 'RecentEdits'; $AllActionPages[] = 'RecentNewPages'; + $AllActionPages[] = 'SetGlobalAccessRights'; + $AllActionPages[] = 'SetGlobalAccessRightsSimple'; $AllActionPages[] = 'UserContribs'; // The GFORGE theme omits them diff --git a/lib/main.php b/lib/main.php index f4579ce84..1a226541a 100644 --- a/lib/main.php +++ b/lib/main.php @@ -717,6 +717,7 @@ class WikiRequest extends Request { case 'upgrade': case 'chown': case 'setacl': + case 'setaclsimple': return WIKIAUTH_ADMIN; /* authcheck occurs only in the plugin. @@ -1087,6 +1088,10 @@ class WikiRequest extends Request { $this->adminActionSubpage(_("SetAcl")); } + function action_setaclsimple () { + $this->adminActionSubpage(_("SetAclSimple")); + } + function action_rename () { $this->adminActionSubpage(_("Rename")); } @@ -1410,9 +1415,10 @@ function main () { //$x = error_reporting(); // DEBUG: why is it 1 here? should be E_ALL if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5? - error_reporting(E_ALL & ~E_STRICT); // exclude E_STRICT + error_reporting(E_ALL & ~E_STRICT); // exclude E_STRICT else - error_reporting(E_ALL); // php4 + error_reporting(E_ALL); // php4 + // don't run the main loop for special requests (test, getimg, xmlrpc, soap, ...) if (!defined('PHPWIKI_NOMAIN') or !PHPWIKI_NOMAIN) main(); diff --git a/lib/plugin/WikiAdminSetAclSimple.php b/lib/plugin/WikiAdminSetAclSimple.php new file mode 100644 index 000000000..c2134e883 --- /dev/null +++ b/lib/plugin/WikiAdminSetAclSimple.php @@ -0,0 +1,181 @@ +> or called via WikiAdminSelect + * Author: Marc-Etienne Vargenau, Alcatel-Lucent + * + */ + +require_once('lib/plugin/WikiAdminSetAcl.php'); + +class WikiPlugin_WikiAdminSetAclSimple +extends WikiPlugin_WikiAdminSetAcl +{ + function getName() { + return _("WikiAdminSetAclSimple"); + } + + function getDescription() { + return _("Set simple individual page permissions."); + } + + function run($dbi, $argstr, &$request, $basepage) { + if ($request->getArg('action') != 'browse') + if ($request->getArg('action') != _("PhpWikiAdministration/SetAclSimple")) + return $this->disabled("(action != 'browse')"); + 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_setacl'); + $pages = array(); + if ($p && !$request->isPost()) + $pages = $p; + elseif ($this->_list) + $pages = $this->_list; + $header = HTML::fieldset(); + if ($p && $request->isPost() && + (!empty($post_args['aclliberal']) || !empty($post_args['aclrestricted']))) { + // without individual PagePermissions: + if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { + $request->_notAuthorized(WIKIAUTH_ADMIN); + $this->disabled("! user->isAdmin"); + } + if (!empty($post_args['aclliberal'])) { + return $this->setaclPages($request, array_keys($p), $this->liberalPerms()); + } else if (!empty($post_args['aclrestricted'])) { + return $this->setaclPages($request, array_keys($p), $this->restrictedPerms()); + } + } + 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_liberal = _("Set Liberal Access Rights"); + $button_label_restrictive = _("Set Restrictive Access Rights"); + $header = $this->setaclForm($header, $pages); + $header->pushContent(HTML::legend(_("Select the pages where to change access rights"))); + + $buttons = HTML::p(Button('submit:admin_setacl[aclliberal]', $button_label_liberal, 'wikiadmin'), + Button('submit:admin_setacl[aclrestricted]', $button_label_restrictive, 'wikiadmin')); + $header->pushContent($buttons); + + return HTML::form(array('action' => $request->getPostURL(), + 'method' => 'post'), + $header, + $pagelist->getContent(), + HiddenInputs($request->getArgs(), + false, + array('admin_setacl')), + ENABLE_PAGEPERM + ? '' + : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))); + } + + /* + * acces rights where everyone can edit + * _EVERY: view edit list create; + * _ADMIN: remove purge dump change; + * _OWNER: remove purge dump change; + */ + + function liberalPerms() { + + $perm = array('view' => array(ACL_EVERY => true), + 'edit' => array(ACL_EVERY => true), + 'create' => array(ACL_EVERY => true), + 'list' => array(ACL_EVERY => true), + 'remove' => array(ACL_ADMIN => true, + ACL_OWNER => true), + 'purge' => array(ACL_ADMIN => true, + ACL_OWNER => true), + 'dump' => array(ACL_ADMIN => true, + ACL_OWNER => true), + 'change' => array(ACL_ADMIN => true, + ACL_OWNER => true)); + return $perm; + } + + /* + * acces rights where only authenticated users can see pages + * _AUTHENTICATED: view edit list create; + * _ADMIN: remove purge dump change; + * _OWNER: remove purge dump change; + * _EVERY: -view -edit -list -create; + */ + + function restrictedPerms() { + + $perm = array('view' => array(ACL_AUTHENTICATED => true, + ACL_EVERY => false), + 'edit' => array(ACL_AUTHENTICATED => true, + ACL_EVERY => false), + 'create' => array(ACL_AUTHENTICATED => true, + ACL_EVERY => false), + 'list' => array(ACL_AUTHENTICATED => true, + ACL_EVERY => false), + 'remove' => array(ACL_ADMIN => true, + ACL_OWNER => true), + 'purge' => array(ACL_ADMIN => true, + ACL_OWNER => true), + 'dump' => array(ACL_ADMIN => true, + ACL_OWNER => true), + 'change' => array(ACL_ADMIN => true, + ACL_OWNER => true)); + return $perm; + } + + function setaclForm(&$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: +?> diff --git a/pgsrc/Help%2FPagePermissions b/pgsrc/Help%2FPagePermissions index 5f81fc0e7..0995fb698 100644 --- a/pgsrc/Help%2FPagePermissions +++ b/pgsrc/Help%2FPagePermissions @@ -1,4 +1,4 @@ -Date: Tue, 1 Jun 2010 17:01:57 +0000 +Date: Fri, 13 Aug 2010 15:31:59 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -111,7 +111,7 @@ Those perms are mapped to those actions. [[Help:ActionPage|Action Pages]] (plugi |= dump | zip, ziphtml, dumpserial, dumphtml |= edit | revert, edit |= create | //edit or create, if the page doesn't exist yet// -|= change | upload, loadfile, remove, lock, unlock, upgrade, chown, setacl, rename. \\ All other actionpages which are not wikiwords. +|= change | upload, loadfile, remove, lock, unlock, upgrade, chown, setacl, setaclsimple, rename. \\ All other actionpages which are not wikiwords. === Default Permissions === diff --git a/pgsrc/Help%2FWikiAdminSetAclSimplePlugin b/pgsrc/Help%2FWikiAdminSetAclSimplePlugin new file mode 100644 index 000000000..a3ee852cd --- /dev/null +++ b/pgsrc/Help%2FWikiAdminSetAclSimplePlugin @@ -0,0 +1,52 @@ +Date: Fri, 13 Aug 2010 15:31:59 +0000 +Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) +X-Rcs-Id: $Id$ +Content-Type: application/x-phpwiki; + pagename=Help%2FWikiAdminSetAclSimplePlugin; + flags=PAGE_LOCKED%2CEXTERNAL_PAGE; + markup=2; + charset=UTF-8 +Content-Transfer-Encoding: binary + +The **~WikiAdminSetAclSimple** [[Help:WikiPlugin|plugin]] allows to change access rights on pages. + +== Usage == +{{{ +<> +}}} + +== Arguments == + +{| class="bordered" +|- +! Argument +! Description +! Default value +|- +| **p** +| Pages to select +| //None// +|- +| **info** +| Columns to include in listing +| pagename, perm, mtime, owner, author +|} + +== Example == + +{{{ +<> +}}} + +<> + +== Author == +* [[PhpWiki:ReiniUrban|Reini Urban]] + +== See Also == +* [[PhpWikiAdministration]] + + +---- +[[PhpWikiDocumentation]] [[CategoryWikiPlugin]] + diff --git a/pgsrc/PhpWikiAdministration b/pgsrc/PhpWikiAdministration index 5a4879cf1..8eadcf5b1 100644 --- a/pgsrc/PhpWikiAdministration +++ b/pgsrc/PhpWikiAdministration @@ -1,4 +1,4 @@ -Date: Wed, 19 May 2010 18:15:54 +0000 +Date: Fri, 13 Aug 2010 15:31:59 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -20,7 +20,12 @@ First select pages and then define the action: or call the available ~WikiAdmin actions directly: -| [[/Chown]] | [[/Markup]] | [[/Purge]] | [[/Remove]] | [[/Rename]] | [[/SearchReplace]] | [[/SetAcl]] +| [[/Chown]] | [[/Markup]] | [[/Purge]] | [[/Remove]] | [[/Rename]] | [[/SearchReplace]] | [[/SetAcl]] | [[/SetAclSimple]] + +== Global Access Rights == + +* [[SetGlobalAccessRightsSimple]] +* [[SetGlobalAccessRights]] == User Management == diff --git a/pgsrc/PhpWikiAdministration%2FSetAcl b/pgsrc/PhpWikiAdministration%2FSetAcl index 2812b4184..f8eff7d7a 100644 --- a/pgsrc/PhpWikiAdministration%2FSetAcl +++ b/pgsrc/PhpWikiAdministration%2FSetAcl @@ -1,4 +1,4 @@ -Date: Thu, 15 Apr 2010 16:32:58 +0000 +Date: Fri, 13 Aug 2010 15:31:59 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -8,6 +8,10 @@ Content-Type: application/x-phpwiki; charset=UTF-8 Content-Transfer-Encoding: binary +For simple Access Rights modifications, see **[[phpwiki:?action=setaclsimple|SetAclSimple]]**. + +---- + <> ---- diff --git a/pgsrc/PhpWikiAdministration%2FSetAclSimple b/pgsrc/PhpWikiAdministration%2FSetAclSimple new file mode 100644 index 000000000..96fd2fbc9 --- /dev/null +++ b/pgsrc/PhpWikiAdministration%2FSetAclSimple @@ -0,0 +1,18 @@ +Date: Fri, 13 Aug 2010 15:31:59 +0000 +Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) +X-Rcs-Id: $Id$ +Content-Type: application/x-phpwiki; + pagename=PhpWikiAdministration%2FSetAclSimple; + flags=PAGE_LOCKED; + markup=2; + charset=UTF-8 +Content-Transfer-Encoding: binary + +For more complex Access Rights modifications, see **[[phpwiki:?action=setacl|SetAcl]]**. + +---- + +<> + +---- +[[CategoryActionPage]] diff --git a/pgsrc/SetGlobalAccessRights b/pgsrc/SetGlobalAccessRights new file mode 100644 index 000000000..3ed839af6 --- /dev/null +++ b/pgsrc/SetGlobalAccessRights @@ -0,0 +1,14 @@ +Date: Fri, 13 Aug 2010 15:31:59 +0000 +Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) +X-Rcs-Id: $Id$ +Content-Type: application/x-phpwiki; + pagename=SetGlobalAccessRights; + flags=PAGE_LOCKED; + markup=2; + charset=UTF-8 +Content-Transfer-Encoding: binary + +<> + +---- +[[CategoryActionPage]] diff --git a/pgsrc/SetGlobalAccessRightsSimple b/pgsrc/SetGlobalAccessRightsSimple new file mode 100644 index 000000000..1fcae4462 --- /dev/null +++ b/pgsrc/SetGlobalAccessRightsSimple @@ -0,0 +1,14 @@ +Date: Fri, 13 Aug 2010 15:31:59 +0000 +Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) +X-Rcs-Id: $Id$ +Content-Type: application/x-phpwiki; + pagename=SetGlobalAccessRightsSimple; + flags=PAGE_LOCKED; + markup=2; + charset=UTF-8 +Content-Transfer-Encoding: binary + +<> + +---- +[[CategoryActionPage]] diff --git a/themes/gforge/pgsrc/PhpWikiAdministration b/themes/gforge/pgsrc/PhpWikiAdministration index edd715b94..b638d6ecf 100644 --- a/themes/gforge/pgsrc/PhpWikiAdministration +++ b/themes/gforge/pgsrc/PhpWikiAdministration @@ -1,4 +1,4 @@ -Date: Thu, 15 Jul 2010 16:58:46 +0000 +Date: Fri, 13 Aug 2010 15:31:51 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -20,7 +20,12 @@ First select pages and then define the action: or call the available ~WikiAdmin actions directly: -| [[/Chown]] | [[/Purge]] | [[/Remove]] | [[/Rename]] | [[/SearchReplace]] | [[/SetAcl]] +| [[/Chown]] | [[/Purge]] | [[/Remove]] | [[/Rename]] | [[/SearchReplace]] | [[/SetAcl]] | [[/SetAclSimple]] + +== Global Access Rights == + +* [[SetGlobalAccessRightsSimple]] +* [[SetGlobalAccessRights]] == Cleanup == diff --git a/themes/gforge/templates/actionbar.tmpl b/themes/gforge/templates/actionbar.tmpl index f2b746379..07f04d501 100644 --- a/themes/gforge/templates/actionbar.tmpl +++ b/themes/gforge/templates/actionbar.tmpl @@ -104,7 +104,7 @@ $isBrowse = $request->getArg('action') == 'browse'; get('setaclMenuItem')) { ?> - +   -- 2.45.0