| [ 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 core.php 24 * @uses authentication_api.php 25 * @uses config_api.php 26 * @uses constant_inc.php 27 * @uses current_user_api.php 28 * @uses form_api.php 29 * @uses helper_api.php 30 * @uses html_api.php 31 * @uses lang_api.php 32 * @uses print_api.php 33 * @uses project_api.php 34 * @uses string_api.php 35 */ 36 37 /** 38 * MantisBT Core API's 39 */ 40 require_once ( 'core.php' ); 41 require_api( 'authentication_api.php' ); 42 require_api( 'config_api.php' ); 43 require_api( 'constant_inc.php' ); 44 require_api( 'current_user_api.php' ); 45 require_api( 'form_api.php' ); 46 require_api( 'helper_api.php' ); 47 require_api( 'html_api.php' ); 48 require_api( 'lang_api.php' ); 49 require_api( 'print_api.php' ); 50 require_api( 'project_api.php' ); 51 require_api( 'string_api.php' ); 52 53 auth_reauthenticate(); 54 55 /** 56 * array_merge_recursive2() 57 * 58 * Similar to array_merge_recursive but keyed-valued are always overwritten. 59 * Priority goes to the 2nd array. 60 * 61 * @static yes 62 * @public yes 63 * @param $paArray1 array 64 * @param $paArray2 array 65 * @return array 66 */ 67 function array_merge_recursive2($p_Array1, $p_Array2) { 68 if (!is_array($p_Array1) or !is_array($p_Array2)) { 69 return $p_Array2; 70 } 71 foreach ( $p_Array2 AS $t_Key2 => $t_Value2) { 72 $p_Array1[$t_Key2] = array_merge_recursive2( @$p_Array1[$t_Key2], $t_Value2); 73 } 74 return $p_Array1; 75 } 76 77 # -------------------- 78 # get_notify_flag cloned from email_notify_flag 79 # Get the value associated with the specific action and flag. 80 # For example, you can get the value associated with notifying "admin" 81 # on action "new", i.e. notify administrators on new bugs which can be 82 # ON or OFF. 83 function get_notify_flag( $action, $flag ) { 84 global $t_notify_flags, $t_default_notify_flags; 85 86 $val = OFF; 87 if ( isset ( $t_notify_flags[$action][$flag] ) ) { 88 $val = $t_notify_flags[$action][$flag]; 89 } else if ( isset ( $t_default_notify_flags[$flag] ) ) { 90 $val = $t_default_notify_flags[$flag]; 91 } 92 return $val; 93 } 94 95 function colour_notify_flag ( $p_action, $p_flag ) { 96 global $t_notify_flags, $t_global_notify_flags, $t_file_notify_flags, $t_colour_project, $t_colour_global; 97 98 $t_file = isset( $t_file_notify_flags[$p_action][$p_flag] ) ? ( $t_file_notify_flags[$p_action][$p_flag] ? 1 : 0 ): -1; 99 $t_global = isset( $t_global_notify_flags[$p_action][$p_flag] ) ? ( $t_global_notify_flags[$p_action][$p_flag] ? 1 : 0 ): -1; 100 $t_project = isset( $t_notify_flags[$p_action][$p_flag] ) ? ( $t_notify_flags[$p_action][$p_flag] ? 1 : 0 ): -1; 101 102 $t_colour = ''; 103 if ( $t_global >= 0 ) { 104 if ( $t_global != $t_file ) { 105 $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override 106 } 107 } 108 if ( $t_project >= 0 ) { 109 if ( $t_project != $t_global ) { 110 $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides 111 } 112 } 113 return $t_colour; 114 } 115 116 # Get the value associated with the specific action and flag. 117 function show_notify_flag( $p_action, $p_flag ) { 118 global $t_can_change_flags , $t_can_change_defaults; 119 $t_flag = get_notify_flag( $p_action, $p_flag ); 120 if ( $t_can_change_flags || $t_can_change_defaults ) { 121 $t_flag_name = $p_action . ':' . $p_flag; 122 $t_set = $t_flag ? "checked=\"checked\"" : ""; 123 return "<input type=\"checkbox\" name=\"flag[]\" value=\"$t_flag_name\" $t_set />"; 124 } else { 125 return ( $t_flag ? '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />' : ' ' ); 126 } 127 } 128 129 function colour_threshold_flag ( $p_access, $p_action ) { 130 global $t_notify_flags, $t_global_notify_flags, $t_file_notify_flags, $t_colour_project, $t_colour_global; 131 132 $t_file = ( $p_access >= $t_file_notify_flags[$p_action]['threshold_min'] ) 133 && ( $p_access <= $t_file_notify_flags[$p_action]['threshold_max'] ); 134 $t_global = ( $p_access >= $t_global_notify_flags[$p_action]['threshold_min'] ) 135 && ( $p_access <= $t_global_notify_flags[$p_action]['threshold_max'] ); 136 $t_project = ( $p_access >= $t_notify_flags[$p_action]['threshold_min'] ) 137 && ( $p_access <= $t_notify_flags[$p_action]['threshold_max'] ); 138 139 $t_colour = ''; 140 if ( $t_global != $t_file ) { 141 $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override 142 } 143 if ( $t_project != $t_global ) { 144 $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides 145 } 146 return $t_colour; 147 } 148 149 function show_notify_threshold( $p_access, $p_action ) { 150 global $t_can_change_flags , $t_can_change_defaults; 151 $t_flag = ( $p_access >= get_notify_flag( $p_action, 'threshold_min' ) ) 152 && ( $p_access <= get_notify_flag( $p_action, 'threshold_max' ) ); 153 if ( $t_can_change_flags || $t_can_change_defaults ) { 154 $t_flag_name = $p_action . ':' . $p_access; 155 $t_set = $t_flag ? "checked=\"checked\"" : ""; 156 return "<input type=\"checkbox\" name=\"flag_threshold[]\" value=\"$t_flag_name\" $t_set />"; 157 } else { 158 return $t_flag ? '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />' : ' '; 159 } 160 } 161 162 function get_section_begin_for_email( $p_section_name ) { 163 global $t_project; 164 $t_access_levels = MantisEnum::getValues( config_get( 'access_levels_enum_string' ) ); 165 echo '<table class="width100">'; 166 echo '<tr><td class="form-title-caps" colspan="' . ( count( $t_access_levels ) + 7 ) . '">' . $p_section_name . '</td></tr>' . "\n"; 167 echo '<tr><td class="form-title" width="30%" rowspan="2">' . lang_get( 'message' ) . '</td>'; 168 echo'<td class="form-title" style="text-align:center" rowspan="2"> ' . lang_get( 'issue_reporter' ) . ' </td>'; 169 echo '<td class="form-title" style="text-align:center" rowspan="2"> ' . lang_get( 'issue_handler' ) . ' </td>'; 170 echo '<td class="form-title" style="text-align:center" rowspan="2"> ' . lang_get( 'users_monitoring_bug' ) . ' </td>'; 171 echo '<td class="form-title" style="text-align:center" rowspan="2"> ' . lang_get( 'users_added_bugnote' ) . ' </td>'; 172 echo '<td class="form-title" style="text-align:center" colspan="' . count( $t_access_levels ) . '"> ' . lang_get( 'access_levels' ) . ' </td></tr><tr>'; 173 174 foreach( $t_access_levels as $t_access_level ) { 175 echo '<td class="form-title" style="text-align:center"> ' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), $t_access_level ) . ' </td>'; 176 } 177 178 echo '</tr>' . "\n"; 179 } 180 181 function get_capability_row_for_email( $p_caption, $p_message_type ) { 182 $t_access_levels = MantisEnum::getValues( config_get( 'access_levels_enum_string' ) ); 183 184 echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>'; 185 echo '<td class="center"' . colour_notify_flag( $p_message_type, 'reporter' ) . '>' . show_notify_flag( $p_message_type, 'reporter' ) . '</td>'; 186 echo '<td class="center"' . colour_notify_flag( $p_message_type, 'handler' ) . '>' . show_notify_flag( $p_message_type, 'handler' ) . '</td>'; 187 echo '<td class="center"' . colour_notify_flag( $p_message_type, 'monitor' ) . '>' . show_notify_flag( $p_message_type, 'monitor' ) . '</td>'; 188 echo '<td class="center"' . colour_notify_flag( $p_message_type, 'bugnotes' ) . '>' . show_notify_flag( $p_message_type, 'bugnotes' ) . '</td>'; 189 190 foreach( $t_access_levels as $t_access_level ) { 191 echo '<td class="center"' . colour_threshold_flag( $t_access_level, $p_message_type ) . '>' . show_notify_threshold( $t_access_level, $p_message_type ) . '</td>'; 192 } 193 194 echo '</tr>' . "\n"; 195 } 196 197 function get_section_end_for_email() { 198 echo '</table><br />' . "\n"; 199 } 200 201 202 html_page_top( lang_get( 'manage_email_config' ) ); 203 204 print_manage_menu( 'adm_permissions_report.php' ); 205 print_manage_config_menu( 'manage_config_email_page.php' ); 206 207 $t_access = current_user_get_access_level(); 208 $t_project = helper_get_current_project(); 209 210 $t_colour_project = config_get( 'colour_project'); 211 $t_colour_global = config_get( 'colour_global'); 212 213 # build a list of all of the actions 214 $t_actions = array( 'owner', 'reopened', 'deleted', 'bugnote' ); 215 if( config_get( 'enable_sponsorship' ) == ON ) { 216 $t_actions[] = 'sponsor'; 217 } 218 219 $t_actions[] = 'relationship'; 220 221 $t_statuses = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) ); 222 foreach( $t_statuses as $t_status ) { 223 $t_actions[] = $t_status; 224 } 225 226 # build a composite of the status flags, exploding the defaults 227 $t_global_default_notify_flags = config_get( 'default_notify_flags', null, null, ALL_PROJECTS ); 228 $t_global_notify_flags = array(); 229 foreach ( $t_global_default_notify_flags as $t_flag => $t_value ) { 230 foreach ($t_actions as $t_action ) { 231 $t_global_notify_flags[$t_action][$t_flag] = $t_value; 232 } 233 } 234 $t_global_notify_flags = array_merge_recursive2( $t_global_notify_flags, config_get( 'notify_flags', null, null, ALL_PROJECTS ) ); 235 236 $t_file_default_notify_flags = config_get_global( 'default_notify_flags' ); 237 $t_file_notify_flags = array(); 238 foreach ( $t_file_default_notify_flags as $t_flag => $t_value ) { 239 foreach ($t_actions as $t_action ) { 240 $t_file_notify_flags[$t_action][$t_flag] = $t_value; 241 } 242 } 243 $t_file_notify_flags = array_merge_recursive2( $t_file_notify_flags, config_get_global( 'notify_flags' ) ); 244 245 $t_default_notify_flags = config_get( 'default_notify_flags' ); 246 $t_notify_flags = array(); 247 foreach ( $t_default_notify_flags as $t_flag => $t_value ) { 248 foreach ($t_actions as $t_action ) { 249 $t_notify_flags[$t_action][$t_flag] = $t_value; 250 } 251 } 252 $t_notify_flags = array_merge_recursive2( $t_notify_flags, config_get( 'notify_flags' ) ); 253 254 $t_can_change_flags = $t_access >= config_get_access( 'notify_flags' ); 255 $t_can_change_defaults = $t_access >= config_get_access( 'default_notify_flags' ); 256 257 echo '<br /><br />'; 258 259 # Email notifications 260 if( config_get( 'enable_email_notification' ) == ON ) { 261 262 if ( $t_can_change_flags || $t_can_change_defaults ) { 263 echo "<form name=\"mail_config_action\" method=\"post\" action=\"manage_config_email_set.php\">\n"; 264 echo form_security_field( 'manage_config_email_set' ); 265 } 266 267 if ( ALL_PROJECTS == $t_project ) { 268 $t_project_title = lang_get( 'config_all_projects' ); 269 } else { 270 $t_project_title = sprintf( lang_get( 'config_project' ) , string_display( project_get_name( $t_project ) ) ); 271 } 272 echo '<p class="bold">' . $t_project_title . '</p>' . "\n"; 273 echo '<p>' . lang_get( 'colour_coding' ) . '<br />'; 274 if ( ALL_PROJECTS <> $t_project ) { 275 echo '<span style="background-color:' . $t_colour_project . '">' . lang_get( 'colour_project' ) . '</span><br />'; 276 } 277 echo '<span style="background-color:' . $t_colour_global . '">' . lang_get( 'colour_global' ) . '</span></p>'; 278 279 get_section_begin_for_email( lang_get( 'email_notification' ) ); 280 # get_capability_row_for_email( lang_get( 'email_on_new' ), 'new' ); # duplicate of status change to 'new' 281 get_capability_row_for_email( lang_get( 'email_on_assigned' ), 'owner' ); 282 get_capability_row_for_email( lang_get( 'email_on_reopened' ), 'reopened' ); 283 get_capability_row_for_email( lang_get( 'email_on_deleted' ), 'deleted' ); 284 get_capability_row_for_email( lang_get( 'email_on_bugnote_added' ), 'bugnote' ); 285 if( config_get( 'enable_sponsorship' ) == ON ) { 286 get_capability_row_for_email( lang_get( 'email_on_sponsorship_changed' ), 'sponsor' ); 287 } 288 289 get_capability_row_for_email( lang_get( 'email_on_relationship_changed' ), 'relationship' ); 290 291 $t_statuses = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) ); 292 foreach ( $t_statuses as $t_status => $t_label ) { 293 get_capability_row_for_email( lang_get( 'status_changed_to' ) . ' \'' . get_enum_element( 'status', $t_status ) . '\'', $t_label ); 294 } 295 296 get_section_end_for_email(); 297 298 if ( $t_can_change_flags || $t_can_change_defaults ) { 299 echo '<p>' . lang_get( 'notify_actions_change_access' ); 300 echo '<select name="notify_actions_access">'; 301 print_enum_string_option_list( 'access_levels', config_get_access( 'notify_flags' ) ); 302 echo '</select> </p>'; 303 304 echo "<input type=\"submit\" class=\"button\" value=\"" . lang_get( 'change_configuration' ) . "\" />\n"; 305 306 echo "</form>\n"; 307 308 echo "<div class=\"right\"><form name=\"mail_config_action\" method=\"post\" action=\"manage_config_revert.php\">\n"; 309 echo form_security_field( 'manage_config_revert' ); 310 echo "<input name=\"revert\" type=\"hidden\" value=\"notify_flags,default_notify_flags\"></input>"; 311 echo "<input name=\"project\" type=\"hidden\" value=\"$t_project\"></input>"; 312 echo "<input name=\"return\" type=\"hidden\" value=\"\"></input>"; 313 echo "<input type=\"submit\" class=\"button\" value=\""; 314 if ( ALL_PROJECTS == $t_project ) { 315 echo lang_get( 'revert_to_system' ); 316 } else { 317 echo lang_get( 'revert_to_all_project' ); 318 } 319 echo "\" />\n"; 320 echo "</form></div>\n"; 321 } 322 323 } 324 325 html_page_bottom();
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 |