jenkins-bot has submitted this change and it was merged.
Change subject: Added a /grants subpage to give a grant/rights table to
Special:OAuth
......................................................................
Added a /grants subpage to give a grant/rights table to Special:OAuth
Change-Id: I8475a213d15df9cf59e68cb76f6da3ba8e6437a4
---
M frontend/language/MWOAuth.i18n.php
M frontend/specialpages/SpecialMWOAuth.php
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
3 files changed, 61 insertions(+), 0 deletions(-)
Approvals:
CSteipp: Looks good to me, approved
jenkins-bot: Verified
diff --git a/frontend/language/MWOAuth.i18n.php
b/frontend/language/MWOAuth.i18n.php
index ab5fbc2..65150c7 100644
--- a/frontend/language/MWOAuth.i18n.php
+++ b/frontend/language/MWOAuth.i18n.php
@@ -60,6 +60,7 @@
'mwoauth-invalid-access-token' => 'No access token exists with the
given key.',
'mwoauth-invalid-access-wrongwiki' => 'The consumer can only be used on
wiki "$1".',
'mwoauth-consumer-conflict' => 'Someone changed the attributes of this
consumer as you viewed it. Please try again. You may want to check the change
log.',
+ 'mwoauth-consumer-grantshelp' => 'Each grant gives access to listed
user rights that a user account already has. See the
([[Special:OAuth/grants|table of grants]]) for more information.',
'mwoauth-consumer-stage-proposed' => 'proposed',
'mwoauth-consumer-stage-rejected' => 'rejected',
@@ -314,6 +315,12 @@
'action-mwoauthproposeconsumer' => 'propose new OAuth consumers',
'action-mwoauthupdateownconsumer' => 'update OAuth consumers you
control',
'action-mwoauthviewsuppressed' => 'view suppressed OAuth consumers',
+
+ 'mwoauth-listgrantrights-summary' => 'The following is a list of OAuth
grants, with their associated access to user rights. Users can authorize
applications to use their account, but with limited permissions based on the
grants the user gave to the application. An application acting on behalf of a
user cannot actually use rights that the user does not have however.
+There may be [[{{MediaWiki:Listgrouprights-helppage}}|additional information]]
about individual rights.',
+ 'mwoauth-listgrants-grant' => 'Grant',
+ 'mwoauth-listgrants-rights' => 'Rights',
+ 'mwoauth-listgrantrights-right-display' => '$1 <code>($2)</code>', #
only translate this message to other languages if you have to change it
);
/** Message documentation (Message documentation)
@@ -916,6 +923,12 @@
'action-mwoauthproposeconsumer' =>
'{{Doc-action|mwoauthproposeconsumer}}',
'action-mwoauthupdateownconsumer' =>
'{{Doc-action|mwoauthupdateownconsumer}}',
'action-mwoauthviewsuppressed' =>
'{{Doc-action|mwoauthviewsuppressed}}',
+
+ 'mwoauth-consumer-grantshelp' => 'Help text shown on consumer proposal
form.',
+ 'mwoauth-listgrantrights-summary' => 'Expanatory text shown at the top
of the grant/rights mapping table.',
+ 'mwoauth-listgrants-grant' => 'Used as table header for the
grant/rights mapping table',
+ 'mwoauth-listgrants-rights' => 'Used as table header for the
grant/rights mapping table',
+ 'mwoauth-listgrantrights-right-display' => 'Used to format rights
descriptions on the grant/rights mapping table',
);
/** Arabic (العربية)
diff --git a/frontend/specialpages/SpecialMWOAuth.php
b/frontend/specialpages/SpecialMWOAuth.php
index 34bef85..a737d0b 100644
--- a/frontend/specialpages/SpecialMWOAuth.php
+++ b/frontend/specialpages/SpecialMWOAuth.php
@@ -121,6 +121,9 @@
$format
);
break;
+ case 'grants':
+ $this->showGrantRightsTables();
+ break;
default:
$format = $request->getVal( 'format',
'html' );
$this->showError(
'mwoauth-bad-request', $format );
@@ -335,4 +338,48 @@
$out->addHtml( $data );
}
}
+
+ protected function showGrantRightsTables() {
+ global $wgMWOAuthGrantPermissions;
+
+ $out = $this->getOutput();
+ $out->addModuleStyles( 'mediawiki.special' );
+
+ $out->addWikiMsg( 'mwoauth-listgrantrights-summary' );
+
+ $out->addHTML(
+ Html::openElement( 'table',
+ array( 'class' => 'wikitable
mw-oauth-listgrouprights-table' ) ) .
+ '<tr>' .
+ Html::element( 'th', null, $this->msg(
'mwoauth-listgrants-grant' )->text() ) .
+ Html::element( 'th', null, $this->msg(
'mwoauth-listgrants-rights' )->text() ) .
+ '</tr>'
+ );
+
+ foreach ( $wgMWOAuthGrantPermissions as $grant => $rights ) {
+ $descs = array();
+ $rights = array_filter( $rights ); // remove ones with
'false'
+ foreach ( $rights as $permission => $granted ) {
+ $descs[] = $this->msg(
+ 'listgrouprights-right-display',
+ User::getRightDescription( $permission
),
+ '<span
class="mw-oaith-listgrantrights-right-name">' . $permission . '</span>'
+ )->parse();
+ }
+ if ( !count( $descs ) ) {
+ $grantCellHtml = '';
+ } else {
+ sort( $descs );
+ $grantCellHtml = '<ul><li>' . implode(
"</li>\n<li>", $descs ) . '</li></ul>';
+ }
+
+ $id = Sanitizer::escapeId( $grant );
+ $out->addHTML( Html::rawElement( 'tr', array( 'id' =>
$id ),
+ "<td>" . wfMessage( "mwoauth-grant-$grant"
)->escaped() . "</td>" .
+ "<td>" . $grantCellHtml . '</td>'
+ ) );
+ }
+
+ $out->addHTML( Html::closeElement( 'table' ) );
+ }
}
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index 4625cbf..4557b60 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -126,6 +126,7 @@
'grants' => array(
'type' => 'checkmatrix',
'label-message' =>
'mwoauth-consumer-grantsneeded',
+ 'help-message' =>
'mwoauth-consumer-grantshelp',
'columns' => array(
$this->msg(
'mwoauth-consumer-required-grant' )->escaped() => 'grant'
),
--
To view, visit https://gerrit.wikimedia.org/r/92029
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8475a213d15df9cf59e68cb76f6da3ba8e6437a4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits