Update for he.
[lhc/web/wiklou.git] / includes / SpecialListusers.php
index d6d4a34..7dba44e 100644 (file)
@@ -22,8 +22,8 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 # http://www.gnu.org/copyleft/gpl.html
 /**
- *
- * @addtogroup SpecialPage
+ * @file
+ * @ingroup SpecialPage
  */
 
 /**
@@ -31,9 +31,8 @@
  * rights (sysop, bureaucrat, developer) will have them displayed
  * next to their names.
  *
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
-
 class UsersPager extends AlphabeticPager {
 
        function __construct($group=null) {
@@ -56,28 +55,35 @@ class UsersPager extends AlphabeticPager {
        }
 
        function getQueryInfo() {
+               $dbr = wfGetDB( DB_SLAVE );
                $conds=array();
                // don't show hidden names
                $conds[]='ipb_deleted IS NULL OR ipb_deleted = 0';
                if ($this->requestedGroup != "") {
                        $conds['ug_group'] = $this->requestedGroup;
+                       $useIndex = '';
+               } else {
+                       $useIndex = $dbr->useIndexClause('user_name');
                }
                if ($this->requestedUser != "") {
-                       $conds[] = 'user_name >= ' . wfGetDB()->addQuotes( $this->requestedUser );
+                       $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser );
                }
 
-               list ($user,$user_groups,$ipblocks) = wfGetDB()->tableNamesN('user','user_groups','ipblocks');
+               list ($user,$user_groups,$ipblocks) = $dbr->tableNamesN('user','user_groups','ipblocks');
 
-               return array(
-                       'tables' => " $user LEFT JOIN $user_groups ON user_id=ug_user LEFT JOIN $ipblocks ON user_id=ipb_user AND ipb_auto=0 ",
+               $query = array(
+                       'tables' => " $user $useIndex LEFT JOIN $user_groups ON user_id=ug_user
+                               LEFT JOIN $ipblocks ON user_id=ipb_user AND ipb_auto=0 ",
                        'fields' => array('user_name',
                                'MAX(user_id) AS user_id',
-                               'COUNT(ug_group) AS numgroups', 
+                               'COUNT(ug_group) AS numgroups',
                                'MAX(ug_group) AS singlegroup'),
-                       'options' => array('GROUP BY' => 'user_name'), 
+                       'options' => array('GROUP BY' => 'user_name'),
                        'conds' => $conds
                );
 
+               wfRunHooks( 'SpecialListusersQueryInfo', array( $this, &$query ) );
+               return $query;
        }
 
        function formatRow( $row ) {
@@ -95,7 +101,9 @@ class UsersPager extends AlphabeticPager {
                        $groups = '';
                }
 
-               return '<li>' . wfSpecialList( $name, $groups ) . '</li>';
+               $item = wfSpecialList( $name, $groups );
+               wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) );
+               return "<li>{$item}</li>";
        }
 
        function getBody() {
@@ -132,20 +140,31 @@ class UsersPager extends AlphabeticPager {
                $out .= Xml::label( wfMsg( 'group' ), 'group' ) . ' ' .
                        Xml::openElement('select',  array( 'name' => 'group', 'id' => 'group' ) ) .
                        Xml::option( wfMsg( 'group-all' ), '' );
-               foreach( User::getAllGroups() as $group )
-                       $out .= Xml::option( User::getGroupName( $group ), $group, $group == $this->requestedGroup );
+               foreach( $this->getAllGroups() as $group => $groupText )
+                       $out .= Xml::option( $groupText, $group, $group == $this->requestedGroup );
                $out .= Xml::closeElement( 'select' ) . ' ';
 
+               wfRunHooks( 'SpecialListusersHeaderForm', array( $this, &$out ) );
+
                # Submit button and form bottom
                if( $this->mLimit )
                        $out .= Xml::hidden( 'limit', $this->mLimit );
-               $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
-                       '</fieldset>' .
+               $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
+               wfRunHooks( 'SpecialListusersHeader', array( $this, &$out ) );
+               $out .= '</fieldset>' .
                        Xml::closeElement( 'form' );
 
                return $out;
        }
 
+       function getAllGroups() {
+               $result = array();
+               foreach( User::getAllGroups() as $group ) {
+                       $result[$group] = User::getGroupName( $group );
+               }
+               return $result;
+       }
+
        /**
         * Preserve group and username offset parameters when paging
         * @return array
@@ -156,6 +175,7 @@ class UsersPager extends AlphabeticPager {
                        $query['group'] = $this->requestedGroup;
                if( $this->requestedUser != '' )
                        $query['username'] = $this->requestedUser;
+               wfRunHooks( 'SpecialListusersDefaultQuery', array( $this, &$query ) );
                return $query;
        }
 
@@ -165,7 +185,7 @@ class UsersPager extends AlphabeticPager {
         * @param int $uid
         * @return array
         */
-       private static function getGroups( $uid ) {
+       protected static function getGroups( $uid ) {
                $dbr = wfGetDB( DB_SLAVE );
                $groups = array();
                $res = $dbr->select( 'user_groups', 'ug_group', array( 'ug_user' => $uid ), __METHOD__ );
@@ -183,7 +203,7 @@ class UsersPager extends AlphabeticPager {
         * @param string $group
         * @return string
         */
-       private static function buildGroupLink( $group ) {
+       protected static function buildGroupLink( $group ) {
                static $cache = array();
                if( !isset( $cache[$group] ) )
                        $cache[$group] = User::makeGroupLinkHtml( $group, User::getGroupMember( $group ) );
@@ -198,10 +218,6 @@ class UsersPager extends AlphabeticPager {
 function wfSpecialListusers( $par = null ) {
        global $wgRequest, $wgOut;
 
-       list( $limit, $offset ) = wfCheckLimits();
-
-       $groupTarget = isset($par) ? $par : $wgRequest->getVal( 'group' );
-
        $up = new UsersPager($par);
 
        # getBody() first to check, if empty
@@ -217,5 +233,3 @@ function wfSpecialListusers( $par = null ) {
 
        $wgOut->addHTML( $s );
 }
-
-