27 # Some places check createpage, while others check create.
28 # As it stands, upload does createpage, but normalize both
29 # to the same action, to stop future similar bugs.
30 if ( $action ===
'createpage' || $action ===
'createtalk' ) {
33 if ( $action ==
'create' || $action ==
'edit' || $action ==
'upload' ) {
36 $errmsg = $blacklisted->getErrorMessage(
'edit' );
38 $blacklisted->getRaw(),
41 ApiResult::setIndexedTagName( $params,
'param' );
45 htmlspecialchars( $blacklisted->getRaw() ),
48 'titleblacklist-forbidden',
54 'line' => $blacklisted->getRaw(),
59 'info' =>
'TitleBlacklist prevents this title from being created',
77 if ( !RequestContext::getMain()->
getUser()->isAllowed(
'tboverride' ) ) {
83 $title->exists() ?
'edit' :
'create'
85 if ( !$blacklisted ) {
89 $params = $blacklisted->getParams();
90 if ( isset( $params[
'autoconfirmed'] ) ) {
94 $msg =
wfMessage(
'titleblacklist-warning' );
95 $notices[
'titleblacklist'] = $msg->plaintextParams( $blacklisted->getRaw() )
114 $blacklisted = $titleBlacklist->userCannot( $newTitle, $user,
'move' );
115 if ( !$blacklisted ) {
116 $blacklisted = $titleBlacklist->userCannot( $oldTitle, $user,
'edit' );
120 $blacklisted->getErrorMessage(
'move' ),
121 $blacklisted->getRaw(),
143 $userName,
User $creatingUser, $override =
true, $log =
false
147 'new-account', $override );
152 $message = $blacklisted->getErrorMessage(
'new-account' );
154 $blacklisted->getRaw(),
157 ApiResult::setIndexedTagName( $params,
'param' );
159 [ $message, $blacklisted->getRaw(), $userName ],
160 'titleblacklist-forbidden',
166 'line' => $blacklisted->getRaw(),
168 'info' =>
'TitleBlacklist prevents this username from being created',
172 return StatusValue::newGood();
184 $title = $editor->getTitle();
189 $ok = $blackList->validate( $bl );
194 $errmsg =
wfMessage(
'titleblacklist-invalid' )->numParams( count( $ok ) )->text();
195 $errlines =
'* <code>' .
196 implode(
"</code>\n* <code>", array_map(
'wfEscapeWikiText', $ok ) ) .
198 $error = Html::openElement(
'div', [
'class' =>
'errorbox' ] ) .
202 Html::closeElement(
'div' ) .
"\n" .
203 Html::element(
'br', [
'clear' =>
'all' ] ) .
"\n";
221 WikiPage $wikiPage, &$user,
$content, $summary, $isminor, $iswatch, $section
238 global $wgTitleBlacklistLogHits;
239 if ( $wgTitleBlacklistLogHits ) {
240 $logEntry =
new ManualLogEntry(
'titleblacklist',
'hit-username' );
241 $logEntry->setPerformer( $user );
242 $logEntry->setTarget(
$title );
243 $logEntry->setParameters( [
244 '4::entry' => $entry,
246 $logid = $logEntry->insert();
247 $logEntry->publish( $logid );
258 if ( $engine ==
'lua' ) {
259 $extraLibraries[
'mw.ext.TitleBlacklist'] =
'Scribunto_LuaTitleBlacklistLibrary';
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Class for creating new log entries and inserting them into the database.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Represents a title blacklist entry.
Hooks for Title Blacklist.
static onClearBlacklist(WikiPage $wikiPage, &$user, $content, $summary, $isminor, $iswatch, $section)
PageContentSaveComplete hook.
static onDisplayBlacklistOverrideNotice(Title $title, $oldid, array &$notices)
Display a notice if a user is only able to create or edit a page because they have tboverride.
static onScribuntoExternalLibraries( $engine, array &$extraLibraries)
External Lua library for Scribunto.
static testUserName( $userName, User $creatingUser, $override=true, $log=false)
Check whether a user name is acceptable for account creation or autocreation, and explain why not if ...
static logFilterHitUsername( $user, $title, $entry)
Logs the filter username hit to Special:Log if $wgTitleBlacklistLogHits is enabled.
static onMovePageCheckPermissions(Title $oldTitle, Title $newTitle, User $user, $reason, Status $status)
MovePageCheckPermissions hook (1.25+)
static onUserCan( $title, $user, $action, &$result)
getUserPermissionsErrorsExpensive hook
static onValidateBlacklist( $editor, $text, $section, &$error)
EditFilter hook.
static singleton()
Get an instance of this class.
static parseBlacklist( $list, $sourceName)
Parse blacklist from a string.
Represents a title within MediaWiki.
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with '#')
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Class representing a MediaWiki article and history.
getTitle()
Get the title object of the article.