| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
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 * @package MantisBT 19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 21 * @link http://www.mantisbt.org 22 * 23 * @uses access_api.php 24 * @uses authentication_api.php 25 * @uses config_api.php 26 * @uses gpc_api.php 27 * @uses helper_api.php 28 * @uses lang_api.php 29 * @uses print_api.php 30 * @uses tag_api.php 31 */ 32 33 if ( !defined( 'BUG_ACTIONGROUP_ATTACH_TAGS_INC_ALLOW' ) ) { 34 return; 35 } 36 37 require_api( 'access_api.php' ); 38 require_api( 'authentication_api.php' ); 39 require_api( 'config_api.php' ); 40 require_api( 'gpc_api.php' ); 41 require_api( 'helper_api.php' ); 42 require_api( 'lang_api.php' ); 43 require_api( 'print_api.php' ); 44 require_api( 'tag_api.php' ); 45 46 /** 47 * Prints the title for the custom action page. 48 */ 49 function action_attach_tags_print_title() { 50 echo '<tr class="form-title">'; 51 echo '<td colspan="2">'; 52 echo lang_get( 'tag_attach_long' ); 53 echo '</td></tr>'; 54 } 55 56 /** 57 * Prints the table and form for the Attach Tags group action page. 58 */ 59 function action_attach_tags_print_fields() { 60 echo '<tr ',helper_alternate_class(),'><th class="category">',lang_get('tag_attach_long'),'</th><td>'; 61 print_tag_input(); 62 echo '<input type="submit" class="button" value="' . lang_get( 'tag_attach' ) . ' " /></td></tr>'; 63 } 64 65 /** 66 * Validates the Attach Tags group action. 67 * Checks if a user can attach the requested tags to a given bug. 68 * @param integer Bug ID 69 * @return string|null On failure: the reason for tags failing validation for the given bug. On success: null. 70 */ 71 function action_attach_tags_validate( $p_bug_id ) { 72 global $g_action_attach_tags_tags; 73 global $g_action_attach_tags_attach; 74 global $g_action_attach_tags_create; 75 76 $t_can_attach = access_has_bug_level( config_get( 'tag_attach_threshold' ), $p_bug_id ); 77 if( !$t_can_attach ) { 78 return lang_get( 'tag_attach_denied' ); 79 } 80 81 if( !isset( $g_action_attach_tags_tags ) ) { 82 if( !isset( $g_action_attach_tags_attach ) ) { 83 $g_action_attach_tags_attach = array(); 84 $g_action_attach_tags_create = array(); 85 } 86 $g_action_attach_tags_tags = tag_parse_string( gpc_get_string( 'tag_string' ) ); 87 foreach ( $g_action_attach_tags_tags as $t_tag_row ) { 88 if ( $t_tag_row['id'] == -1 ) { 89 $g_action_attach_tags_create[$t_tag_row['name']] = $t_tag_row; 90 } else if( $t_tag_row['id'] >= 0 ) { 91 $g_action_attach_tags_attach[$t_tag_row['name']] = $t_tag_row; 92 } 93 } 94 } 95 96 $t_can_create = access_has_bug_level( config_get( 'tag_create_threshold' ), $p_bug_id ); 97 if( count( $g_action_attach_tags_create ) > 0 && !$t_can_create ) { 98 return lang_get( 'tag_create_denied' ); 99 } 100 101 if( count( $g_action_attach_tags_create ) == 0 && 102 count( $g_action_attach_tags_attach ) == 0 ) { 103 return lang_get( 'tag_none_attached' ); 104 } 105 106 return null; 107 } 108 109 /** 110 * Attaches all the tags to each bug in the group action. 111 * @param integer Bug ID 112 * @return null Previous validation ensures that this function doesn't fail. Therefore we can always return null to indicate no errors occurred. 113 */ 114 function action_attach_tags_process( $p_bug_id ) { 115 global $g_action_attach_tags_attach, $g_action_attach_tags_create; 116 117 $t_user_id = auth_get_current_user_id(); 118 119 foreach( $g_action_attach_tags_create as $t_tag_row ) { 120 $t_tag_row['id'] = tag_create( $t_tag_row['name'], $t_user_id ); 121 $g_action_attach_tags_attach[] = $t_tag_row; 122 } 123 $g_action_attach_tags_create = array(); 124 125 foreach( $g_action_attach_tags_attach as $t_tag_row ) { 126 if ( !tag_bug_is_attached( $t_tag_row['id'], $p_bug_id ) ) { 127 tag_bug_attach( $t_tag_row['id'], $p_bug_id, $t_user_id ); 128 } 129 } 130 131 return null; 132 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |