本文整理汇总了PHP中Block::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::delete方法的具体用法?PHP Block::delete怎么用?PHP Block::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block::delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAdminInterface
/**
* Build and return admin interface
*
* Any module providing an admin interface is required to have this function, which
* returns a string containing the (x)html of it's admin interface.
* @return string
*/
function getAdminInterface()
{
switch (@$_REQUEST['section']) {
case 'toggle':
$block = new Block($_REQUEST['id']);
if ($block->getStatus() == 'active') {
$block->setStatus('inactive');
$block->save();
} else {
$block->setStatus('active');
$block->save();
}
return $this->topLevelAdmin();
break;
case 'addedit':
$block = new Block(@$_REQUEST['blocks_id']);
$form = $block->getAddEditForm();
if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['blocks_submit'])) {
return $this->topLevelAdmin();
} else {
return $block->getAddEditForm()->display();
}
break;
case 'delete':
$block = new Block(@$_REQUEST['blocks_id']);
$block->delete();
return $this->topLevelAdmin();
break;
default:
return $this->topLevelAdmin();
}
}
示例2: test_delete_block
public function test_delete_block()
{
$params = array('title' => $this->title, 'type' => $this->type);
$block = new Block($params);
$block->insert();
$count = DB::get_value('SELECT count(*) FROM {blocks}');
$block->delete();
$this->assert_equal($count - 1, DB::get_value('SELECT count(*) FROM {blocks}'), 'Count of blocks should decrease by one');
}
示例3: doSubmit
function doSubmit()
{
global $wgOut;
$block = new Block();
$this->ip = trim($this->ip);
if ($this->ip[0] == "#") {
$block->mId = substr($this->ip, 1);
} else {
$block->mAddress = $this->ip;
}
# Delete block (if it exists)
# We should probably check for errors rather than just declaring success
$block->delete();
# Make log entry
$log = new LogPage('block');
$log->addEntry('unblock', Title::makeTitle(NS_USER, $this->ip), $this->reason);
# Report to the user
$titleObj = Title::makeTitle(NS_SPECIAL, "Ipblocklist");
$success = $titleObj->getFullURL("action=success&ip=" . urlencode($this->ip));
$wgOut->redirect($success);
}
示例4: deleteBlock
private function deleteBlock($id_block = null)
{
if (is_null($id_block)) {
return false;
}
$items = $this->getItemByBlock($id_block);
$del = true;
if ($items && count($items) > 0) {
foreach ($items as $it) {
$item = new Item($it['id_item']);
$del &= $item->delete();
}
}
if ($del) {
$block = new Block($id_block);
return $block->delete();
}
return false;
}
示例5: enumBlocks
function enumBlocks($callback, $tag, $flags = 0)
{
global $wgAntiLockFlags;
$block = new Block();
if ($flags & Block::EB_FOR_UPDATE) {
$db = wfGetDB(DB_MASTER);
if ($wgAntiLockFlags & ALF_NO_BLOCK_LOCK) {
$options = '';
} else {
$options = 'FOR UPDATE';
}
$block->forUpdate(true);
} else {
$db = wfGetDB(DB_SLAVE);
$options = '';
}
if ($flags & Block::EB_RANGE_ONLY) {
$cond = " AND ipb_range_start <> ''";
} else {
$cond = '';
}
$now = wfTimestampNow();
list($ipblocks, $user) = $db->tableNamesN('ipblocks', 'user');
$sql = "SELECT {$ipblocks}.*,user_name FROM {$ipblocks},{$user} " . "WHERE user_id=ipb_by {$cond} ORDER BY ipb_timestamp DESC {$options}";
$res = $db->query($sql, 'Block::enumBlocks');
$num_rows = $db->numRows($res);
while ($row = $db->fetchObject($res)) {
$block->initFromRow($row);
if ($flags & Block::EB_RANGE_ONLY && $block->mRangeStart == '') {
continue;
}
if (!($flags & Block::EB_KEEP_EXPIRED)) {
if ($block->mExpiry && $now > $block->mExpiry) {
$block->delete();
} else {
call_user_func($callback, $block, $tag);
}
} else {
call_user_func($callback, $block, $tag);
}
}
$db->freeResult($res);
return $num_rows;
}
示例6: testIsMarkingBlockForDeletion
public function testIsMarkingBlockForDeletion()
{
$memory = new Block(897);
$memory->delete();
$data = $memory->read();
$this->assertEquals('Sample 2', $data);
}