本文整理汇总了PHP中Block::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::getId方法的具体用法?PHP Block::getId怎么用?PHP Block::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block::getId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addDBData
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: getBlockInfo
/**
* 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: __construct
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: getBlockId
/**
* 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: getAllAsObject
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;
}