]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllUsers.php
getName should not translate
[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 getDescription()
37     {
38         return _("List all once authenticated users.");
39     }
40
41     function getDefaultArguments()
42     {
43         return array_merge
44         (
45             PageList::supportedArgs(),
46             array('noheader' => false,
47                 'include_empty' => true,
48                 'debug' => false
49             ));
50     }
51
52     // info arg allows multiple columns
53     // info=mtime,hits,summary,version,author,locked,minor,markup or all
54     // exclude arg allows multiple pagenames exclude=WikiAdmin,.SecretUser
55     //
56     // include_empty shows also users which stored their preferences,
57     // but never saved their homepage
58     //
59     // sortby: [+|-] pagename|mtime|hits
60
61     function run($dbi, $argstr, &$request, $basepage)
62     {
63         $args = $this->getArgs($argstr, $request);
64
65         extract($args);
66         if (defined('DEBUG') && DEBUG && $debug) {
67             $timer = new DebugTimer;
68         }
69
70         $group = $request->getGroup();
71         if (method_exists($group, '_allUsers')) {
72             $allusers = $group->_allUsers();
73         } else {
74             $allusers = array();
75         }
76         $args['count'] = count($allusers);
77         // deleted pages show up as version 0.
78         $pagelist = new PageList($info, $exclude, $args);
79         if (!$noheader)
80             $pagelist->setCaption(_("Authenticated users on this wiki (%d total):"));
81         if ($include_empty and empty($info))
82             $pagelist->_addColumn('version');
83         list($offset, $pagesize) = $pagelist->limit($args['limit']);
84         if (!$pagesize) {
85             $pagelist->addPageList($allusers);
86         } else {
87             for ($i = $offset; $i < $offset + $pagesize - 1; $i++) {
88                 if ($i >= $args['count']) break;
89                 $pagelist->addPage(trim($allusers[$i]));
90             }
91         }
92         /*
93         $page_iter = $dbi->getAllPages($include_empty, $sortby, $limit);
94         while ($page = $page_iter->next()) {
95             if ($page->isUserPage($include_empty))
96                 $pagelist->addPage($page);
97         }
98         */
99
100         if (defined('DEBUG') && DEBUG and $debug) {
101             return HTML($pagelist,
102                 HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
103         } else {
104             return $pagelist;
105         }
106     }
107 }
108
109 // Local Variables:
110 // mode: php
111 // tab-width: 8
112 // c-basic-offset: 4
113 // c-hanging-comment-ender-p: nil
114 // indent-tabs-mode: nil
115 // End: