示例#1
0
     break;
 case 'UP_PRIOR':
     if (access_has_bug_level(config_get('update_bug_threshold'), $t_bug_id)) {
         $f_priority = gpc_get_int('priority');
         /** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
         bug_set_field($t_bug_id, 'priority', $f_priority);
         helper_call_custom_function('issue_update_notify', array($t_bug_id));
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'UP_STATUS':
     $f_status = gpc_get_int('status');
     $t_project = bug_get_field($t_bug_id, 'project_id');
     if (access_has_bug_level(access_get_status_threshold($f_status, $t_project), $t_bug_id)) {
         if (TRUE == bug_check_workflow($t_status, $f_status)) {
             /** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
             bug_set_field($t_bug_id, 'status', $f_status);
             # Add bugnote if supplied
             if (!is_blank($f_bug_notetext)) {
                 bugnote_add($t_bug_id, $f_bug_notetext, null, $f_bug_noteprivate);
             }
             helper_call_custom_function('issue_update_notify', array($t_bug_id));
         } else {
             $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_status');
         }
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'UP_CATEGORY':
示例#2
0
     break;
 case 'UP_PRIOR':
     if (access_has_bug_level(config_get('update_bug_threshold'), $t_bug_id)) {
         $f_priority = gpc_get_int('priority');
         # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
         bug_set_field($t_bug_id, 'priority', $f_priority);
         email_bug_updated($t_bug_id);
         helper_call_custom_function('issue_update_notify', array($t_bug_id));
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'UP_STATUS':
     $f_status = gpc_get_int('status');
     if (access_has_bug_level(access_get_status_threshold($f_status, $t_bug->project_id), $t_bug_id)) {
         if (true == bug_check_workflow($t_status, $f_status)) {
             # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
             bug_set_field($t_bug_id, 'status', $f_status);
             # Add bugnote if supplied
             if (!is_blank($f_bug_notetext)) {
                 bugnote_add($t_bug_id, $f_bug_notetext, null, $f_bug_noteprivate);
                 # No need to call email_generic(), bugnote_add() does it
             } else {
                 email_bug_updated($t_bug_id);
             }
             helper_call_custom_function('issue_update_notify', array($t_bug_id));
         } else {
             $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_status');
         }
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
示例#3
0
function html_button_bug_assign_to($p_bug_id)
{
    # make sure status is allowed of assign would cause auto-set-status
    $t_status = bug_get_field($p_bug_id, 'status');
    # workflow implementation
    if (ON == config_get('auto_set_status_to_assigned') && !bug_check_workflow($t_status, config_get('bug_assigned_status'))) {
        # workflow
        return;
    }
    # make sure current user has access to modify bugs.
    if (!access_has_bug_level(config_get('update_bug_assign_threshold', config_get('update_bug_threshold')), $p_bug_id)) {
        return;
    }
    $t_reporter_id = bug_get_field($p_bug_id, 'reporter_id');
    $t_handler_id = bug_get_field($p_bug_id, 'handler_id');
    $t_current_user_id = auth_get_current_user_id();
    $t_new_status = ON == config_get('auto_set_status_to_assigned') ? config_get('bug_assigned_status') : $t_status;
    $t_options = array();
    $t_default_assign_to = null;
    if ($t_handler_id != $t_current_user_id && access_has_bug_level(config_get('handle_bug_threshold'), $p_bug_id, $t_current_user_id)) {
        $t_options[] = array($t_current_user_id, '[' . lang_get('myself') . ']');
        $t_default_assign_to = $t_current_user_id;
    }
    if ($t_handler_id != $t_reporter_id && user_exists($t_reporter_id) && access_has_bug_level(config_get('handle_bug_threshold'), $p_bug_id, $t_reporter_id)) {
        $t_options[] = array($t_reporter_id, '[' . lang_get('reporter') . ']');
        if ($t_default_assign_to === null) {
            $t_default_assign_to = $t_reporter_id;
        }
    }
    print "<form method=\"post\" action=\"bug_assign.php\">";
    $t_button_text = lang_get('bug_assign_to_button');
    print "<input type=\"submit\" class=\"button\" value=\"{$t_button_text}\" />";
    print " <select name=\"handler_id\">";
    # space at beginning of line is important
    $t_already_selected = false;
    foreach ($t_options as $t_entry) {
        $t_id = string_attribute($t_entry[0]);
        $t_caption = string_attribute($t_entry[1]);
        # if current user and reporter can't be selected, then select the first
        # user in the list.
        if ($t_default_assign_to === null) {
            $t_default_assign_to = $t_id;
        }
        print "<option value=\"{$t_id}\" ";
        if ($t_id == $t_default_assign_to && !$t_already_selected) {
            check_selected($t_id, $t_default_assign_to);
            $t_already_selected = true;
        }
        print ">{$t_caption}</option>";
    }
    # allow un-assigning if already assigned.
    if ($t_handler_id != 0) {
        print "<option value=\"0\"></option>";
    }
    $t_project_id = bug_get_field($p_bug_id, 'project_id');
    # 0 means currently selected
    print_assign_to_option_list(0, $t_project_id);
    print "</select>";
    $t_bug_id = string_attribute($p_bug_id);
    print "<input type=\"hidden\" name=\"bug_id\" value=\"{$t_bug_id}\" />\n";
    print "</form>\n";
}
示例#4
0
    if ($t_existing_bug->status < $t_closed_status && $t_updated_bug->status >= $t_closed_status) {
        $t_close_issue = true;
    } else {
        if ($t_existing_bug->status >= $t_resolved_status && $t_updated_bug->status <= config_get('bug_reopen_status')) {
            $t_reopen_issue = true;
        }
    }
}
# If resolving or closing, ensure that all dependant issues have been resolved.
if (($t_resolve_issue || $t_close_issue) && !relationship_can_resolve_bug($f_bug_id)) {
    trigger_error(ERROR_BUG_RESOLVE_DEPENDANTS_BLOCKING, ERROR);
}
# Validate any change to the status of the issue.
if ($t_existing_bug->status !== $t_updated_bug->status) {
    access_ensure_bug_level(config_get('update_bug_status_threshold'), $f_bug_id);
    if (!bug_check_workflow($t_existing_bug->status, $t_updated_bug->status)) {
        error_parameters(lang_get('status'));
        trigger_error(ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR);
    }
    if (!access_has_bug_level(access_get_status_threshold($t_updated_bug->status, $t_updated_bug->project_id), $f_bug_id)) {
        # The reporter may be allowed to close or reopen the issue regardless.
        $t_can_bypass_status_access_thresholds = false;
        if ($t_close_issue && $t_existing_bug->status >= $t_resolved_status && $t_existing_bug->reporter_id === auth_get_current_user_id() && config_get('allow_reporter_close')) {
            $t_can_bypass_status_access_thresholds = true;
        } else {
            if ($t_reopen_issue && $t_existing_bug->status < $t_closed_status && $t_existing_bug->reporter_id === auth_get_current_user_id() && config_get('allow_reporter_reopen')) {
                $t_can_bypass_status_access_thresholds = true;
            }
        }
        if (!$t_can_bypass_status_access_thresholds) {
            trigger_error(ERROR_ACCESS_DENIED, ERROR);
示例#5
0
/**
 * Print a button to close the given bug
 * Only if user can close bugs and workflow allows moving them to that status
 * @param BugData $p_bug Bug object
 * @return null
 */
function html_button_bug_close($p_bug)
{
    $t_closed_status = config_get('bug_closed_status_threshold', null, null, $p_bug->project_id);
    if (access_can_close_bug($p_bug) && bug_check_workflow($p_bug->status, $t_closed_status)) {
        html_button('bug_change_status_page.php', lang_get('close_bug_button'), array('id' => $p_bug->id, 'new_status' => $t_closed_status));
    }
}
示例#6
0
/**
 * Check if the specified bug can be reopened
 * @param BugData      $p_bug     Bug to check access against.
 * @param integer|null $p_user_id Integer representing user id, defaults to null to use current user.
 * @return boolean whether user has access to reopen bugs
 * @access public
 */
function access_can_reopen_bug(BugData $p_bug, $p_user_id = null)
{
    if (!bug_is_resolved($p_bug->id)) {
        # Can't reopen a bug that's not resolved
        return false;
    }
    if ($p_user_id === null) {
        $p_user_id = auth_get_current_user_id();
    }
    $t_reopen_status = config_get('bug_reopen_status', null, null, $p_bug->project_id);
    # Reopen status must be reachable by workflow
    if (!bug_check_workflow($p_bug->status, $t_reopen_status)) {
        return false;
    }
    # If allow_reporter_reopen is enabled, then reporters can always reopen
    # their own bugs as long as their access level is reporter or above
    if (ON == config_get('allow_reporter_reopen', null, null, $p_bug->project_id) && bug_is_user_reporter($p_bug->id, $p_user_id) && access_has_project_level(config_get('report_bug_threshold', null, $p_user_id, $p_bug->project_id), $p_bug->project_id, $p_user_id)) {
        return true;
    }
    # Other users's access level must allow them to reopen bugs
    $t_reopen_bug_threshold = config_get('reopen_bug_threshold', null, null, $p_bug->project_id);
    if (access_has_bug_level($t_reopen_bug_threshold, $p_bug->id, $p_user_id)) {
        # User must be allowed to change status to reopen status
        $t_reopen_status_threshold = access_get_status_threshold($t_reopen_status, $p_bug->project_id);
        return access_has_bug_level($t_reopen_status_threshold, $p_bug->id, $p_user_id);
    }
    return false;
}
示例#7
0
/**
 * Returns the resulting status for a bug after an assignment action is performed.
 * If the option "auto_set_status_to_assigned" is enabled, the resulting status
 * is calculated based on current handler and status , and requested modifications.
 * @param integer $p_current_handler	Current handler user id
 * @param integer $p_new_handler		New handler user id
 * @param integer $p_current_status		Current bug status
 * @param integer $p_new_status			New bug status (as being part of a status change combined action)
 * @return integer		Calculated status after assignment
 */
function bug_get_status_for_assign($p_current_handler, $p_new_handler, $p_current_status, $p_new_status = null)
{
    if (null === $p_new_status) {
        $p_new_status = $p_current_status;
    }
    if (config_get('auto_set_status_to_assigned')) {
        $t_assigned_status = config_get('bug_assigned_status');
        if ($p_current_handler == NO_USER && $p_new_handler != NO_USER && $p_new_status == $p_current_status && $p_new_status < $t_assigned_status && bug_check_workflow($p_current_status, $t_assigned_status)) {
            return $t_assigned_status;
        }
    }
    return $p_new_status;
}