Gergő Tisza has uploaded a new change for review.
https://gerrit.wikimedia.org/r/231746
Change subject: Remove queue name from OAuth consumer management URL
......................................................................
Remove queue name from OAuth consumer management URL
Bug: T109163
Change-Id: I49a79b73c4bf951a07a1820aa193076908af3107
---
M OAuth.setup.php
M frontend/MWOAuthUIUtils.php
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
M frontend/specialpages/SpecialMWOAuthListConsumers.php
M frontend/specialpages/SpecialMWOAuthManageConsumers.php
5 files changed, 40 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth
refs/changes/46/231746/1
diff --git a/OAuth.setup.php b/OAuth.setup.php
index 8784ab3..8a9a786 100644
--- a/OAuth.setup.php
+++ b/OAuth.setup.php
@@ -59,6 +59,7 @@
# Utility functions
$classes['MediaWiki\Extensions\OAuth\MWOAuthUtils'] =
"$backendDir/MWOAuthUtils.php";
+ $classes['MediaWiki\Extensions\OAuth\MWOAuthUIUtils'] =
"$frontendDir/MWOAuthUIUtils.php";
$classes['MediaWiki\Extensions\OAuth\MWOAuthException'] =
"$backendDir/MWOAuthException.php";
# Data access objects
diff --git a/frontend/MWOAuthUIUtils.php b/frontend/MWOAuthUIUtils.php
index 8fc3d0d..6a6190e 100644
--- a/frontend/MWOAuthUIUtils.php
+++ b/frontend/MWOAuthUIUtils.php
@@ -8,7 +8,7 @@
* Maos stage keys to human-readable names which describe them as a
state
* @var array
*/
- public static $stageKeyToStateNameMap = array(
+ public static $stageToStageKeyMap = array(
MWOAuthConsumer::STAGE_PROPOSED => 'proposed',
MWOAuthConsumer::STAGE_REJECTED => 'rejected',
MWOAuthConsumer::STAGE_EXPIRED => 'expired',
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index 0346caa..2bf277c 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -409,7 +409,7 @@
$time = $this->getLanguage()->timeanddate(
wfTimestamp( TS_MW, $cmr->get( 'registration' ) ), true
);
- $stageKey = MWOAuthUIUtils::$stageKeyToStateNameMap[$cmr->get(
'stage' )];
+ $stageKey = MWOAuthUIUtils::$stageToStageKeyMap[$cmr->get(
'stage' )];
$encStageKey = htmlspecialchars( $stageKey ); // sanity
// Show last log entry (@TODO: title namespace?)
// @TODO: inject DB
diff --git a/frontend/specialpages/SpecialMWOAuthListConsumers.php
b/frontend/specialpages/SpecialMWOAuthListConsumers.php
index 407d9cf..d75f3b5 100644
--- a/frontend/specialpages/SpecialMWOAuthListConsumers.php
+++ b/frontend/specialpages/SpecialMWOAuthListConsumers.php
@@ -92,7 +92,7 @@
$s .= "\n";
}
- $stageKey = MWOAuthUIUtils::$stageKeyToStateNameMap[$cmr->get(
'stage' )];
+ $stageKey = MWOAuthUIUtils::$stageToStageKeyMap[$cmr->get(
'stage' )];
$data = array(
'mwoauthlistconsumers-name' => htmlspecialchars(
$cmr->get( 'name' )
@@ -232,7 +232,7 @@
MWOAuthConsumer::newFromRow( $db, $row ),
$this->getContext() );
$cmrKey = $cmr->get( 'consumerKey' );
- $stageKey = MWOAuthUIUtils::$stageKeyToStateNameMap[$cmr->get(
'stage' )];
+ $stageKey = MWOAuthUIUtils::$stageToStageKeyMap[$cmr->get(
'stage' )];
$links = array();
$links[] = \Linker::linkKnown(
@@ -243,7 +243,7 @@
);
if ( $this->getUser()->isAllowed( 'mwoauthmanageconsumer' ) ) {
$links[] = \Linker::linkKnown(
- \SpecialPage::getTitleFor(
'OAuthManageConsumers', "{$stageKey}/{$cmrKey}" ),
+ \SpecialPage::getTitleFor(
'OAuthManageConsumers', $cmrKey ),
$this->msg( 'mwoauthmanageconsumers-review'
)->escaped()
);
}
diff --git a/frontend/specialpages/SpecialMWOAuthManageConsumers.php
b/frontend/specialpages/SpecialMWOAuthManageConsumers.php
index 452f7ea..3ce18ad 100755
--- a/frontend/specialpages/SpecialMWOAuthManageConsumers.php
+++ b/frontend/specialpages/SpecialMWOAuthManageConsumers.php
@@ -26,8 +26,10 @@
* their approval/rejection and also for listing approved/disabled consumers
*/
class SpecialMWOAuthManageConsumers extends \SpecialPage {
- protected $stage; // integer; MWOAuthConsumer::STAGE_* constant
- protected $stageKey; // string
+ /** @var bool|int An MWOAuthConsumer::STAGE_* constant on queue/list
subpages, false otherwise*/
+ protected $stage = false;
+ /** @var string A stage key from MWOAuthUIUtils::$stageToStageKeyMap */
+ protected $stageKey;
public function __construct() {
parent::__construct( 'OAuthManageConsumers',
'mwoauthmanageconsumer' );
@@ -52,19 +54,27 @@
throw new \ErrorPageError( 'mwoauth-error',
'mwoauth-db-readonly' );
}
- // Format is Special:OAuthManageConsumers[/<stage>[/<consumer
key>]]
+ // Format is Special:OAuthManageConsumers[/<stage>|/<consumer
key>]
+ // B/C format is
Special:OAuthManageConsumers[/<stage>[/<consumer key>]]
+ $stageKey = $consumerKey = null;
$navigation = explode( '/', $par );
- $stageKey = isset( $navigation[0] ) ? $navigation[0] : null;
- $consumerKey = isset( $navigation[1] ) ? $navigation[1] : null;
-
- $this->stage = array_search( $stageKey,
MWOAuthUIUtils::$stageKeyToStateNameMap, true );
- if ( $this->stage !== false ) {
- $this->stageKey = $stageKey;
- if ( $consumerKey ) {
- $this->handleConsumerForm( $consumerKey );
+ if ( count( $navigation ) === 2 ) {
+ $this->stage = false;
+ $consumerKey = $navigation[1];
+ } elseif ( count( $navigation ) === 1 && $navigation[0] ) {
+ $this->stage = array_search( $navigation[0],
MWOAuthUIUtils::$stageToStageKeyMap, true );
+ if ( $this->stage !== false ) {
+ $consumerKey = null;
+ $this->stageKey = $navigation[0];
} else {
- $this->showConsumerList();
+ $consumerKey = $navigation[0];
}
+ }
+
+ if ( $consumerKey ) {
+ $this->handleConsumerForm( $consumerKey );
+ } elseif ( $this->stage !== false ) {
+ $this->showConsumerList();
} else {
$this->showMainHub();
}
@@ -110,9 +120,9 @@
* @return void
*/
protected function showMainHub() {
- $keyStageMapQ = array_flip( array_intersect(
MWOAuthUIUtils::$stageKeyToStateNameMap,
+ $keyStageMapQ = array_flip( array_intersect(
MWOAuthUIUtils::$stageToStageKeyMap,
MWOAuthUIUtils::$queueStageKeys ) );
- $keyStageMapL = array_flip( array_intersect(
MWOAuthUIUtils::$stageKeyToStateNameMap,
+ $keyStageMapL = array_flip( array_intersect(
MWOAuthUIUtils::$stageToStageKeyMap,
MWOAuthUIUtils::$listStageKeys ) );
$out = $this->getOutput();
@@ -175,7 +185,8 @@
} elseif ( $cmr->get( 'deleted' ) && !$user->isAllowed(
'mwoauthviewsuppressed' ) ) {
throw new \PermissionsError( 'mwoauthviewsuppressed' );
}
- $pending = !in_array( $cmr->get( 'stage' ), array(
+ $startingStage = $cmr->get( 'stage' );
+ $pending = !in_array( $startingStage, array(
MWOAuthConsumer::STAGE_APPROVED,
MWOAuthConsumer::STAGE_DISABLED ) );
if ( $pending ) {
@@ -298,7 +309,7 @@
'default' => $cmr->get( 'deleted' )
? $this->msg(
'mwoauth-consumer-stage-suppressed' )
: $this->msg(
'mwoauth-consumer-stage-' .
-
MWOAuthUIUtils::$stageKeyToStateNameMap[$cmr->get( 'stage' )] )
+
MWOAuthUIUtils::$stageToStageKeyMap[$cmr->get( 'stage' )] )
),
'action' => array(
'type' => 'radio',
@@ -343,13 +354,14 @@
$status = $form->show();
if ( $status instanceof \Status && $status->isOk() ) {
- $type =
MWOAuthUIUtils::$stageKeyToStateNameMap[$status->value['result']->get( 'stage'
)];
+ $oldStageKey =
MWOAuthUIUtils::$stageToStageKeyMap[$startingStage];
+ $newStageKey =
MWOAuthUIUtils::$stageToStageKeyMap[$status->value['result']->get( 'stage' )];
// Messages: mwoauthmanageconsumers-success-approved,
mwoauthmanageconsumers-success-rejected,
// mwoauthmanageconsumers-success-disabled
- $this->getOutput()->addWikiMsg(
"mwoauthmanageconsumers-success-$type" );
- $returnTo = \Title::newFromText(
'Special:OAuthManageConsumers/' . $this->stageKey );
+ $this->getOutput()->addWikiMsg(
"mwoauthmanageconsumers-success-$newStageKey" );
+ $returnTo = \Title::newFromText(
'Special:OAuthManageConsumers/' . $oldStageKey );
$this->getOutput()->addReturnTo( $returnTo, array(),
- $this->msg( 'mwoauthmanageconsumers-link' .
$this->stageKey )->escaped() );
+ $this->msg( 'mwoauthmanageconsumers-link' .
$oldStageKey )->escaped() );
} else {
$out = $this->getOutput();
// Show all of the status updates
@@ -396,10 +408,10 @@
MWOAuthConsumer::newFromRow( $db, $row ),
$this->getContext() );
$cmrKey = $cmr->get( 'consumerKey' );
- $stageKey = MWOAuthUIUtils::$stageKeyToStateNameMap[$cmr->get(
'stage' )];
+ $stageKey = MWOAuthUIUtils::$stageToStageKeyMap[$cmr->get(
'stage' )];
$link = \Linker::linkKnown(
- $this->getPageTitle( "{$stageKey}/{$cmrKey}" ),
+ $this->getPageTitle( $cmrKey ),
$this->msg( 'mwoauthmanageconsumers-review' )->escaped()
);
--
To view, visit https://gerrit.wikimedia.org/r/231746
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I49a79b73c4bf951a07a1820aa193076908af3107
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits