Merge "Add function to clear mPreparedEdit, to use in cases of mutable content"
[lhc/web/wiklou.git] / includes / api / ApiProtect.php
index 428eef3..80c76b3 100644 (file)
@@ -28,7 +28,6 @@
  * @ingroup API
  */
 class ApiProtect extends ApiBase {
-
        public function execute() {
                global $wgRestrictionLevels;
                $params = $this->extractRequestParams();
@@ -47,7 +46,11 @@ class ApiProtect extends ApiBase {
                        if ( count( $expiry ) == 1 ) {
                                $expiry = array_fill( 0, count( $params['protections'] ), $expiry[0] );
                        } else {
-                               $this->dieUsageMsg( array( 'toofewexpiries', count( $expiry ), count( $params['protections'] ) ) );
+                               $this->dieUsageMsg( array(
+                                       'toofewexpiries',
+                                       count( $expiry ),
+                                       count( $params['protections'] )
+                               ) );
                        }
                }
 
@@ -90,9 +93,9 @@ class ApiProtect extends ApiBase {
                                $expiryarray[$p[0]] = $exp;
                        }
                        $resultProtections[] = array( $p[0] => $protections[$p[0]],
-                                       'expiry' => ( $expiryarray[$p[0]] == $db->getInfinity() ?
-                                                               'infinite' :
-                                                               wfTimestamp( TS_ISO_8601, $expiryarray[$p[0]] ) ) );
+                               'expiry' => ( $expiryarray[$p[0]] == $db->getInfinity() ?
+                                       'infinite' :
+                                       wfTimestamp( TS_ISO_8601, $expiryarray[$p[0]] ) ) );
                }
 
                $cascade = $params['cascade'];
@@ -100,7 +103,13 @@ class ApiProtect extends ApiBase {
                $watch = $params['watch'] ? 'watch' : $params['watchlist'];
                $this->setWatch( $watch, $titleObj, 'watchdefault' );
 
-               $status = $pageObj->doUpdateRestrictions( $protections, $expiryarray, $cascade, $params['reason'], $this->getUser() );
+               $status = $pageObj->doUpdateRestrictions(
+                       $protections,
+                       $expiryarray,
+                       $cascade,
+                       $params['reason'],
+                       $this->getUser()
+               );
 
                if ( !$status->isOK() ) {
                        $this->dieStatus( $status );
@@ -167,18 +176,25 @@ class ApiProtect extends ApiBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'title' => "Title of the page you want to (un)protect. Cannot be used together with {$p}pageid",
                        'pageid' => "ID of the page you want to (un)protect. Cannot be used together with {$p}title",
                        'token' => 'A protect token previously retrieved through prop=info',
                        'protections' => 'List of protection levels, formatted action=group (e.g. edit=sysop)',
-                       'expiry' => array( 'Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.',
-                                       'Use \'infinite\', \'indefinite\' or \'never\', for a never-expiring protection.' ),
+                       'expiry' => array(
+                               'Expiry timestamps. If only one timestamp is ' .
+                                       'set, it\'ll be used for all protections.',
+                               'Use \'infinite\', \'indefinite\' or \'never\', for a never-expiring protection.'
+                       ),
                        'reason' => 'Reason for (un)protecting',
-                       'cascade' => array( 'Enable cascading protection (i.e. protect pages included in this page)',
-                                       'Ignored if not all protection levels are \'sysop\' or \'protect\'' ),
+                       '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',
-                       'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
+                       'watchlist' => 'Unconditionally add or remove the page from your ' .
+                               'watchlist, use preferences or do not change watch',
                );
        }
 
@@ -221,8 +237,10 @@ class ApiProtect extends ApiBase {
 
        public function getExamples() {
                return array(
-                       'api.php?action=protect&title=Main%20Page&token=123ABC&protections=edit=sysop|move=sysop&cascade=&expiry=20070901163000|never',
-                       'api.php?action=protect&title=Main%20Page&token=123ABC&protections=edit=all|move=all&reason=Lifting%20restrictions'
+                       'api.php?action=protect&title=Main%20Page&token=123ABC&' .
+                               'protections=edit=sysop|move=sysop&cascade=&expiry=20070901163000|never',
+                       'api.php?action=protect&title=Main%20Page&token=123ABC&' .
+                               'protections=edit=all|move=all&reason=Lifting%20restrictions'
                );
        }