// fetch all the
- DB_DataObject::debugLevel(1);
+ //DB_DataObject::debugLevel(1);
$d = DB_DataObject::factory('mtrack_change');
$d->ontable = 'mtrack_ticket';
$d->onid = $this->id;
while ($d->fetch()) {
$this->events[$d->id] = clone($d);
}
-
+ /*
$d = DB_DataObject::factory('mtrack_change_audit');
$d->whereAddIn('change_id', array_keys($this->events), 'int');
$d->find();
$this->events[$d->change_id]->audit[] = clone($d);
}
-
- foreach($this->events as $id->$c) {
+ */
+ foreach($this->events as $id=>$c) {
echo $this->eventToHtml($c);
}
exit;
$preamble = 0;
- $cid = "comment:{$e->change_id}";
+ $cid = "comment:{$e->id}";
// tidied up by jquery..
- $timestamp = $link->date($e->changedate, false);
+ $timestamp = $this->link->date($e->changedate, false);
$comments = array();
$comment_title = array_shift(explode("\n", $e->reason));
}
-
- foreach ($e->audit as $citem) {
- //print_r($citem);
- $main = false;
-
- $ar = explode(':', $citem['fieldname'], 3);
- if (count($ar) != 3) {
- continue;
- }
-
- list($tbl,,$field) = $ar;
-
- if ($tbl != 'ticket') {
- // can get here if we created a new keyword, for example
- //var_dump($citem);
- continue;
- }
-
- switch($field) {
-
- case 'spent': //?? ignore why?
- continue;
-
-
-
- case '@components':
- $comment_fields[] = $field;
- $ar = MTrackComponent::loadByIds($citem['value']);
- $ar = array_map( function($e) { return $e->toHtml(); }, $ar);
- $citem['value'] = join(', ', $ar);
-
-
- break;
-
- case '@milestones':
- $comment_fields[] = $field;
- $citem['value'] = $e->get_milestones_list($citem['value']);
- break;
-
- case '@keywords':
-
-
- $comment_fields[] = $field;
- $ar = MTrackKeyword::loadByIds($citem['value']);
- $ar = array_map( function($e) { return $e->toHtml(); }, $ar);
- $citem['value'] = join(', ', $ar);
- break;
-
- case 'estimated':
- $comment_fields[] = $field;
- if ($citem['value'] !== null) {
- $citem['value'] += 0;
- }
- if ($citem['oldvalue'] !== null) {
- $citem['oldvalue'] += 0;
- }
- break;
-
- default:
- $comment_fields[] = $field;
- if ($field[0] == '@') {
- $main = isset($pseudo_fields[$field]) ? $pseudo_fields[$field] : '';
- $field = substr($field, 1, -1);
- } else {
- $main = $e->issue->$field;
- }
-
- }
-
-
- require_once 'MTrack/Ticket_CustomFields.php';
- $f = MTrackTicket_CustomFields::getInstance()->fieldByName($field);
-
-
-
- if ($f) {
- $label = htmlentities($f->label, ENT_QUOTES, 'utf-8');
- } else {
- if ($field == 'attachment' && strlen($citem['oldvalue'])) {
- $label = "Attachment: $citem[oldvalue]";
- } else {
- $label = ucfirst($field);
- }
- }
-
- if ($citem['oldvalue'] == null) {
- /* don't bother printing out a set if this is the initial thing
- * and if the field values are currently the same */
-
- if ($main != $citem['value'] || $e->change_id != 'top') {
-
- /* Special case for description; since it is multi-line and often
- * very large, render it as a diff against the current ticket
- * description field */
- if ($field == 'description') {
- if ($this->issue->description == $citem['value']) {
- $comment_body .= "<b>Description</b>: no longer empty; see above<br>";
- continue;
- }
-
- $initial_lines = count(explode("\n", $this->issue->description));
- $diff = $this->diff_strings($this->issue->description, $citem['value']);
- $diff_add = 0;
- $diff_rem = 0;
- foreach (explode("\n", $diff) as $line) {
- if (!strlen($line)) continue;
- if ($line[0] == '-') {
- $diff_rem++;
- } else if ($line[0] == '+') {
- $diff_add++;
- }
- }
- if (abs($diff_add - $diff_rem) > $initial_lines / 2) {
- $comment_body .= "<b>initial $label</b><br>" .
- MTrack_Wiki::format_to_html($citem['value']);
- } else {
- $diff = $this->collapse_diff($diff);
- $comment_body .= "<b>initial $label</b> (diff to above):<br>$diff\n";
- }
- } else {
- $comment_body .= "<b>$label</b> $citem[value]<br>\n";
- }
- }
- continue;
- }
-
- if ($citem['action'] == 'changed') {
- $lines = explode("\n", $citem['value'], 3);
- if (count($lines) >= 2) {
- $diff = $this->diff_strings($citem['oldvalue'], $citem['value']);
- $diff = $this->collapse_diff($diff);
- $comment_body .= "<b>$label</b> $citem[action]\n$diff\n";
- } else {
- $comment_body .= "<b>$label</b> $citem[action] to $citem[value]<br>\n";
- }
- continue;
- }
-
- $comment_body .= "<b>$label</b> $citem[action]<br>\n";
+
+ $comment_fields = str_replace("\n", "<BR>" , htmlspecialchars($e->cachedAuditToString()."\n"));
+ //$comment_body .= "<b>$label</b> $citem[action]<br>\n";
- }
+
$commit_info = array();
if ($comment_title &&
}
- if ($this->cid == $this->issue->created) {
+ if ($this->id == $this->issue->created) {
$type = 'Created';
$comment_title = 'Issue Created';
}
$html = '
<div class="ticketevent">
- <span class="ticketevent-expand" id="ticketevent-expand-' . $this->cid . '">+ ' . $type.'</span>
- <a class="pmark" href="#'.$cid.'">#'.$this->cid.'</a>
+ <span class="ticketevent-expand" id="ticketevent-expand-' . $e->id . '">+ ' . $type.'</span>
+ <a class="pmark" href="#'.$cid.'">#'.$e->id.'</a>
- <span class="ticketevent-expand" id="ticketevent-expand-title-' . $this->cid . '">' .
- (strlen($comment_title) ? $comment_title : implode(', ', $comment_fields)) . '
+ <span class="ticketevent-expand" id="ticketevent-expand-title-' . $e->id . '">' .
+ (strlen($comment_title) ? $comment_title : $comment_fields) . '
</span>
<span style="float:right">' .
- $link->username($this->who, array('no_image' => true, 'fullname' => true)) . '
+ $this->link->username($e->person_id, array('no_image' => true, 'fullname' => true)) . '
- <a name="'.$cid.'">'.$timestamp.'</a>
</span>
</div>
- <div class="ticketchangeinfo" id="ticketchangeinfo-' . $this->cid . '">' .
- $link->username($this->who, array('no_name' => true, 'size' => 48));
-
+ ';
-
+ /*
foreach ($this->effort as $eff) {
$exp = (float)$eff['expended'];
if ($eff['expended'] != 0) {
$preamble++;
}
}
-
+ */
if ($preamble) {
$html .= "<br>\n";
foreach ($comments as $cid => $text) {
// look for changesets in the comments..
// and display them as expandable linsk..
- $html .= MTrack_Wiki::format_to_html($text);
+ $html .= '<pre class="showdown-render">' . htmlspecialchars($text) .
+ "\n\n" . $comment_fields . '</PRE>'; // MTrack_Wiki::format_to_html($text);
}