Index: trunk/extensions/TitleBlacklist/TitleBlacklist.php |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | $wgHooks['getUserPermissionsErrorsExpensive'][] = 'TitleBlacklistHooks::userCan'; |
48 | 48 | $wgHooks['AbortMove'][] = 'TitleBlacklistHooks::abortMove'; |
49 | 49 | $wgHooks['AbortNewAccount'][] = 'TitleBlacklistHooks::abortNewAccount'; |
| 50 | +$wgHooks['AuthPluginAutoCreate'][] = 'TitleBlacklistHooks::abortNewAccountAuto'; |
50 | 51 | $wgHooks['EditFilter'][] = 'TitleBlacklistHooks::validateBlacklist'; |
51 | 52 | $wgHooks['ArticleSaveComplete'][] = 'TitleBlacklistHooks::clearBlacklist'; |
52 | 53 | |
Index: trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php |
— | — | @@ -84,27 +84,44 @@ |
85 | 85 | global $wgTitleBlacklist; |
86 | 86 | efInitTitleBlacklist(); |
87 | 87 | $title = $editor->mTitle; |
88 | | - if( $title->getNamespace() != NS_MEDIAWIKI || $title->getDBkey() != 'Titleblacklist' ) |
| 88 | + if( $title->getNamespace() == NS_MEDIAWIKI && $title->getDBkey() == 'Titleblacklist' ) { |
| 89 | + |
| 90 | + $bl = $wgTitleBlacklist->parseBlacklist( $text ); |
| 91 | + $ok = $wgTitleBlacklist->validate( $bl ); |
| 92 | + if( count( $ok ) == 0 ) { |
| 93 | + return true; |
| 94 | + } |
| 95 | + |
| 96 | + wfLoadExtensionMessages( 'TitleBlacklist' ); |
| 97 | + $errmsg = wfMsgExt( 'titleblacklist-invalid', array( 'parsemag' ), count( $ok ) ); |
| 98 | + $errlines = '* <tt>' . implode( "</tt>\n* <tt>", array_map( 'wfEscapeWikiText', $ok ) ) . '</tt>'; |
| 99 | + $error = '<div class="errorbox">' . |
| 100 | + $errmsg . |
| 101 | + "\n" . |
| 102 | + $errlines . |
| 103 | + "</div>\n" . |
| 104 | + "<br clear='all' />\n"; |
| 105 | + |
| 106 | + // $error will be displayed by the edit class |
89 | 107 | return true; |
| 108 | + } else if (!$section) { |
| 109 | + # Block redirects to nonexistent blacklisted titles |
| 110 | + $retitle = Title::newFromRedirect( $text ); |
| 111 | + if ( $retitle !== null && !$retitle->exists() ) { |
| 112 | + $blacklisted = $wgTitleBlacklist->isBlacklisted( $retitle, 'create' ); |
| 113 | + if ( $blacklisted instanceof TitleBlacklistEntry ) { |
| 114 | + wfLoadExtensionMessages( 'TitleBlacklist' ); |
| 115 | + $error = ( '<div class="errorbox">' . |
| 116 | + wfMsg( 'titleblacklist-forbidden-edit', |
| 117 | + htmlspecialchars( $blacklisted->getRaw() ), |
| 118 | + $retitle->getFullText() ) . |
| 119 | + "</div>\n" . |
| 120 | + "<br clear='all' />\n" ); |
| 121 | + } |
| 122 | + } |
90 | 123 | |
91 | | - $bl = $wgTitleBlacklist->parseBlacklist( $text ); |
92 | | - $ok = $wgTitleBlacklist->validate( $bl ); |
93 | | - if( count( $ok ) == 0 ) { |
94 | 124 | return true; |
95 | 125 | } |
96 | | - |
97 | | - wfLoadExtensionMessages( 'TitleBlacklist' ); |
98 | | - $errmsg = wfMsgExt( 'titleblacklist-invalid', array( 'parsemag' ), count( $ok ) ); |
99 | | - $errlines = '* <tt>' . implode( "</tt>\n* <tt>", array_map( 'wfEscapeWikiText', $ok ) ) . '</tt>'; |
100 | | - $error = '<div class="errorbox">' . |
101 | | - $errmsg . |
102 | | - "\n" . |
103 | | - $errlines . |
104 | | - "</div>\n" . |
105 | | - "<br clear='all' />\n"; |
106 | | - |
107 | | - // $error will be displayed by the edit class |
108 | | - return true; |
109 | 126 | } |
110 | 127 | |
111 | 128 | /** ArticleSaveComplete hook */ |