Gergő Tisza has uploaded a new change for review.

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

Change subject: Use HTMLRestrictionsField
......................................................................

Use HTMLRestrictionsField

Change-Id: I8c2a2713e94b0254d840bd71044a6cc1318a1b7c
Depends-On: Ib50238e3be5eec63eb5df97154b60dc4ca33d581
---
M control/MWOAuthConsumerSubmitControl.php
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
2 files changed, 6 insertions(+), 26 deletions(-)


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

diff --git a/control/MWOAuthConsumerSubmitControl.php 
b/control/MWOAuthConsumerSubmitControl.php
index a987621..32c4f8c 100644
--- a/control/MWOAuthConsumerSubmitControl.php
+++ b/control/MWOAuthConsumerSubmitControl.php
@@ -88,14 +88,6 @@
                                        $grants = \FormatJson::decode( $s, true 
);
                                        return is_array( $grants ) && 
MWOAuthUtils::grantsAreValid( $grants );
                                },
-                               'restrictions' => function( $s ) {
-                                       try {
-                                               \MWRestrictions::newFromJson( 
$s );
-                                               return true;
-                                       } catch ( \InvalidArgumentException $ex 
) {
-                                               return false;
-                                       }
-                               },
                                'rsaKey'       => $validateRsaKey,
                                'agreement'    => function( $s ) {
                                        return ( $s == true );
@@ -103,14 +95,6 @@
                        ),
                        'update'      => array(
                                'consumerKey'  => '/^[0-9a-f]{32}$/',
-                               'restrictions' => function( $s ) {
-                                       try {
-                                               \MWRestrictions::newFromJson( 
$s );
-                                               return true;
-                                       } catch ( \InvalidArgumentException $ex 
) {
-                                               return false;
-                                       }
-                               },
                                'rsaKey'       => $validateRsaKey,
                                'resetSecret'  => function( $s ) { return 
is_bool( $s ); },
                                'reason'       => '/^.{0,255}$/',
@@ -242,7 +226,7 @@
                                        'stage'              => $stage,
                                        'stageTimestamp'     => $now,
                                        'grants'             => $grants,
-                                       'restrictions'       => 
\MWRestrictions::newFromJson( $this->vals['restrictions'] ),
+                                       'restrictions'       => 
$this->vals['restrictions'],
                                        'deleted'            => 0
                                ) + $this->vals
                        );
@@ -295,7 +279,7 @@
 
                        $cmr->setFields( array(
                                'rsaKey'       => $this->vals['rsaKey'],
-                               'restrictions' => \MWRestrictions::newFromJson( 
$this->vals['restrictions'] ),
+                               'restrictions' => $this->vals['restrictions'],
                                'secretKey'    => $this->vals['resetSecret']
                                        ? \MWCryptRand::generateHex( 32 )
                                        : $cmr->get( 'secretKey' )
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php 
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index 3d4ad9f..13d93bb 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -177,11 +177,9 @@
                                                'validation-callback' => null 
// different format
                                        ),
                                        'restrictions' => array(
-                                               'type' => 'textarea',
-                                               'label-message' => 
'mwoauth-consumer-restrictions-json',
+                                               'class' => 
'HTMLRestrictionsField',
                                                'required' => true,
-                                               'default' => 
\MWRestrictions::newDefault()->toJson( true ),
-                                               'rows' => 5
+                                               'default' => 
\MWRestrictions::newDefault(),
                                        ),
                                        'rsaKey' => array(
                                                'type' => 'textarea',
@@ -270,11 +268,9 @@
                                                ), $this->getContext() ),
                                        ),
                                        'restrictions' => array(
-                                               'type' => 'textarea',
-                                               'label-message' => 
'mwoauth-consumer-restrictions-json',
+                                               'class' => 
'HTMLRestrictionsField',
                                                'required' => true,
-                                               'default' => 
$cmr->getDAO()->get( 'restrictions' )->toJson( true ),
-                                               'rows' => 5
+                                               'default' => 
$cmr->getDAO()->get( 'restrictions' ),
                                        ),
                                        'resetSecret' => array(
                                                'type' => 'check',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8c2a2713e94b0254d840bd71044a6cc1318a1b7c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to