/** * Get an array of timeline events * Events for which the skip() method returns true will be excluded * @param integer $p_start_time Timestamp representing start time of the period. * @param integer $p_end_time Timestamp representing end time of the period. * @return array */ function timeline_events($p_start_time, $p_end_time) { $t_issue_ids = timeline_get_affected_issues($p_start_time, $p_end_time); $t_timeline_events = array(); foreach ($t_issue_ids as $t_issue_id) { $t_history_events_array = history_get_raw_events_array($t_issue_id, null, $p_start_time, $p_end_time); $t_history_events_array = array_reverse($t_history_events_array); foreach ($t_history_events_array as $t_history_event) { if ($t_history_event['date'] < $p_start_time || $t_history_event['date'] >= $p_end_time) { continue; } $t_event = null; $t_user_id = $t_history_event['userid']; $t_timestamp = $t_history_event['date']; switch ($t_history_event['type']) { case NEW_BUG: $t_event = new IssueCreatedTimelineEvent($t_timestamp, $t_user_id, $t_issue_id); break; case BUGNOTE_ADDED: $t_bugnote_id = $t_history_event['old_value']; $t_event = new IssueNoteCreatedTimelineEvent($t_timestamp, $t_user_id, $t_issue_id, $t_bugnote_id); break; case BUG_MONITOR: # Skip monitors added for others due to reminders, only add monitor events where added # user is the same as the logged in user. if ((int) $t_history_event['old_value'] == (int) $t_history_event['userid']) { $t_event = new IssueMonitorTimelineEvent($t_timestamp, $t_user_id, $t_issue_id, true); } break; case BUG_UNMONITOR: $t_event = new IssueMonitorTimelineEvent($t_timestamp, $t_user_id, $t_issue_id, false); break; case TAG_ATTACHED: $t_event = new IssueTagTimelineEvent($t_timestamp, $t_user_id, $t_issue_id, $t_history_event['old_value'], true); break; case TAG_DETACHED: $t_event = new IssueTagTimelineEvent($t_timestamp, $t_user_id, $t_issue_id, $t_history_event['old_value'], false); break; case NORMAL_TYPE: switch ($t_history_event['field']) { case 'status': $t_event = new IssueStatusChangeTimelineEvent($t_timestamp, $t_user_id, $t_issue_id, $t_history_event['old_value'], $t_history_event['new_value']); break; case 'handler_id': $t_event = new IssueAssignedTimelineEvent($t_timestamp, $t_user_id, $t_issue_id, $t_history_event['new_value']); break; } break; } # Do not include skipped events if ($t_event != null && !$t_event->skip()) { $t_timeline_events[] = $t_event; } } } return $t_timeline_events; }
function history_get_events_array($p_bug_id, $p_user_id = null) { $t_normal_date_format = config_get('normal_date_format'); $raw_history = history_get_raw_events_array($p_bug_id, $p_user_id); $raw_history_count = count($raw_history); $history = array(); for ($i = 0; $i < $raw_history_count; $i++) { $history[$i] = history_localize_item($raw_history[$i]['field'], $raw_history[$i]['type'], $raw_history[$i]['old_value'], $raw_history[$i]['new_value']); $history[$i]['date'] = date($t_normal_date_format, $raw_history[$i]['date']); $history[$i]['userid'] = $raw_history[$i]['userid']; $history[$i]['username'] = $raw_history[$i]['username']; } return $history; }
/** * Retrieves the history events for the specified bug id and returns it in an array * The array is indexed from 0 to N-1. The second dimension is: 'date', 'username', * 'note', 'change'. * @param integer $p_bug_id A valid bug identifier. * @param integer $p_user_id A valid user identifier. * @return array */ function history_get_events_array($p_bug_id, $p_user_id = null) { $t_normal_date_format = config_get('normal_date_format'); $t_raw_history = history_get_raw_events_array($p_bug_id, $p_user_id); $t_history = array(); foreach ($t_raw_history as $k => $t_item) { extract($t_item, EXTR_PREFIX_ALL, 'v'); $t_history[$k] = history_localize_item($v_field, $v_type, $v_old_value, $v_new_value); $t_history[$k]['date'] = date($t_normal_date_format, $v_date); $t_history[$k]['userid'] = $v_userid; $t_history[$k]['username'] = $v_username; } return $t_history; }
/** * Get history details about an issue. * * @param string $p_username The name of the user trying to access the issue. * @param string $p_password The password of the user. * @param integer $p_issue_id The id of the issue to retrieve. * @return array that represents a HistoryDataArray structure */ function mc_issue_get_history($p_username, $p_password, $p_issue_id) { global $g_project_override; $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!bug_exists($p_issue_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Issue does not exist'); } $t_project_id = bug_get_field($p_issue_id, 'project_id'); if (!mci_has_readonly_access($t_user_id, $t_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $g_project_override = $t_project_id; if (!access_has_bug_level(config_get('view_bug_threshold', null, null, $t_project_id), $p_issue_id, $t_user_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_user_access_level = user_get_access_level($t_user_id, $t_project_id); if (!access_compare_level($t_user_access_level, config_get('view_history_threshold'))) { return mci_soap_fault_access_denied($t_user_id); } log_event(LOG_WEBSERVICE, 'retrieving history for issue \'' . $p_issue_id . '\''); $t_bug_history = history_get_raw_events_array($p_issue_id, $t_user_id); return $t_bug_history; }
/** * Build the bug raw data visible for specified user to be translated and sent by email to the user * (Filter the bug data according to user access level) * return array with bug data. See usage in email_format_bug_message(...) * @param int $p_user_id * @param int $p_bug_id * @param string $p_message_id * @return array */ function email_build_visible_bug_data($p_user_id, $p_bug_id, $p_message_id) { $t_project_id = bug_get_field($p_bug_id, 'project_id'); $t_user_access_level = user_get_access_level($p_user_id, $t_project_id); $t_user_bugnote_order = user_pref_get_pref($p_user_id, 'bugnote_order'); $t_user_bugnote_limit = user_pref_get_pref($p_user_id, 'email_bugnote_limit'); $row = bug_get_extended_row($p_bug_id); $t_bug_data = array(); $t_bug_data['email_bug'] = $p_bug_id; if ($p_message_id !== 'email_notification_title_for_action_bug_deleted') { $t_bug_data['email_bug_view_url'] = string_get_bug_view_url_with_fqdn($p_bug_id); } if (access_compare_level($t_user_access_level, config_get('view_handler_threshold'))) { if (0 != $row['handler_id']) { $t_bug_data['email_handler'] = user_get_name($row['handler_id']); } else { $t_bug_data['email_handler'] = ''; } } $t_bug_data['email_reporter'] = user_get_name($row['reporter_id']); $t_bug_data['email_project_id'] = $row['project_id']; $t_bug_data['email_project'] = project_get_field($row['project_id'], 'name'); $t_category_name = category_full_name($row['category_id'], false); $t_bug_data['email_category'] = $t_category_name; $t_bug_data['email_date_submitted'] = $row['date_submitted']; $t_bug_data['email_last_modified'] = $row['last_updated']; $t_bug_data['email_status'] = $row['status']; $t_bug_data['email_severity'] = $row['severity']; $t_bug_data['email_priority'] = $row['priority']; $t_bug_data['email_reproducibility'] = $row['reproducibility']; $t_bug_data['email_resolution'] = $row['resolution']; $t_bug_data['email_fixed_in_version'] = $row['fixed_in_version']; if (!is_blank($row['target_version']) && access_compare_level($t_user_access_level, config_get('roadmap_view_threshold'))) { $t_bug_data['email_target_version'] = $row['target_version']; } $t_bug_data['email_summary'] = $row['summary']; $t_bug_data['email_description'] = $row['description']; $t_bug_data['email_additional_information'] = $row['additional_information']; $t_bug_data['email_steps_to_reproduce'] = $row['steps_to_reproduce']; $t_bug_data['set_category'] = '[' . $t_bug_data['email_project'] . '] ' . $t_category_name; $t_bug_data['custom_fields'] = custom_field_get_linked_fields($p_bug_id, $t_user_access_level); $t_bug_data['bugnotes'] = bugnote_get_all_visible_bugnotes($p_bug_id, $t_user_bugnote_order, $t_user_bugnote_limit, $p_user_id); # put history data if (ON == config_get('history_default_visible') && access_compare_level($t_user_access_level, config_get('view_history_threshold'))) { $t_bug_data['history'] = history_get_raw_events_array($p_bug_id, $p_user_id); } # Sponsorship Information if (config_get('enable_sponsorship') == ON && access_has_bug_level(config_get('view_sponsorship_total_threshold'), $p_bug_id, $p_user_id)) { $t_sponsorship_ids = sponsorship_get_all_ids($p_bug_id); $t_bug_data['sponsorship_total'] = sponsorship_get_amount($t_sponsorship_ids); if (access_has_bug_level(config_get('view_sponsorship_details_threshold'), $p_bug_id, $p_user_id)) { $t_bug_data['sponsorships'] = array(); foreach ($t_sponsorship_ids as $id) { $t_bug_data['sponsorships'][] = sponsorship_get($id); } } } $t_bug_data['relations'] = relationship_get_summary_text($p_bug_id); return $t_bug_data; }
function gantt_get_assigned_date($p_bug_id) { //TRY TO GET THE ASSIGNMENT DATE $t_history = history_get_raw_events_array($p_bug_id); foreach ($t_history as $t_item) { if ('handler_id' == $t_item['field']) { // Use the date of the first assignment date if any found: return $t_item['date']; } } //END OF GETTING ASSIGNMENT DATE return null; }