.
#------------------------------
# $Revision: 2643 $
# $Author: al $
# $Date: 2009-06-18 19:06:27 -0400 (Thu, 18 Jun 2009) $
#------------------------------
$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
require_once( $t_core_dir . 'prepare_api.php' );
### Custom Function API ###
# --------------------
# Checks the provided bug and determines whether it should be included in the changelog
# or not.
# returns true: to include, false: to exclude.
function custom_function_default_changelog_include_issue( $p_issue_id ) {
$t_issue = bug_get( $p_issue_id );
return ( ( $t_issue->duplicate_id == 0 ) && ( $t_issue->resolution == FIXED ) &&
( $t_issue->status >= config_get( 'bug_resolved_status_threshold' ) ) );
}
# --------------------
# Prints one entry in the changelog.
function custom_function_default_changelog_print_issue( $p_issue_id, $p_issue_level = 0 ) {
$t_bug = bug_get( $p_issue_id );
$t_category = is_blank( $t_bug->category ) ? '' : '[' . $t_bug->category . '] ';
echo str_pad( '', $p_issue_level * 6, ' ' ), '- ', string_get_bug_view_link( $p_issue_id ), ': ', $t_category, string_display_line_links( $t_bug->summary );
if ( $t_bug->handler_id != 0 ) {
echo ' (', prepare_user_name( $t_bug->handler_id ), ')';
}
echo ' - ', get_enum_element( 'status', $t_bug->status ), '.
';
}
# --------------------
# Checks the provided bug and determines whether it should be included in the roadmap or not.
# returns true: to include, false: to exclude.
function custom_function_default_roadmap_include_issue( $p_issue_id ) {
$t_issue = bug_get( $p_issue_id );
return ( $t_issue->duplicate_id == 0 );
}
# --------------------
# Prints one entry in the roadmap.
function custom_function_default_roadmap_print_issue( $p_issue_id, $p_issue_level = 0 ) {
$t_bug = bug_get( $p_issue_id );
if ( bug_is_resolved( $p_issue_id ) ) {
$t_strike_start = '';
$t_strike_end = '';
} else {
$t_strike_start = $t_strike_end = '';
}
$t_category = is_blank( $t_bug->category ) ? '' : '[' . $t_bug->category . '] ';
echo str_pad( '', $p_issue_level * 6, ' ' ), '- ', $t_strike_start, string_get_bug_view_link( $p_issue_id ), ': ', $t_category, string_display_line_links( $t_bug->summary );
if ( $t_bug->handler_id != 0 ) {
echo ' (', prepare_user_name( $t_bug->handler_id ), ')';
}
echo ' - ', get_enum_element( 'status', $t_bug->status ), $t_strike_end, '.
';
}
# --------------------
# format the bug summary.
function custom_function_default_format_issue_summary( $p_issue_id, $p_context=0 ) {
switch ( $p_context ) {
case SUMMARY_CAPTION:
$t_string = bug_format_id( $p_issue_id ) . ': ' . string_attribute( bug_get_field( $p_issue_id, 'summary' ) );
break;
case SUMMARY_FIELD:
$t_string = bug_format_id( $p_issue_id ) . ': ' . string_display_line_links( bug_get_field( $p_issue_id, 'summary' ) );
break;
case SUMMARY_EMAIL:
$t_string = bug_format_id( $p_issue_id ) . ': ' . string_attribute( bug_get_field( $p_issue_id, 'summary' ) );
break;
default:
$t_string = string_attribute( bug_get_field( $p_issue_id, 'summary' ) );
break;
}
return $t_string;
}
# --------------------
# Register a checkin in source control by adding a history entry and a note
# This can be overriden to do extra work.
# The issue status/resolution would only be set if the issue is fixed, and hence $p_fixed is passed as true.
function custom_function_default_checkin( $p_issue_id, $p_comment, $p_file, $p_new_version, $p_fixed ) {
if ( bug_exists( $p_issue_id ) ) {
history_log_event_special( $p_issue_id, CHECKIN, $p_file, $p_new_version );
bugnote_add( $p_issue_id, $p_comment, 0, VS_PRIVATE == config_get( 'source_control_notes_view_status' ) );
$t_status = config_get( 'source_control_set_status_to' );
if ( ( OFF != $t_status ) && $p_fixed ) {
bug_set_field( $p_issue_id, 'status', $t_status );
bug_set_field( $p_issue_id, 'resolution', config_get( 'source_control_set_resolution_to' ) );
}
}
}
# --------------------
# Hook to validate field issue data before updating
# Verify that the proper fields are set with the appropriate values before proceeding
# to change the status.
# In case of invalid data, this function should call trigger_error()
# p_issue_id is the issue number that can be used to get the existing state
# p_new_issue_data is an object (BugData) with the appropriate fields updated
function custom_function_default_issue_update_validate( $p_issue_id, $p_new_issue_data, $p_bugnote_text ) {
}
# --------------------
# Hook to notify after an issue has been updated.
# In case of errors, this function should call trigger_error()
# p_issue_id is the issue number that can be used to get the existing state
function custom_function_default_issue_update_notify( $p_issue_id ) {
}
# --------------------
# Hook to validate field settings before creating an issue
# Verify that the proper fields are set before proceeding to create an issue
# In case of errors, this function should call trigger_error()
# p_new_issue_data is an object (BugData) with the appropriate fields updated
function custom_function_default_issue_create_validate( $p_new_issue_data ) {
}
# --------------------
# Hook to notify after aa issue has been created.
# In case of errors, this function should call trigger_error()
# p_issue_id is the issue number that can be used to get the existing state
function custom_function_default_issue_create_notify( $p_issue_id ) {
}
# --------------------
# Hook to validate field settings before deleting an issue.
# Verify that the issue can be deleted before the actual deletion.
# In the case that the issue should not be deleted, this function should
# call trigger_error().
# p_issue_id is the issue number that can be used to get the existing state
function custom_function_default_issue_delete_validate( $p_issue_id ) {
}
# --------------------
# Hook to notify after an issue has been deleted.
# p_issue_data is the issue data (BugData) that reflects the last status of the
# issue before it was deleted.
function custom_function_default_issue_delete_notify( $p_issue_data ) {
}
# --------------------
# Hook for authentication
# can Mantis update the password
function custom_function_default_auth_can_change_password( ) {
$t_can_change = array( PLAIN, CRYPT, CRYPT_FULL_SALT, MD5 );
if ( in_array( config_get( 'login_method' ), $t_can_change ) ) {
return true;
} else {
return false;
}
}
# --------------------
# returns an array of the column names to be displayed.
# The column names to use are those of the field names in the bug table.
# In addition, you can use the following:
# - "selection" for selection checkboxes.
# - "edit" for icon to open the edit page.
# - "custom_xxxx" were xxxx is the name of the custom field that is valid for the
# current project. In case of "All Projects, the field will be empty where it is
# not applicable.
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
function custom_function_default_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
if ( $p_columns_target == COLUMNS_TARGET_CSV_PAGE ) {
$t_columns = config_get( 'csv_columns' );
} else if ( $p_columns_target == COLUMNS_TARGET_VIEW_PAGE ) {
$t_columns = config_get( 'view_issues_page_columns' );
} else {
$t_columns = config_get( 'print_issues_page_columns' );
}
return $t_columns;
}
# --------------------
# Print the title of a column given its name.
# $p_column: custom_xxx for custom field xxx, or otherwise field name as in bug table.
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
function custom_function_default_print_column_title( $p_column, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
global $t_sort, $t_dir;
if ( strpos( $p_column, 'custom_' ) === 0 ) {
$t_custom_field = substr( $p_column, 7 );
if ( COLUMNS_TARGET_CSV_PAGE != $p_columns_target ) {
echo '