]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllUsers.php
private --> protected
[SourceForge/phpwiki.git] / lib / plugin / AllUsers.php
1 <?php
2
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 along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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     {
38         return _("AllUsers");
39     }
40
41     function getDescription()
42     {
43         return _("List all once authenticated users.");
44     }
45
46     function getDefaultArguments()
47     {
48         return array_merge
49         (
50             PageList::supportedArgs(),
51             array('noheader' => false,
52                 'include_empty' => true,
53                 'debug' => false
54             ));
55     }
56
57     // info arg allows multiple columns
58     // info=mtime,hits,summary,version,author,locked,minor,markup or all
59     // exclude arg allows multiple pagenames exclude=WikiAdmin,.SecretUser
60     //
61     // include_empty shows also users which stored their preferences,
62     // but never saved their homepage
63     //
64     // sortby: [+|-] pagename|mtime|hits
65
66     function run($dbi, $argstr, &$request, $basepage)
67     {
68         $args = $this->getArgs($argstr, $request);
69
70         extract($args);
71         if (defined('DEBUG') && DEBUG && $debug) {
72             $timer = new DebugTimer;
73         }
74
75         $group = $request->getGroup();
76         if (method_exists($group, '_allUsers')) {
77             $allusers = $group->_allUsers();
78         } else {
79             $allusers = array();
80         }
81         $args['count'] = count($allusers);
82         // deleted pages show up as version 0.
83         $pagelist = new PageList($info, $exclude, $args);
84         if (!$noheader)
85             $pagelist->setCaption(_("Authenticated users on this wiki (%d total):"));
86         if ($include_empty and empty($info))
87             $pagelist->_addColumn('version');
88         list($offset, $pagesize) = $pagelist->limit($args['limit']);
89         if (!$pagesize) {
90             $pagelist->addPageList($allusers);
91         } else {
92             for ($i = $offset; $i < $offset + $pagesize - 1; $i++) {
93                 if ($i >= $args['count']) break;
94                 $pagelist->addPage(trim($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 (defined('DEBUG') && DEBUG and $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 // Local Variables:
115 // mode: php
116 // tab-width: 8
117 // c-basic-offset: 4
118 // c-hanging-comment-ender-p: nil
119 // indent-tabs-mode: nil
120 // End: