Allow users to add, remove and apply change tags using the API
[lhc/web/wiklou.git] / includes / api / ApiEditPage.php
index ef8957e..8c7d31d 100644 (file)
@@ -331,6 +331,15 @@ class ApiEditPage extends ApiBase {
                        $requestArray['wpWatchthis'] = '';
                }
 
+               // Apply change tags
+               if ( count( $params['tags'] ) ) {
+                       if ( $user->isAllowed( 'applychangetags' ) ) {
+                               $requestArray['wpChangeTags'] = implode( ',', $params['tags'] );
+                       } else {
+                               $this->dieUsage( 'You don\'t have permission to set change tags.', 'taggingnotallowed' );
+                       }
+               }
+
                // Pass through anything else we might have been given, to support extensions
                // This is kind of a hack but it's the best we can do to make extensions work
                $requestArray += $this->getRequest()->getValues();
@@ -475,6 +484,9 @@ class ApiEditPage extends ApiBase {
                        case EditPage::AS_TEXTBOX_EMPTY:
                                $this->dieUsageMsg( 'emptynewsection' );
 
+                       case EditPage::AS_CHANGE_TAG_ERROR:
+                               $this->dieStatus( $status );
+
                        case EditPage::AS_SUCCESS_NEW_ARTICLE:
                                $r['new'] = '';
                                // fall-through
@@ -531,6 +543,10 @@ class ApiEditPage extends ApiBase {
                        ),
                        'text' => null,
                        'summary' => null,
+                       'tags' => array(
+                               ApiBase::PARAM_TYPE => ChangeTags::listExplicitlyDefinedTags(),
+                               ApiBase::PARAM_ISMULTI => true,
+                       ),
                        'minor' => false,
                        'notminor' => false,
                        'bot' => false,