Beispiel #1
0
/**
 * 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.
 * @param integer $p_max_events The maximum number of events to return or 0 for unlimited.
 * @return array
 */
function timeline_events($p_start_time, $p_end_time, $p_max_events)
{
    $t_timeline_events = array();
    $t_result = history_get_range_result(null, $p_start_time, $p_end_time, 'DESC');
    $t_count = 0;
    while ($t_history_event = history_get_event_from_row($t_result, auth_get_current_user_id(), true)) {
        $t_event = null;
        $t_user_id = $t_history_event['userid'];
        $t_timestamp = $t_history_event['date'];
        $t_issue_id = $t_history_event['bug_id'];
        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;
            $t_count++;
            if ($p_max_events > 0 && $t_count >= $p_max_events) {
                break;
            }
        }
    }
    return $t_timeline_events;
}
Beispiel #2
0
/**
 * 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;
}