Replace usages of deprecated User::isAllowed. Step 2.
[lhc/web/wiklou.git] / includes / specials / pagers / BlockListPager.php
index 01aed22..718da6d 100644 (file)
@@ -45,9 +45,9 @@ class BlockListPager extends TablePager {
         * @param array $conds
         */
        public function __construct( $page, $conds ) {
+               parent::__construct( $page->getContext(), $page->getLinkRenderer() );
                $this->conds = $conds;
                $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
-               parent::__construct( $page->getContext() );
        }
 
        function getFieldNames() {
@@ -70,6 +70,12 @@ class BlockListPager extends TablePager {
                return $headers;
        }
 
+       /**
+        * @param string $name
+        * @param string $value
+        * @return string
+        * @suppress PhanTypeArraySuspicious
+        */
        function formatValue( $name, $value ) {
                static $msg = null;
                if ( $msg === null ) {
@@ -97,7 +103,7 @@ class BlockListPager extends TablePager {
 
                $formatted = '';
 
-               $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+               $linkRenderer = $this->getLinkRenderer();
 
                switch ( $name ) {
                        case 'ipb_timestamp':
@@ -131,7 +137,11 @@ class BlockListPager extends TablePager {
                                        $value,
                                        /* User preference timezone */true
                                ) );
-                               if ( $this->getUser()->isAllowed( 'block' ) ) {
+                               if ( MediaWikiServices::getInstance()
+                                               ->getPermissionManager()
+                                               ->userHasRight( $this->getUser(), 'block' )
+                               ) {
+                                       $links = [];
                                        if ( $row->ipb_auto ) {
                                                $links[] = $linkRenderer->makeKnownLink(
                                                        SpecialPage::getTitleFor( 'Unblock' ),
@@ -250,7 +260,7 @@ class BlockListPager extends TablePager {
         */
        private function getRestrictionListHTML( stdClass $row ) {
                $items = [];
-               $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+               $linkRenderer = $this->getLinkRenderer();
 
                foreach ( $this->restrictions as $restriction ) {
                        if ( $restriction->getBlockId() !== (int)$row->ipb_id ) {
@@ -259,6 +269,7 @@ class BlockListPager extends TablePager {
 
                        switch ( $restriction->getType() ) {
                                case PageRestriction::TYPE:
+                                       '@phan-var PageRestriction $restriction';
                                        if ( $restriction->getTitle() ) {
                                                $items[$restriction->getType()][] = Html::rawElement(
                                                        'li',
@@ -350,7 +361,10 @@ class BlockListPager extends TablePager {
                $info['conds'][] = 'ipb_expiry > ' . $db->addQuotes( $db->timestamp() );
 
                # Is the user allowed to see hidden blocks?
-               if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+               if ( !MediaWikiServices::getInstance()
+                               ->getPermissionManager()
+                               ->userHasRight( $this->getUser(), 'hideuser' )
+               ) {
                        $info['conds']['ipb_deleted'] = 0;
                }