aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiBlock.php
diff options
context:
space:
mode:
authorDavid Barratt <dbarratt@wikimedia.org>2018-08-27 18:19:37 -0400
committerJforrester <jforrester@wikimedia.org>2018-10-24 00:47:08 +0000
commit0813c46daaa7ca1b52008633a5eb8a769df67137 (patch)
tree7ea2cc178bc357468a46907d7e15c681f9b42ba5 /includes/api/ApiBlock.php
parent07a5c71646a120a41a51b254499c3364b11a68d3 (diff)
downloadmediawikicore-0813c46daaa7ca1b52008633a5eb8a769df67137.tar.gz
mediawikicore-0813c46daaa7ca1b52008633a5eb8a769df67137.zip
Update Special:Block to set Partial Blocks
Make the necessary UI changes to Special:Block in order to set/update partial blocks. Bug: T197109 Change-Id: Ib3067824b5dcbdd893ab1f165d169a35d0716cb2
Diffstat (limited to 'includes/api/ApiBlock.php')
-rw-r--r--includes/api/ApiBlock.php42
1 files changed, 41 insertions, 1 deletions
diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php
index 8f4028310a79..3581ac851490 100644
--- a/includes/api/ApiBlock.php
+++ b/includes/api/ApiBlock.php
@@ -54,6 +54,30 @@ class ApiBlock extends ApiBase {
}
}
+ $editingRestriction = 'sitewide';
+ $pageRestrictions = '';
+ if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
+ if ( $params['pagerestrictions'] ) {
+ $count = count( $params['pagerestrictions'] );
+ if ( $count > 10 ) {
+ $this->dieWithError(
+ $this->msg(
+ 'apierror-integeroutofrange-abovebotmax',
+ 'pagerestrictions',
+ 10,
+ $count
+ )
+ );
+ }
+ }
+
+ if ( $params['partial'] ) {
+ $editingRestriction = 'partial';
+ }
+
+ $pageRestrictions = implode( "\n", $params['pagerestrictions'] );
+ }
+
if ( $params['userid'] !== null ) {
$username = User::whoIs( $params['userid'] );
@@ -107,6 +131,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 +163,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 +180,7 @@ class ApiBlock extends ApiBase {
}
public function getAllowedParams() {
- return [
+ $params = [
'user' => [
ApiBase::PARAM_TYPE => 'user',
],
@@ -171,6 +202,15 @@ class ApiBlock extends ApiBase {
ApiBase::PARAM_ISMULTI => true,
],
];
+
+ if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
+ $params['partial'] = false;
+ $params['pagerestrictions'] = [
+ ApiBase::PARAM_ISMULTI => true,
+ ];
+ }
+
+ return $params;
}
public function needsToken() {