]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllUsers.php
Removed history
[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$");
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 // Local Variables:
113 // mode: php
114 // tab-width: 8
115 // c-basic-offset: 4
116 // c-hanging-comment-ender-p: nil
117 // indent-tabs-mode: nil
118 // End:
119 ?>