function showList()
 {
     # Purge expired entries on one in every 10 queries
     if (!mt_rand(0, 10)) {
         Block::purgeExpired();
     }
     $conds = array();
     # Is the user allowed to see hidden blocks?
     if (!$this->getUser()->isAllowed('hideuser')) {
         $conds['ipb_deleted'] = 0;
     }
     if ($this->target !== '') {
         list($target, $type) = Block::parseTarget($this->target);
         switch ($type) {
             case Block::TYPE_ID:
             case Block::TYPE_AUTO:
                 $conds['ipb_id'] = $target;
                 break;
             case Block::TYPE_IP:
             case Block::TYPE_RANGE:
                 list($start, $end) = IP::parseRange($target);
                 $dbr = wfGetDB(DB_SLAVE);
                 $conds[] = $dbr->makeList(array('ipb_address' => $target, Block::getRangeCond($start, $end)), LIST_OR);
                 $conds['ipb_auto'] = 0;
                 break;
             case Block::TYPE_USER:
                 $conds['ipb_address'] = (string) $this->target;
                 $conds['ipb_auto'] = 0;
                 break;
         }
     }
     # Apply filters
     if (in_array('userblocks', $this->options)) {
         $conds['ipb_user'] = 0;
     }
     if (in_array('tempblocks', $this->options)) {
         $conds['ipb_expiry'] = 'infinity';
     }
     if (in_array('addressblocks', $this->options)) {
         $conds[] = "ipb_user != 0 OR ipb_range_end > ipb_range_start";
     }
     if (in_array('rangeblocks', $this->options)) {
         $conds[] = "ipb_range_end = ipb_range_start";
     }
     # Check for other blocks, i.e. global/tor blocks
     $otherBlockLink = array();
     wfRunHooks('OtherBlockLogLink', array(&$otherBlockLink, $this->target));
     $out = $this->getOutput();
     # Show additional header for the local block only when other blocks exists.
     # Not necessary in a standard installation without such extensions enabled
     if (count($otherBlockLink)) {
         $out->addHTML(Html::element('h2', array(), $this->msg('ipblocklist-localblock')->text()) . "\n");
     }
     $pager = new BlockListPager($this, $conds);
     if ($pager->getNumRows()) {
         $out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
     } elseif ($this->target) {
         $out->addWikiMsg('ipblocklist-no-results');
     } else {
         $out->addWikiMsg('ipblocklist-empty');
     }
     if (count($otherBlockLink)) {
         $out->addHTML(Html::rawElement('h2', array(), $this->msg('ipblocklist-otherblocks', count($otherBlockLink))->parse()) . "\n");
         $list = '';
         foreach ($otherBlockLink as $link) {
             $list .= Html::rawElement('li', array(), $link) . "\n";
         }
         $out->addHTML(Html::rawElement('ul', array('class' => 'mw-ipblocklist-otherblocks'), $list) . "\n");
     }
 }
Example #2
0
 /**
  * Show the list of blocked accounts matching the actual filter.
  * @param BlockListPager $pager The BlockListPager instance for this page
  */
 protected function showList(BlockListPager $pager)
 {
     $out = $this->getOutput();
     # Check for other blocks, i.e. global/tor blocks
     $otherBlockLink = [];
     Hooks::run('OtherBlockLogLink', [&$otherBlockLink, $this->target]);
     # Show additional header for the local block only when other blocks exists.
     # Not necessary in a standard installation without such extensions enabled
     if (count($otherBlockLink)) {
         $out->addHTML(Html::element('h2', [], $this->msg('ipblocklist-localblock')->text()) . "\n");
     }
     if ($pager->getNumRows()) {
         $out->addParserOutputContent($pager->getFullOutput());
     } elseif ($this->target) {
         $out->addWikiMsg('ipblocklist-no-results');
     } else {
         $out->addWikiMsg('ipblocklist-empty');
     }
     if (count($otherBlockLink)) {
         $out->addHTML(Html::rawElement('h2', [], $this->msg('ipblocklist-otherblocks', count($otherBlockLink))->parse()) . "\n");
         $list = '';
         foreach ($otherBlockLink as $link) {
             $list .= Html::rawElement('li', [], $link) . "\n";
         }
         $out->addHTML(Html::rawElement('ul', ['class' => 'mw-ipblocklist-otherblocks'], $list) . "\n");
     }
 }