function custom_function_default_roadmap_print_issue($p_issue_id, $p_issue_level = 0)
{
    static $t_status;
    $t_bug = bug_get($p_issue_id);
    if (bug_is_resolved($p_issue_id)) {
        $t_strike_start = '<strike>';
        $t_strike_end = '</strike>';
    } else {
        $t_strike_start = $t_strike_end = '';
    }
    if ($t_bug->category_id) {
        $t_category_name = category_get_name($t_bug->category_id);
    } else {
        $t_category_name = '';
    }
    $t_category = is_blank($t_category_name) ? '' : '<b>[' . string_display_line($t_category_name) . ']</b> ';
    echo utf8_str_pad('', $p_issue_level * 6, '&#160;'), '- ', $t_strike_start, string_get_bug_view_link($p_issue_id), ': ', $t_category, string_display_line_links($t_bug->summary);
    if ($t_bug->handler_id != 0) {
        echo ' (', prepare_user_name($t_bug->handler_id), ')';
    }
    if (!isset($t_status[$t_bug->status])) {
        $t_status[$t_bug->status] = get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
    }
    echo ' - ', $t_status[$t_bug->status], $t_strike_end, '.<br />';
}
예제 #2
0
function custom_function_default_roadmap_print_issue($p_issue_id, $p_issue_level = 0)
{
    $t_bug = bug_get($p_issue_id);
    if (bug_is_resolved($p_issue_id)) {
        $t_strike_start = '<strike>';
        $t_strike_end = '</strike>';
    } else {
        $t_strike_start = $t_strike_end = '';
    }
    $t_category = is_blank($t_bug->category) ? '' : '<b>[' . $t_bug->category . ']</b> ';
    echo str_pad('', $p_issue_level * 6, '&nbsp;'), '- ', $t_strike_start, string_get_bug_view_link($p_issue_id), ': ', $t_category, string_display_line_links($t_bug->summary);
    if ($t_bug->handler_id != 0) {
        echo ' (', prepare_user_name($t_bug->handler_id), ')';
    }
    echo ' - ', get_enum_element('status', $t_bug->status), $t_strike_end, '.<br />';
}
예제 #3
0
/**
 * Check if the specified bug can be reopened
 * @param BugData $p_bug Bug to check access against
 * @param int|null $p_user_id integer representing user id, defaults to null to use current user
 * @return bool whether user has access to reopen bugs
 * @access public
 */
function access_can_reopen_bug($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();
    }
    # 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)) {
        $t_reopen_status = config_get('bug_reopen_status', null, null, $p_bug->project_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;
}
예제 #4
0
/**
 * Check if a given bug is overdue
 * @param int p_bug_id integer representing bug id
 * @return bool true if bug is overdue, false otherwise
 * @access public
 * @uses database_api.php
 */
function bug_is_overdue($p_bug_id)
{
    $t_due_date = bug_get_field($p_bug_id, 'due_date');
    if (!date_is_null($t_due_date)) {
        $t_now = db_now();
        if ($t_now > $t_due_date) {
            if (!bug_is_resolved($p_bug_id)) {
                return true;
            }
        }
    }
    return false;
}
예제 #5
0
 private function add_bug(&$p_email, $p_overwrite_project_id = FALSE)
 {
     $this->show_memory_usage('Start add bug');
     //Merge References and In-Reply-To headers into one array
     $t_references = $p_email['References'];
     $t_references[] = $p_email['In-Reply-To'];
     if ($this->_mail_add_bugnotes) {
         $t_bug_id = $this->mail_is_a_bugnote($p_email['Subject'], $t_references);
     } else {
         $t_bug_id = FALSE;
     }
     if ($t_bug_id !== FALSE && !bug_is_readonly($t_bug_id)) {
         // @TODO@ Disabled for now until we find a good solution on how to handle the reporters possible lack of access permissions
         //			access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $f_bug_id );
         $t_description = $p_email['X-Mantis-Body'];
         $t_description = $this->identify_replies($t_description);
         $t_description = $this->strip_signature($t_description);
         $t_description = $this->add_additional_info('note', $p_email, $t_description);
         $t_project_id = bug_get_field($t_bug_id, 'project_id');
         ERP_set_temporary_overwrite('project_override', $t_project_id);
         # Event integration
         # Core mantis event already exists within bugnote_add function
         $t_description = event_signal('EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id);
         if (bug_is_resolved($t_bug_id)) {
             # Reopen issue and add a bug note
             bug_reopen($t_bug_id, $t_description);
         } elseif (!is_blank($t_description)) {
             # Add a bug note
             bugnote_add($t_bug_id, $t_description);
         }
     } elseif ($this->_mail_add_bug_reports) {
         // @TODO@ Disabled for now until we find a good solution on how to handle the reporters possible lack of access permissions
         //			access_ensure_project_level( config_get('report_bug_threshold' ) );
         $f_master_bug_id = $t_bug_id !== FALSE && bug_is_readonly($t_bug_id) ? $t_bug_id : 0;
         $this->fix_empty_fields($p_email);
         $t_project_id = $p_overwrite_project_id === FALSE ? $this->_mailbox['project_id'] : $p_overwrite_project_id;
         ERP_set_temporary_overwrite('project_override', $t_project_id);
         $t_bug_data = new BugData();
         $t_bug_data->build = '';
         $t_bug_data->platform = '';
         $t_bug_data->os = '';
         $t_bug_data->os_build = '';
         $t_bug_data->version = '';
         $t_bug_data->profile_id = 0;
         $t_bug_data->handler_id = 0;
         $t_bug_data->view_state = (int) config_get('default_bug_view_status');
         $t_bug_data->category_id = (int) $this->_mailbox['global_category_id'];
         $t_bug_data->reproducibility = (int) config_get('default_bug_reproducibility');
         $t_bug_data->severity = (int) config_get('default_bug_severity');
         $t_bug_data->priority = (int) ($this->_mail_use_bug_priority ? $p_email['Priority'] : config_get('default_bug_priority'));
         $t_bug_data->projection = (int) config_get('default_bug_projection');
         $t_bug_data->eta = (int) config_get('default_bug_eta');
         $t_bug_data->resolution = config_get('default_bug_resolution');
         $t_bug_data->status = config_get('bug_submit_status');
         $t_bug_data->summary = $p_email['Subject'];
         $t_description = $p_email['X-Mantis-Body'];
         $t_description = $this->strip_signature($t_description);
         $t_description = $this->add_additional_info('issue', $p_email, $t_description);
         $t_bug_data->description = $t_description;
         $t_bug_data->steps_to_reproduce = config_get('default_bug_steps_to_reproduce');
         $t_bug_data->additional_information = config_get('default_bug_additional_info');
         $t_bug_data->due_date = date_get_null();
         $t_bug_data->project_id = $t_project_id;
         $t_bug_data->reporter_id = $p_email['Reporter_id'];
         // This function might do stuff that EmailReporting cannot handle. Disabled
         //helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) );
         // @TODO@ Disabled for now but possibly needed for other future features
         # Validate the custom fields before adding the bug.
         /*			$t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id );
         			foreach( $t_related_custom_field_ids as $t_id )
         			{
         				$t_def = custom_field_get_definition( $t_id );
         
         				# Produce an error if the field is required but wasn't posted
         				if ( !gpc_isset_custom_field( $t_id, $t_def['type'] ) &&
         					( $t_def['require_report'] ||
         						$t_def['type'] == CUSTOM_FIELD_TYPE_ENUM ||
         						$t_def['type'] == CUSTOM_FIELD_TYPE_LIST ||
         						$t_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST ||
         						$t_def['type'] == CUSTOM_FIELD_TYPE_RADIO ) ) {
         					error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
         					trigger_error( ERROR_EMPTY_FIELD, ERROR );
         				}
         				if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL ) ) )
         				{
         					error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
         					trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
         				}
         			}*/
         # Allow plugins to pre-process bug data
         $t_bug_data = event_signal('EVENT_REPORT_BUG_DATA', $t_bug_data);
         $t_bug_data = event_signal('EVENT_ERP_REPORT_BUG_DATA', $t_bug_data);
         # Create the bug
         $t_bug_id = $t_bug_data->create();
         // @TODO@ Disabled for now but possibly needed for other future features
         # Handle custom field submission
         /*			foreach( $t_related_custom_field_ids as $t_id )
         {
         				# Do not set custom field value if user has no write access.
         				if( !custom_field_has_write_access( $t_id, $t_bug_id ) )
         				{
         					continue;
         				}
         
         				$t_def = custom_field_get_definition( $t_id );
         				if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ), false ) ) {
         				{
         					error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
         					trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
         				}
         			}*/
         // Lets link a readonly already existing bug to the newly created one
         if ($f_master_bug_id > 0) {
             $f_rel_type = BUG_RELATED;
             # update master bug last updated
             bug_update_date($f_master_bug_id);
             # Add the relationship
             relationship_add($t_bug_id, $f_master_bug_id, $f_rel_type);
             # Add log line to the history (both issues)
             history_log_event_special($f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $t_bug_id);
             history_log_event_special($t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id);
             # Send the email notification
             email_relationship_added($f_master_bug_id, $t_bug_id, relationship_get_complementary_type($f_rel_type));
         }
         helper_call_custom_function('issue_create_notify', array($t_bug_id));
         # Allow plugins to post-process bug data with the new bug ID
         event_signal('EVENT_REPORT_BUG', array($t_bug_data, $t_bug_id));
         email_new_bug($t_bug_id);
     } else {
         // Not allowed to add issues and not allowed / able to add notes. Need to stop processing
         $this->custom_error('Not allowed to create a new issue. Email ignored');
         return;
     }
     $this->custom_error('Reporter: ' . $p_email['Reporter_id'] . ' - ' . $p_email['From_parsed']['email'] . ' --> Issue ID: #' . $t_bug_id, FALSE);
     $this->show_memory_usage('Finished add bug');
     $this->show_memory_usage('Start processing attachments');
     # Add files
     if ($this->_allow_file_upload) {
         if (count($p_email['X-Mantis-Parts']) > 0) {
             $t_rejected_files = NULL;
             while ($t_part = array_shift($p_email['X-Mantis-Parts'])) {
                 $t_file_rejected = $this->add_file($t_bug_id, $t_part);
                 if ($t_file_rejected !== TRUE) {
                     $t_rejected_files .= $t_file_rejected;
                 }
             }
             if ($t_rejected_files !== NULL) {
                 $t_part = array('name' => 'Rejected files.txt', 'ctype' => 'text/plain', 'body' => 'List of rejected files' . "\n\n" . $t_rejected_files);
                 $t_reject_rejected_files = $this->add_file($t_bug_id, $t_part);
                 if ($t_reject_rejected_files !== TRUE) {
                     $t_part['body'] .= $t_reject_rejected_files;
                     $this->custom_error('Failed to add "' . $t_part['name'] . '" to the issue. See below for all errors.' . "\n" . $t_part['body']);
                 }
             }
         }
     }
     //Add the users in Cc and To list in mail header
     $this->add_monitors($t_bug_id, $p_email);
     //Add the message-id to the database
     $this->add_msg_id($t_bug_id, $p_email['Message-ID']);
     ERP_set_temporary_overwrite('project_override', NULL);
     $this->show_memory_usage('Finished processing attachments');
 }
예제 #6
0
/**
 * Check if the specified bug can be reopened
 * @param BugData $p_bug Bug to check access against
 * @param int|null $p_user_id integer representing user id, defaults to null to use current user
 * @return bool whether user has access to reopen bugs
 * @access public
 */
function access_can_reopen_bug($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();
    }
    # If allow_reporter_reopen is enabled, then reporters can always reopen their own bugs
    if (ON == config_get('allow_reporter_reopen', null, null, $p_bug->project_id) && bug_is_user_reporter($p_bug->id, $p_user_id)) {
        return true;
    }
    $t_reopen_status = config_get('reopen_bug_threshold', null, null, $p_bug->project_id);
    $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);
}
예제 #7
0
     }
     bug_cache_database_result($t_row);
     # check limit_Reporter (Issue #4770)
     # reporters can view just issues they reported
     if (ON === $t_limit_reporters && $t_user_access_level_is_reporter && !bug_is_user_reporter($t_row['id'], $t_user_id)) {
         continue;
     }
     $t_issue_id = $t_row['id'];
     $t_issue_parent = $t_row['source_bug_id'];
     $t_parent_version = $t_row['parent_version'];
     if (!helper_call_custom_function('roadmap_include_issue', array($t_issue_id))) {
         continue;
     }
     if (!isset($t_issues_counted[$t_issue_id])) {
         $t_issues_planned++;
         if (bug_is_resolved($t_issue_id)) {
             $t_issues_resolved++;
         }
         $t_issues_counted[$t_issue_id] = true;
     }
     if (0 === strcasecmp($t_parent_version, $t_version)) {
         $t_issue_ids[] = $t_issue_id;
         $t_issue_parents[] = $t_issue_parent;
     } else {
         if (!in_array($t_issue_id, $t_issue_ids)) {
             $t_issue_ids[] = $t_issue_id;
             $t_issue_parents[] = null;
         }
     }
     $t_issue_handlers[] = $t_row['handler_id'];
 }
예제 #8
0
function gantt_get_resolution_date($p_bug_id)
{
    if (bug_is_resolved($p_bug_id)) {
        $t_history = history_get_raw_events_array($p_bug_id);
        $t_resolution_date = null;
        foreach ($t_history as $t_item) {
            if ('status' == $t_item['field']) {
                if ($t_item['new_value'] >= config_get('bug_resolved_status_threshold')) {
                    $t_resolution_date = $t_item['date'];
                }
            }
        }
        return $t_resolution_date;
    }
    // The issue is not resolved yet
    return null;
}