From bba9dc82be45d5019ffe0c72ce7e70b5b8405fb7 Mon Sep 17 00:00:00 2001 From: rurban Date: Sun, 13 Jun 2004 15:33:20 +0000 Subject: [PATCH] new support for arguments owner, author, creator in most relevant PageList plugins. in WikiAdmin* via preSelectS() git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3676 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/PageList.php | 61 ++++++++++++++++++- lib/WikiDB.php | 11 +++- lib/plugin/AllPages.php | 37 ++++++++--- lib/plugin/WikiAdminChmod.php | 14 ++++- lib/plugin/WikiAdminChown.php | 11 +++- lib/plugin/WikiAdminRemove.php | 11 +++- lib/plugin/WikiAdminRename.php | 11 +++- lib/plugin/WikiAdminSearchReplace.php | 15 +++-- lib/plugin/WikiAdminSelect.php | 88 +++++++++++++-------------- lib/plugin/WikiAdminSetAcl.php | 16 +++-- 10 files changed, 202 insertions(+), 73 deletions(-) diff --git a/lib/PageList.php b/lib/PageList.php index 176835722..973823074 100644 --- a/lib/PageList.php +++ b/lib/PageList.php @@ -1,4 +1,4 @@ -getDbh(); + $allPagehandles = $dbi->getAllPages($perm, $sortby, $limit); + $allPages = array(); + while ($pagehandle = $allPagehandles->next()) { + $name = $pagehandle->getName(); + $author = $pagehandle->getAuthor(); + if ($author) { + if (preg_match('/[\?\*]/', $wildcard)) { + if (glob_match($wildcard, $author)) + $allPages[] = $name; + } elseif ($wildcard == $author) { + $allPages[] = $name; + } + } + } + return $allPages; + } + + function allPagesByOwner($wildcard, $perm=false, $sortby=false, $limit=false) { + $dbi = $GLOBALS['request']->getDbh(); + $allPagehandles = $dbi->getAllPages($perm, $sortby, $limit); + $allPages = array(); + while ($pagehandle = $allPagehandles->next()) { + $name = $pagehandle->getName(); + $owner = $page->getOwner(); + if ($owner) { + if (preg_match('/[\?\*]/', $wildcard)) { + if (glob_match($wildcard, $owner)) + $allPages[] = $name; + } elseif ($wildcard == $owner) { + $allPages[] = $name; + } + } + } + return $allPages; + } + + function allPagesByCreator($wildcard, $perm=false, $sortby=false, $limit=false) { + $dbi = $GLOBALS['request']->getDbh(); + $allPagehandles = $dbi->getAllPages($perm, $sortby, $limit); + $allPages = array(); + while ($pagehandle = $allPagehandles->next()) { + $name = $pagehandle->getName(); + $creator = $page->getCreator(); + if ($creator) { + if (preg_match('/[\?\*]/', $wildcard)) { + if (glob_match($wildcard, $creator)) + $allPages[] = $name; + } elseif ($wildcard == $creator) { + $allPages[] = $name; + } + } + } + return $allPages; + } //////////////////// // private @@ -942,6 +998,9 @@ extends PageList { } // $Log: not supported by cvs2svn $ +// Revision 1.84 2004/06/08 13:51:56 rurban +// some comments only +// // Revision 1.83 2004/05/18 13:35:39 rurban // improve Pagelist layout by equal pagename width for limited lists // diff --git a/lib/WikiDB.php b/lib/WikiDB.php index 9c4b2c848..96d5ffc98 100644 --- a/lib/WikiDB.php +++ b/lib/WikiDB.php @@ -1,5 +1,5 @@ getCurrentRevision()) return $current->get('author_id'); + else return ''; + } + }; /** @@ -1842,6 +1848,9 @@ class WikiDB_cache }; // $Log: not supported by cvs2svn $ +// Revision 1.68 2004/06/08 21:03:20 rurban +// updated RssParser for XmlParser quirks (store parser object params in globals) +// // Revision 1.67 2004/06/07 19:12:49 rurban // fixed rename version=0, bug #966284 // diff --git a/lib/plugin/AllPages.php b/lib/plugin/AllPages.php index 93bead1ea..c81319fef 100644 --- a/lib/plugin/AllPages.php +++ b/lib/plugin/AllPages.php @@ -1,7 +1,7 @@ false, 'include_empty' => false, + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, 'exclude' => '', 'info' => '', 'sortby' => 'pagename', // +mtime,-pagename @@ -65,8 +69,20 @@ extends WikiPlugin elseif ($sortby) $request->setArg('sortby',$sortby); - if (! $request->getArg('count')) $args['count'] = $dbi->numPages(false,$exclude); - else $args['count'] = $request->getArg('count'); + if ($debug) + $timer = new DebugTimer; + if ( !empty($args['owner']) ) + $pages = PageList::allPagesByOwner($args['owner'],$include_empty,$args['sortby'],$args['limit']); + elseif ( !empty($args['author']) ) + $pages = PageList::allPagesByAuthor($args['author'],$include_empty,$args['sortby'],$args['limit']); + elseif ( !empty($args['creator']) ) { + $pages = PageList::allPagesByCreator($args['creator'],$include_empty,$args['sortby'],$args['limit']); + } else { + if (! $request->getArg('count')) $args['count'] = $dbi->numPages(false,$exclude); + else $args['count'] = $request->getArg('count'); + } + if (empty($args['count']) and $pages) + $args['count'] = count($pages); $pagelist = new PageList($info, $exclude, $args); //if (!$sortby) $sorted='pagename'; if (!$noheader) @@ -76,10 +92,10 @@ extends WikiPlugin if ($include_empty) $pagelist->_addColumn('version'); - //if (defined('DEBUG') and DEBUG) $debug = true; - if ($debug) - $timer = new DebugTimer; - $pagelist->addPages( $dbi->getAllPages($include_empty, $sortby, $limit) ); + if ( !empty($pages) ) + $pagelist->addPageList($pages); + else + $pagelist->addPages( $dbi->getAllPages($include_empty, $sortby, $limit) ); if ($debug) { return HTML($pagelist, HTML::p(fmt("Elapsed time: %s s", $timer->getStats()))); @@ -95,6 +111,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.21 2004/04/20 00:06:53 rurban +// paging support +// // Revision 1.20 2004/02/22 23:20:33 rurban // fixed DumpHtmlToDir, // enhanced sortby handling in PageList diff --git a/lib/plugin/WikiAdminChmod.php b/lib/plugin/WikiAdminChmod.php index 4981328fb..6c34dd50d 100644 --- a/lib/plugin/WikiAdminChmod.php +++ b/lib/plugin/WikiAdminChmod.php @@ -1,5 +1,5 @@ false, + 'perm' => false, + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, /* Pages to exclude in listing */ 'exclude' => '', /* Columns to include in listing */ @@ -202,6 +207,11 @@ extends WikiPlugin_WikiAdminSelect } // $Log: not supported by cvs2svn $ +// Revision 1.8 2004/06/04 20:32:54 rurban +// Several locale related improvements suggested by Pierrick Meignen +// LDAP fix by John Cole +// reanable admin check without ENABLE_PAGEPERM in the admin plugins +// // Revision 1.7 2004/06/03 22:24:42 rurban // reenable admin check on !ENABLE_PAGEPERM, honor s=Wildcard arg, fix warning after Remove // diff --git a/lib/plugin/WikiAdminChown.php b/lib/plugin/WikiAdminChown.php index 88fb31bf3..1cb4e3189 100644 --- a/lib/plugin/WikiAdminChown.php +++ b/lib/plugin/WikiAdminChown.php @@ -1,5 +1,5 @@ false, 'user' => false, + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, /* Pages to exclude in listing */ 'exclude' => '', /* Columns to include in listing */ @@ -191,6 +195,9 @@ extends WikiPlugin_WikiAdminSelect } // $Log: not supported by cvs2svn $ +// Revision 1.3 2004/06/08 10:05:11 rurban +// simplified admin action shortcuts +// // Revision 1.2 2004/06/07 18:59:42 rurban // added Chown link to Owner in statusbar // diff --git a/lib/plugin/WikiAdminRemove.php b/lib/plugin/WikiAdminRemove.php index d0c019f52..1585db3b5 100644 --- a/lib/plugin/WikiAdminRemove.php +++ b/lib/plugin/WikiAdminRemove.php @@ -1,5 +1,5 @@ false, + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, /* * Show only pages which have been 'deleted' this * long (in days). (negative or non-numeric @@ -245,6 +249,9 @@ class _PageList_Column_remove extends _PageList_Column { // $Log: not supported by cvs2svn $ +// Revision 1.24 2004/06/08 10:05:11 rurban +// simplified admin action shortcuts +// // Revision 1.23 2004/06/03 22:24:48 rurban // reenable admin check on !ENABLE_PAGEPERM, honor s=Wildcard arg, fix warning after Remove // diff --git a/lib/plugin/WikiAdminRename.php b/lib/plugin/WikiAdminRename.php index 6ab0a693e..35d08d890 100644 --- a/lib/plugin/WikiAdminRename.php +++ b/lib/plugin/WikiAdminRename.php @@ -1,5 +1,5 @@ false, + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, /* Pages to exclude in listing */ 'exclude' => '', /* Columns to include in listing */ @@ -253,6 +257,9 @@ class _PageList_Column_renamed_pagename extends _PageList_Column { }; // $Log: not supported by cvs2svn $ +// Revision 1.17 2004/06/08 10:05:12 rurban +// simplified admin action shortcuts +// // Revision 1.16 2004/06/07 18:57:31 rurban // fix rename: Change pagename in all linked pages // diff --git a/lib/plugin/WikiAdminSearchReplace.php b/lib/plugin/WikiAdminSearchReplace.php index 9354a1ee3..e790a62ac 100644 --- a/lib/plugin/WikiAdminSearchReplace.php +++ b/lib/plugin/WikiAdminSearchReplace.php @@ -1,5 +1,5 @@ * * KNOWN ISSUES: - * Currently we must be Admin. - * Future versions will support PagePermissions. - * requires PHP 4.2 so far. + * Requires PHP 4.2 so far. */ require_once('lib/PageList.php'); require_once('lib/plugin/WikiAdminSelect.php'); @@ -45,12 +43,16 @@ extends WikiPlugin_WikiAdminSelect function getVersion() { return preg_replace("/[Revision: $]/", '', - "\$Revision: 1.13 $"); + "\$Revision: 1.14 $"); } function getDefaultArguments() { return array( 's' => false, + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, /* Pages to exclude */ 'exclude' => '.', /* Columns to include in listing */ @@ -250,6 +252,9 @@ function stri_replace($find,$replace,$string) { } // $Log: not supported by cvs2svn $ +// Revision 1.13 2004/06/13 14:30:26 rurban +// security fix: check permissions in SearchReplace +// // Revision 1.12 2004/06/08 10:05:12 rurban // simplified admin action shortcuts // diff --git a/lib/plugin/WikiAdminSelect.php b/lib/plugin/WikiAdminSelect.php index ac9618dce..f21e900c0 100644 --- a/lib/plugin/WikiAdminSelect.php +++ b/lib/plugin/WikiAdminSelect.php @@ -1,5 +1,5 @@ * Author: Reini Urban * - * KNOWN ISSUES: + * "list" PagePermissions supported implicitly by PageList. * Just a framework, nothing more. - * Future versions will support PagePermissions. */ // maybe display more attributes with this class... require_once('lib/PageList.php'); @@ -47,11 +46,16 @@ extends WikiPlugin function getVersion() { return preg_replace("/[Revision: $]/", '', - "\$Revision: 1.15 $"); + "\$Revision: 1.16 $"); } function getDefaultArguments() { return array('s' => '', // preselect pages + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, + 'only' => '', 'exclude' => '', 'info' => 'most', @@ -70,61 +74,52 @@ extends WikiPlugin return $list; } + /** + * Preselect a list of pagenames by: + * s: comma-seperated list of pagename wildcards + * author, owner, creator + */ function preSelectS (&$args, &$request) { + // override plugin argument by GET: probably not needed if s||="" is used + // anyway, we force it for unique interface. if (!empty($request->getArg['s'])) $args['s'] = $request->getArg['s']; - if ( !empty($args['s']) ) { - $s = $args['s']; - $sl = explodePageList($args['s']); - $this->_list = array(); - if ($sl) { - $request->setArg('verify', 1); - foreach ($sl as $name) { + if ( !empty($args['owner']) ) + $sl = PageList::allPagesByOwner($args['owner'],false,$args['sortby'],$args['limit']); + elseif ( !empty($args['author']) ) + $sl = PageList::allPagesByAuthor($args['author'],false,$args['sortby'],$args['limit']); + elseif ( !empty($args['creator']) ) + $sl = PageList::allPagesByCreator($args['creator'],false,$args['sortby'],$args['limit']); + elseif ( !empty($args['s']) or !empty($args['only']) ) { + // all pages by name + $sl = explodePageList(empty($args['only']) ? $args['s'] : $args['only']); + } + $this->_list = array(); + if ($sl) { + $request->setArg('verify', 1); + if (!empty($args['exclude'])) + $exclude = explodePageList($args['exclude']); + foreach ($sl as $name) { + if (!empty($args['exclude'])) { + if (!in_array($name, $exclude)) + $this->_list[$name] = 1; + } else { $this->_list[$name] = 1; } } - } else { - $s = '*'; - if (!empty($args['s'])) - $s = $args['s']; - $this->_list = array(); } + return $this->_list; } function run($dbi, $argstr, &$request, $basepage) { //if ($request->getArg('action') != 'browse') // return $this->disabled("(action != 'browse')"); $args = $this->getArgs($argstr, $request); - if (!empty($args['only'])) - $only = explodePageList($args['only']); - else - $only = false; - if (!empty($args['exclude'])) - $exclude = explodePageList($args['exclude']); - else - $exclude = false; + $this->_args = $args; + $this->preSelectS(&$args, &$request); + $info = $args['info']; $this->debug = $args['debug']; - //TODO: use the method preSelectS() - if (!empty($request->getArg['s'])) - $args['s'] = $request->getArg['s']; - if ( //( $request->getArg('WikiAdminSelect') == _("Go")) and - !empty($args['s'])) { - $s = $args['s']; - $sl = explodePageList($args['s']); - $this->_list = array(); - if ($sl) { - $request->setArg('verify',1); - foreach ($sl as $name) { - $this->_list[$name] = 1; - } - } - } else { - $s = '*'; - if (!empty($args['s'])) - $s = $args['s']; - $this->_list = array(); - } // array_multisort($this->_list, SORT_NUMERIC, SORT_DESC); $pagename = $request->getArg('pagename'); @@ -247,6 +242,11 @@ extends WikiPlugin } // $Log: not supported by cvs2svn $ +// Revision 1.15 2004/06/01 15:28:01 rurban +// AdminUser only ADMIN_USER not member of Administrators +// some RateIt improvements by dfrankow +// edit_toolbar buttons +// // Revision 1.14 2004/02/24 15:20:07 rurban // fixed minor warnings: unchecked args, POST => Get urls for sortby e.g. // diff --git a/lib/plugin/WikiAdminSetAcl.php b/lib/plugin/WikiAdminSetAcl.php index f78c4b91e..98da0564c 100644 --- a/lib/plugin/WikiAdminSetAcl.php +++ b/lib/plugin/WikiAdminSetAcl.php @@ -1,5 +1,5 @@ * * KNOWN ISSUES: - * Doesn't accept yet s=wildcard preselection * Requires PHP 4.2 so far. */ require_once('lib/PageList.php'); @@ -46,13 +45,17 @@ extends WikiPlugin_WikiAdminSelect function getVersion() { return preg_replace("/[Revision: $]/", '', - "\$Revision: 1.16 $"); + "\$Revision: 1.17 $"); } function getDefaultArguments() { return array( - 's' => false, - 'p' => "[]", + 'p' => "[]", // list of pages + 's' => false, /* select by pagename */ + /* select pages by meta-data: */ + 'author' => false, + 'owner' => false, + 'creator' => false, /* Pages to exclude in listing */ 'exclude' => '', /* Columns to include in listing */ @@ -297,6 +300,9 @@ class _PageList_Column_perm extends _PageList_Column { }; // $Log: not supported by cvs2svn $ +// Revision 1.16 2004/06/08 13:50:43 rurban +// show getfacl and acl line +// // Revision 1.15 2004/06/08 10:05:12 rurban // simplified admin action shortcuts // -- 2.45.0