]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/AllUsers.php
include [all] Include and file path should be devided with single space. File path...
[SourceForge/phpwiki.git] / lib / plugin / AllUsers.php
1 <?php // -*-php-*-
2 /*
3  * Copyright 2002,2004 $ThePhpWikiProgrammingTeam
4  *
5  * This file is part of PhpWiki.
6  *
7  * PhpWiki is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * PhpWiki is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 require_once 'lib/PageList.php';
23
24 /**
25  * Based on AllPages and WikiGroup.
26  *
27  * We list all users,
28  * either homepage users (prefs stored in a page),
29  * users with db prefs and
30  * externally authenticated users with a db users table, 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 _("List all once authenticated users.");
41     }
42
43     function getDefaultArguments() {
44         return array_merge
45             (
46              PageList::supportedArgs(),
47              array('noheader'      => false,
48                    'include_empty' => true,
49                    'debug'         => false
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         $args = $this->getArgs($argstr, $request);
63
64         extract($args);
65         if (defined('DEBUG') && DEBUG && $debug) {
66             $timer = new DebugTimer;
67         }
68
69         $group = $request->getGroup();
70         if (method_exists($group,'_allUsers')) {
71             $allusers = $group->_allUsers();
72         } else {
73             $allusers = array();
74         }
75         $args['count'] = count($allusers);
76         // deleted pages show up as version 0.
77         $pagelist = new PageList($info, $exclude, $args);
78         if (!$noheader)
79             $pagelist->setCaption(_("Authenticated users on this wiki (%d total):"));
80         if ($include_empty and empty($info))
81             $pagelist->_addColumn('version');
82         list($offset, $pagesize) = $pagelist->limit($args['limit']);
83         if (!$pagesize) {
84             $pagelist->addPageList($allusers);
85         } else {
86             for ($i=$offset; $i < $offset + $pagesize - 1; $i++) {
87                 if ($i >= $args['count']) break;
88                 $pagelist->addPage(trim($allusers[$i]));
89             }
90         }
91         /*
92         $page_iter = $dbi->getAllPages($include_empty, $sortby, $limit);
93         while ($page = $page_iter->next()) {
94             if ($page->isUserPage($include_empty))
95                 $pagelist->addPage($page);
96         }
97         */
98
99         if (defined('DEBUG') && DEBUG and $debug) {
100             return HTML($pagelist,
101                         HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
102         } else {
103             return $pagelist;
104         }
105     }
106 };
107
108 // Local Variables:
109 // mode: php
110 // tab-width: 8
111 // c-basic-offset: 4
112 // c-hanging-comment-ender-p: nil
113 // indent-tabs-mode: nil
114 // End: