<?php
# Copyright (c) 2010 John Reese
# Licensed under the MIT license
class SourceRelatedChangesetsColumn extends MantisColumn {
public $title = "Related Changesets";
public $column = "related_changesets";
public $sortable = false;
private $changeset_cache = array();
public function cache( $p_bugs ) {
$t_bug_table = plugin_table( 'bug', 'Source' );
$t_bug_ids = array();
foreach ( $p_bugs as $t_bug ) {
$t_bug_ids[] = $t_bug->id;
}
$t_bug_ids = implode( ',', $t_bug_ids );
$t_query = "SELECT * FROM $t_bug_table WHERE bug_id IN ( $t_bug_ids )";
$t_result = db_query_bound( $t_query );
while ( $t_row = db_fetch_array( $t_result ) ) {
if ( isset( $this->changeset_cache[ $t_row['bug_id'] ] ) ) {
$this->changeset_cache[ $t_row['bug_id'] ]++;
} else {
$this->changeset_cache[ $t_row['bug_id'] ] = 1;
}
}
}
public function display( $p_bug, $p_columns_target ) {
echo $this->changeset_cache[ $p_bug->id ];
}
}