Пример #1
0
/**
 * Retrieves the access level needed to change the configuration option in the
 * project's parent (ALL_PROJECTS level if project, or file-level if all projects)
 * @param integer $p_project Project.
 * @param string  $p_option  Configuration option to retrieve.
 * @return integer access level
 */
function config_get_access_parent($p_project, $p_option)
{
    if ($p_project == ALL_PROJECTS) {
        return config_get_global('admin_site_threshold');
    } else {
        return config_get_access($p_option, null, ALL_PROJECTS);
    }
}
function set_capability_enum($p_threshold, $p_all_projects_only = false)
{
    global $t_access, $t_project;
    if ($t_access >= config_get_access($p_threshold) && (ALL_PROJECTS == $t_project || !$p_all_projects_only)) {
        $f_flag = gpc_get('flag_' . $p_threshold);
        $f_access = gpc_get_int('access_' . $p_threshold);
        # @@debug @@ echo "<br />for $p_threshold "; var_dump($f_flag, $f_access); echo '<br />';
        if ($f_flag != config_get($p_threshold)) {
            config_set($p_threshold, $f_flag, NO_USER, $t_project, $f_access);
        }
    }
}
function get_capability_enum($p_caption, $p_threshold, $p_enum, $p_all_projects_only = false)
{
    global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
    $t_file = config_get_global($p_threshold);
    $t_global = config_get($p_threshold, null, null, ALL_PROJECTS);
    $t_project = config_get($p_threshold);
    $t_can_change = access_has_project_level(config_get_access($p_threshold), $t_project_id, $t_user) && (ALL_PROJECTS == $t_project_id || !$p_all_projects_only);
    $t_colour = '';
    if ($t_global != $t_file) {
        $t_colour = ' bgcolor="' . $t_colour_global . '" ';
        # all projects override
        if ($t_can_change) {
            set_overrides($p_threshold);
        }
    }
    if ($t_project != $t_global) {
        $t_colour = ' bgcolor="' . $t_colour_project . '" ';
        # project overrides
        if ($t_can_change) {
            set_overrides($p_threshold);
        }
    }
    echo '<tr ' . helper_alternate_class() . '><td>' . string_display($p_caption) . '</td>';
    if ($t_can_change) {
        echo '<td class="left" colspan="3"' . $t_colour . '><select name="flag_' . $p_threshold . '">';
        print_enum_string_option_list($p_enum, config_get($p_threshold));
        echo '</select></td><td colspan="' . (count($t_access_levels) - 3) . '"></td>';
        $t_show_submit = true;
    } else {
        $t_value = MantisEnum::getLabel(lang_get($p_enum . '_enum_string'), config_get($p_threshold)) . '&nbsp;';
        echo '<td class="left" colspan="3"' . $t_colour . '>' . $t_value . '</td><td colspan="' . (count($t_access_levels) - 3) . '"></td>';
    }
    if ($t_can_change) {
        echo '<td><select name="access_' . $p_threshold . '">';
        print_enum_string_option_list('access_levels', config_get_access($p_threshold));
        echo '</select> </td>';
    } else {
        echo '<td>' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), config_get_access($p_threshold)) . '&nbsp;</td>';
    }
    echo '</tr>' . "\n";
}
 get_capability_row_for_email(lang_get('email_on_reopened'), 'reopened');
 get_capability_row_for_email(lang_get('email_on_deleted'), 'deleted');
 get_capability_row_for_email(lang_get('email_on_bugnote_added'), 'bugnote');
 if (config_get('enable_sponsorship') == ON) {
     get_capability_row_for_email(lang_get('email_on_sponsorship_changed'), 'sponsor');
 }
 get_capability_row_for_email(lang_get('email_on_relationship_changed'), 'relation');
 $t_statuses = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
 foreach ($t_statuses as $t_status => $t_label) {
     get_capability_row_for_email(lang_get('status_changed_to') . ' \'' . get_enum_element('status', $t_status) . '\'', $t_label);
 }
 get_section_end_for_email();
 if ($g_can_change_flags || $g_can_change_defaults) {
     echo '<p>' . lang_get('notify_actions_change_access') . "\n";
     echo '<select name="notify_actions_access">' . "\n";
     print_enum_string_option_list('access_levels', config_get_access('notify_flags'));
     echo "\n</select></p>";
     echo '<input type="submit" class="button" value="' . lang_get('change_configuration') . '" />' . "\n";
     echo "</form>\n";
     echo '<div class="right">' . "\n";
     echo '<form id="mail_config_action" method="post" action="manage_config_revert.php">' . "\n";
     echo form_security_field('manage_config_revert') . "\n";
     echo '<input name="revert" type="hidden" value="notify_flags,default_notify_flags" />' . "\n";
     echo '<input name="project" type="hidden" value="' . $t_project . '" />' . "\n";
     echo '<input name="return" type="hidden" value="' . string_attribute(form_action_self()) . '" />' . "\n";
     echo '<input type="submit" class="button" value="';
     if (ALL_PROJECTS == $t_project) {
         echo lang_get('revert_to_system');
     } else {
         echo lang_get('revert_to_all_project');
     }
Пример #5
0
/**
 * access section end
 * @return void
 */
function access_end()
{
    global $g_access;
    echo '</tbody></table>' . "\n";
    echo '<div class="footer">' . "\n";
    if ($g_access >= config_get_access('set_status_threshold')) {
        echo lang_get('access_change_access_label') . "&nbsp;\n";
        echo '<select name="status_access">' . "\n\t\t";
        print_enum_string_option_list('access_levels', config_get_access('set_status_threshold'));
        echo "\n" . '</select>' . "\n";
    }
    echo '</div>' . "\n";
    echo '</div>' . "\n";
    echo '<br />' . "\n\n";
}
Пример #6
0
require_api('helper_api.php');
require_api('html_api.php');
require_api('lang_api.php');
require_api('print_api.php');
require_api('project_api.php');
require_api('string_api.php');
form_security_validate('manage_config_revert');
auth_reauthenticate();
$f_project_id = gpc_get_int('project', 0);
$f_revert = gpc_get_string('revert', '');
$f_return = gpc_get_string('return');
$t_access = true;
$t_revert_vars = explode(',', $f_revert);
array_walk($t_revert_vars, 'trim');
foreach ($t_revert_vars as $t_revert) {
    $t_access &= access_has_project_level(config_get_access($t_revert), $f_project_id);
}
if (!$t_access) {
    access_denied();
}
if ('' != $f_revert) {
    # Confirm with the user
    helper_ensure_confirmed(lang_get('config_delete_sure') . lang_get('word_separator') . string_html_specialchars(implode(', ', $t_revert_vars)) . lang_get('word_separator') . lang_get('in_project') . lang_get('word_separator') . project_get_name($f_project_id), lang_get('delete_config_button'));
    foreach ($t_revert_vars as $t_revert) {
        config_delete($t_revert, null, $f_project_id);
    }
}
form_security_purge('manage_config_revert');
$t_redirect_url = $f_return;
html_page_top(null, $t_redirect_url);
html_operation_successful($t_redirect_url);
function access_row()
{
    global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
    $t_enum_status = get_enum_to_array(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, null, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get_global('update_bug_status_threshold');
        }
    }
    $t_global_set = config_get('set_status_threshold', null, null, ALL_PROJECTS);
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold', null, null, ALL_PROJECTS);
        }
    }
    $t_project_set = config_get('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold');
        }
    }
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo '<tr ' . helper_alternate_class() . '><td width="30%">' . string_no_break(get_enum_to_string(lang_get('status_enum_string'), $t_status)) . '</td>';
        if (NEW_ == $t_status) {
            $t_level = $t_project_new;
            $t_can_change = $t_access >= config_get_access('report_bug_threshold');
            $t_colour = '';
            if ($t_global_new != $t_file_new) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
            if ($t_project_new != $t_global_new) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
        } else {
            $t_level = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : false;
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : false;
            $t_level_file = isset($t_file_set[$t_status]) ? $t_file_set[$t_status] : false;
            $t_can_change = $t_access >= config_get_access('set_status_threshold');
            $t_colour = '';
            if ($t_level_global != $t_level_file) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
            if ($t_level != $t_level_global) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
        }
        if ($t_can_change) {
            echo '<td' . $t_colour . '><select name="access_change_' . $t_status . '">';
            print_enum_string_option_list('access_levels', $t_level);
            echo '</select> </td>';
            $t_can_change_flags = true;
        } else {
            echo '<td class="center"' . $t_colour . '>' . get_enum_to_string(config_get('access_levels_enum_string'), $t_level) . '</td>';
        }
        echo '</tr>' . "\n";
    }
}
            $t_default_flags[$t_flag] = OFF;
        }
        if (isset($t_flags[$t_action][$t_flag]) != $t_default_flags[$t_flag]) {
            $t_notify_flags[$t_action][$t_flag] = isset($t_flags[$t_action][$t_flag]) ? ON : OFF;
        }
    }
    if ($t_default_flags['threshold_min'] != $t_thresholds_min[$t_action]) {
        $t_notify_flags[$t_action]['threshold_min'] = $t_thresholds_min[$t_action];
    }
    if ($t_default_flags['threshold_max'] != $t_thresholds_max[$t_action]) {
        $t_notify_flags[$t_action]['threshold_max'] = $t_thresholds_max[$t_action];
    }
}
if (isset($t_notify_flags)) {
    $t_existing_flags = config_get('notify_flags');
    $t_existing_access = config_get_access('notify_flags');
    if ($t_existing_flags != $t_notify_flags || $t_existing_access != $f_actions_access) {
        # only set the flags if they are different
        config_set('notify_flags', $t_notify_flags, NO_USER, $t_project, $f_actions_access);
    }
}
form_security_purge('manage_config_email_set');
?>

<br />
<div align="center">
<?php 
echo lang_get('operation_successful') . '<br />';
print_bracket_link($t_redirect_url, lang_get('proceed'));
?>
</div>
/**
 * Get enumeration row
 * @param string  $p_caption           Caption.
 * @param string  $p_threshold         Threshold.
 * @param string  $p_enum              Enumeration.
 * @param boolean $p_all_projects_only All projects only.
 * @return void
 */
function get_capability_enum($p_caption, $p_threshold, $p_enum, $p_all_projects_only = false)
{
    global $g_user, $g_project_id, $t_show_submit, $g_access_levels;
    $t_file = config_get_global($p_threshold);
    $t_global = config_get($p_threshold, null, null, ALL_PROJECTS);
    $t_project = config_get($p_threshold);
    $t_can_change = access_has_project_level(config_get_access($p_threshold), $g_project_id, $g_user) && (ALL_PROJECTS == $g_project_id || !$p_all_projects_only);
    echo '<tr>' . "\n";
    echo "\t" . '<td>' . string_display($p_caption) . '</td>' . "\n";
    # Value
    $t_color = set_color($p_threshold, $t_file, $t_global, $t_project, $t_can_change);
    echo "\t" . '<td class="left" colspan="3"' . $t_color . '>';
    if ($t_can_change) {
        echo '<select name="flag_' . $p_threshold . '">';
        print_enum_string_option_list($p_enum, config_get($p_threshold));
        echo '</select>';
        $t_show_submit = true;
    } else {
        $t_value = MantisEnum::getLabel(lang_get($p_enum . '_enum_string'), config_get($p_threshold)) . '&#160;';
        echo $t_value;
    }
    echo '</td>' . "\n\t" . '<td colspan="' . (count($g_access_levels) - 3) . '"></td>' . "\n";
    print_who_can_change($p_threshold, $t_can_change);
    echo '</tr>' . "\n";
}
/**
 * Set capability enum
 * @param string  $p_threshold         Threshold.
 * @param boolean $p_all_projects_only All projects only.
 * @return void
 */
function set_capability_enum($p_threshold, $p_all_projects_only = false)
{
    global $g_access, $g_project;
    if ($g_access >= config_get_access($p_threshold) && (ALL_PROJECTS == $g_project || !$p_all_projects_only)) {
        $f_flag = gpc_get('flag_' . $p_threshold);
        $f_access = gpc_get_int('access_' . $p_threshold);
        if ($f_flag != config_get($p_threshold) || $f_access != config_get_access($p_threshold)) {
            config_set($p_threshold, $f_flag, NO_USER, $g_project, $f_access);
        }
    }
}
/**
 * access row
 */
function access_row()
{
    global $t_access, $t_can_change_flags;
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, null, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    $t_global_set = config_get('set_status_threshold', null, null, ALL_PROJECTS);
    $t_project_set = config_get('set_status_threshold');
    $t_submit_status = config_get('bug_submit_status');
    # Print the table rows
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo "\t\t" . '<tr><td class="width30">' . string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_status)) . '</td>' . "\n";
        if ($t_status == $t_submit_status) {
            # 'NEW' status
            $t_level_project = $t_project_new;
            $t_can_change = $t_access >= config_get_access('report_bug_threshold');
            $t_colour = set_colour_override($t_file_new, $t_global_new, $t_project_new);
            if ($t_can_change && $t_colour != '') {
                set_overrides('report_bug_threshold');
            }
        } else {
            # Other statuses
            # File level: fallback if set_status_threshold is not defined
            if (isset($t_file_set[$t_status])) {
                $t_level_file = $t_file_set[$t_status];
            } else {
                $t_level_file = config_get_global('update_bug_status_threshold');
            }
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : $t_level_file;
            $t_level_project = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : $t_level_global;
            $t_can_change = $t_access >= config_get_access('set_status_threshold');
            $t_colour = set_colour_override($t_level_file, $t_level_global, $t_level_project);
            if ($t_can_change && $t_colour != '') {
                set_overrides('set_status_threshold');
            }
        }
        if ($t_can_change) {
            echo '<td' . $t_colour . '><select name="access_change_' . $t_status . '">' . "\n";
            print_enum_string_option_list('access_levels', $t_level_project);
            echo '</select> </td>' . "\n";
            $t_can_change_flags = true;
        } else {
            echo '<td class="center"' . $t_colour . '>' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_level_project) . '</td>' . "\n";
        }
        echo '</tr>' . "\n";
    }
}
require_once $t_core_path . 'email_api.php';
form_security_validate('manage_config_email_set');
auth_reauthenticate();
$t_can_change_level = min(config_get_access('notify_flags'), config_get_access('default_notify_flags'));
access_ensure_project_level($t_can_change_level);
$t_redirect_url = 'manage_config_email_page.php';
$t_project = helper_get_current_project();
$f_flags = gpc_get('flag', array());
$f_thresholds = gpc_get('flag_threshold', array());
$f_actions_access = gpc_get_int('notify_actions_access');
html_page_top1(lang_get('manage_email_config'));
html_meta_redirect($t_redirect_url);
html_page_top2();
$t_access = current_user_get_access_level();
$t_can_change_flags = $t_access >= config_get_access('notify_flags');
$t_can_change_defaults = $t_access >= config_get_access('default_notify_flags');
# build a list of the possible actions and flags
$t_valid_actions = array('owner', 'reopened', 'deleted', 'bugnote');
if (config_get('enable_sponsorship') == ON) {
    $t_valid_actions[] = 'sponsor';
}
if (config_get('enable_relationship') == ON) {
    $t_valid_actions[] = 'relationship';
}
$t_statuses = get_enum_to_array(config_get('status_enum_string'));
ksort($t_statuses);
reset($t_statuses);
foreach ($t_statuses as $t_status => $t_label) {
    $t_valid_actions[] = $t_label;
}
$t_valid_flags = array('reporter', 'handler', 'monitor', 'bugnotes');
                    $t_workflow_row .= ',';
                }
                $t_workflow_row .= $t_next_state . ':' . get_enum_element('status', $t_next_state);
                $t_first = false;
            }
        }
        if ('' != $t_workflow_row) {
            $t_workflow[$t_state] = $t_workflow_row;
        }
    }
    if ($t_workflow != config_get('status_enum_workflow')) {
        config_set('status_enum_workflow', $t_workflow, NO_USER, $t_project, $f_access);
    }
}
# process the access level changes
if (config_get_access('status_enum_workflow') <= $t_access) {
    # get changes to access level to change these values
    $f_access = gpc_get('status_access');
    # walk through the status labels to set the status threshold
    $t_enum_status = explode_enum_string(config_get('status_enum_string'));
    $t_set_status = array();
    foreach ($t_statuses as $t_status_id => $t_status_label) {
        $f_level = gpc_get('access_change_' . $t_status_id);
        if (NEW_ == $t_status_id) {
            if ((int) $f_level != config_get('report_bug_threshold')) {
                config_set('report_bug_threshold', (int) $f_level, ALL_USERS, $t_project, $f_access);
            }
        } else {
            $t_set_status[$t_status_id] = (int) $f_level;
        }
    }
Пример #14
0
    }
    if ($t_workflow == $t_workflow_parent && $f_access == $t_access_current) {
        # If new value is equal to parent and access has not changed
        config_delete('status_enum_workflow', ALL_USERS, $t_project);
    } else {
        if ($t_workflow != config_get('status_enum_workflow') || $f_access != $t_access_current) {
            # Set config if value or access have changed
            config_set('status_enum_workflow', $t_workflow, NO_USER, $t_project, $f_access);
        }
    }
}
# process the access level changes
if (config_get_access('status_enum_workflow') <= $t_access) {
    # get changes to access level to change these values
    $f_access = gpc_get('status_access');
    $t_access_current = config_get_access('status_enum_workflow');
    # Build access level reference arrays (parent level and current config)
    $t_set_parent = config_get_parent($t_project, 'set_status_threshold');
    $t_set_current = config_get('set_status_threshold');
    $t_bug_submit_status = config_get('bug_submit_status');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_set_parent[$t_status])) {
            if ($t_bug_submit_status == $t_status) {
                $t_set_parent[$t_status] = config_get_parent($t_project, 'report_bug_threshold');
            } else {
                $t_set_parent[$t_status] = config_get_parent($t_project, 'update_bug_status_threshold');
            }
        }
        if (!isset($t_set_current[$t_status])) {
            if ($t_bug_submit_status == $t_status) {
                $t_set_current[$t_status] = config_get('report_bug_threshold');
    # get changes to access level to change these values
    $f_access = gpc_get('status_access');
    # walk through the status labels to set the status threshold
    $t_enum_status = explode(',', config_get('status_enum_string'));
    $t_set_status = array();
    foreach ($t_statuses as $t_status_id => $t_status_label) {
        $f_level = gpc_get('access_change_' . $t_status_id);
        if (config_get('bug_submit_status') == $t_status_id) {
            if ((int) $f_level != config_get('report_bug_threshold')) {
                config_set('report_bug_threshold', (int) $f_level, ALL_USERS, $t_project, $f_access);
            }
        } else {
            $t_set_status[$t_status_id] = (int) $f_level;
        }
    }
    if ($t_set_status != config_get('set_status_threshold') || $f_access != config_get_access('status_enum_workflow')) {
        config_set('set_status_threshold', $t_set_status, ALL_USERS, $t_project, $f_access);
    }
}
form_security_purge('manage_config_workflow_set');
?>

<br />
<div align="center">
<?php 
echo lang_get('operation_successful') . '<br />';
print_bracket_link($t_redirect_url, lang_get('proceed'));
?>
</div>

<?php 
	# walk through the status labels to set the status threshold
	$t_enum_status = explode( ',', config_get( 'status_enum_string' ) );
	$t_set_status = array();
	foreach( $t_statuses as $t_status_id => $t_status_label) {
		$f_level = gpc_get( 'access_change_' . $t_status_id );
		if ( config_get( 'bug_submit_status' ) == $t_status_id ) {
			if ( (int)$f_level != config_get( 'report_bug_threshold' ) ) {
				config_set( 'report_bug_threshold', (int)$f_level, ALL_USERS, $t_project, $f_access );
			}
		} else {
			$t_set_status[$t_status_id] = (int)$f_level;
		}
	}

	if ( ( $t_set_status != config_get( 'set_status_threshold' ) )
			|| ( $f_access != config_get_access( 'status_enum_workflow' ) ) ) {
		config_set( 'set_status_threshold', $t_set_status, ALL_USERS, $t_project, $f_access );
	}
}

form_security_purge( 'manage_config_workflow_set' );
?>

<br />
<div>
<?php
echo lang_get( 'operation_successful' ) . '<br />';
print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
?>
</div>