View Issue Details

IDProjectCategoryView StatusLast Update
0009782mantisbttaggingpublic2016-06-27 08:57
Reporterolegos Assigned To 
Status acknowledgedResolutionopen 
Product Version1.2.0a2 
Summary0009782: Detach Tags group action

There is already Attach Tags group action (for attaching tags to multiple issues after selecting them in View Issues list). I think a corresponding Detach Tags group action is needed.

TagsNo tags attached.




2013-03-13 07:47

reporter   ~0035847

We too would love this feature



2013-09-23 09:03

reporter   ~0038095

Is there a reason, why this feature was not implemented (because there are problems, retrictions, ...) or was it just because a lack of time and importance? Reason for asking is, that we think about implementing it ourselves




2013-09-23 09:31

developer   ~0038097


Lack of time is the most likely reason.

Feel free to submit a patch. Best would be to send a pull request on our Github repo. Alternatively, upload a git patch here (or worst case a unified diff with a clear reference of which source file you used for patching)



2013-10-02 03:53


bug_actiongroup_detach_tags_inc.php (3,717 bytes)   
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <>.

	 * @package MantisBT
	 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito -
	 * @copyright Copyright (C) 2002 - 2013  MantisBT Team -
	 * @link

	 * Enhanced by Philipp Ramsenthaler 2013
	 * Requires Tag API
	require_once( 'tag_api.php' );

	 * Prints the title for the custom action page.
	function action_detach_tags_print_title() {
        echo '<tr class="form-title">';
        echo '<td colspan="2">';
        echo lang_get( 'tag_detach_long' );
        echo '</td></tr>';

	 * Prints the table and form for the Detach Tags group action page.
	function action_detach_tags_print_fields() {
		echo '<tr ',helper_alternate_class(),'><td class="category">',lang_get('tag_detach_long'),'</td><td>';
		//Possible TODO Show only tags which are included in given issues
		echo '<input type="submit" class="button" value="' . lang_get( 'tag_detach' ) . ' " /></td></tr>';

	 * Validates the Detach Tags group action.
	 * Gets called for every bug, but performs the real tag validation only
	 * the first time.  Any invalid tags will be skipped, as there is no simple
	 * or clean method of presenting these errors to the user.
	 * @param integer Bug ID
	 * @return boolean True
	function action_detach_tags_validate( $p_bug_id ) {
		global $g_action_detach_tags_valid;
		if ( !isset( $g_action_detach_tags_valid ) ) {
			$f_tag_string = gpc_get_string( 'tag_string' );
			$f_tag_select = gpc_get_string( 'tag_select' );

			global $g_action_detach_tags_detach, $g_action_detach_tags_failed;
			$g_action_detach_tags_detach = array();
			$g_action_detach_tags_failed = array();

			$t_tags = tag_parse_string( $f_tag_string );
			$t_can_detach = access_has_bug_level( config_get( 'tag_detach_threshold' ), $p_bug_id );

			foreach ( $t_tags as $t_tag_row ) {
				if ( -2 == $t_tag_row['id'] ) {
					$g_action_detach_tags_failed[] = $t_tag_row;
				} else if ( $t_can_detach ) {
					$g_action_detach_tags_detach[] = $t_tag_row;
				} else {
					$g_action_detach_tags_failed[] = $t_tag_row;

			if ( 0 < $f_tag_select && tag_exists( $f_tag_select ) ) {
				if ( $t_can_detach ) {
					$g_action_detach_tags_detach[] = tag_get( $f_tag_select );
				} else {
					$g_action_detach_tags_failed[] = tag_get( $f_tag_select );


		global $g_action_detach_tags_detach,  $g_action_detach_tags_failed;

		return true;

	 * Detaches all the tags to each bug in the group action.
	 * @param integer Bug ID
	 * @return boolean True if all tags detach properly
	function action_detach_tags_process( $p_bug_id ) {
		global $g_action_detach_tags_detach/*, $g_action_detach_tags_create*/;

		$t_user_id = auth_get_current_user_id();

		foreach( $g_action_detach_tags_detach as $t_tag_row ) {
			if ( tag_bug_is_attached( $t_tag_row['id'], $p_bug_id ) ) {
				tag_bug_detach( $t_tag_row['id'], $p_bug_id, $t_user_id );

		return true;


2013-10-02 04:01

reporter   ~0038181


since I'm new to all this, all I can offer is the enclosed file, which is a copy from the latest version on github of the bug_actiongroup_attach_tags_inc.php and then modified to be the detach group action (it has to be a new file anyway).

These two changes should go into the languages files (don't know how to do it)
$s_tag_detach_long= 'Detach Tags';
$s_actiongroup_menu_detach_tags='Detach Tags';

And a change in the config_defaults_inc.php - which should probably better be made in the bug_group_action_api.php (but I tried not to mess around with the corecode to stay compatible)

$g_custom_group_actions =array(
    array(  'action' => 'EXT_DETACH_TAGS',  
        'label' => 'actiongroup_menu_detach_tags' )


2016-06-25 09:40

reporter   ~0053447

I got this working on our Mantis install a few weeks back, and now that it's proved stable I'm happy to share how to implement this yourself. There are a few small changes and one entirely new file (which I've linked in the post).



2016-06-27 08:57

developer   ~0053467

@ObSkewer, thanks for your contribution.

It would be a lot better if you could submit it as a Github pull request (preferred), git-formatted patch or even unified diff, so we could review the code and eventually merge it without having to retype all the code changes from the screenshots in your blog. Thanks for your understanding.

Also, please note that updating config_defaults_inc.php is really not necessary here at all, since you're defining the group action in the core API.

Issue History

Date Modified Username Field Change
2008-11-06 23:29 olegos New Issue
2008-11-07 03:47 vboctor Status new => acknowledged
2013-03-13 07:47 pramsent Note Added: 0035847
2013-09-23 09:03 pramsent Note Added: 0038095
2013-09-23 09:31 dregad Note Added: 0038097
2013-10-02 03:53 pramsent File Added: bug_actiongroup_detach_tags_inc.php
2013-10-02 04:01 pramsent Note Added: 0038181
2016-06-25 09:40 ObSkewer Note Added: 0053447
2016-06-27 08:57 dregad Note Added: 0053467