svn:eol-style
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 21 Jun 2009 11:16:15 +0000 (11:16 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 21 Jun 2009 11:16:15 +0000 (11:16 +0000)
includes/specials/SpecialActiveusers.php

index d4c6bfe..e873546 100644 (file)
-<?php\r
-\r
-# Copyright (C) 2008 Aaron Schulz\r
-#\r
-# http://www.mediawiki.org/\r
-#\r
-# This program is free software; you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License as published by\r
-# the Free Software Foundation; either version 2 of the License, or\r
-# (at your option) any later version.\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License along\r
-# with this program; if not, write to the Free Software Foundation, Inc.,\r
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
-# http://www.gnu.org/copyleft/gpl.html\r
-/**\r
- *\r
- * @addtogroup SpecialPage\r
- */\r
-\r
-/**\r
- * This class is used to get a list of user. The ones with specials\r
- * rights (sysop, bureaucrat, developer) will have them displayed\r
- * next to their names.\r
- *\r
- * @addtogroup SpecialPage\r
- */\r
-\r
-class ActiveUsersPager extends UsersPager {\r
-\r
-       function __construct($group=null) {\r
-               global $wgRequest;\r
-               $un = $wgRequest->getText( 'username' );\r
-               $this->requestedUser = '';\r
-               if ( $un != '' ) {\r
-                       $username = Title::makeTitleSafe( NS_USER, $un );\r
-                       if( ! is_null( $username ) ) {\r
-                               $this->requestedUser = $username->getText();\r
-                       }\r
-               }\r
-               parent::__construct();\r
-       }\r
-\r
-\r
-       function getIndexField() {\r
-               return 'rc_user_text';\r
-       }\r
-\r
-       function getQueryInfo() {\r
-               $dbr = wfGetDB( DB_SLAVE );\r
-               $conds = array();\r
-               // don't show hidden names\r
-               $conds[] = 'ipb_deleted IS NULL';\r
-               $useIndex = $dbr->useIndexClause('rc_user_text');\r
-               if( $this->requestedUser != "" ) {\r
-                       $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser );\r
-               }\r
-               $conds[] = 'rc_user > 0'; // Users - no anons\r
-\r
-               list ($recentchanges,$ipblocks) = $dbr->tableNamesN('recentchanges','ipblocks');\r
-\r
-               $query = array(\r
-                       'tables' => " $recentchanges $useIndex \r
-                               LEFT JOIN $ipblocks ON rc_user=ipb_user AND ipb_auto=0 AND ipb_deleted=1 ",\r
-                       'fields' => array('rc_user_text AS user_name', // inheritance\r
-                               'rc_user_text', // for Pager\r
-                               'MAX(rc_user) AS user_id',\r
-                               'COUNT(*) AS recentedits',\r
-                               'MAX(ipb_user) AS blocked'),\r
-                       'options' => array('GROUP BY' => 'user_name'),\r
-                       'conds' => $conds\r
-               );\r
-               return $query;\r
-       }\r
-\r
-       function formatRow( $row ) {\r
-               $userPage = Title::makeTitle( NS_USER, $row->rc_user_text );\r
-               $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );\r
-\r
-               $list = array();\r
-               foreach( self::getGroups( $row->user_id ) as $group )\r
-                       $list[] = self::buildGroupLink( $group );\r
-               $groups = implode( ', ', $list );\r
-\r
-               $item = wfSpecialList( $name, $groups );\r
-               $count = wfMsgExt( 'activeusers-count', array('parsemag'), $row->recentedits );\r
-               $blocked = $row->blocked ? ' '.wfMsg('listusers-blocked') : '';\r
-\r
-               return "<li>{$item} [{$count}]{$blocked}</li>";\r
-       }\r
-\r
-       function getPageHeader() {\r
-               global $wgScript, $wgRequest;\r
-               $self = $this->getTitle();\r
-\r
-               # Form tag\r
-               $out  = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .\r
-                       '<fieldset>' .\r
-                       Xml::element( 'legend', array(), wfMsg( 'activeusers' ) );\r
-               $out .= Xml::hidden( 'title', $self->getPrefixedDbKey() );\r
-\r
-               # Username field\r
-               $out .= Xml::label( wfMsg( 'activeusers-from' ), 'offset' ) . ' ' .\r
-                       Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' ';\r
-\r
-               # Submit button and form bottom\r
-               if( $this->mLimit )\r
-                       $out .= Xml::hidden( 'limit', $this->mLimit );\r
-               $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );\r
-\r
-               $out .= '</fieldset>' . Xml::closeElement( 'form' );\r
-\r
-               return $out;\r
-       }\r
-}\r
-\r
-/**\r
- * constructor\r
- * $par string (optional) A group to list users from\r
- */\r
-function wfSpecialActiveusers( $par = null ) {\r
-       global $wgRequest, $wgOut;\r
-\r
-       $up = new ActiveUsersPager();\r
-\r
-       # getBody() first to check, if empty\r
-       $usersbody = $up->getBody();\r
-       $s = $up->getPageHeader();\r
-       if( $usersbody ) {\r
-               $s .=   $up->getNavigationBar();\r
-               $s .=   '<ul>' . $usersbody . '</ul>';\r
-               $s .=   $up->getNavigationBar() ;\r
-       } else {\r
-               $s .=   '<p>' . wfMsgHTML('activeusers-noresult') . '</p>';\r
-       };\r
-\r
-       $wgOut->addHTML( $s );\r
-}\r
+<?php
+
+# Copyright (C) 2008 Aaron Schulz
+#
+# http://www.mediawiki.org/
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# http://www.gnu.org/copyleft/gpl.html
+/**
+ *
+ * @addtogroup SpecialPage
+ */
+
+/**
+ * This class is used to get a list of user. The ones with specials
+ * rights (sysop, bureaucrat, developer) will have them displayed
+ * next to their names.
+ *
+ * @addtogroup SpecialPage
+ */
+
+class ActiveUsersPager extends UsersPager {
+
+       function __construct($group=null) {
+               global $wgRequest;
+               $un = $wgRequest->getText( 'username' );
+               $this->requestedUser = '';
+               if ( $un != '' ) {
+                       $username = Title::makeTitleSafe( NS_USER, $un );
+                       if( ! is_null( $username ) ) {
+                               $this->requestedUser = $username->getText();
+                       }
+               }
+               parent::__construct();
+       }
+
+
+       function getIndexField() {
+               return 'rc_user_text';
+       }
+
+       function getQueryInfo() {
+               $dbr = wfGetDB( DB_SLAVE );
+               $conds = array();
+               // don't show hidden names
+               $conds[] = 'ipb_deleted IS NULL';
+               $useIndex = $dbr->useIndexClause('rc_user_text');
+               if( $this->requestedUser != "" ) {
+                       $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser );
+               }
+               $conds[] = 'rc_user > 0'; // Users - no anons
+
+               list ($recentchanges,$ipblocks) = $dbr->tableNamesN('recentchanges','ipblocks');
+
+               $query = array(
+                       'tables' => " $recentchanges $useIndex 
+                               LEFT JOIN $ipblocks ON rc_user=ipb_user AND ipb_auto=0 AND ipb_deleted=1 ",
+                       'fields' => array('rc_user_text AS user_name', // inheritance
+                               'rc_user_text', // for Pager
+                               'MAX(rc_user) AS user_id',
+                               'COUNT(*) AS recentedits',
+                               'MAX(ipb_user) AS blocked'),
+                       'options' => array('GROUP BY' => 'user_name'),
+                       'conds' => $conds
+               );
+               return $query;
+       }
+
+       function formatRow( $row ) {
+               $userPage = Title::makeTitle( NS_USER, $row->rc_user_text );
+               $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
+
+               $list = array();
+               foreach( self::getGroups( $row->user_id ) as $group )
+                       $list[] = self::buildGroupLink( $group );
+               $groups = implode( ', ', $list );
+
+               $item = wfSpecialList( $name, $groups );
+               $count = wfMsgExt( 'activeusers-count', array('parsemag'), $row->recentedits );
+               $blocked = $row->blocked ? ' '.wfMsg('listusers-blocked') : '';
+
+               return "<li>{$item} [{$count}]{$blocked}</li>";
+       }
+
+       function getPageHeader() {
+               global $wgScript, $wgRequest;
+               $self = $this->getTitle();
+
+               # Form tag
+               $out  = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
+                       '<fieldset>' .
+                       Xml::element( 'legend', array(), wfMsg( 'activeusers' ) );
+               $out .= Xml::hidden( 'title', $self->getPrefixedDbKey() );
+
+               # Username field
+               $out .= Xml::label( wfMsg( 'activeusers-from' ), 'offset' ) . ' ' .
+                       Xml::input( 'username', 20, $this->requestedUser, array( 'id' => 'offset' ) ) . ' ';
+
+               # Submit button and form bottom
+               if( $this->mLimit )
+                       $out .= Xml::hidden( 'limit', $this->mLimit );
+               $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
+
+               $out .= '</fieldset>' . Xml::closeElement( 'form' );
+
+               return $out;
+       }
+}
+
+/**
+ * constructor
+ * $par string (optional) A group to list users from
+ */
+function wfSpecialActiveusers( $par = null ) {
+       global $wgRequest, $wgOut;
+
+       $up = new ActiveUsersPager();
+
+       # getBody() first to check, if empty
+       $usersbody = $up->getBody();
+       $s = $up->getPageHeader();
+       if( $usersbody ) {
+               $s .=   $up->getNavigationBar();
+               $s .=   '<ul>' . $usersbody . '</ul>';
+               $s .=   $up->getNavigationBar() ;
+       } else {
+               $s .=   '<p>' . wfMsgHTML('activeusers-noresult') . '</p>';
+       };
+
+       $wgOut->addHTML( $s );
+}