]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllUsers.php
Activated Id substitution for Subversion
[SourceForge/phpwiki.git] / lib / plugin / AllUsers.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
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 list all users, 
29  * either homepage users (prefs stored in a page), 
30  * users with db prefs and 
31  * externally authenticated users with a db users table, if auth_user_exists is defined.
32  */
33 class WikiPlugin_AllUsers
34 extends WikiPlugin
35 {
36     function getName () {
37         return _("AllUsers");
38     }
39
40     function getDescription() {
41         return _("List all once authenticated users.");
42     }
43
44     function getVersion() {
45         return preg_replace("/[Revision: $]/", '',
46                             "\$Revision: 1.19 $");
47     }
48
49     function getDefaultArguments() {
50         return array_merge
51             (
52              PageList::supportedArgs(),
53              array('noheader'      => false,
54                    'include_empty' => true,
55                    'debug'         => false
56                    ));
57     }
58     // info arg allows multiple columns
59     // info=mtime,hits,summary,version,author,locked,minor,markup or all
60     // exclude arg allows multiple pagenames exclude=WikiAdmin,.SecretUser
61     //
62     // include_empty shows also users which stored their preferences,
63     // but never saved their homepage
64     //
65     // sortby: [+|-] pagename|mtime|hits
66
67     function run($dbi, $argstr, &$request, $basepage) {
68         $args = $this->getArgs($argstr, $request);
69         extract($args);
70         if ($debug)
71             $timer = new DebugTimer;
72
73         $group = $request->getGroup();
74         if (method_exists($group,'_allUsers')) {
75             $allusers = $group->_allUsers();
76         } else {
77                 $allusers = array();
78         }
79         $args['count'] = count($allusers);
80         // deleted pages show up as version 0.
81         $pagelist = new PageList($info, $exclude, $args);
82         if (!$noheader)
83             $pagelist->setCaption(_("Authenticated users on this wiki (%d total):"));
84         if ($include_empty and empty($info))
85             $pagelist->_addColumn('version');
86         list($offset, $pagesize) = $pagelist->limit($args['limit']);
87         if (!$pagesize) {
88             $pagelist->addPageList($allusers);
89         } else {
90             for ($i=$offset; $i < $offset + $pagesize - 1; $i++) {
91                 if ($i >= $args['count']) break;
92                 $pagelist->addPage(trim($allusers[$i]));
93             }
94         }
95         /*
96         $page_iter = $dbi->getAllPages($include_empty, $sortby, $limit);
97         while ($page = $page_iter->next()) {
98             if ($page->isUserPage($include_empty))
99                 $pagelist->addPage($page);
100         }
101         */
102
103         if ($debug) {
104             return HTML($pagelist,
105                         HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
106         } else {
107             return $pagelist;
108         }
109     }
110 };
111
112 // $Log: not supported by cvs2svn $
113 // Revision 1.18  2004/11/23 15:17:19  rurban
114 // better support for case_exact search (not caseexact for consistency),
115 // plugin args simplification:
116 //   handle and explode exclude and pages argument in WikiPlugin::getArgs
117 //     and exclude in advance (at the sql level if possible)
118 //   handle sortby and limit from request override in WikiPlugin::getArgs
119 // ListSubpages: renamed pages to maxpages
120 //
121 // Revision 1.17  2004/11/19 13:25:31  rurban
122 // clarify docs
123 //
124 // Revision 1.16  2004/09/25 16:37:18  rurban
125 // add support for all PageList options
126 //
127 // Revision 1.15  2004/07/08 13:50:33  rurban
128 // various unit test fixes: print error backtrace on _DEBUG_TRACE; allusers fix; new PHPWIKI_NOMAIN constant for omitting the mainloop
129 //
130 // Revision 1.14  2004/06/25 14:29:22  rurban
131 // WikiGroup refactoring:
132 //   global group attached to user, code for not_current user.
133 //   improved helpers for special groups (avoid double invocations)
134 // new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write())
135 // fixed a XHTML validation error on userprefs.tmpl
136 //
137 // Revision 1.13  2004/06/16 10:38:59  rurban
138 // Disallow refernces in calls if the declaration is a reference
139 // ("allow_call_time_pass_reference clean").
140 //   PhpWiki is now allow_call_time_pass_reference = Off clean,
141 //   but several external libraries may not.
142 //   In detail these libs look to be affected (not tested):
143 //   * Pear_DB odbc
144 //   * adodb oracle
145 //
146 // Revision 1.12  2004/04/20 00:56:00  rurban
147 // more paging support and paging fix for shorter lists
148 //
149 // Revision 1.11  2004/03/10 13:54:54  rurban
150 // adodb WikiGroup fix
151 //
152 // Revision 1.10  2004/03/08 19:30:01  rurban
153 // fixed Theme->getButtonURL
154 // AllUsers uses now WikiGroup (also DB User and DB Pref users)
155 // PageList fix for empty pagenames
156 //
157 // Revision 1.9  2004/02/22 23:20:33  rurban
158 // fixed DumpHtmlToDir,
159 // enhanced sortby handling in PageList
160 //   new button_heading th style (enabled),
161 // added sortby and limit support to the db backends and plugins
162 //   for paging support (<<prev, next>> links on long lists)
163 //
164 // Revision 1.8  2004/02/17 12:11:36  rurban
165 // 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, ...)
166 //
167 // Revision 1.7  2003/12/21 00:29:45  carstenklapp
168 // Minor bugfix: Fixed broken debug argument.
169 //
170 // Internal changes: Only create a DebugTimer when actually called for;
171 // moved debug message out of page content and into deferred page error
172 // notification via trigger_error. Memory management: Only include_once
173 // lib/PageList when absolutely necessary (at this time, this will
174 // probably only benefit the PluginManager as an incremental speedup &
175 // slightly reduced memory).
176 //
177 // Revision 1.6  2003/02/27 20:10:31  dairiki
178 // Disable profiling output when DEBUG is defined but false.
179 //
180 // Revision 1.5  2003/02/21 04:08:26  dairiki
181 // New class DebugTimer in prepend.php to help report timing.
182 //
183 // Revision 1.4  2003/01/18 21:19:25  carstenklapp
184 // Code cleanup:
185 // Reformatting; added copyleft, getVersion, getDescription
186 //
187
188 // Local Variables:
189 // mode: php
190 // tab-width: 8
191 // c-basic-offset: 4
192 // c-hanging-comment-ender-p: nil
193 // indent-tabs-mode: nil
194 // End:
195 ?>