コード例 #1
0
ファイル: Blocks.php プロジェクト: swat30/safeballot
 /**
  * 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
0
ファイル: test_block.php プロジェクト: habari/tests
 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
0
 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
0
ファイル: advancetopmenu.php プロジェクト: abdoumej/libsamy
 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
0
 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
0
ファイル: Block.php プロジェクト: swordkee/phalcon-demo
 public function testIsMarkingBlockForDeletion()
 {
     $memory = new Block(897);
     $memory->delete();
     $data = $memory->read();
     $this->assertEquals('Sample 2', $data);
 }