FunPika has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/181947

Change subject: Add ignoretitleblacklist parameter to createaccount API
......................................................................

Add ignoretitleblacklist parameter to createaccount API

This allows the wpIgnoreTitleBlacklist checkbox on the account creation form
to be used in the API.

Change-Id: I5f1d083c8fd6921cbc7e0f843085dc3facc87018
---
M TitleBlacklist.hooks.php
M TitleBlacklist.php
M i18n/en.json
M i18n/qqq.json
4 files changed, 44 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TitleBlacklist 
refs/changes/47/181947/1

diff --git a/TitleBlacklist.hooks.php b/TitleBlacklist.hooks.php
index c82b32d..5c30f08 100644
--- a/TitleBlacklist.hooks.php
+++ b/TitleBlacklist.hooks.php
@@ -235,4 +235,42 @@
                        $logEntry->publish( $logid );
                }
        }
+
+       /**
+        * @param ApiBase $module
+        * @param array $params
+        * @return bool
+        */
+       public static function onAPIGetAllowedParams( &$module, &$params ) {
+               if ( $module instanceof ApiCreateAccount ) {
+                       $params['ignoretitleblacklist'] = array(
+                                       ApiBase::PARAM_TYPE => 'boolean',
+                                       ApiBase::PARAM_DFLT => false
+                       );
+               }
+
+               return true;
+       }
+
+       /**
+        * Pass API parameter on to the login form when using
+        * API account creation.
+        *
+        * @param ApiBase $apiModule
+        * @param LoginForm $loginForm
+        * @return hook return value
+        */
+       public static function addNewAccountApiForm( $apiModule, $loginForm ) {
+               global $wgRequest;
+               $main = $apiModule->getMain();
+
+               if ( $main->getVal( 'ignoretitleblacklist' ) !== null ) {
+                       $wgRequest->setVal( 'wpIgnoreTitleBlacklist', '1' );
+
+                       // Suppress "unrecognized parameter" warning:
+                       $main->getVal( 'wpIgnoreTitleBlacklist' );
+               }
+
+               return true;
+       }
 }
diff --git a/TitleBlacklist.php b/TitleBlacklist.php
index f07bb0b..7b9efae 100644
--- a/TitleBlacklist.php
+++ b/TitleBlacklist.php
@@ -94,6 +94,8 @@
        }
        return true;
 };
+$wgHooks['APIGetAllowedParams'][] = 
'TitleBlacklistHooks::onAPIGetAllowedParams';
+$wgHooks['AddNewAccountApiForm'][] = 
'TitleBlacklistHooks::addNewAccountApiForm';
 
 $wgLogTypes[] = 'titleblacklist';
 $wgLogActionsHandlers['titleblacklist/*'] = 'LogFormatter';
diff --git a/i18n/en.json b/i18n/en.json
index 068ff6e..25d7327 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -25,5 +25,6 @@
        "apihelp-titleblacklist-param-action": "The action to be checked.",
        "apihelp-titleblacklist-param-nooverride": "Don't try to override the 
titleblacklist.",
        "apihelp-titleblacklist-example-1": "Check whether [[Foo]] is 
blacklisted",
-       "apihelp-titleblacklist-example-2": "Check whether [[Bar]] is 
blacklisted for editing"
+       "apihelp-titleblacklist-example-2": "Check whether [[Bar]] is 
blacklisted for editing",
+       "apihelp-createaccount-param-ignoretitleblacklist": "Ignore the 
blacklist (requires tboverride or tboverride-account)."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 8fedb8e..2636cdf 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -33,5 +33,6 @@
        "apihelp-titleblacklist-param-action": 
"{{doc-apihelp-param|titleblacklist|action}}",
        "apihelp-titleblacklist-param-nooverride": 
"{{doc-apihelp-param|titleblacklist|nooverride}}",
        "apihelp-titleblacklist-example-1": 
"{{doc-apihelp-example|titleblacklist}}",
-       "apihelp-titleblacklist-example-2": 
"{{doc-apihelp-example|titleblacklist}}"
+       "apihelp-titleblacklist-example-2": 
"{{doc-apihelp-example|titleblacklist}}",
+       "apihelp-createaccount-param-ignoretitleblacklist": 
"{{doc-apihelp-param|createaccount|ignoretitleblacklist}}",
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/181947
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f1d083c8fd6921cbc7e0f843085dc3facc87018
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TitleBlacklist
Gerrit-Branch: master
Gerrit-Owner: FunPika <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to