Aaron Schulz has uploaded a new change for review.

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


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, 63 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth 
refs/changes/29/92029/1

diff --git a/frontend/language/MWOAuth.i18n.php 
b/frontend/language/MWOAuth.i18n.php
index 0d1d3c2..af36d3a 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',
@@ -316,6 +317,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)
@@ -919,6 +926,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 (العربية)
@@ -4114,10 +4127,10 @@
        'mwoauthmanagemygrants-review' => 'hantera åtkomst',
        'mwoauthmanagemygrants-revoke' => 'återkalla åtkomst',
        'mwoauthmanagemygrants-grantaccept' => 'Beviljas',
-       'mwoauthmanagemygrants-update-text' => 'Använd formuläret nedan för att 
ändra de behörigheter som beviljats för en applikation (OAuth konsument)  att 
agera åt dina vägnar. 
+       'mwoauthmanagemygrants-update-text' => 'Använd formuläret nedan för att 
ändra de behörigheter som beviljats för en applikation (OAuth konsument)  att 
agera åt dina vägnar.
 * Om du separat auktoriserat en applikation för att tillgå olika systerprojekt 
åt dina vägnar har du separata konfigurationer för varje sådant projekt för den 
applikationen.
 * Att använda "*" i wikifältet ger tillgång till alla projekt på denna 
webbplats: att använda ett wikiprojektID begränsar åtkomst till ett enskilt 
projekt. Förinställda projektinställningar har företräde.',
-       'mwoauthmanagemygrants-revoke-text' => 'Använd formuläret nedan för att 
återkalla åtkomst för en applikation (OAuth konsument) att agera åt dina 
vägnar. 
+       'mwoauthmanagemygrants-revoke-text' => 'Använd formuläret nedan för att 
återkalla åtkomst för en applikation (OAuth konsument) att agera åt dina vägnar.
 * Om du separat har auktoriserat en applikation för att få åtkomst till ett 
annat systerprojekt åt dina vägnar så kommer du att ha separata konfigurationer 
för varje enskilt projekt för den applikationen.
 * Om du helt vill återkalla åtkomst till en applikation, se till att återkalla 
den från alla projekt där du accepterat den.',
        'mwoauthmanagemygrants-confirm-legend' => 'Hantera 
konsumentåtkomst-token',
diff --git a/frontend/specialpages/SpecialMWOAuth.php 
b/frontend/specialpages/SpecialMWOAuth.php
index 0e60c42..25eb956 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 8aa13ea..23cc3a1 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: newchange
Gerrit-Change-Id: I8475a213d15df9cf59e68cb76f6da3ba8e6437a4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

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

Reply via email to