/**
  * Unblocks the specified user or provides the reason the unblock failed.
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if ($params['gettoken']) {
         $res['unblocktoken'] = $wgUser->editToken();
         $this->getResult()->addValue(null, $this->getModuleName(), $res);
         return;
     }
     if (is_null($params['id']) && is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-notarget'));
     }
     if (!is_null($params['id']) && !is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-idanduser'));
     }
     if (!$wgUser->isAllowed('block')) {
         $this->dieUsageMsg(array('cantunblock'));
     }
     $id = $params['id'];
     $user = $params['user'];
     $reason = is_null($params['reason']) ? '' : $params['reason'];
     $retval = IPUnblockForm::doUnblock($id, $user, $reason, $range);
     if ($retval) {
         $this->dieUsageMsg($retval);
     }
     $res['id'] = intval($id);
     $res['user'] = $user;
     $res['reason'] = $reason;
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
 /**
  * Unblocks the specified user or provides the reason the unblock failed.
  */
 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     if ($params['gettoken']) {
         $res['unblocktoken'] = $wgUser->editToken();
         $this->getResult()->addValue(null, $this->getModuleName(), $res);
         return;
     }
     if (is_null($params['id']) && is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-notarget'));
     }
     if (!is_null($params['id']) && !is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-idanduser'));
     }
     if (is_null($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     if (!$wgUser->isAllowed('block')) {
         $this->dieUsageMsg(array('cantunblock'));
     }
     if (wfReadOnly()) {
         $this->dieUsageMsg(array('readonlytext'));
     }
     $id = $params['id'];
     $user = $params['user'];
     $reason = is_null($params['reason']) ? '' : $params['reason'];
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = IPUnblockForm::doUnblock($id, $user, $reason, $range);
     if (!empty($retval)) {
         $this->dieUsageMsg($retval);
     }
     $dbw->commit();
     $res['id'] = $id;
     $res['user'] = $user;
     $res['reason'] = $reason;
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
Example #3
0
 /**
  * Unblocks the specified user or provides the reason the unblock failed.
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if ($params['gettoken']) {
         $res['unblocktoken'] = $wgUser->editToken();
         $this->getResult()->addValue(null, $this->getModuleName(), $res);
         return;
     }
     if (is_null($params['id']) && is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-notarget'));
     }
     if (!is_null($params['id']) && !is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-idanduser'));
     }
     if (!$wgUser->isAllowed('block')) {
         $this->dieUsageMsg(array('cantunblock'));
     }
     # bug 15810: blocked admins should have limited access here
     if ($wgUser->isBlocked()) {
         $status = IPBlockForm::checkUnblockSelf($params['user']);
         if ($status !== true) {
             $this->dieUsageMsg(array($status));
         }
     }
     $id = $params['id'];
     $user = $params['user'];
     $reason = is_null($params['reason']) ? '' : $params['reason'];
     $retval = IPUnblockForm::doUnblock($id, $user, $reason, $range);
     if ($retval) {
         $this->dieUsageMsg($retval);
     }
     $res['id'] = intval($id);
     $res['user'] = $user;
     $res['reason'] = $reason;
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }