|
|
ef5584 |
|
|
|
ef5584 |
# Mantis - a php based bugtracking system
|
|
|
ef5584 |
|
|
|
ef5584 |
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
|
|
|
ef5584 |
# Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net
|
|
|
ef5584 |
|
|
|
ef5584 |
# Mantis is free software: you can redistribute it and/or modify
|
|
|
ef5584 |
# it under the terms of the GNU General Public License as published by
|
|
|
ef5584 |
# the Free Software Foundation, either version 2 of the License, or
|
|
|
ef5584 |
# (at your option) any later version.
|
|
|
ef5584 |
#
|
|
|
ef5584 |
# Mantis is distributed in the hope that it will be useful,
|
|
|
ef5584 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ef5584 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
ef5584 |
# GNU General Public License for more details.
|
|
|
ef5584 |
#
|
|
|
ef5584 |
# You should have received a copy of the GNU General Public License
|
|
|
ef5584 |
# along with Mantis. If not, see <http://www.gnu.org/licenses/>.
|
|
|
ef5584 |
|
|
|
ef5584 |
#------------------------------
|
|
|
ef5584 |
# $Revision: 2643 $
|
|
|
ef5584 |
# $Author: al $
|
|
|
ef5584 |
# $Date: 2009-06-18 19:06:27 -0400 (Thu, 18 Jun 2009) $
|
|
|
ef5584 |
#------------------------------
|
|
|
ef5584 |
|
|
|
ef5584 |
require_once( 'core.php' );
|
|
|
ef5584 |
|
|
|
ef5584 |
$t_core_path = config_get( 'core_path' );
|
|
|
ef5584 |
require_once( $t_core_path.'email_api.php' );
|
|
|
ef5584 |
|
|
|
ef5584 |
auth_reauthenticate();
|
|
|
ef5584 |
|
|
|
ef5584 |
form_security_validate('manage_config_email_set');
|
|
|
ef5584 |
|
|
|
ef5584 |
$t_can_change_level = min( config_get_access( 'notify_flags' ), config_get_access( 'default_notify_flags' ) );
|
|
|
ef5584 |
access_ensure_project_level( $t_can_change_level );
|
|
|
ef5584 |
|
|
|
ef5584 |
$t_redirect_url = 'manage_config_email_page.php';
|
|
|
ef5584 |
$t_project = helper_get_current_project();
|
|
|
ef5584 |
|
|
|
ef5584 |
$f_flags = gpc_get( 'flag', array() );
|
|
|
ef5584 |
$f_thresholds = gpc_get( 'flag_threshold', array() );
|
|
|
ef5584 |
$f_actions_access = gpc_get_int( 'notify_actions_access' );
|
|
|
ef5584 |
|
|
|
ef5584 |
html_page_top1( lang_get( 'manage_email_config' ) );
|
|
|
ef5584 |
html_meta_redirect( $t_redirect_url );
|
|
|
ef5584 |
html_page_top2();
|
|
|
ef5584 |
|
|
|
ef5584 |
$t_access = current_user_get_access_level();
|
|
|
ef5584 |
$t_can_change_flags = $t_access >= config_get_access( 'notify_flags' );
|
|
|
ef5584 |
$t_can_change_defaults = $t_access >= config_get_access( 'default_notify_flags' );
|
|
|
ef5584 |
|
|
|
ef5584 |
# build a list of the possible actions and flags
|
|
|
ef5584 |
$t_valid_actions = array( 'owner', 'reopened', 'deleted', 'bugnote' );
|
|
|
ef5584 |
if( config_get( 'enable_sponsorship' ) == ON ) {
|
|
|
ef5584 |
$t_valid_actions[] = 'sponsor';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
if( config_get( 'enable_relationship' ) == ON ) {
|
|
|
ef5584 |
$t_valid_actions[] = 'relationship';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$t_statuses = get_enum_to_array( config_get( 'status_enum_string' ) );
|
|
|
ef5584 |
ksort( $t_statuses );
|
|
|
ef5584 |
reset( $t_statuses );
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach( $t_statuses as $t_status => $t_label ) {
|
|
|
ef5584 |
$t_valid_actions[] = $t_label;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$t_valid_flags = array( 'reporter', 'handler', 'monitor' , 'bugnotes' );
|
|
|
ef5584 |
|
|
|
ef5584 |
# initialize the thresholds
|
|
|
ef5584 |
foreach( $t_valid_actions as $t_action ) {
|
|
|
ef5584 |
$t_thresholds_min[$t_action] = NOBODY;
|
|
|
ef5584 |
$t_thresholds_max[$t_action] = ANYBODY;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
# parse flags and thresholds
|
|
|
ef5584 |
foreach( $f_flags as $t_flag_value ) {
|
|
|
ef5584 |
list( $t_action, $t_flag ) = split( ':', $t_flag_value );
|
|
|
ef5584 |
$t_flags[$t_action][$t_flag] = ON;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
foreach( $f_thresholds as $t_threshold_value ) {
|
|
|
ef5584 |
list( $t_action, $t_threshold ) = split( ':', $t_threshold_value );
|
|
|
ef5584 |
if ( $t_threshold < $t_thresholds_min[$t_action] ) {
|
|
|
ef5584 |
$t_thresholds_min[$t_action] = $t_threshold;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
if ( $t_threshold > $t_thresholds_max[$t_action] ) {
|
|
|
ef5584 |
$t_thresholds_max[$t_action] = $t_threshold;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
# if we can set defaults, find them
|
|
|
ef5584 |
if ( $t_can_change_defaults ) {
|
|
|
ef5584 |
$t_first = true;
|
|
|
ef5584 |
|
|
|
ef5584 |
# for flags, assume they are true, unless one of the actions has them off
|
|
|
ef5584 |
foreach ( $t_valid_flags as $t_flag ) {
|
|
|
ef5584 |
$t_default_flags[$t_flag] = ON;
|
|
|
ef5584 |
foreach ( $t_valid_actions as $t_action ) {
|
|
|
ef5584 |
if ( ! isset( $t_flags[$t_action][$t_flag] ) ) {
|
|
|
ef5584 |
unset( $t_default_flags[$t_flag] );
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
# for thresholds, find the subset that matches all of the actions
|
|
|
ef5584 |
$t_default_min = ANYBODY;
|
|
|
ef5584 |
$t_default_max = NOBODY;
|
|
|
ef5584 |
foreach ( $t_valid_actions as $t_action ) {
|
|
|
ef5584 |
if ( $t_default_max > $t_thresholds_max[$t_action] ) {
|
|
|
ef5584 |
$t_default_max = $t_thresholds_max[$t_action];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
if ( $t_default_min < $t_thresholds_min[$t_action] ) {
|
|
|
ef5584 |
$t_default_min = $t_thresholds_min[$t_action];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$t_default_flags['threshold_min'] = $t_default_min;
|
|
|
ef5584 |
$t_default_flags['threshold_max'] = $t_default_max;
|
|
|
ef5584 |
|
|
|
ef5584 |
$t_existing_default_flags = config_get( 'default_notify_flags' );
|
|
|
ef5584 |
if ( $t_existing_default_flags != $t_default_flags ) { # only set the flags if they are different
|
|
|
ef5584 |
config_set( 'default_notify_flags', $t_default_flags, NO_USER, $t_project, $f_actions_access );
|
|
|
ef5584 |
}
|
|
|
ef5584 |
} else {
|
|
|
ef5584 |
$t_default_flags = config_get( 'default_notify_flags' );
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
# set the values for specific actions if different from the defaults
|
|
|
ef5584 |
$t_notify_flags = array();
|
|
|
ef5584 |
foreach ( $t_valid_actions as $t_action ) {
|
|
|
ef5584 |
$t_action_printed = false;
|
|
|
ef5584 |
foreach ( $t_valid_flags as $t_flag ) {
|
|
|
ef5584 |
if ( ! isset( $t_default_flags[$t_flag] ) ) {
|
|
|
ef5584 |
$t_default_flags[$t_flag] = OFF;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
if ( isset( $t_flags[$t_action][$t_flag] ) <> $t_default_flags[$t_flag] ) {
|
|
|
ef5584 |
$t_notify_flags[$t_action][$t_flag] = isset( $t_flags[$t_action][$t_flag] ) ? ON : OFF;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
if ( $t_default_flags['threshold_min'] <> $t_thresholds_min[$t_action] ) {
|
|
|
ef5584 |
$t_notify_flags[$t_action]['threshold_min'] = $t_thresholds_min[$t_action];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
if ( $t_default_flags['threshold_max'] <> $t_thresholds_max[$t_action] ) {
|
|
|
ef5584 |
$t_notify_flags[$t_action]['threshold_max'] = $t_thresholds_max[$t_action];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
if ( isset( $t_notify_flags ) ) {
|
|
|
ef5584 |
$t_existing_flags = config_get( 'notify_flags' );
|
|
|
ef5584 |
if ( $t_existing_flags != $t_notify_flags ) { # only set the flags if they are different
|
|
|
ef5584 |
config_set( 'notify_flags', $t_notify_flags, NO_USER, $t_project, $f_actions_access );
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
echo '' . lang_get( 'operation_successful' ) . ' ';
|
|
|
ef5584 |
print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
|
|
|
ef5584 |
?>
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
|