private function blockStats($blockId)
 {
     $this->wg->Out->setPageTitle(sprintf("%s #%s", wfMsg('phalanx-stats-title'), $blockId));
     $data = Phalanx::newFromId($blockId);
     if (!isset($data["id"])) {
         $this->wg->Out->addWikiMsg('phalanx-stats-block-notfound', $blockId);
         return;
     }
     $data['author_id'] = User::newFromId($data['author_id'])->getName();
     $data['timestamp'] = $this->wg->Lang->timeanddate($data['timestamp']);
     if ($data['expire'] == null) {
         $data['expire'] = 'infinite';
     } else {
         $data['expire'] = $this->wg->Lang->timeanddate($data['expire']);
     }
     $data['regex'] = $data['regex'] ? 'Yes' : 'No';
     $data['case'] = $data['case'] ? 'Yes' : 'No';
     $data['exact'] = $data['exact'] ? 'Yes' : 'No';
     $data['lang'] = empty($data['lang']) ? 'All' : $data['lang'];
     if ($data['type'] & Phalanx::TYPE_EMAIL && !$this->wg->User->isAllowed('phalanxemailblock')) {
         /* hide email from non-privildged users */
         $data['text'] = wfMsg('phalanx-email-filter-hidden');
     }
     $data['type'] = implode(', ', Phalanx::getTypeNames($data['type']));
     /* stats table */
     $headers = array(wfMsg('phalanx-stats-table-id'), wfMsg('phalanx-stats-table-user'), wfMsg('phalanx-stats-table-type'), wfMsg('phalanx-stats-table-create'), wfMsg('phalanx-stats-table-expire'), wfMsg('phalanx-stats-table-exact'), wfMsg('phalanx-stats-table-regex'), wfMsg('phalanx-stats-table-case'), wfMsg('phalanx-stats-table-language'));
     $tableAttribs = array('class' => 'wikitable', 'width' => '100%');
     /* pull these out of the array, so they dont get used in the top rows */
     $row = $data->toArray();
     unset($row['text']);
     unset($row['reason']);
     unset($row['comment']);
     unset($row['ip_hex']);
     // parse block comment
     if ($data['comment'] != '') {
         $comment = ParserPool::parse($data['comment'], $this->wg->Title, new ParserOptions())->getText();
     } else {
         $comment = '';
     }
     $table = Xml::buildTable(array($row), $tableAttribs, $headers);
     $table = str_replace("</table>", "", $table);
     $table .= "<tr><th>" . wfMsg('phalanx-stats-table-text') . "</th><td colspan='8'>" . htmlspecialchars($data['text']) . "</td></tr>";
     $table .= "<tr><th>" . wfMsg('phalanx-stats-table-reason') . "</th><td colspan='8'>{$data['reason']}</td></tr>";
     $table .= "<tr><th>" . wfMsg('phalanx-stats-table-comment') . "</th><td colspan='8'>{$comment}</td></tr>";
     $table .= "</table>";
     $this->setVal('table', $table);
     $this->setVal('editUrl', $this->phalanxTitle->getLocalUrl(array('id' => $data['id'])));
     /* match statistics */
     $pager = new PhalanxStatsPager($blockId);
     $this->setVal('statsPager', $pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
 }
 /**
  * Returns current block data
  *
  * @return array
  */
 private function blockDataForForm()
 {
     $data = array();
     $id = $this->wg->Request->getInt('id');
     if ($id > 0) {
         // block edit
         $data = Phalanx::newFromId($id);
         if ($data['type'] & Phalanx::TYPE_EMAIL && !$this->app->wg->User->isAllowed('phalanxemailblock')) {
             // VSTF members should not be able to view email blocks
             $data = [];
         } else {
             $data['type'] = Phalanx::getTypeNames($data['type']);
             $data['checkId'] = $id;
             $data['checkBlocker'] = '';
             return $data;
         }
     }
     // block creation
     $pager = new PhalanxPager();
     $data['checkBlocker'] = $this->wg->Request->getText('wpPhalanxCheckBlocker', '');
     $data['checkId'] = $this->wg->Request->getIntOrNull('id');
     $data['type'] = $pager->getSearchFilter();
     $data['text'] = $this->wg->Request->getText('target', '');
     // prefill the filter content using target URL parameter
     $data['lang'] = '';
     $data['expire'] = '';
     $data['reason'] = '';
     $data['comment'] = '';
     return $data;
 }
Esempio n. 3
0
 /**
  * Delete Phalanx block
  *
  * @param $id Int - block ID
  * @return boolean true or false if error
  *
  * @author moli
  */
 public static function onDeletePhalanxBlock($id)
 {
     wfProfileIn(__METHOD__);
     $phalanx = Phalanx::newFromId($id);
     $id = $phalanx->delete();
     if ($id) {
         $service = new PhalanxService();
         $ids = array($id);
         $ret = $service->reload($ids);
     } else {
         $ret = false;
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }