SOAP API: do not try to unserialize an invalid filter
[mantis.git] / tag_update.php
blobae143739083a2165b3ce625b5a62fa8d4c491340
1 <?php
2 # MantisBT - A PHP based bugtracking system
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.
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.
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/>.
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
20 * @link http://www.mantisbt.org
22 * @uses core.php
23 * @uses access_api.php
24 * @uses authentication_api.php
25 * @uses compress_api.php
26 * @uses config_api.php
27 * @uses form_api.php
28 * @uses gpc_api.php
29 * @uses print_api.php
30 * @uses tag_api.php
31 * @uses user_api.php
34 /**
35 * MantisBT Core API's
37 require_once( 'core.php' );
38 require_api( 'access_api.php' );
39 require_api( 'authentication_api.php' );
40 require_api( 'compress_api.php' );
41 require_api( 'config_api.php' );
42 require_api( 'form_api.php' );
43 require_api( 'gpc_api.php' );
44 require_api( 'print_api.php' );
45 require_api( 'tag_api.php' );
46 require_api( 'user_api.php' );
48 form_security_validate( 'tag_update' );
50 compress_enable();
52 $f_tag_id = gpc_get_int( 'tag_id' );
53 $t_tag_row = tag_get( $f_tag_id );
55 if ( !( access_has_global_level( config_get( 'tag_edit_threshold' ) )
56 || ( auth_get_current_user_id() == $t_tag_row['user_id'] )
57 && access_has_global_level( config_get( 'tag_edit_own_threshold' ) ) ) )
59 access_denied();
62 if ( access_has_global_level( config_get( 'tag_edit_threshold' ) ) ) {
63 $f_new_user_id = gpc_get_int( 'user_id', $t_tag_row['user_id'] );
64 } else {
65 $f_new_user_id = $t_tag_row['user_id'];
68 $f_new_name = gpc_get_string( 'name', $t_tag_row['name'] );
69 $f_new_description = gpc_get_string( 'description', $t_tag_row['description'] );
71 $t_update = false;
73 if ( $t_tag_row['user_id'] != $f_new_user_id ) {
74 user_ensure_exists( $f_new_user_id );
75 $t_update = true;
78 if ( $t_tag_row['name'] != $f_new_name ||
79 $t_tag_row['description'] != $f_new_description ) {
81 $t_update = true;
84 tag_update( $f_tag_id, $f_new_name, $f_new_user_id, $f_new_description );
86 form_security_purge( 'tag_update' );
88 $t_url = 'tag_view_page.php?tag_id='.$f_tag_id;
89 print_successful_redirect( $t_url );