/** * Create a new Block object from a database row * @param stdClass $row Row from the ipblocks table * @return Block */ public static function newFromRow($row) { $block = new Block(); $block->initFromRow($row); return $block; }
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; }
function formatRow($row) { $block = new Block(); $block->initFromRow($row); return $this->mForm->formatRow($block); }
function enumBlocks($callback, $tag, $flags = 0) { global $wgAntiLockFlags; $block = new Block(); if ($flags & 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 = ''; } $ipblocks = $db->tableName('ipblocks'); $sql = "SELECT * FROM {$ipblocks} ORDER BY ipb_timestamp DESC {$options}"; $res = $db->query($sql, 'Block::enumBans'); while ($row = $db->fetchObject($res)) { $block->initFromRow($row); if (!($flags & EB_KEEP_EXPIRED)) { if (!$block->deleteIfExpired()) { $callback($block, $tag); } } else { $callback($block, $tag); } } wfFreeResult($res); }