| [ 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 access_api.php 25 * @uses authentication_api.php 26 * @uses config_api.php 27 * @uses constant_inc.php 28 * @uses current_user_api.php 29 * @uses form_api.php 30 * @uses gpc_api.php 31 * @uses helper_api.php 32 * @uses html_api.php 33 * @uses lang_api.php 34 * @uses print_api.php 35 */ 36 37 /** 38 * MantisBT Core API's 39 */ 40 require_once ( 'core.php' ); 41 require_api( 'access_api.php' ); 42 require_api( 'authentication_api.php' ); 43 require_api( 'config_api.php' ); 44 require_api( 'constant_inc.php' ); 45 require_api( 'current_user_api.php' ); 46 require_api( 'form_api.php' ); 47 require_api( 'gpc_api.php' ); 48 require_api( 'helper_api.php' ); 49 require_api( 'html_api.php' ); 50 require_api( 'lang_api.php' ); 51 require_api( 'print_api.php' ); 52 53 form_security_validate('manage_config_email_set'); 54 55 auth_reauthenticate(); 56 57 $t_can_change_level = min( config_get_access( 'notify_flags' ), config_get_access( 'default_notify_flags' ) ); 58 access_ensure_project_level( $t_can_change_level ); 59 60 $t_redirect_url = 'manage_config_email_page.php'; 61 $t_project = helper_get_current_project(); 62 63 $f_flags = gpc_get( 'flag', array() ); 64 $f_thresholds = gpc_get( 'flag_threshold', array() ); 65 $f_actions_access = gpc_get_int( 'notify_actions_access' ); 66 67 html_page_top( lang_get( 'manage_email_config' ), $t_redirect_url ); 68 69 $t_access = current_user_get_access_level(); 70 $t_can_change_flags = $t_access >= config_get_access( 'notify_flags' ); 71 $t_can_change_defaults = $t_access >= config_get_access( 'default_notify_flags' ); 72 73 # build a list of the possible actions and flags 74 $t_valid_actions = array( 'owner', 'reopened', 'deleted', 'bugnote' ); 75 if( config_get( 'enable_sponsorship' ) == ON ) { 76 $t_valid_actions[] = 'sponsor'; 77 } 78 79 $t_valid_actions[] = 'relationship'; 80 81 $t_statuses = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) ); 82 ksort( $t_statuses ); 83 reset( $t_statuses ); 84 85 foreach( $t_statuses as $t_status => $t_label ) { 86 $t_valid_actions[] = $t_label; 87 } 88 $t_valid_flags = array( 'reporter', 'handler', 'monitor' , 'bugnotes' ); 89 90 # initialize the thresholds 91 foreach( $t_valid_actions as $t_action ) { 92 $t_thresholds_min[$t_action] = NOBODY; 93 $t_thresholds_max[$t_action] = ANYBODY; 94 } 95 96 97 # parse flags and thresholds 98 foreach( $f_flags as $t_flag_value ) { 99 list( $t_action, $t_flag ) = explode( ':', $t_flag_value ); 100 $t_flags[$t_action][$t_flag] = ON; 101 } 102 foreach( $f_thresholds as $t_threshold_value ) { 103 list( $t_action, $t_threshold ) = explode( ':', $t_threshold_value ); 104 if ( $t_threshold < $t_thresholds_min[$t_action] ) { 105 $t_thresholds_min[$t_action] = $t_threshold; 106 } 107 if ( $t_threshold > $t_thresholds_max[$t_action] ) { 108 $t_thresholds_max[$t_action] = $t_threshold; 109 } 110 } 111 112 # if we can set defaults, find them 113 if ( $t_can_change_defaults ) { 114 $t_first = true; 115 116 # for flags, assume they are true, unless one of the actions has them off 117 foreach ( $t_valid_flags as $t_flag ) { 118 $t_default_flags[$t_flag] = ON; 119 foreach ( $t_valid_actions as $t_action ) { 120 if ( !isset( $t_flags[$t_action][$t_flag] ) ) { 121 unset( $t_default_flags[$t_flag] ); 122 } 123 } 124 } 125 # for thresholds, find the subset that matches all of the actions 126 $t_default_min = ANYBODY; 127 $t_default_max = NOBODY; 128 foreach ( $t_valid_actions as $t_action ) { 129 if ( $t_default_max > $t_thresholds_max[$t_action] ) { 130 $t_default_max = $t_thresholds_max[$t_action]; 131 } 132 if ( $t_default_min < $t_thresholds_min[$t_action] ) { 133 $t_default_min = $t_thresholds_min[$t_action]; 134 } 135 } 136 $t_default_flags['threshold_min'] = $t_default_min; 137 $t_default_flags['threshold_max'] = $t_default_max; 138 139 $t_existing_default_flags = config_get( 'default_notify_flags' ); 140 $t_existing_default_access = config_get_access( 'default_notify_flags' ); 141 if ( ( $t_existing_default_flags != $t_default_flags ) 142 || ( $t_existing_default_access != $f_actions_access ) ) { # only set the flags if they are different 143 config_set( 'default_notify_flags', $t_default_flags, NO_USER, $t_project, $f_actions_access ); 144 } 145 } else { 146 $t_default_flags = config_get( 'default_notify_flags' ); 147 } 148 149 # set the values for specific actions if different from the defaults 150 $t_notify_flags = array(); 151 foreach ( $t_valid_actions as $t_action ) { 152 $t_action_printed = false; 153 foreach ( $t_valid_flags as $t_flag ) { 154 if ( !isset( $t_default_flags[$t_flag] ) ) { 155 $t_default_flags[$t_flag] = OFF; 156 } 157 if ( isset( $t_flags[$t_action][$t_flag] ) <> $t_default_flags[$t_flag] ) { 158 $t_notify_flags[$t_action][$t_flag] = isset( $t_flags[$t_action][$t_flag] ) ? ON : OFF; 159 } 160 } 161 if ( $t_default_flags['threshold_min'] <> $t_thresholds_min[$t_action] ) { 162 $t_notify_flags[$t_action]['threshold_min'] = $t_thresholds_min[$t_action]; 163 } 164 if ( $t_default_flags['threshold_max'] <> $t_thresholds_max[$t_action] ) { 165 $t_notify_flags[$t_action]['threshold_max'] = $t_thresholds_max[$t_action]; 166 } 167 } 168 if ( isset( $t_notify_flags ) ) { 169 $t_existing_flags = config_get( 'notify_flags' ); 170 $t_existing_access = config_get_access( 'notify_flags' ); 171 if ( ( $t_existing_flags != $t_notify_flags ) 172 || ( $t_existing_access != $f_actions_access ) ) { # only set the flags if they are different 173 config_set( 'notify_flags', $t_notify_flags, NO_USER, $t_project, $f_actions_access ); 174 } 175 } 176 177 form_security_purge('manage_config_email_set'); 178 ?> 179 180 <br /> 181 <div> 182 <?php 183 echo lang_get( 'operation_successful' ) . '<br />'; 184 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); 185 ?> 186 </div> 187 188 <?php 189 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 |