/** * Output a message that informs the user that they cannot create an account because * there is a block on them or their IP which prevents account creation. Note that * User::isBlockedFromCreateAccount(), which gets this block, ignores the 'hardblock' * setting on blocks (bug 13611). * @param Block $block The block causing this error * @throws ErrorPageError */ function userBlockedMessage(Block $block) { # Let's be nice about this, it's likely that this feature will be used # for blocking large numbers of innocent people, e.g. range blocks on # schools. Don't blame it on the user. There's a small chance that it # really is the user's fault, i.e. the username is blocked and they # haven't bothered to log out before trying to create an account to # evade it, but we'll leave that to their guilty conscience to figure # out. $errorParams = array($block->getTarget(), $block->mReason ? $block->mReason : $this->msg('blockednoreason')->text(), $block->getByName()); if ($block->getType() === Block::TYPE_RANGE) { $errorMessage = 'cantcreateaccount-range-text'; $errorParams[] = $this->getRequest()->getIP(); } else { $errorMessage = 'cantcreateaccount-text'; } throw new ErrorPageError('cantcreateaccounttitle', $errorMessage, $errorParams); }
/** * Throw a UsageException, which will (if uncaught) call the main module's * error handler and die with an error message including block info. * * @since 1.27 * @param Block $block The block used to generate the UsageException * @throws UsageException always */ public function dieBlocked(Block $block) { // Die using the appropriate message depending on block type if ($block->getType() == Block::TYPE_AUTO) { $this->dieUsage('Your IP address has been blocked automatically, because it was used by a blocked user', 'autoblocked', 0, array('blockinfo' => ApiQueryUserInfo::getBlockInfo($block))); } else { $this->dieUsage('You have been blocked from editing', 'blocked', 0, array('blockinfo' => ApiQueryUserInfo::getBlockInfo($block))); } }
function test_simple_components() { $comp = new Blank(3); $this->assertIdentical($comp->getType(), BLANK); $comp = new Block("hoho", 3); $this->assertIdentical($comp->getType(), BLOCK); $comp = new Heading("hoho", 3); $this->assertIdentical($comp->getType(), HEADING); $comp = new Footer("hoho", 3); $this->assertIdentical($comp->getType(), FOOTER); }