2007-12-08 21:06:21 +00:00
|
|
|
<?php
|
2008-08-05 15:57:10 +00:00
|
|
|
/**
|
2008-08-08 23:26:44 +00:00
|
|
|
* Title Blacklist class
|
2010-11-08 21:55:05 +00:00
|
|
|
* @author Victor Vasiliev
|
|
|
|
* @copyright © 2007-2010 Victor Vasiliev et al
|
2018-04-07 01:23:42 +00:00
|
|
|
* @license GPL-2.0-or-later
|
2008-08-09 01:54:39 +00:00
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
2019-07-03 12:58:55 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
2010-06-06 15:12:22 +00:00
|
|
|
* @ingroup Extensions
|
2008-08-09 01:54:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a title blacklist for MediaWiki
|
2007-12-08 21:06:21 +00:00
|
|
|
*/
|
|
|
|
class TitleBlacklist {
|
2019-06-05 16:27:36 +00:00
|
|
|
/** @var TitleBlacklistEntry[] */
|
2017-06-29 17:40:05 +00:00
|
|
|
private $mBlacklist = null;
|
|
|
|
|
2019-06-05 16:27:36 +00:00
|
|
|
/** @var TitleBlacklistEntry[] */
|
2017-06-29 17:40:05 +00:00
|
|
|
private $mWhitelist = null;
|
2017-01-23 10:58:52 +00:00
|
|
|
|
|
|
|
/** @var TitleBlacklist */
|
|
|
|
protected static $instance = null;
|
|
|
|
|
2012-05-24 23:55:22 +00:00
|
|
|
const VERSION = 3; // Blacklist format
|
2007-12-08 21:06:21 +00:00
|
|
|
|
2011-07-30 15:13:28 +00:00
|
|
|
/**
|
|
|
|
* Get an instance of this class
|
|
|
|
*
|
|
|
|
* @return TitleBlacklist
|
|
|
|
*/
|
|
|
|
public static function singleton() {
|
2017-01-23 10:58:52 +00:00
|
|
|
if ( self::$instance === null ) {
|
|
|
|
self::$instance = new self;
|
|
|
|
}
|
|
|
|
return self::$instance;
|
|
|
|
}
|
2011-07-30 15:13:28 +00:00
|
|
|
|
2017-01-23 10:58:52 +00:00
|
|
|
/**
|
|
|
|
* Destroy/reset the current singleton instance.
|
|
|
|
*
|
|
|
|
* This is solely for testing and will fail unless MW_PHPUNIT_TEST is
|
|
|
|
* defined.
|
|
|
|
*/
|
|
|
|
public static function destroySingleton() {
|
|
|
|
if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
|
|
|
|
throw new MWException(
|
|
|
|
'Can not invoke ' . __METHOD__ . '() ' .
|
|
|
|
'out of tests (MW_PHPUNIT_TEST not set).'
|
|
|
|
);
|
2011-07-30 15:13:28 +00:00
|
|
|
}
|
2017-01-23 10:58:52 +00:00
|
|
|
|
|
|
|
self::$instance = null;
|
2011-07-30 15:13:28 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Load all configured blacklist sources
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2007-12-08 21:06:21 +00:00
|
|
|
public function load() {
|
2015-04-29 21:25:24 +00:00
|
|
|
global $wgTitleBlacklistSources, $wgTitleBlacklistCaching;
|
|
|
|
|
2019-07-03 12:58:55 +00:00
|
|
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
2012-08-29 13:53:38 +00:00
|
|
|
// Try to find something in the cache
|
2018-06-28 13:46:07 +00:00
|
|
|
$cachedBlacklist = $cache->get( $cache->makeKey( 'title_blacklist_entries' ) );
|
2017-06-02 15:43:58 +00:00
|
|
|
if ( is_array( $cachedBlacklist ) && count( $cachedBlacklist ) > 0
|
|
|
|
&& ( $cachedBlacklist[0]->getFormatVersion() == self::VERSION )
|
|
|
|
) {
|
2007-12-19 18:35:44 +00:00
|
|
|
$this->mBlacklist = $cachedBlacklist;
|
|
|
|
return;
|
|
|
|
}
|
2007-12-23 09:47:36 +00:00
|
|
|
|
2007-12-09 12:15:13 +00:00
|
|
|
$sources = $wgTitleBlacklistSources;
|
2017-06-06 16:18:36 +00:00
|
|
|
$sources['local'] = [ 'type' => 'message' ];
|
|
|
|
$this->mBlacklist = [];
|
|
|
|
foreach ( $sources as $sourceName => $source ) {
|
2017-06-02 15:43:58 +00:00
|
|
|
$this->mBlacklist = array_merge(
|
|
|
|
$this->mBlacklist,
|
2019-04-27 04:30:31 +00:00
|
|
|
self::parseBlacklist( self::getBlacklistText( $source ), $sourceName )
|
2017-06-02 15:43:58 +00:00
|
|
|
);
|
2007-12-09 12:15:13 +00:00
|
|
|
}
|
2018-06-28 13:46:07 +00:00
|
|
|
$cache->set( $cache->makeKey( 'title_blacklist_entries' ),
|
2017-06-02 15:43:58 +00:00
|
|
|
$this->mBlacklist, $wgTitleBlacklistCaching['expiry'] );
|
2018-06-28 13:46:07 +00:00
|
|
|
wfDebugLog( 'TitleBlacklist-cache', 'Updated ' . $cache->makeKey( 'title_blacklist_entries' )
|
2015-01-06 00:38:46 +00:00
|
|
|
. ' with ' . count( $this->mBlacklist ) . ' entries.' );
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
2008-01-08 18:00:59 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
2012-05-24 23:55:22 +00:00
|
|
|
* Load local whitelist
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2008-01-08 18:00:59 +00:00
|
|
|
public function loadWhitelist() {
|
2015-04-29 21:25:24 +00:00
|
|
|
global $wgTitleBlacklistCaching;
|
|
|
|
|
2019-07-03 12:58:55 +00:00
|
|
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
2018-06-28 13:46:07 +00:00
|
|
|
$cachedWhitelist = $cache->get( $cache->makeKey( 'title_whitelist_entries' ) );
|
2017-06-02 15:43:58 +00:00
|
|
|
if ( is_array( $cachedWhitelist ) && count( $cachedWhitelist ) > 0
|
|
|
|
&& ( $cachedWhitelist[0]->getFormatVersion() != self::VERSION )
|
|
|
|
) {
|
2008-01-08 18:00:59 +00:00
|
|
|
$this->mWhitelist = $cachedWhitelist;
|
|
|
|
return;
|
|
|
|
}
|
2019-04-27 04:30:31 +00:00
|
|
|
$this->mWhitelist = self::parseBlacklist( wfMessage( 'titlewhitelist' )
|
2012-05-24 23:55:22 +00:00
|
|
|
->inContentLanguage()->text(), 'whitelist' );
|
2018-06-28 13:46:07 +00:00
|
|
|
$cache->set( $cache->makeKey( 'title_whitelist_entries' ),
|
2017-06-02 15:43:58 +00:00
|
|
|
$this->mWhitelist, $wgTitleBlacklistCaching['expiry'] );
|
2008-01-08 18:00:59 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Get the text of a blacklist from a specified source
|
|
|
|
*
|
2017-12-24 03:17:33 +00:00
|
|
|
* @param array $source A blacklist source from $wgTitleBlacklistSources
|
2016-10-08 12:04:58 +00:00
|
|
|
* @return string The content of the blacklist source as a string
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2008-08-09 01:54:39 +00:00
|
|
|
private static function getBlacklistText( $source ) {
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( !is_array( $source ) || count( $source ) <= 0 ) {
|
|
|
|
return ''; // Return empty string in error case
|
2007-12-09 12:15:13 +00:00
|
|
|
}
|
|
|
|
|
2015-05-19 16:05:32 +00:00
|
|
|
if ( $source['type'] == 'message' ) {
|
2012-08-29 13:53:38 +00:00
|
|
|
return wfMessage( 'titleblacklist' )->inContentLanguage()->text();
|
2015-05-19 16:05:32 +00:00
|
|
|
} elseif ( $source['type'] == 'localpage' && count( $source ) >= 2 ) {
|
2007-12-10 19:02:38 +00:00
|
|
|
$title = Title::newFromText( $source['src'] );
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( is_null( $title ) ) {
|
2007-12-09 12:15:13 +00:00
|
|
|
return '';
|
|
|
|
}
|
2012-09-24 09:24:32 +00:00
|
|
|
if ( $title->getNamespace() == NS_MEDIAWIKI ) {
|
2016-02-27 18:21:20 +00:00
|
|
|
$msg = wfMessage( $title->getText() )->inContentLanguage();
|
|
|
|
if ( !$msg->isDisabled() ) {
|
|
|
|
return $msg->text();
|
2007-12-09 12:15:13 +00:00
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
2016-10-08 12:04:58 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
|
|
|
if ( $page->exists() ) {
|
|
|
|
return ContentHandler::getContentText( $page->getContent() );
|
2007-12-09 12:15:13 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-19 16:05:32 +00:00
|
|
|
} elseif ( $source['type'] == 'url' && count( $source ) >= 2 ) {
|
2008-08-09 01:54:39 +00:00
|
|
|
return self::getHttp( $source['src'] );
|
2015-05-19 16:05:32 +00:00
|
|
|
} elseif ( $source['type'] == 'file' && count( $source ) >= 2 ) {
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( file_exists( $source['src'] ) ) {
|
2007-12-10 19:02:38 +00:00
|
|
|
return file_get_contents( $source['src'] );
|
2007-12-09 12:15:13 +00:00
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
2011-03-22 23:07:21 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Parse blacklist from a string
|
|
|
|
*
|
2017-08-10 11:26:29 +00:00
|
|
|
* @param string $list Text of a blacklist source
|
|
|
|
* @param string $sourceName
|
2019-04-27 04:30:31 +00:00
|
|
|
* @return TitleBlacklistEntry[]
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2012-05-24 23:55:22 +00:00
|
|
|
public static function parseBlacklist( $list, $sourceName ) {
|
2007-12-08 21:06:21 +00:00
|
|
|
$lines = preg_split( "/\r?\n/", $list );
|
2017-06-06 16:18:36 +00:00
|
|
|
$result = [];
|
2011-03-22 23:07:21 +00:00
|
|
|
foreach ( $lines as $line ) {
|
2019-04-27 04:30:31 +00:00
|
|
|
$entry = TitleBlacklistEntry::newFromString( $line, $sourceName );
|
|
|
|
if ( $entry ) {
|
|
|
|
$result[] = $entry;
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
|
2008-01-14 13:52:05 +00:00
|
|
|
return $result;
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
2015-09-10 23:48:04 +00:00
|
|
|
* Check whether the blacklist restricts given user
|
2010-11-08 21:55:05 +00:00
|
|
|
* performing a specific action on the given Title
|
|
|
|
*
|
2017-08-10 11:26:29 +00:00
|
|
|
* @param Title $title Title to check
|
|
|
|
* @param User $user User to check
|
|
|
|
* @param string $action Action to check; 'edit' if unspecified
|
|
|
|
* @param bool $override If set to true, overrides work
|
2012-09-24 09:24:32 +00:00
|
|
|
* @return TitleBlacklistEntry|bool The corresponding TitleBlacklistEntry if
|
|
|
|
* blacklisted; otherwise false
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2010-11-08 21:55:05 +00:00
|
|
|
public function userCannot( $title, $user, $action = 'edit', $override = true ) {
|
2015-09-10 23:48:04 +00:00
|
|
|
$entry = $this->isBlacklisted( $title, $action );
|
|
|
|
if ( !$entry ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$params = $entry->getParams();
|
|
|
|
if ( isset( $params['autoconfirmed'] ) && $user->isAllowed( 'autoconfirmed' ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( $override && self::userCanOverride( $user, $action ) ) {
|
2010-11-08 21:55:05 +00:00
|
|
|
return false;
|
2011-08-22 20:37:26 +00:00
|
|
|
}
|
2015-09-10 23:48:04 +00:00
|
|
|
return $entry;
|
2010-11-08 21:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-03-22 22:30:23 +00:00
|
|
|
* Check whether the blacklist restricts
|
2008-08-09 01:54:39 +00:00
|
|
|
* performing a specific action on the given Title
|
|
|
|
*
|
2017-08-10 11:26:29 +00:00
|
|
|
* @param Title $title Title to check
|
|
|
|
* @param string $action Action to check; 'edit' if unspecified
|
2012-09-24 09:24:32 +00:00
|
|
|
* @return TitleBlacklistEntry|bool The corresponding TitleBlacklistEntry if blacklisted;
|
2008-08-09 01:54:39 +00:00
|
|
|
* otherwise FALSE
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
public function isBlacklisted( $title, $action = 'edit' ) {
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( !( $title instanceof Title ) ) {
|
2009-05-17 14:12:38 +00:00
|
|
|
$title = Title::newFromText( $title );
|
2014-01-07 18:08:24 +00:00
|
|
|
if ( !( $title instanceof Title ) ) {
|
|
|
|
// The fact that the page name is invalid will stop whatever
|
|
|
|
// action is going through. No sense in doing more work here.
|
|
|
|
return false;
|
|
|
|
}
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
$blacklist = $this->getBlacklist();
|
2014-01-07 18:08:24 +00:00
|
|
|
$autoconfirmedItem = false;
|
2007-12-08 21:06:21 +00:00
|
|
|
foreach ( $blacklist as $item ) {
|
2013-09-08 04:24:56 +00:00
|
|
|
if ( $item->matches( $title->getFullText(), $action ) ) {
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( $this->isWhitelisted( $title, $action ) ) {
|
2008-01-08 18:00:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-01-07 18:08:24 +00:00
|
|
|
$params = $item->getParams();
|
|
|
|
if ( !isset( $params['autoconfirmed'] ) ) {
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
if ( !$autoconfirmedItem ) {
|
|
|
|
$autoconfirmedItem = $item;
|
|
|
|
}
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-07 18:08:24 +00:00
|
|
|
return $autoconfirmedItem;
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
2011-03-22 22:30:23 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
2011-03-22 22:30:23 +00:00
|
|
|
* Check whether it has been explicitly whitelisted that the
|
2008-08-09 01:54:39 +00:00
|
|
|
* current User may perform a specific action on the given Title
|
|
|
|
*
|
2017-08-10 11:26:29 +00:00
|
|
|
* @param Title $title Title to check
|
|
|
|
* @param string $action Action to check; 'edit' if unspecified
|
2012-09-24 09:24:32 +00:00
|
|
|
* @return bool True if whitelisted; otherwise false
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2008-01-08 18:00:59 +00:00
|
|
|
public function isWhitelisted( $title, $action = 'edit' ) {
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( !( $title instanceof Title ) ) {
|
2009-05-17 14:12:38 +00:00
|
|
|
$title = Title::newFromText( $title );
|
2008-01-08 18:00:59 +00:00
|
|
|
}
|
|
|
|
$whitelist = $this->getWhitelist();
|
2012-08-29 13:53:38 +00:00
|
|
|
foreach ( $whitelist as $item ) {
|
2013-09-08 04:24:56 +00:00
|
|
|
if ( $item->matches( $title->getFullText(), $action ) ) {
|
2008-01-08 18:00:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-03-22 22:30:23 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Get the current blacklist
|
|
|
|
*
|
2015-09-11 00:08:09 +00:00
|
|
|
* @return TitleBlacklistEntry[]
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2007-12-08 21:06:21 +00:00
|
|
|
public function getBlacklist() {
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( is_null( $this->mBlacklist ) ) {
|
2007-12-08 21:06:21 +00:00
|
|
|
$this->load();
|
|
|
|
}
|
|
|
|
return $this->mBlacklist;
|
|
|
|
}
|
2011-03-22 22:30:23 +00:00
|
|
|
|
2011-08-22 20:37:26 +00:00
|
|
|
/**
|
2008-08-09 01:54:39 +00:00
|
|
|
* Get the current whitelist
|
|
|
|
*
|
2019-04-27 04:30:31 +00:00
|
|
|
* @return TitleBlacklistEntry[]
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2008-01-08 18:00:59 +00:00
|
|
|
public function getWhitelist() {
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( is_null( $this->mWhitelist ) ) {
|
2008-01-08 18:00:59 +00:00
|
|
|
$this->loadWhitelist();
|
|
|
|
}
|
|
|
|
return $this->mWhitelist;
|
|
|
|
}
|
2011-03-22 22:30:23 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Get the text of a blacklist source via HTTP
|
|
|
|
*
|
2017-08-10 11:26:29 +00:00
|
|
|
* @param string $url URL of the blacklist source
|
2011-08-22 20:37:26 +00:00
|
|
|
* @return string The content of the blacklist source as a string
|
2011-03-14 23:44:41 +00:00
|
|
|
*/
|
2008-08-09 01:54:39 +00:00
|
|
|
private static function getHttp( $url ) {
|
2007-12-31 23:02:22 +00:00
|
|
|
global $messageMemc, $wgTitleBlacklistCaching;
|
2018-06-28 13:46:07 +00:00
|
|
|
|
|
|
|
$key = 'title_blacklist_source:' . md5( $url ); // Global shared
|
|
|
|
$warnkey = $messageMemc->makeKey( 'titleblacklistwarning', md5( $url ) );
|
2007-12-19 18:35:44 +00:00
|
|
|
$result = $messageMemc->get( $key );
|
|
|
|
$warn = $messageMemc->get( $warnkey );
|
2018-06-28 13:46:07 +00:00
|
|
|
|
2017-06-02 15:43:58 +00:00
|
|
|
if ( !is_string( $result )
|
|
|
|
|| ( !$warn && !mt_rand( 0, $wgTitleBlacklistCaching['warningchance'] ) )
|
|
|
|
) {
|
2007-12-19 18:35:44 +00:00
|
|
|
$result = Http::get( $url );
|
|
|
|
$messageMemc->set( $warnkey, 1, $wgTitleBlacklistCaching['warningexpiry'] );
|
|
|
|
$messageMemc->set( $key, $result, $wgTitleBlacklistCaching['expiry'] );
|
|
|
|
}
|
2018-06-28 13:46:07 +00:00
|
|
|
|
2007-12-19 18:35:44 +00:00
|
|
|
return $result;
|
|
|
|
}
|
2011-03-22 22:30:23 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Invalidate the blacklist cache
|
|
|
|
*/
|
2007-12-23 09:47:36 +00:00
|
|
|
public function invalidate() {
|
2019-07-03 12:58:55 +00:00
|
|
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
2018-06-28 13:46:07 +00:00
|
|
|
$cache->delete( $cache->makeKey( 'title_blacklist_entries' ) );
|
2007-12-23 09:47:36 +00:00
|
|
|
}
|
2011-08-22 20:37:26 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Validate a new blacklist
|
|
|
|
*
|
2017-12-24 03:17:33 +00:00
|
|
|
* @suppress PhanParamSuspiciousOrder The preg_match() params are in the correct order
|
2019-04-27 04:30:31 +00:00
|
|
|
* @param TitleBlacklistEntry[] $blacklist
|
|
|
|
* @return string[] List of invalid entries; empty array means blacklist is valid
|
2008-08-09 01:54:39 +00:00
|
|
|
*/
|
2019-06-05 16:27:36 +00:00
|
|
|
public function validate( array $blacklist ) {
|
2017-06-06 16:18:36 +00:00
|
|
|
$badEntries = [];
|
2012-08-29 13:53:38 +00:00
|
|
|
foreach ( $blacklist as $e ) {
|
2019-02-13 00:27:11 +00:00
|
|
|
Wikimedia\suppressWarnings();
|
2007-12-23 09:47:36 +00:00
|
|
|
$regex = $e->getRegex();
|
2012-08-29 13:53:38 +00:00
|
|
|
if ( preg_match( "/{$regex}/u", '' ) === false ) {
|
2007-12-23 09:47:36 +00:00
|
|
|
$badEntries[] = $e->getRaw();
|
2011-03-22 23:07:21 +00:00
|
|
|
}
|
2019-02-13 00:27:11 +00:00
|
|
|
Wikimedia\restoreWarnings();
|
2007-12-23 09:47:36 +00:00
|
|
|
}
|
|
|
|
return $badEntries;
|
|
|
|
}
|
2011-03-22 22:30:23 +00:00
|
|
|
|
2010-11-08 21:55:05 +00:00
|
|
|
/**
|
|
|
|
* Inidcates whether user can override blacklist on certain action.
|
2011-08-22 20:37:26 +00:00
|
|
|
*
|
2017-08-10 11:26:29 +00:00
|
|
|
* @param User $user
|
|
|
|
* @param string $action Action
|
2011-08-22 20:37:26 +00:00
|
|
|
*
|
|
|
|
* @return bool
|
2010-11-08 21:55:05 +00:00
|
|
|
*/
|
2011-09-22 06:10:45 +00:00
|
|
|
public static function userCanOverride( $user, $action ) {
|
|
|
|
return $user->isAllowed( 'tboverride' ) ||
|
|
|
|
( $action == 'new-account' && $user->isAllowed( 'tboverride-account' ) );
|
2010-11-08 21:55:05 +00:00
|
|
|
}
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|