CSteipp has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91806
Change subject: Improve wiki selection
......................................................................
Improve wiki selection
* Except domain names in wiki form
* Add a dropdown for "All wikis", "Current wiki", or "Specific wiki",
and add autocomplete of domain names in 'other' text box
Bug: 55703
Change-Id: I417490107414a8f2f310ab612e65da7c8f547b09
---
M backend/MWOAuthUtils.php
M control/MWOAuthConsumerSubmitControl.php
M frontend/MWOAuthUI.setup.php
M frontend/language/MWOAuth.i18n.php
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
5 files changed, 44 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth
refs/changes/06/91806/1
diff --git a/backend/MWOAuthUtils.php b/backend/MWOAuthUtils.php
index 000a572..c576ff3 100644
--- a/backend/MWOAuthUtils.php
+++ b/backend/MWOAuthUtils.php
@@ -280,6 +280,20 @@
}
/**
+ * Get the pretty names of all local wikis
+ *
+ * @return associative array of local wiki names indexed by wiki ID
+ */
+ public static function getAllWikiNames() {
+ global $wgConf;
+ $wikiNames = array();
+ foreach ( $wgConf->getLocalDatabases() as $dbname ) {
+ $wikiNames[$dbname] = WikiMap::getWikiName( $dbname );
+ }
+ return $wikiNames;
+ }
+
+ /**
* Quickly get a new server with all the default configurations
*
* @return MWOAuthServer with default configurations
diff --git a/control/MWOAuthConsumerSubmitControl.php
b/control/MWOAuthConsumerSubmitControl.php
index d49e550..203a440 100644
--- a/control/MWOAuthConsumerSubmitControl.php
+++ b/control/MWOAuthConsumerSubmitControl.php
@@ -68,7 +68,10 @@
return Sanitizer::validateEmail( $s );
},
'wiki' => function( $s ) {
global $wgConf;
- return in_array( $s,
$wgConf->getLocalDatabases() ) || $s === '*'; },
+ return ( $s === '*'
+ || in_array( $s,
$wgConf->getLocalDatabases() )
+ || array_search( $s,
MWOAuthUtils::getAllWikiNames() )
+ ); },
'grants' => function( $s ) {
$grants = FormatJSON::decode( $s, true
);
return is_array( $grants ) &&
MWOAuthUtils::grantsAreValid( $grants );
@@ -158,6 +161,11 @@
return $this->failure( 'consumer_exists',
'mwoauth-consumer-alreadyexists' );
}
+ $wikiNames = MWOAuthUtils::getAllWikiNames();
+ if ( array_search( $this->vals['wiki'], $wikiNames ) ) {
+ $this->vals['wiki'] = array_search(
$this->vals['wiki'], $wikiNames );
+ }
+
$curVer = $dbw->selectField(
'oauth_registered_consumer',
'oarc_version',
array( 'oarc_name' => $this->vals['name'],
'oarc_user_id' => $centralUserId ),
diff --git a/frontend/MWOAuthUI.setup.php b/frontend/MWOAuthUI.setup.php
index 63ca406..03907e8 100644
--- a/frontend/MWOAuthUI.setup.php
+++ b/frontend/MWOAuthUI.setup.php
@@ -37,6 +37,13 @@
'remoteExtPath' => 'OAuth/frontend/modules',
'messages' => array( 'mwoauth-desc' )
);
+ $wgResourceModules['ext.MWOAuth.WikiSelect'] = array(
+ 'scripts' => array( 'ext.MWOAuth.WikiSelect.js' ),
+ 'dependencies' => array( 'jquery.ui.autocomplete' ),
+ 'localBasePath' => dirname( __FILE__ ) . '/modules',
+ 'remoteExtPath' => 'OAuth/frontend/modules',
+ 'messages' => array( 'mwoauth-desc' )
+ );
}
/**
diff --git a/frontend/language/MWOAuth.i18n.php
b/frontend/language/MWOAuth.i18n.php
index 6211086..42de2e7 100644
--- a/frontend/language/MWOAuth.i18n.php
+++ b/frontend/language/MWOAuth.i18n.php
@@ -39,6 +39,8 @@
'mwoauth-consumer-grantsneeded' => 'Applicable grants:',
'mwoauth-consumer-required-grant' => 'Applicable to consumer',
'mwoauth-consumer-wiki' => 'Applicable wiki:',
+ 'mwoauth-consumer-wiki-thiswiki' => 'Current wiki ($1)',
+ 'mwoauth-consumer-wiki-other' => 'Specific wiki',
'mwoauth-consumer-restrictions' => 'Usage restrictions:',
'mwoauth-consumer-restrictions-json' => 'Usage restrictions (JSON):',
'mwoauth-consumer-rsakey' => 'Public RSA key:',
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index 1453e93..bc82211 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -56,6 +56,12 @@
$this->setHeaders();
$this->getOutput()->disallowUserJs();
+ $this->getOutput()->addModules( 'ext.MWOAuth.WikiSelect' );
+ $this->getOutput()->addInlineScript(
+ "var wgOAuthWikiList = ['" .
+ implode( "','", array_values(
MWOAuthUtils::getAllWikiNames() ) ) .
+ "'];"
+ );
$block = $user->getBlock();
if ( $block ) {
@@ -111,7 +117,12 @@
'required' => true
),
'wiki' => array(
- 'type' => 'text',
+ 'type' => 'selectorother',
+ 'options' => array(
+ wfMessage(
'mwoauth-consumer-allwikis' )->escaped() => '*',
+ wfMessage(
'mwoauth-consumer-wiki-thiswiki', wfWikiID() )->escaped() => wfWikiID()
+ ),
+ 'other' => wfMessage(
'mwoauth-consumer-wiki-other' )->escaped(),
'label-message' =>
'mwoauth-consumer-wiki',
'required' => true,
'default' => '*'
--
To view, visit https://gerrit.wikimedia.org/r/91806
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I417490107414a8f2f310ab612e65da7c8f547b09
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: CSteipp <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits