* - string: Any non-empty string, not expected to be very long or contain newlines.
* <input type="text"> would be an appropriate HTML form field.
* - submodule: The name of a submodule of this module, see PARAM_SUBMODULE_MAP.
+ * - tags: A string naming an existing, explicitly-defined tag. Should usually be
+ * used with PARAM_ISMULTI.
* - text: Any non-empty string, expected to be very long or contain newlines.
* <textarea> would be an appropriate HTML form field.
* - timestamp: A timestamp in any format recognized by MWTimestamp, or the
break;
case 'upload': // nothing to do
break;
+ case 'tags':
+ // If change tagging was requested, check that the tags are valid.
+ if ( !is_array( $value ) && !$multi ) {
+ $value = array( $value );
+ }
+ $tagsStatus = ChangeTags::canAddTagsAccompanyingChange( $value );
+ if ( !$tagsStatus->isGood() ) {
+ $this->dieStatus( $tagsStatus );
+ }
+ break;
default:
ApiBase::dieDebug( __METHOD__, "Param $encParamName's type is unknown - $type" );
}
),
'reason' => null,
'tags' => array(
- ApiBase::PARAM_TYPE => ChangeTags::listExplicitlyDefinedTags(),
+ ApiBase::PARAM_TYPE => 'tags',
ApiBase::PARAM_ISMULTI => true,
),
'watch' => array(
// Apply change tags
if ( count( $params['tags'] ) ) {
- if ( $user->isAllowed( 'applychangetags' ) ) {
+ $tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
+ if ( $tagStatus->isOk() ) {
$requestArray['wpChangeTags'] = implode( ',', $params['tags'] );
} else {
- $this->dieUsage( 'You don\'t have permission to set change tags.', 'taggingnotallowed' );
+ $this->dieStatus( $tagStatus );
}
}
),
'summary' => null,
'tags' => array(
- ApiBase::PARAM_TYPE => ChangeTags::listExplicitlyDefinedTags(),
+ ApiBase::PARAM_TYPE => 'tags',
ApiBase::PARAM_ISMULTI => true,
),
'minor' => false,
$type = null;
break;
+ case 'tags':
+ $tags = ChangeTags::listExplicitlyDefinedTags();
+ $count = count( $tags );
+ $info[] = $context->msg( 'api-help-param-list' )
+ ->params( $multi ? 2 : 1 )
+ ->params( $context->getLanguage()->commaList( $tags ) )
+ ->parse();
+ $hintPipeSeparated = false;
+ $type = null;
+ break;
+
case 'limit':
if ( isset( $settings[ApiBase::PARAM_MAX2] ) ) {
$info[] = $context->msg( 'api-help-param-limit2' )
if ( isset( $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX] ) ) {
$item['submoduleparamprefix'] = $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX];
}
+ } elseif ( $settings[ApiBase::PARAM_TYPE] === 'tags' ) {
+ $item['type'] = ChangeTags::listExplicitlyDefinedTags();
} else {
$item['type'] = $settings[ApiBase::PARAM_TYPE];
}
ApiBase::PARAM_TYPE => 'integer'
),
'tags' => array(
- ApiBase::PARAM_TYPE => ChangeTags::listExplicitlyDefinedTags(),
+ ApiBase::PARAM_TYPE => 'tags',
ApiBase::PARAM_ISMULTI => true,
),
'user' => array(
*/
class ApiTag extends ApiBase {
- protected function getAvailableTags() {
- return ChangeTags::listExplicitlyDefinedTags();
- }
-
public function execute() {
$params = $this->extractRequestParams();
$user = $this->getUser();
ApiBase::PARAM_ISMULTI => true,
),
'add' => array(
- ApiBase::PARAM_TYPE => $this->getAvailableTags(),
+ ApiBase::PARAM_TYPE => 'tags',
ApiBase::PARAM_ISMULTI => true,
),
'remove' => array(