summaryrefslogtreecommitdiff
path: root/includes/api/ApiProtect.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiProtect.php')
-rw-r--r--includes/api/ApiProtect.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php
index 522d02b2..aad37066 100644
--- a/includes/api/ApiProtect.php
+++ b/includes/api/ApiProtect.php
@@ -38,7 +38,6 @@ class ApiProtect extends ApiBase {
public function execute() {
global $wgUser, $wgRestrictionTypes, $wgRestrictionLevels;
- $this->getMain()->requestWriteMode();
$params = $this->extractRequestParams();
$titleObj = NULL;
@@ -59,7 +58,7 @@ class ApiProtect extends ApiBase {
$errors = $titleObj->getUserPermissionsErrors('protect', $wgUser);
if($errors)
// We don't care about multiple errors, just report one of them
- $this->dieUsageMsg(current($errors));
+ $this->dieUsageMsg(reset($errors));
$expiry = (array)$params['expiry'];
if(count($expiry) != count($params['protections']))
@@ -106,10 +105,12 @@ class ApiProtect extends ApiBase {
}
$cascade = $params['cascade'];
- if($titleObj->exists()) {
- $articleObj = new Article($titleObj);
+ $articleObj = new Article($titleObj);
+ if($params['watch'])
+ $articleObj->doWatch();
+ if($titleObj->exists())
$ok = $articleObj->updateRestrictions($protections, $params['reason'], $cascade, $expiryarray);
- } else
+ else
$ok = $titleObj->updateTitleProtection($protections['create'], $params['reason'], $expiryarray['create']);
if(!$ok)
// This is very weird. Maybe the article was deleted or the user was blocked/desysopped in the meantime?
@@ -125,6 +126,10 @@ class ApiProtect extends ApiBase {
public function mustBePosted() { return true; }
+ public function isWriteMode() {
+ return true;
+ }
+
public function getAllowedParams() {
return array (
'title' => null,
@@ -138,7 +143,8 @@ class ApiProtect extends ApiBase {
ApiBase :: PARAM_DFLT => 'infinite',
),
'reason' => '',
- 'cascade' => false
+ 'cascade' => false,
+ 'watch' => false,
);
}
@@ -152,6 +158,7 @@ class ApiProtect extends ApiBase {
'reason' => 'Reason for (un)protecting (optional)',
'cascade' => array('Enable cascading protection (i.e. protect pages included in this page)',
'Ignored if not all protection levels are \'sysop\' or \'protect\''),
+ 'watch' => 'If set, add the page being (un)protected to your watchlist',
);
}
@@ -169,6 +176,6 @@ class ApiProtect extends ApiBase {
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiProtect.php 44426 2008-12-10 22:39:41Z catrope $';
+ return __CLASS__ . ': $Id: ApiProtect.php 48122 2009-03-07 12:58:41Z catrope $';
}
}