summaryrefslogtreecommitdiff
path: root/extensions/TitleBlacklist/TitleBlacklist.hooks.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
commita2190ac74dd4d7080b12bab90e552d7aa81209ef (patch)
tree8b31f38de9882d18df54cf8d9e0de74167a094eb /extensions/TitleBlacklist/TitleBlacklist.hooks.php
parent15e69f7b20b6596b9148030acce5b59993b95a45 (diff)
parent257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff)
Merge branch 'mw-1.26'
Diffstat (limited to 'extensions/TitleBlacklist/TitleBlacklist.hooks.php')
-rw-r--r--extensions/TitleBlacklist/TitleBlacklist.hooks.php70
1 files changed, 32 insertions, 38 deletions
diff --git a/extensions/TitleBlacklist/TitleBlacklist.hooks.php b/extensions/TitleBlacklist/TitleBlacklist.hooks.php
index 34be8eb7..3b455064 100644
--- a/extensions/TitleBlacklist/TitleBlacklist.hooks.php
+++ b/extensions/TitleBlacklist/TitleBlacklist.hooks.php
@@ -48,27 +48,29 @@ class TitleBlacklistHooks {
/**
* Display a notice if a user is only able to create or edit a page
- * because they have tboverride (or autoconfirmed).
+ * because they have tboverride.
*
* @param Title $title
* @param integer $oldid
* @param array &$notices
*/
public static function displayBlacklistOverrideNotice( Title $title, $oldid, array &$notices ) {
+ if ( !RequestContext::getMain()->getUser()->isAllowed( 'tboverride' ) ) {
+ return true;
+ }
+
$blacklisted = TitleBlacklist::singleton()->isBlacklisted(
$title,
$title->exists() ? 'edit' : 'create'
);
- if ( $blacklisted ) {
- $params = $blacklisted->getParams();
- $msg = wfMessage(
- isset( $params['autoconfirmed'] ) ?
- 'titleblacklist-autoconfirmed-warning' :
- 'titleblacklist-warning'
- );
- $notices['titleblacklist'] = $msg->rawParams(
- htmlspecialchars( $blacklisted->getRaw() ) )->parseAsBlock();
+ if ( !$blacklisted ) {
+ return true;
}
+
+ $params = $blacklisted->getParams();
+ $msg = wfMessage( 'titleblacklist-warning' );
+ $notices['titleblacklist'] = $msg->rawParams(
+ htmlspecialchars( $blacklisted->getRaw() ) )->parseAsBlock();
return true;
}
@@ -105,40 +107,15 @@ class TitleBlacklistHooks {
}
/**
- * AbortMove hook (<1.24)
- *
- * @todo: Remove once 1.24 support is dropped
- *
- * @param $old Title
- * @param $nt Title
- * @param $user User
- * @param $err
- * @return bool
- */
- public static function abortMove( $old, $nt, $user, &$err, $reason ) {
- if ( method_exists( 'MovePage', 'checkPermissions' ) ) {
- // Don't use this hook, use MovePageCheckPermissions instead
- return true;
- }
-
- $status = new Status();
- self::onMovePageCheckPermissions( $old, $nt, $user, $reason, $status );
- if ( !$status->isOK() ) {
- $err = $status->getHTML();
- }
-
- return $status->isOK();
- }
-
- /**
* Check whether a user name is acceptable,
* and set a message if unacceptable.
*
- * Used by abortNewAccount and centralAuthAutoCreate
+ * Used by abortNewAccount and centralAuthAutoCreate.
+ * May also be called externally to vet alternate account names.
*
* @return bool Acceptable
*/
- private static function acceptNewUserName( $userName, $permissionsUser, &$err, $override = true, $log = false ) {
+ public static function acceptNewUserName( $userName, $permissionsUser, &$err, $override = true, $log = false ) {
global $wgUser;
$title = Title::makeTitleSafe( NS_USER, $userName );
$blacklisted = TitleBlacklist::singleton()->userCannot( $title, $permissionsUser,
@@ -162,6 +139,8 @@ class TitleBlacklistHooks {
* AbortNewAccount hook
*
* @param User $user
+ * @param string &$message
+ * @return bool
*/
public static function abortNewAccount( $user, &$message ) {
global $wgUser, $wgRequest;
@@ -170,6 +149,21 @@ class TitleBlacklistHooks {
}
/**
+ * AbortAutoAccount hook
+ *
+ * @param User $user
+ * @param string &$message
+ * @return bool
+ */
+ public static function abortAutoAccount( $user, &$message ) {
+ global $wgTitleBlacklistBlockAutoAccountCreation;
+ if ( $wgTitleBlacklistBlockAutoAccountCreation ) {
+ return self::abortNewAccount( $user, $message );
+ }
+ return true;
+ }
+
+ /**
* EditFilter hook
*
* @param $editor EditPage