Merge "CologneBlue rewrite: remove hard dependency on SkinLegacy, kill Quickbar nonsense"
[lhc/web/wiklou.git] / includes / specials / SpecialListusers.php
index 75be397..11d7f4d 100644 (file)
  */
 class UsersPager extends AlphabeticPager {
 
-       function __construct( IContextSource $context = null, $par = null ) {
+       /**
+        * @param $context IContextSource
+        * @param $par null|array
+        */
+       function __construct( IContextSource $context = null, $par = null, $including = null ) {
                if ( $context ) {
                        $this->setContext( $context );
                }
@@ -58,6 +62,7 @@ class UsersPager extends AlphabeticPager {
                }
                $this->editsOnly = $request->getBool( 'editsOnly' );
                $this->creationSort = $request->getBool( 'creationSort' );
+               $this->including = $including;
 
                $this->requestedUser = '';
                if ( $un != '' ) {
@@ -69,16 +74,22 @@ class UsersPager extends AlphabeticPager {
                parent::__construct();
        }
 
+       /**
+        * @return string
+        */
        function getIndexField() {
                return $this->creationSort ? 'user_id' : 'user_name';
        }
 
+       /**
+        * @return Array
+        */
        function getQueryInfo() {
                $dbr = wfGetDB( DB_SLAVE );
                $conds = array();
                // Don't show hidden names
-               if( !$this->getUser()->isAllowed('hideuser') ) {
-                       $conds[] = 'ipb_deleted IS NULL';
+               if( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+                       $conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0';
                }
 
                $options = array();
@@ -105,18 +116,21 @@ class UsersPager extends AlphabeticPager {
                $query = array(
                        'tables' => array( 'user', 'user_groups', 'ipblocks'),
                        'fields' => array(
-                               $this->creationSort ? 'MAX(user_name) AS user_name' : 'user_name',
-                               $this->creationSort ? 'user_id' : 'MAX(user_id) AS user_id',
-                               'MAX(user_editcount) AS edits',
-                               'COUNT(ug_group) AS numgroups',
-                               'MAX(ug_group) AS singlegroup', // the usergroup if there is only one
-                               'MIN(user_registration) AS creation',
-                               'MAX(ipb_deleted) AS ipb_deleted' // block/hide status
+                               'user_name' => $this->creationSort ? 'MAX(user_name)' : 'user_name',
+                               'user_id' => $this->creationSort ? 'user_id' : 'MAX(user_id)',
+                               'edits' => 'MAX(user_editcount)',
+                               'numgroups' => 'COUNT(ug_group)',
+                               'singlegroup' => 'MAX(ug_group)', // the usergroup if there is only one
+                               'creation' => 'MIN(user_registration)',
+                               'ipb_deleted' => 'MAX(ipb_deleted)' // block/hide status
                        ),
                        'options' => $options,
                        'join_conds' => array(
                                'user_groups' => array( 'LEFT JOIN', 'user_id=ug_user' ),
-                               'ipblocks' => array( 'LEFT JOIN', 'user_id=ipb_user AND ipb_deleted=1 AND ipb_auto=0' ),
+                               'ipblocks' => array( 'LEFT JOIN', array(
+                                       'user_id=ipb_user',
+                                       'ipb_auto' => 0
+                               )),
                        ),
                        'conds' => $conds
                );
@@ -125,28 +139,29 @@ class UsersPager extends AlphabeticPager {
                return $query;
        }
 
+       /**
+        * @param $row Object
+        * @return String
+        */
        function formatRow( $row ) {
-               if ($row->user_id == 0) #Bug 16487
+               if ( $row->user_id == 0 ) { #Bug 16487
                        return '';
+               }
 
                $userName = $row->user_name;
 
                $ulinks = Linker::userLink( $row->user_id, $userName );
                $ulinks .= Linker::userToolLinks( $row->user_id, $userName );
 
-               $userPage = Title::makeTitle( NS_USER, $row->user_name );
-               $name = Linker::link( $userPage, htmlspecialchars( $userPage->getText() ) );
-
                $lang = $this->getLanguage();
 
+               $groups = '';
                $groups_list = self::getGroups( $row->user_id );
-               if( count( $groups_list ) > 0 ) {
+               if( !$this->including && count( $groups_list ) > 0 ) {
                        $list = array();
                        foreach( $groups_list as $group )
                                $list[] = self::buildGroupLink( $group, $userName );
                        $groups = $lang->commaList( $list );
-               } else {
-                       $groups = '';
                }
 
                $item = $lang->specialList( $ulinks, $groups );
@@ -154,25 +169,25 @@ class UsersPager extends AlphabeticPager {
                        $item = "<span class=\"deleted\">$item</span>";
                }
 
+               $edits = '';
                global $wgEdititis;
-               if ( $wgEdititis ) {
+               if ( !$this->including && $wgEdititis ) {
                        $edits = ' [' . $this->msg( 'usereditcount' )->numParams( $row->edits )->escaped() . ']';
-               } else {
-                       $edits = '';
                }
 
                $created = '';
                # Some rows may be NULL
-               if( $row->creation ) {
+               if( !$this->including && $row->creation ) {
                        $user = $this->getUser();
                        $d = $lang->userDate( $row->creation, $user );
                        $t = $lang->userTime( $row->creation, $user );
                        $created = $this->msg( 'usercreated', $d, $t, $row->user_name )->escaped();
                        $created = ' ' . $this->msg( 'parentheses' )->rawParams( $created )->escaped();
                }
+               $blocked = !is_null( $row->ipb_deleted ) ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
 
                wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) );
-               return "<li>{$item}{$edits}{$created}</li>";
+               return Html::rawElement( 'li', array(), "{$item}{$edits}{$created}{$blocked}" );
        }
 
        function doBatchLookups() {
@@ -186,9 +201,12 @@ class UsersPager extends AlphabeticPager {
                $this->mResult->rewind();
        }
 
+       /**
+        * @return string
+        */
        function getPageHeader( ) {
                global $wgScript;
-               // @todo Add a PrefixedBaseDBKey
+
                list( $self ) = explode( '/', $this->getTitle()->getPrefixedDBkey() );
 
                # Form tag
@@ -243,10 +261,12 @@ class UsersPager extends AlphabeticPager {
         */
        function getDefaultQuery() {
                $query = parent::getDefaultQuery();
-               if( $this->requestedGroup != '' )
+               if( $this->requestedGroup != '' ) {
                        $query['group'] = $this->requestedGroup;
-               if( $this->requestedUser != '' )
+               }
+               if( $this->requestedUser != '' ) {
                        $query['username'] = $this->requestedUser;
+               }
                wfRunHooks( 'SpecialListusersDefaultQuery', array( $this, &$query ) );
                return $query;
        }
@@ -278,7 +298,7 @@ class UsersPager extends AlphabeticPager {
 /**
  * @ingroup SpecialPage
  */
-class SpecialListUsers extends SpecialPage {
+class SpecialListUsers extends IncludableSpecialPage {
 
        /**
         * Constructor
@@ -296,12 +316,16 @@ class SpecialListUsers extends SpecialPage {
                $this->setHeaders();
                $this->outputHeader();
 
-               $up = new UsersPager( $this->getContext(), $par );
+               $up = new UsersPager( $this->getContext(), $par, $this->including() );
 
                # getBody() first to check, if empty
                $usersbody = $up->getBody();
 
-               $s = $up->getPageHeader();
+               $s = '';
+               if ( !$this->including() ) {
+                       $s = $up->getPageHeader();
+               }
+
                if( $usersbody ) {
                        $s .= $up->getNavigationBar();
                        $s .= Html::rawElement( 'ul', array(), $usersbody );