summaryrefslogtreecommitdiff
path: root/extensions/TitleBlacklist/TitleBlacklist.hooks.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /extensions/TitleBlacklist/TitleBlacklist.hooks.php
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
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