Exemple #1
0
/**
 * Print the value of the custom field (if the field is applicable to the project of
 * the specified issue and the current user has read access to it.
 * see custom_function_default_print_column_title() for rules about column names.
 * @param string  $p_column         Name of field to show in the column.
 * @param BugData $p_bug            Bug object.
 * @param integer $p_columns_target See COLUMNS_TARGET_* in constant_inc.php.
 * @return void
 */
function custom_function_default_print_column_value($p_column, BugData $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    if (COLUMNS_TARGET_CSV_PAGE == $p_columns_target) {
        $t_column_start = '';
        $t_column_end = '';
        $t_column_empty = '';
    } else {
        $t_column_start = '<td class="column-%s">';
        $t_column_end = '</td>';
        $t_column_empty = '&#160;';
    }
    $t_custom_field = column_get_custom_field_name($p_column);
    if ($t_custom_field !== null) {
        printf($t_column_start, 'custom-' . $t_custom_field);
        $t_field_id = custom_field_get_id_from_name($t_custom_field);
        if ($t_field_id === false) {
            echo '@', $t_custom_field, '@';
        } else {
            $t_issue_id = $p_bug->id;
            $t_project_id = $p_bug->project_id;
            if (custom_field_is_linked($t_field_id, $t_project_id)) {
                $t_def = custom_field_get_definition($t_field_id);
                print_custom_field_value($t_def, $t_field_id, $t_issue_id);
            } else {
                # field is not linked to project
                echo $t_column_empty;
            }
        }
        echo $t_column_end;
    } else {
        $t_plugin_columns = columns_get_plugin_columns();
        if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
            $t_function = 'print_column_' . $p_column;
        } else {
            $t_function = 'csv_format_' . $p_column;
        }
        if (function_exists($t_function)) {
            if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
                $t_function($p_bug, $p_columns_target);
            } else {
                $t_function($p_bug);
            }
        } else {
            if (isset($t_plugin_columns[$p_column])) {
                $t_column_object = $t_plugin_columns[$p_column];
                print_column_plugin($t_column_object, $p_bug, $p_columns_target);
            } else {
                printf($t_column_start, $p_column);
                if (isset($p_bug->{$p_column})) {
                    echo string_display_line($p_bug->{$p_column}) . $t_column_end;
                } else {
                    echo '@' . $p_column . '@' . $t_column_end;
                }
            }
        }
    }
}
    # has read access
    $t_custom_fields_found = true;
    $t_def = custom_field_get_definition($t_id);
    ?>
	<tr <?php 
    echo helper_alternate_class();
    ?>
>
		<td class="category">
			<?php 
    echo string_display(lang_get_defaulted($t_def['name']));
    ?>
		</td>
		<td colspan="5">
		<?php 
    print_custom_field_value($t_def, $t_id, $f_bug_id);
    ?>
		</td>
	</tr>
<?php 
}
# foreach
?>

<?php 
if ($t_custom_fields_found) {
    ?>
<!-- spacer -->
<tr class="spacer">
	<td colspan="6"></td>
</tr>
function custom_function_default_print_column_value($p_column, $p_issue_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    if (COLUMNS_TARGET_CSV_PAGE == $p_columns_target) {
        $t_column_start = '';
        $t_column_end = '';
        $t_column_empty = '';
    } else {
        $t_column_start = '<td>';
        $t_column_end = '</td>';
        $t_column_empty = '&nbsp;';
    }
    if (strpos($p_column, 'custom_') === 0) {
        echo $t_column_start;
        $t_custom_field = substr($p_column, 7);
        $t_field_id = custom_field_get_id_from_name($t_custom_field);
        if ($t_field_id === false) {
            echo '@', $t_custom_field, '@';
        } else {
            $t_issue_id = $p_issue_row['id'];
            $t_project_id = $p_issue_row['project_id'];
            if (custom_field_is_linked($t_field_id, $t_project_id)) {
                $t_def = custom_field_get_definition($t_field_id);
                print_custom_field_value($t_def, $t_field_id, $t_issue_id);
            } else {
                // field is not linked to project
                echo $t_column_empty;
            }
        }
        echo $t_column_end;
    } else {
        if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
            $t_function = 'print_column_' . $p_column;
        } else {
            $t_function = 'csv_format_' . $p_column;
        }
        if (function_exists($t_function)) {
            if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
                $t_function($p_issue_row, $p_columns_target);
            } else {
                $t_function($p_issue_row[$p_column]);
            }
        } else {
            if (isset($p_issue_row[$p_column])) {
                echo $t_column_start . $p_issue_row[$p_column] . $t_column_end;
            } else {
                echo $t_column_start . '@' . $p_column . '@' . $t_column_end;
            }
        }
    }
}
function custom_function_override_print_column_value($p_column, $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    if (COLUMNS_TARGET_CSV_PAGE == $p_columns_target) {
        $t_column_start = '';
        $t_column_end = '';
        $t_column_empty = '';
    } else {
        $t_column_start = '<td class="center">';
        $t_column_end = '</td>';
        $t_column_empty = '&#160;';
    }
    $t_custom_field = column_get_custom_field_name($p_column);
    if ($t_custom_field !== null) {
        echo $t_column_start;
        $t_field_id = custom_field_get_id_from_name($t_custom_field);
        if ($t_field_id === false) {
            echo '@', $t_custom_field, '@';
        } else {
            $t_issue_id = $p_bug->id;
            $t_project_id = $p_bug->project_id;
            if (custom_field_is_linked($t_field_id, $t_project_id)) {
                $t_def = custom_field_get_definition($t_field_id);
                if (strpos($p_column, 'custom_Deadline') === 0 && $t_def['type'] == CUSTOM_FIELD_TYPE_DATE) {
                    $deadline_date = custom_field_get_value($t_field_id, $t_issue_id);
                    if ($p_issue_row['status'] < 80) {
                        $current_date = strtotime(date("Y-m-d"));
                        if ($current_date >= $deadline_date) {
                            echo '<b><font color="red">';
                            print_custom_field_value($t_def, $t_field_id, $t_issue_id);
                            echo '</font></b>';
                        } else {
                            print_custom_field_value($t_def, $t_field_id, $t_issue_id);
                        }
                    } elseif ($deadline_date) {
                        if (lang_get_current() == 'german') {
                            echo '<b>ERLEDIGT!</b>';
                        } else {
                            echo '<b>DONE!</b>';
                        }
                    }
                } else {
                    print_custom_field_value($t_def, $t_field_id, $t_issue_id);
                }
            } else {
                // field is not linked to project
                echo $t_column_empty;
            }
        }
        echo $t_column_end;
    } else {
        $t_plugin_columns = columns_get_plugin_columns();
        if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
            if ($p_column == 'summary') {
                $t_function = 'print_column_summary_BFE';
            } else {
                $t_function = 'print_column_' . $p_column;
            }
        } else {
            $t_function = 'csv_format_' . $p_column;
        }
        if (function_exists($t_function)) {
            if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
                $t_function($p_bug, $p_columns_target);
            } else {
                $t_function($p_bug);
            }
        } else {
            if (isset($t_plugin_columns[$p_column])) {
                $t_column_object = $t_plugin_columns[$p_column];
                print_column_plugin($t_column_object, $p_bug, $p_columns_target);
            } else {
                if (isset($p_bug->{$p_column})) {
                    echo $t_column_start . string_display_line($p_bug->{$p_column}) . $t_column_end;
                } else {
                    echo $t_column_start . '@' . $p_column . '@' . $t_column_end;
                }
            }
        }
    }
}
</tr>
<?php 
        $t_related_custom_field_ids = custom_field_get_linked_ids($v_project_id);
        foreach ($t_related_custom_field_ids as $t_id) {
            $t_def = custom_field_get_definition($t_id);
            ?>
<tr class="print">
	<td class="print-category">
		<?php 
            echo lang_get_defaulted($t_def['name']);
            ?>
:
	</td>
	<td class="print" colspan="5">
		<?php 
            print_custom_field_value($t_def, $t_id, $v_id);
            ?>
	</td>
</tr>
<?php 
        }
        // foreach
        ?>
<tr>
	<td class="print-spacer" colspan="6">
		<hr size="1" width="100%" />
	</td>
</tr>
<tr class="print">
	<td class="print-category">
		<?php 
                    echo '<td class="custom_field pad1 center" title="', string_display(lang_get_defaulted($t_def['name'])), '">', print_custom_field_value($t_def, $t_id, $t_bug->id), '</td>';
                }
            }
        }
    } else {
        foreach ($g_show_only_custom_fields as $t_display_id) {
            foreach ($t_related_custom_field_ids as $key => $t_id) {
                if (!custom_field_has_read_access($t_id, $t_bug->id)) {
                    continue;
                }
                # has read access #d8d8d8
                $t_custom_fields_found = true;
                $t_def = custom_field_get_definition($t_id);
                $t_def_custom = 'custom_' . strtolower($t_def['name']);
                if ($key + 1 === $t_display_id) {
                    echo '<td class="custom_field pad1 center" title="', string_display(lang_get_defaulted($t_def['name'])), '">', print_custom_field_value($t_def, $t_id, $t_bug->id), '</td>';
                }
            }
        }
    }
    echo '</tr>';
    if ($t_custom_fields_found) {
        # spacer
        echo '<tr class="custom_spacer"><td colspan="20"></td></tr>';
    }
    # custom fields found
    #*********
    ?>
</tr>
</tr>
<?php 
	<td class="print">
		<?php echo string_display_line( $t_bug->target_version ) ?>
	</td>
	<td class="print" colspan="2">&#160;</td>
</tr>
<?php
$t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug->project_id );
foreach( $t_related_custom_field_ids as $t_custom_field_id ) {
	$t_def = custom_field_get_definition( $t_custom_field_id );
?>
<tr class="print">
	<td class="print-category">
		<?php echo sprintf( lang_get( 'label' ), lang_get_defaulted( $t_def['name'] ) ) ?>
	</td>
	<td class="print" colspan="5">
		<?php print_custom_field_value( $t_def, $t_custom_field_id, $t_id ); ?>
	</td>
</tr>
<?php
}       // foreach
?>
<tr>
	<td class="print-spacer" colspan="6">
		<hr />
	</td>
</tr>
<tr class="print">
	<td class="print-category">
		<?php echo sprintf( lang_get( 'label' ), $t_lang_summary ) ?>
	</td>
	<td class="print" colspan="5">