1<?php
2# MantisBT - A PHP based bugtracking system
3
4# MantisBT is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 2 of the License, or
7# (at your option) any later version.
8#
9# MantisBT is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Tag Update
19 *
20 * @package MantisBT
21 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
22 * @link http://www.mantisbt.org
23 *
24 * @uses core.php
25 * @uses access_api.php
26 * @uses authentication_api.php
27 * @uses compress_api.php
28 * @uses config_api.php
29 * @uses form_api.php
30 * @uses gpc_api.php
31 * @uses print_api.php
32 * @uses tag_api.php
33 * @uses user_api.php
34 */
35
36require_once( 'core.php' );
37require_api( 'access_api.php' );
38require_api( 'authentication_api.php' );
39require_api( 'compress_api.php' );
40require_api( 'config_api.php' );
41require_api( 'form_api.php' );
42require_api( 'gpc_api.php' );
43require_api( 'print_api.php' );
44require_api( 'tag_api.php' );
45require_api( 'user_api.php' );
46
47form_security_validate( 'tag_update' );
48
49compress_enable();
50
51$f_tag_id = gpc_get_int( 'tag_id' );
52tag_ensure_exists( $f_tag_id );
53$t_tag_row = tag_get( $f_tag_id );
54
55$t_can_edit = access_has_global_level( config_get( 'tag_edit_threshold' ) );
56if( $t_can_edit ) {
57	$f_new_user_id = gpc_get_int( 'user_id', $t_tag_row['user_id'] );
58} else {
59	$t_can_edit_own_tag = access_has_global_level( config_get( 'tag_edit_own_threshold' ) );
60	if( !( $t_can_edit_own_tag && auth_get_current_user_id() == $t_tag_row['user_id'] ) ) {
61		access_denied();
62	}
63	# Never change the owner when user is editing their own tag
64	$f_new_user_id = $t_tag_row['user_id'];
65}
66
67$f_new_name = gpc_get_string( 'name', $t_tag_row['name'] );
68$f_new_description = gpc_get_string( 'description', $t_tag_row['description'] );
69
70tag_update( $f_tag_id, $f_new_name, $f_new_user_id, $f_new_description );
71
72form_security_purge( 'tag_update' );
73
74$t_url = 'tag_view_page.php?tag_id='.$f_tag_id;
75print_successful_redirect( $t_url );
76