id = $pi ? $pi: (isset($_GET['id']) ? $_GET['id'] : 0);
$this->id = (int) $this->id ;
$this->loadIssue();
if (!$this->issue) {
$this->jerr( "OPPS");
}
$start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit'] : 100;
// fetch all the
//DB_DataObject::debugLevel(1);
$d = DB_DataObject::factory('mtrack_change');
$d->ontable = 'mtrack_ticket';
$d->onid = $this->id;
$d->orderBy('changedate ASC'); // last first?
$d->limit ($start, $limit);
$d->audit = array();
$d->find();
$this->events = array();
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();
while ($d->fetch()) {
$this->events[$d->change_id]->audit[] = clone($d);
}
*/
foreach($this->events as $id=>$c) {
echo $this->eventToHtml($c);
}
exit;
//$this->renderEvents();
}
function eventToHtml($e)
{
$preamble = 0;
$cid = "comment:{$e->id}";
// tidied up by jquery..
$timestamp = $this->link->date($e->changedate, false);
$comments = array();
// default is that something changed..
$type = 'Changed';
$comment_body = '';
$comment_title = '';
$comment_fields = array();
if (!empty($e->reason)) {
$comments[] = $e->reason;
$type = 'Comment added';
$comment_title = array_shift(explode("\n", $e->reason));
}
$comment_fields = str_replace("\n", "
" , htmlspecialchars($e->cachedAuditToString()."\n"));
//$comment_body .= "$label $citem[action]
\n";
$commit_info = array();
if ($comment_title &&
preg_match('/\(In \[changeset:([^,]+),([a-z0-9]+)\]\)(.*)$/i', $comment_title, $commit_info)) {
$type = 'Commit';
$comment_title = '[' . $commit_info[2] . ']'.$commit_info[3];
}
if ($this->id == $this->issue->created) {
$type = 'Created';
$comment_title = 'Issue Created';
}
$html = '
' . htmlspecialchars($text) . "\n\n" . $comment_fields . ''; // MTrack_Wiki::format_to_html($text); } $html .= ''; if ($commit_info) { // list the files that where changed... //$html.= print_r($M, true); $rp = '/' . $commit_info[1] . '/' . $commit_info[2]; $fullrp = $rp; $repo = MTrackSCM::factory($rp); $cd = $repo->historyWithChangelog(null, 1, 'rev', $rp); //print_r($cd);exit; if (!is_array($cd->ent->files) || !count($cd->ent->files)) { return $html; } $num = count(array_keys($cd->ent->files)); $map = array( 'D' => 'DELETED', 'M' => 'MODIFIED', 'A' => 'ADDED' ); $file_summary = array(); foreach($map as $k=>$v) { $summary[$v] = 0; } foreach ($cd->ent->files as $id => $file) { $type = isset($map[$file->status]) ? $map[$file->status] : '??? '. $file->status; if ($num > 10) { // will bork on unknown... $summary[$type]++; continue; } $html .= '