Esempio n. 1
0
require_api('string_api.php');
require_api('user_api.php');
$f_bug_id = gpc_get_int('bug_id', 0);
$f_bugnote_id = gpc_get_int('bugnote_id', 0);
$f_rev_id = gpc_get_int('rev_id', 0);
$t_title = '';
if ($f_bug_id) {
    $t_bug_id = $f_bug_id;
    $t_bug_data = bug_get($t_bug_id, true);
    $t_bug_revisions = array_reverse(bug_revision_list($t_bug_id), true);
    $t_title = lang_get('issue_id') . $t_bug_id;
} else {
    if ($f_bugnote_id) {
        $t_bug_id = bugnote_get_field($f_bugnote_id, 'bug_id');
        $t_bug_data = bug_get($t_bug_id, true);
        $t_bug_revisions = array_reverse(bug_revision_list($t_bug_id, REV_ANY, $f_bugnote_id), true);
        $t_title = lang_get('bugnote') . ' ' . $f_bugnote_id;
    } else {
        if ($f_rev_id) {
            $t_bug_revisions = array_reverse(bug_revision_like($f_rev_id), true);
            if (count($t_bug_revisions) < 1) {
                trigger_error(ERROR_GENERIC, ERROR);
            }
            $t_bug_id = $t_bug_revisions[$f_rev_id]['bug_id'];
            $t_bug_data = bug_get($t_bug_id, true);
            $t_title = lang_get('issue_id') . $t_bug_id;
        } else {
            trigger_error(ERROR_GENERIC, ERROR);
        }
    }
}
require_api('string_api.php');
require_api('user_api.php');
$f_bug_id = gpc_get_int('bug_id', 0);
$f_bugnote_id = gpc_get_int('bugnote_id', 0);
$f_rev_id = gpc_get_int('rev_id', 0);
$t_title = '';
if ($f_bug_id) {
    $t_bug_id = $f_bug_id;
    $t_bug_data = bug_get($t_bug_id, true);
    $t_bug_revisions = array_reverse(bug_revision_list($t_bug_id), true);
    $t_title = lang_get('issue_id') . $t_bug_id;
} else {
    if ($f_bugnote_id) {
        $t_bug_id = bugnote_get_field($f_bugnote_id, 'bug_id');
        $t_bug_data = bug_get($t_bug_id, true);
        $t_bug_revisions = bug_revision_list($t_bug_id, REV_ANY, $f_bugnote_id);
        $t_title = lang_get('bugnote') . ' ' . $f_bugnote_id;
    } else {
        if ($f_rev_id) {
            $t_bug_revisions = bug_revision_like($f_rev_id);
            if (count($t_bug_revisions) < 1) {
                trigger_error(ERROR_GENERIC, ERROR);
            }
            $t_bug_id = $t_bug_revisions[$f_rev_id]['bug_id'];
            $t_bug_data = bug_get($t_bug_id, true);
            $t_title = lang_get('issue_id') . $t_bug_id;
        } else {
            trigger_error(ERROR_GENERIC, ERROR);
        }
    }
}
 /**
  * Get last change values for:
  * - Description
  * - Steps to reproduce
  * - Additional information
  *
  * @param $bug_id
  * @param $version_date
  * @param $type_id
  * @return null
  */
 public function calculate_last_text_fields($bug_id, $version_date, $type_id)
 {
     $output_value = null;
     $min_pos_time_difference = 0;
     $min_pos_time_difference_description = null;
     $min_neg_time_difference = 0;
     $min_neg_time_difference_description = null;
     $revision_events = bug_revision_list($bug_id);
     foreach ($revision_events as $revision_event) {
         if ($revision_event['type'] == $type_id) {
             $revision_event_timestamp = $revision_event['timestamp'];
             $local_time_difference = $version_date - $revision_event_timestamp;
             if ($local_time_difference > 0) {
                 /* initial value */
                 if ($min_pos_time_difference == 0) {
                     $min_pos_time_difference = $local_time_difference;
                     $min_pos_time_difference_description = $revision_event['value'];
                 }
                 /* overwrite existing if it is closer to event date */
                 if ($min_pos_time_difference > $local_time_difference) {
                     $min_pos_time_difference = $local_time_difference;
                     $min_pos_time_difference_description = $revision_event['value'];
                 }
             } else {
                 /* initial value */
                 if ($min_neg_time_difference == 0) {
                     $min_neg_time_difference = $local_time_difference;
                     $min_neg_time_difference_description = $revision_event['value'];
                 }
                 /* overwrite existing if it is closer to event date */
                 if ($min_neg_time_difference < $local_time_difference) {
                     $min_neg_time_difference = $local_time_difference;
                     $min_neg_time_difference_description = $revision_event['value'];
                 }
             }
         }
     }
     if (!is_null($min_pos_time_difference_description)) {
         $output_value = $min_pos_time_difference_description;
     } else {
         $output_value = $min_neg_time_difference_description;
     }
     return $output_value;
 }