Update of /cvsroot/mantisbt/mantisbt/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3737/core
Modified Files:
columns_api.php custom_function_api.php filter_api.php
Log Message:
Adding support for sorting in View Issues page by custom fields.
Index: custom_function_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/custom_function_api.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- custom_function_api.php 25 Jan 2005 13:57:28 -0000 1.14
+++ custom_function_api.php 28 Jan 2005 21:58:16 -0000 1.15
@@ -181,9 +181,13 @@
# 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.
function custom_function_default_print_column_title( $p_column,
$p_print = false ) {
+ global $t_sort, $t_dir;
+
if ( strpos( $p_column, 'custom_' ) === 0 ) {
$t_custom_field = substr( $p_column, 7 );
+ echo '<td>';
+
$t_field_id = custom_field_get_id_from_name(
$t_custom_field );
if ( $t_field_id === false ) {
echo '@', $t_custom_field, '@';
@@ -191,11 +195,14 @@
$t_def = custom_field_get_definition(
$t_field_id );
$t_custom_field = lang_get_defaulted(
$t_def['name'] );
- echo '<td>', $t_custom_field, '</td>';
+ print_view_bug_sort_link( $t_custom_field,
$p_column, $t_sort, $t_dir, $p_print );
+ print_sort_icon( $t_dir, $t_sort, $p_column );
}
+
+ echo '</td>';
} else {
$t_function = 'print_column_title_' . $p_column;
- $t_function();
+ $t_function( $t_sort, $t_dir, $p_print );
}
}
@@ -216,7 +223,7 @@
} 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 );
@@ -228,7 +235,7 @@
echo '</td>';
} else {
$t_function = 'print_column_' . $p_column;
- $t_function( $p_issue_row );
+ $t_function( $p_issue_row, $p_print );
}
}
Index: columns_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/columns_api.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- columns_api.php 25 Jan 2005 13:57:29 -0000 1.1
+++ columns_api.php 28 Jan 2005 21:58:16 -0000 1.2
@@ -10,33 +10,30 @@
# --------------------------------------------------------
?>
<?php
- function print_column_title_selection( $p_print = false ) {
+
+ function print_column_title_selection( $p_sort, $p_dir, $p_print =
false ) {
echo '<td> </td>';
}
- function print_column_title_edit( $p_print = false ) {
+ function print_column_title_edit( $p_sort, $p_dir, $p_print = false ) {
echo '<td> </td>';
}
- function print_column_title_bug_id( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_bug_id( $p_sort, $p_dir, $p_print = false )
{
echo '<td>';
- print_view_bug_sort_link( lang_get( 'id' ), 'id', $t_sort,
$t_dir, $p_print );
- print_sort_icon( $t_dir, $t_sort, 'id' );
+ print_view_bug_sort_link( lang_get( 'id' ), 'id', $p_sort,
$p_dir, $p_print );
+ print_sort_icon( $p_dir, $p_sort, 'id' );
echo '</td>';
}
- function print_column_title_priority( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_priority( $p_sort, $p_dir, $p_print = false
) {
echo '<td>';
- print_view_bug_sort_link( 'P', 'priority', $t_sort, $t_dir,
$p_print );
- print_sort_icon( $t_dir, $t_sort, 'priority' );
+ print_view_bug_sort_link( 'P', 'priority', $p_sort, $p_dir,
$p_print );
+ print_sort_icon( $p_dir, $p_sort, 'priority' );
echo '</td>';
}
- function print_column_title_attachment( $p_print = false ) {
+ function print_column_title_attachment( $p_sort, $p_dir, $p_print =
false ) {
$t_show_attachments = config_get( 'show_attachment_indicator' );
if ( ON == $t_show_attachments ) {
@@ -46,65 +43,53 @@
}
}
- function print_column_title_category( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_category( $p_sort, $p_dir, $p_print = false
) {
echo '<td>';
- print_view_bug_sort_link( lang_get( 'category' ), 'category',
$t_sort, $t_dir, $p_print );
- print_sort_icon( $t_dir, $t_sort, 'category' );
+ print_view_bug_sort_link( lang_get( 'category' ), 'category',
$p_sort, $p_dir, $p_print );
+ print_sort_icon( $p_dir, $p_sort, 'category' );
echo '</td>';
}
- function print_column_title_sponsorship( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_sponsorship( $p_sort, $p_dir, $p_print =
false ) {
$t_enable_sponsorship = config_get( 'enable_sponsorship' );
if ( ON == $t_enable_sponsorship ) {
echo "\t<td>";
- print_view_bug_sort_link( sponsorship_get_currency(),
'sponsorship_total', $t_sort, $t_dir, $p_print );
- print_sort_icon( $t_dir, $t_sort, 'sponsorship_total' );
+ print_view_bug_sort_link( sponsorship_get_currency(),
'sponsorship_total', $p_sort, $p_dir, $p_print );
+ print_sort_icon( $p_dir, $p_sort, 'sponsorship_total' );
echo "</td>\n";
}
}
- function print_column_title_severity( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_severity( $p_sort, $p_dir, $p_print = false
) {
echo '<td>';
- print_view_bug_sort_link( lang_get( 'severity' ), 'severity',
$t_sort, $t_dir, $p_print );
- print_sort_icon( $t_dir, $t_sort, 'severity' );
+ print_view_bug_sort_link( lang_get( 'severity' ), 'severity',
$p_sort, $p_dir, $p_print );
+ print_sort_icon( $p_dir, $p_sort, 'severity' );
echo '</td>';
}
- function print_column_title_status( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_status( $p_sort, $p_dir, $p_print = false )
{
echo '<td>';
- print_view_bug_sort_link( lang_get( 'status' ), 'status',
$t_sort, $t_dir, $p_print );
- print_sort_icon( $t_dir, $t_sort, 'status' );
+ print_view_bug_sort_link( lang_get( 'status' ), 'status',
$p_sort, $p_dir, $p_print );
+ print_sort_icon( $p_dir, $p_sort, 'status' );
echo '</td>';
}
- function print_column_title_last_updated( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_last_updated( $p_sort, $p_dir, $p_print =
false ) {
echo '<td>';
- print_view_bug_sort_link( lang_get( 'updated' ),
'last_updated', $t_sort, $t_dir, $p_print );
- print_sort_icon( $t_dir, $t_sort, 'last_updated' );
+ print_view_bug_sort_link( lang_get( 'updated' ),
'last_updated', $p_sort, $p_dir, $p_print );
+ print_sort_icon( $p_dir, $p_sort, 'last_updated' );
echo '</td>';
}
- function print_column_title_summary( $p_print = false ) {
- global $t_sort, $t_dir;
-
+ function print_column_title_summary( $p_sort, $p_dir, $p_print = false
) {
echo '<td>';
- print_view_bug_sort_link( lang_get( 'summary' ), 'summary',
$t_sort, $t_dir, $p_print );
- print_sort_icon( $t_dir, $t_sort, 'summary' );
+ print_view_bug_sort_link( lang_get( 'summary' ), 'summary',
$p_sort, $p_dir, $p_print );
+ print_sort_icon( $p_dir, $p_sort, 'summary' );
echo '</td>';
}
- function print_column_title_bugnotes_count( $p_print = false ) {
+ function print_column_title_bugnotes_count( $p_sort, $p_dir, $p_print =
false ) {
echo '<td> # </td>';
}
@@ -180,10 +165,10 @@
echo '<td class="center">';
if ( $bugnote_count > 0 ) {
- $t_bugnote_link = '<a href="' .
string_get_bug_view_url( $p_row['id'] )
- . '&nbn=' . $bugnote_count . '#bugnotes">'
- . $bugnote_count . '</a>';
-
+ $t_bugnote_link = '<a href="' .
string_get_bug_view_url( $p_row['id'] )
+ . '&nbn=' . $bugnote_count . '#bugnotes">'
+ . $bugnote_count . '</a>';
+
if ( $v_bugnote_updated > strtotime(
'-'.$t_filter['highlight_changed'].' hours' ) ) {
printf( '<span class="bold">%s</span>',
$t_bugnote_link );
} else {
@@ -200,11 +185,11 @@
# Check for attachments
$t_attachment_count = 0;
- if ( ( ON == $t_show_attachments )
+ if ( ( ON == $t_show_attachments )
&& ( file_can_view_bug_attachments( $p_row['id'] ) ) ) {
$t_attachment_count = file_bug_attachment_count(
$p_row['id'] );
}
-
+
if ( ON == $t_show_attachments ) {
echo "\t<td>";
if ( 0 < $t_attachment_count ) {
@@ -230,7 +215,7 @@
echo '<td class="center">';
# type project name if viewing 'all projects'
- if ( ON == config_get( 'show_bug_project_links' )
+ if ( ON == config_get( 'show_bug_project_links' )
&& helper_get_current_project() == ALL_PROJECTS ) {
echo '<small>[';
print_view_bug_sort_link( $t_project_name,
'project_id', $t_sort, $t_dir, $p_print );
@@ -250,14 +235,14 @@
function print_column_status( $p_row, $p_print = false ) {
echo '<td class="center">';
printf( '<u><a title="%s">%s</a></u>'
- , get_enum_element( 'resolution', $p_row['resolution']
)
+ , get_enum_element( 'resolution', $p_row['resolution'] )
, get_enum_element( 'status', $p_row['status'] )
);
-
+
# print username instead of status
- if ( ON == config_get( 'show_assigned_names' )
+ if ( ON == config_get( 'show_assigned_names' )
&& $p_row['handler_id'] > 0 ) {
- printf( ' (%s)', $p_row['handler_id'] );
+ printf( ' (%s)', prepare_user_name(
$p_row['handler_id'] ) );
}
echo '</td>';
}
Index: filter_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/filter_api.php,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- filter_api.php 15 Jan 2005 23:19:11 -0000 1.75
+++ filter_api.php 28 Jan 2005 21:58:16 -0000 1.76
@@ -58,13 +58,13 @@
$t_report_bug_threshold = config_get(
'report_bug_threshold' );
$t_current_user_id = auth_get_current_user_id();
-
+
if ( null === $p_user_id ) {
$t_user_id = $t_current_user_id;
} else {
$t_user_id = $p_user_id;
}
-
+
$c_user_id = db_prepare_int( $t_user_id );
if ( null === $p_project_id ) {
@@ -84,7 +84,7 @@
} else {
$t_filter = $custom_filter;
}
-
+
$t_filter = filter_ensure_valid_filter( $t_filter );
if ( false === $t_filter ) {
@@ -320,7 +320,7 @@
array_push( $t_where_clauses, '('. implode( ' OR ',
$t_clauses ) .')' );
}
- # priority
+ # priority
$t_any_found = false;
foreach( $t_filter['show_priority'] as $t_filter_member ) {
if ( ( '[any]' == $t_filter_member ) || ( 0 ===
$t_filter_member ) ) {
@@ -481,19 +481,19 @@
$t_any_found = true;
}
if ( !$t_any_found ) {
- $t_def = custom_field_get_definition(
$t_cfid );
+ $t_def = custom_field_get_definition(
$t_cfid );
$t_table_name =
$t_custom_field_string_table . '_' . $t_cfid;
array_push( $t_join_clauses, "LEFT JOIN
$t_custom_field_string_table as $t_table_name ON $t_table_name.bug_id =
$t_bug_table.id" );
foreach(
$t_filter['custom_fields'][$t_cfid] as $t_filter_member ) {
if ( isset( $t_filter_member )
&&
( '[any]' !=
strtolower( $t_filter_member ) ) &&
- ( !is_blank( trim(
$t_filter_member ) ) ) ) {
-
+ ( !is_blank( trim(
$t_filter_member ) ) ) ) {
+
$t_filter_member =
stripslashes( $t_filter_member );
if ( '[none]' ==
$t_filter_member ) { # coerce filter value if selecting 'none'
$t_filter_member = '';
}
-
+
if( $t_first_time ) {
$t_first_time =
false;
$t_custom_where_clause = '(';
@@ -541,7 +541,7 @@
OR
($t_bug_text_table.additional_information LIKE '%$c_search%')
OR ($t_bug_table.id
LIKE '%$c_search%')
OR
($t_bugnote_text_table.note LIKE '%$c_search%'))";
-
+
array_push( $t_where_clauses, "($t_bug_text_table.id =
$t_bug_table.bug_text_id)" );
$t_from_clauses = array( $t_bug_text_table,
$t_project_table, $t_bug_table );
@@ -558,18 +558,18 @@
} else {
$t_where = '';
}
-
+
if ( null === $p_show_sticky ) {
$t_where .= " AND $t_bug_table.sticky = 0";
}
else {
$t_where .= " AND $t_bug_table.sticky = 1";
}
-
+
if ( false === $t_filter['sticky_issues'] && true ===
$p_show_sticky ) {
$t_where .= " AND 1 = 0";
}
-
+
# Possibly do two passes. First time, grab the IDs of issues
that match the filters. Second time, grab the IDs of issues that
# have bugnotes that match the text search if necessary.
$t_id_array = array();
@@ -606,7 +606,7 @@
} else {
$t_where = "WHERE 1 != 1";
}
-
+
$t_from = 'FROM ' . $t_bug_table;
# Get the total number of bugs that meet the criteria.
@@ -650,11 +650,6 @@
$p_page_number = 1;
}
- $query2 = "SELECT DISTINCT $t_select
- $t_from
- $t_join
- $t_where";
-
# Now add the rest of the criteria i.e. sorting, limit.
$c_sort = db_prepare_string( $t_filter['sort'] );
@@ -666,20 +661,33 @@
$t_filter['dir'] = 'DESC';
}
+ # if sorting by a custom field
+ if ( strpos( $c_sort, 'custom_' ) === 0 ) {
+ $t_custom_field = substr( $c_sort, strlen( 'custom_' ) );
+ $t_custom_field_id = custom_field_get_id_from_name(
$t_custom_field );
+ $t_join .= " LEFT JOIN $t_custom_field_string_table ON ( (
$t_custom_field_string_table.bug_id = $t_bug_table.id ) AND (
$t_custom_field_string_table.field_id = $t_custom_field_id ) )";
+ $c_sort = "$t_custom_field_string_table.value";
+ }
+
if ( 'DESC' == $t_filter['dir'] ) {
$c_dir = 'DESC';
} else {
$c_dir = 'ASC';
}
- $query2 .= " ORDER BY $c_sort $c_dir";
+ $t_order = " ORDER BY $c_sort $c_dir";
if ( $c_sort != 'last_updated' ) {
- $query2 .= ', last_updated DESC, date_submitted DESC';
- }
- else {
- $query2 .= ', date_submitted DESC';
+ $t_order .= ', last_updated DESC, date_submitted DESC';
+ } else {
+ $t_order .= ', date_submitted DESC';
}
+ $query2 = "SELECT DISTINCT $t_select
+ $t_from
+ $t_join
+ $t_where
+ $t_order";
+
# Figure out the offset into the db query
#
# for example page number 1, per page 5:
@@ -701,7 +709,7 @@
$row = db_fetch_array( $result2 );
$row['date_submitted'] = db_unixtimestamp (
$row['date_submitted'] );
$row['last_updated'] = db_unixtimestamp (
$row['last_updated'] );
-
+
array_push( $rows, $row );
bug_add_to_cache( $row );
}
@@ -776,13 +784,13 @@
$t_tdclass = 'small-caption';
$t_trclass = 'row-category2';
$t_action = 'view_all_set.php?f=3';
-
+
if ( $p_for_screen == false ) {
$t_tdclass = 'print';
$t_trclass = '';
$t_action = 'view_all_set.php';
}
-?>
+?>
<br />
<form method="post" name="filters" id="filters_form"
action="<?php PRINT $t_action; ?>">
@@ -798,7 +806,7 @@
<input type="hidden" name="page_number" value="<?php PRINT
$p_page_number ?>" />
<input type="hidden" name="view_type" value="<?php PRINT
$t_view_type ?>" />
<table class="width100" cellspacing="1">
-
+
<?php
if ( $p_expanded ) {
$t_filter_cols = 7;
@@ -1140,7 +1148,7 @@
}
}
?>
- </td>
+ </td>
<td class="small-caption" valign="top"
id="hide_status_filter_target">
<?php
$t_output = '';
@@ -1443,7 +1451,7 @@
$t_output = '';
$t_any_found = false;
- $t_values .= '<td class="small-caption"
valign="top" id="custom_field_' . $t_accessible_custom_fields_ids[$i] .
'_filter_target"> ' ;
+ $t_values .= '<td class="small-caption"
valign="top" id="custom_field_' . $t_accessible_custom_fields_ids[$i] .
'_filter_target"> ' ;
if ( !isset(
$t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]] ) ) {
$t_values .= lang_get( 'any' );
} else {
@@ -1489,7 +1497,7 @@
$t_values .= '</tr>' . "\n";
echo $t_fields;
- echo $t_values;
+ echo $t_values;
$t_col_idx = 0;
$t_row_idx++;
@@ -1512,7 +1520,7 @@
$t_values .= '</tr>' . "\n";
echo $t_fields;
- echo $t_values;
+ echo $t_values;
}
}
}
@@ -1612,7 +1620,7 @@
$t_filters_table = config_get( 'mantis_filters_table' );
# check that the user can save non current filters (if required)
- if ( ( ALL_PROJECTS <= $c_project_id ) && ( !is_blank( $p_name
) ) &&
+ if ( ( ALL_PROJECTS <= $c_project_id ) && ( !is_blank( $p_name
) ) &&
( !access_has_project_level( config_get(
'stored_query_create_threshold' ) ) ) ) {
return -1;
}
@@ -1678,7 +1686,7 @@
if ( isset( $g_cache_filter_db_filters[$p_filter_id] ) ) {
return $g_cache_filter_db_filters[$p_filter_id];
}
-
+
if ( null === $p_user_id ) {
$t_user_id = auth_get_current_user_id();
} else {
@@ -1813,7 +1821,7 @@
$t_all_id = ALL_PROJECTS;
$query = "DELETE FROM $t_filters_table
- WHERE project_id<='$t_all_id'
+ WHERE project_id<='$t_all_id'
AND name=''";
$result = db_query( $query );
}
@@ -1821,7 +1829,7 @@
function filter_db_get_available_queries( $p_project_id = null,
$p_user_id = null ) {
$t_filters_table = config_get( 'mantis_filters_table' );
$t_overall_query_arr = array();
-
+
if ( null === $p_project_id ) {
$t_project_id = helper_get_current_project();
} else {
@@ -2004,7 +2012,7 @@
return $p_filter_arr;
}
-
+
/**
* The following functions each print out an individual filter field.
* They are derived from view_filters_page.php
@@ -2014,11 +2022,11 @@
* print_filter_[filter_name]
*
* Where [filter_name] is the same as the "name" of the form element for
- * that filter. This naming convention is depended upon by the
controller
+ * that filter. This naming convention is depended upon by the
controller
* at the end of the script.
*/
/**
- * I expect that this code could be made simpler by refactoring into a
+ * I expect that this code could be made simpler by refactoring into a
* class so as to avoid all those calls to global(which are pretty ugly)
*
* These functions could also be shared by view_filters_page.php
@@ -2030,18 +2038,18 @@
<select <?php PRINT $t_select_modifier;?> name="reporter_id[]">
<option value="[any]" <?php check_selected(
$t_filter['reporter_id'], '[any]' ); ?>>[<?php echo lang_get( 'any' )
?>]</option>
<?php
- if ( access_has_project_level( config_get(
'report_bug_threshold' ) ) ) {
+ if ( access_has_project_level( config_get(
'report_bug_threshold' ) ) ) {
PRINT '<option value="' .
META_FILTER_MYSELF . '" ';
check_selected(
$t_filter['reporter_id'], META_FILTER_MYSELF );
PRINT '>[' . lang_get( 'myself' ) .
']</option>';
- }
+ }
?>
<?php print_reporter_option_list(
$t_filter['reporter_id'] ) ?>
</select>
<?php
}
-
-
+
+
function print_filter_user_monitor(){
global $t_select_modifier, $t_filter;
?>
@@ -2068,17 +2076,17 @@
<option value="[any]" <?php check_selected(
$t_filter['handler_id'], '[any]' ); ?>>[<?php echo lang_get( 'any' )
?>]</option>
<option value="[none]" <?php check_selected(
$t_filter['handler_id'], '[none]' ); ?>>[<?php echo lang_get( 'none' )
?>]</option>
<?php
- if ( access_has_project_level( config_get(
'handle_bug_threshold' ) ) ) {
+ if ( access_has_project_level( config_get(
'handle_bug_threshold' ) ) ) {
PRINT '<option value="' .
META_FILTER_MYSELF . '" ';
check_selected(
$t_filter['handler_id'], META_FILTER_MYSELF );
PRINT '>[' . lang_get( 'myself' ) .
']</option>';
- }
+ }
?>
<?php print_assign_to_option_list(
$t_filter['handler_id'] ) ?>
</select>
<?php
}
-
+
function print_filter_show_category(){
global $t_select_modifier, $t_filter;
?>
@@ -2091,7 +2099,7 @@
</select>
<?php
}
-
+
function print_filter_show_severity(){
global $t_select_modifier, $t_filter;
?><!-- Severity -->
@@ -2101,7 +2109,7 @@
</select>
<?php
}
-
+
function print_filter_show_resolution(){
global $t_select_modifier, $t_filter;
?><!-- Resolution -->
@@ -2111,7 +2119,7 @@
</select>
<?php
}
-
+
function print_filter_show_status(){
global $t_select_modifier, $t_filter;
?> <!-- Status -->
@@ -2121,7 +2129,7 @@
</select>
<?php
}
-
+
function print_filter_hide_status(){
global $t_select_modifier, $t_filter;
?><!-- Hide Status -->
@@ -2222,11 +2230,11 @@
<?php if ( ! $p_hide_checkbox ) {
?>
<tr>
- <input type="checkbox" name="do_filter_by_date" <?php
- check_checked( $t_filter['do_filter_by_date'],
'on' );
- if ( ON == config_get( 'use_javascript' ) ) {
+ <input type="checkbox" name="do_filter_by_date" <?php
+ check_checked( $t_filter['do_filter_by_date'],
'on' );
+ if ( ON == config_get( 'use_javascript' ) ) {
print
"onclick=\"SwitchDateFields();\""; } ?> />
- <?php echo lang_get( 'use_date_filters' ) ?>
+ <?php echo lang_get( 'use_date_filters' ) ?>
</tr>
<?php }
?>
@@ -2295,7 +2303,7 @@
global $t_filter, $t_accessible_custom_fields_names,
$t_accessible_custom_fields_types, $t_accessible_custom_fields_values,
$t_accessible_custom_fields_ids, $t_select_modifier;
$j = array_search($p_field_id, $t_accessible_custom_fields_ids);
- if($j === null || $j === false){
+ if($j === null || $j === false){
# Note: Prior to PHP 4.2.0, array_search() returns NULL
on failure instead of FALSE.
?>
<span style="color:red;weight:bold;">
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
|