.
/**
* @package MantisBT
* @copyright Copyright (C) 2002 - 2014 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/
/**
* MantisBT Core API's
*/
require_once( 'core.php' );
/**
* requires tag_api
*/
require_once( 'tag_api.php' );
form_security_validate( 'tag_attach' );
$f_bug_id = gpc_get_int( 'bug_id' );
$f_tag_select = gpc_get_int( 'tag_select' );
$f_tag_string = gpc_get_string( 'tag_string' );
$t_user_id = auth_get_current_user_id();
access_ensure_bug_level( config_get( 'tag_attach_threshold' ), $f_bug_id, $t_user_id );
/** @todo The handling of tag strings which can include multiple tags should be moved
* to the APIs. This is to allow other clients of the API to support such
* functionality. The access level checks should also be moved to the API.
*/
$t_tags = tag_parse_string( $f_tag_string );
$t_can_create = access_has_global_level( config_get( 'tag_create_threshold' ) );
$t_tags_create = array();
$t_tags_attach = array();
$t_tags_failed = array();
foreach ( $t_tags as $t_tag_row ) {
if ( -1 == $t_tag_row['id'] ) {
if ( $t_can_create ) {
$t_tags_create[] = $t_tag_row;
} else {
$t_tags_failed[] = $t_tag_row;
}
} else if ( -2 == $t_tag_row['id'] ) {
$t_tags_failed[] = $t_tag_row;
} else {
$t_tags_attach[] = $t_tag_row;
}
}
if ( 0 < $f_tag_select && tag_exists( $f_tag_select ) ) {
$t_tags_attach[] = tag_get( $f_tag_select );
}
// failed to attach at least one tag
if ( count( $t_tags_failed ) > 0 ) {
html_page_top( lang_get( 'tag_attach_long' ) . ' ' . bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
?>
', lang_get( 'tag_create_denied' ), ' | '; } else if ( -2 == $t_tag_row['id'] ) { echo '', lang_get( 'tag_invalid_name' ), ' | '; } echo '', string_html_specialchars( $t_tag_row['name'] ), ' | '; if ( !is_blank( $t_tag_string ) ) { $t_tag_string .= config_get( 'tag_separator' ); } $t_tag_string .= $t_tag_row['name']; } ?>