]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllUsers.php
more paging support and paging fix for shorter lists
[SourceForge/phpwiki.git] / lib / plugin / AllUsers.php
1 <?php // -*-php-*-
2 rcs_id('$Id: AllUsers.php,v 1.12 2004-04-20 00:56:00 rurban Exp $');
3 /*
4  Copyright 2002,2004 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
8  PhpWiki is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  PhpWiki is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with PhpWiki; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 require_once('lib/PageList.php');
24
25 /**
26  * Based on AllPages and WikiGroup.
27  *
28  * We query homepage users (prefs stored in a page), 
29  * users with db prefs and externally authenticated users with a db users table,
30  * if auth_user_exists is defined.
31  */
32 class WikiPlugin_AllUsers
33 extends WikiPlugin
34 {
35     function getName () {
36         return _("AllUsers");
37     }
38
39     function getDescription() {
40         return _("With external authentication all users which stored their Preferences. Without external authentication all once signed-in users (from version 1.3.4 on).");
41     }
42
43     function getVersion() {
44         return preg_replace("/[Revision: $]/", '',
45                             "\$Revision: 1.12 $");
46     }
47
48     function getDefaultArguments() {
49         return array('noheader'      => false,
50                      'include_empty' => true,
51                      'exclude'       => '',
52                      'info'          => '',   // which columns? default: list of pagenames only
53                      'sortby'        => '',   // +mtime,-pagename
54                      'limit'         => 50,
55                      'paging'        => 'auto',
56                      'debug'         => false
57                      );
58     }
59     // info arg allows multiple columns
60     // info=mtime,hits,summary,version,author,locked,minor,markup or all
61     // exclude arg allows multiple pagenames exclude=WikiAdmin,.SecretUser
62     //
63     // include_empty shows also users which stored their preferences,
64     // but never saved their homepage
65     //
66     // sortby: [+|-] pagename|mtime|hits
67
68     function run($dbi, $argstr, &$request, $basepage) {
69         $args = $this->getArgs($argstr, $request);
70         extract($args);
71         if ($sorted = $request->getArg('sortby'))
72             $sortby = $sorted;
73         elseif ($sortby)
74             $request->setArg('sortby',$sortby);
75
76         //if (defined('DEBUG') and DEBUG) $debug = true;
77         if ($debug)
78             $timer = new DebugTimer;
79
80         $group = WikiGroup::getGroup($request);
81         $allusers = $group->_allUsers();
82         $args['count'] = count($allusers);
83         // deleted pages show up as version 0.
84         $pagelist = new PageList($info, $exclude, $args);
85         if (!$noheader)
86             $pagelist->setCaption(_("Authenticated users on this wiki (%d total):"));
87         if ($include_empty and empty($info))
88             $pagelist->_addColumn('version');
89         list($offset,$pagesize) = $pagelist->limit($args['limit']);
90         if (!$pagesize) $pagelist->addPageList($pages);
91         else {
92             for ($i=$offset; $i < $offset + $pagesize - 1; $i++) {
93                 if ($i >= $args['count']) break;
94                 $pagelist->addPage($allusers[$i]);
95             }
96         }
97         /*
98         $page_iter = $dbi->getAllPages($include_empty, $sortby, $limit);
99         while ($page = $page_iter->next()) {
100             if ($page->isUserPage($include_empty))
101                 $pagelist->addPage($page);
102         }
103         */
104
105         if ($debug) {
106             return HTML($pagelist,
107                         HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
108         } else {
109             return $pagelist;
110         }
111     }
112 };
113
114 // $Log: not supported by cvs2svn $
115 // Revision 1.11  2004/03/10 13:54:54  rurban
116 // adodb WikiGroup fix
117 //
118 // Revision 1.10  2004/03/08 19:30:01  rurban
119 // fixed Theme->getButtonURL
120 // AllUsers uses now WikiGroup (also DB User and DB Pref users)
121 // PageList fix for empty pagenames
122 //
123 // Revision 1.9  2004/02/22 23:20:33  rurban
124 // fixed DumpHtmlToDir,
125 // enhanced sortby handling in PageList
126 //   new button_heading th style (enabled),
127 // added sortby and limit support to the db backends and plugins
128 //   for paging support (<<prev, next>> links on long lists)
129 //
130 // Revision 1.8  2004/02/17 12:11:36  rurban
131 // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...)
132 //
133 // Revision 1.7  2003/12/21 00:29:45  carstenklapp
134 // Minor bugfix: Fixed broken debug argument.
135 //
136 // Internal changes: Only create a DebugTimer when actually called for;
137 // moved debug message out of page content and into deferred page error
138 // notification via trigger_error. Memory management: Only include_once
139 // lib/PageList when absolutely necessary (at this time, this will
140 // probably only benefit the PluginManager as an incremental speedup &
141 // slightly reduced memory).
142 //
143 // Revision 1.6  2003/02/27 20:10:31  dairiki
144 // Disable profiling output when DEBUG is defined but false.
145 //
146 // Revision 1.5  2003/02/21 04:08:26  dairiki
147 // New class DebugTimer in prepend.php to help report timing.
148 //
149 // Revision 1.4  2003/01/18 21:19:25  carstenklapp
150 // Code cleanup:
151 // Reformatting; added copyleft, getVersion, getDescription
152 //
153
154 // Local Variables:
155 // mode: php
156 // tab-width: 8
157 // c-basic-offset: 4
158 // c-hanging-comment-ender-p: nil
159 // indent-tabs-mode: nil
160 // End:
161 ?>