コード例 #1
0
 function addDBData()
 {
     $user = User::newFromName('UTBlockee');
     if ($user->getID() == 0) {
         $user->addToDatabase();
         $user->setPassword('UTBlockeePassword');
         $user->saveSettings();
     }
     // Delete the last round's block if it's still there
     $oldBlock = Block::newFromTarget('UTBlockee');
     if ($oldBlock) {
         // An old block will prevent our new one from saving.
         $oldBlock->delete();
     }
     $this->block = new Block('UTBlockee', $user->getID(), 0, 'Parce que', 0, false, time() + 100500);
     $this->madeAt = wfTimestamp(TS_MW);
     $this->block->insert();
     // save up ID for use in assertion. Since ID is an autoincrement,
     // its value might change depending on the order the tests are run.
     // ApiBlockTest insert its own blocks!
     $newBlockId = $this->block->getId();
     if ($newBlockId) {
         $this->blockId = $newBlockId;
     } else {
         throw new MWException("Failed to insert block for BlockTest; old leftover block remaining?");
     }
     $this->addXffBlocks();
 }
コード例 #2
0
ファイル: ApiQueryUserInfo.php プロジェクト: D66Ha/mediawiki
 /**
  * Get basic info about a given block
  * @param Block $block
  * @return array Array containing several keys:
  *  - blockid - ID of the block
  *  - blockedby - username of the blocker
  *  - blockedbyid - user ID of the blocker
  *  - blockreason - reason provided for the block
  *  - blockedtimestamp - timestamp for when the block was placed/modified
  *  - blockexpiry - expiry time of the block
  */
 public static function getBlockInfo(Block $block)
 {
     global $wgContLang;
     $vals = array();
     $vals['blockid'] = $block->getId();
     $vals['blockedby'] = $block->getByName();
     $vals['blockedbyid'] = $block->getBy();
     $vals['blockreason'] = $block->mReason;
     $vals['blockedtimestamp'] = wfTimestamp(TS_ISO_8601, $block->mTimestamp);
     $vals['blockexpiry'] = $wgContLang->formatExpiry($block->getExpiry(), TS_ISO_8601, 'infinite');
     return $vals;
 }
コード例 #3
0
ファイル: Exception.php プロジェクト: yusufchang/app
 public function __construct(Block $block)
 {
     global $wgLang, $wgRequest;
     $blocker = $block->getBlocker();
     if ($blocker instanceof User) {
         // local user
         $blockerUserpage = $block->getBlocker()->getUserPage();
         $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]";
     } else {
         // foreign user
         $link = $blocker;
     }
     $reason = $block->mReason;
     if ($reason == '') {
         $reason = wfMsg('blockednoreason');
     }
     /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
      * This could be a username, an IP range, or a single IP. */
     $intended = $block->getTarget();
     parent::__construct('blockedtitle', $block->mAuto ? 'autoblockedtext' : 'blockedtext', array($link, $reason, $wgRequest->getIP(), $block->getByName(), $block->getId(), $wgLang->formatExpiry($block->mExpiry), $intended, $wgLang->timeanddate(wfTimestamp(TS_MW, $block->mTimestamp), true)));
 }
コード例 #4
0
ファイル: User.php プロジェクト: slackfaith/deadbrain_site
 /**
  * If user is blocked, return the ID for the block
  * @return Int Block ID
  */
 public function getBlockId()
 {
     $this->getBlockedStatus();
     return $this->mBlock ? $this->mBlock->getId() : false;
 }
コード例 #5
0
 public function getAllAsObject($restriction = '')
 {
     $sql = "SELECT *\n\t\t\t\tFROM block\n\t\t\t\tWHERE 1=1";
     $sql .= $restriction . ";";
     try {
         $result = mysql_query($sql);
         if (!$result) {
             throw new MysqlException();
         }
         $blocks = array();
         while ($row = mysql_fetch_assoc($result)) {
             $b = new Block();
             $b->setId($row['block_id']);
             $b->setVon($row['von']);
             $b->setBis($row['bis']);
             $blocks[$b->getId()] = $b;
         }
     } catch (MysqlException $e) {
         Html::showAll($e);
     }
     return $blocks;
 }