PageRenderTime 54ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/gforge/plugins/wiki/www/lib/plugin/AllUsers.php

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