Set API limits for page restrictions to 10
[lhc/web/wiklou.git] / includes / api / ApiBlock.php
index 8f40283..8976626 100644 (file)
@@ -54,6 +54,16 @@ class ApiBlock extends ApiBase {
                        }
                }
 
+               $editingRestriction = 'sitewide';
+               $pageRestrictions = '';
+               if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
+                       if ( $params['partial'] ) {
+                               $editingRestriction = 'partial';
+                       }
+
+                       $pageRestrictions = implode( "\n", $params['pagerestrictions'] );
+               }
+
                if ( $params['userid'] !== null ) {
                        $username = User::whoIs( $params['userid'] );
 
@@ -107,6 +117,8 @@ class ApiBlock extends ApiBase {
                        'Watch' => $params['watchuser'],
                        'Confirm' => true,
                        'Tags' => $params['tags'],
+                       'EditingRestriction' => $editingRestriction,
+                       'PageRestrictions' => $pageRestrictions,
                ];
 
                $retval = SpecialBlock::processForm( $data, $this->getContext() );
@@ -137,6 +149,11 @@ class ApiBlock extends ApiBase {
                $res['allowusertalk'] = $params['allowusertalk'];
                $res['watchuser'] = $params['watchuser'];
 
+               if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
+                       $res['partial'] = $params['partial'];
+                       $res['pagerestrictions'] = $params['pagerestrictions'];
+               }
+
                $this->getResult()->addValue( null, $this->getModuleName(), $res );
        }
 
@@ -149,7 +166,7 @@ class ApiBlock extends ApiBase {
        }
 
        public function getAllowedParams() {
-               return [
+               $params = [
                        'user' => [
                                ApiBase::PARAM_TYPE => 'user',
                        ],
@@ -171,6 +188,17 @@ class ApiBlock extends ApiBase {
                                ApiBase::PARAM_ISMULTI => true,
                        ],
                ];
+
+               if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
+                       $params['partial'] = false;
+                       $params['pagerestrictions'] = [
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_ISMULTI_LIMIT1 => 10,
+                               ApiBase::PARAM_ISMULTI_LIMIT2 => 10,
+                       ];
+               }
+
+               return $params;
        }
 
        public function needsToken() {