Skip to content

Commit

Permalink
Add handling for custom fields sequence numbers through the manage pr…
Browse files Browse the repository at this point in the history
…oject

edit page.

A manage_proj_custom_field_update.php
- Action page for setting the sequence number for the custom fields.

M manage_proj_edit_page.php
- Displayed an edit box with the sequence number and add an update button next to each one to allow the manager to
update the sequence numbers.

M core/custom_field_api.php
- (custom_field_get_sequence): Gets the sequence number for the specified field in the specified project.
- (custom_field_set_sequence): Sets the sequence number for the specified field in the specified project.
- (custom_field_get_linked_ids): Added sorting by field name as a secondary key after sequence number.

M lang/strings_english.txt
- Added caption for the update button.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1845 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Feb 15, 2003
1 parent 0370da8 commit 2425c50
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 12 deletions.
49 changes: 47 additions & 2 deletions core/custom_field_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: custom_field_api.php,v 1.16 2003-02-11 05:41:31 vboctor Exp $
# $Id: custom_field_api.php,v 1.17 2003-02-15 14:13:54 vboctor Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -539,7 +539,7 @@ function custom_field_get_linked_ids( $p_project_id ) {
$t_custom_field_project_table p, $t_custom_field_table f
WHERE p.project_id='$c_project_id'
AND p.field_id = f.id
ORDER BY p.sequence ASC";
ORDER BY p.sequence ASC, f.name ASC";
$result = db_query( $query );

$t_row_count = db_num_rows( $result );
Expand Down Expand Up @@ -639,6 +639,30 @@ function custom_field_get_value( $p_field_id, $p_bug_id ) {
}
}

# --------------------
# Gets the sequence number for the specified custom field for the specified
# project. Returns false in case of error.
function custom_field_get_sequence( $p_field_id, $p_project_id ) {
$c_field_id = db_prepare_int( $p_field_id );
$c_project_id = db_prepare_int( $p_project_id );

$t_custom_field_project_table = config_get( 'mantis_custom_field_project_table' );
$query = "SELECT sequence FROM
$t_custom_field_project_table
WHERE field_id='$c_field_id' AND
project_id='$c_project_id'
LIMIT 1";
$result = db_query( $query );

if ( 0 == db_num_rows( $result ) ) {
return false;
}

$t_row = db_fetch_array( $result );

return $t_row['sequence'];
}

#===================================
# Data Modification
#===================================
Expand Down Expand Up @@ -724,6 +748,27 @@ function custom_field_set_value( $p_field_id, $p_bug_id, $p_value ) {
return true;
}

# --------------------
# Sets the sequence number for the specified custom field for the specified
# project.
function custom_field_set_sequence( $p_field_id, $p_project_id, $p_sequence ) {
$c_field_id = db_prepare_int( $p_field_id );
$c_project_id = db_prepare_int( $p_project_id );
$c_sequence = db_prepare_int( $p_sequence );

$t_custom_field_project_table = config_get( 'mantis_custom_field_project_table' );

$query = "UPDATE $t_custom_field_project_table
SET sequence='$c_sequence'
WHERE field_id='$c_field_id'
AND project_id='$c_project_id'";
$result = db_query( $query );

custom_field_clear_cache( $p_field_id );

return true;
}

#===================================
# Output
#===================================
Expand Down
9 changes: 5 additions & 4 deletions lang/strings_english.txt
Expand Up @@ -9,11 +9,11 @@
###########################################################################
# English strings for Mantis
# -------------------------------------------------
# $Revision: 1.116 $
# $Author: jfitzell $
# $Date: 2003-02-15 10:25:22 $
# $Revision: 1.117 $
# $Author: vboctor $
# $Date: 2003-02-15 14:13:54 $
#
# $Id: strings_english.txt,v 1.116 2003-02-15 10:25:22 jfitzell Exp $
# $Id: strings_english.txt,v 1.117 2003-02-15 14:13:54 vboctor Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -560,6 +560,7 @@
$s_actions = 'Actions';
$s_version = 'Version';
$s_timestamp = 'Timestamp';
$s_update = 'Update';

# manage_proj_menu_page.php
$s_add_project_title = 'Add Project';
Expand Down
45 changes: 45 additions & 0 deletions manage_proj_custom_field_update.php
@@ -0,0 +1,45 @@
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
?>
<?php
require_once( 'core.php' );

$t_core_path = config_get( 'core_path' );

require_once( $t_core_path.'custom_field_api.php' );
?>
<?php
$f_field_id = gpc_get_int( 'field_id' );
$f_project_id = gpc_get_int( 'project_id' );
$f_sequence = gpc_get_int( 'sequence' );

# We should check both since we are in the project section and an
# admin might raise the first threshold and not realize they need
# to raise the second
access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
access_ensure_project_level( config_get( 'custom_field_link_threshold' ), $f_project_id );

custom_field_set_sequence( $f_field_id, $f_project_id, $f_sequence );

$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
?>
<?php print_page_top1() ?>
<?php
print_meta_redirect( $t_redirect_url );
?>
<?php print_page_top2() ?>

<br />
<div align="center">
<?php
echo lang_get( 'operation_successful' ).'<br />';

print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
?>
</div>

<?php print_page_bot1( __FILE__ ) ?>
13 changes: 7 additions & 6 deletions manage_proj_edit_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: manage_proj_edit_page.php,v 1.61 2003-02-15 10:25:17 jfitzell Exp $
# $Id: manage_proj_edit_page.php,v 1.62 2003-02-15 14:13:53 vboctor Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -354,15 +354,16 @@
<?php echo $t_desc['name'] ?>
</td>
<td>
<?php echo $t_field_id ?>
<form method="post" action="manage_proj_custom_field_update.php">
<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
<input type="hidden" name="field_id" value="<?php echo $t_field_id ?>" />
<input type="text" name="sequence" value="<?php echo custom_field_get_sequence( $t_field_id, $f_project_id ) ?>" size="2" />
<input type="submit" value="<?php echo lang_get( 'update' ) ?>" />
</form>
</td>
<td class="center">
<?php
# You need global permissions to edit custom field defs
if ( access_has_global_level( config_get( 'manage_custom_fields' ) ) ) {
print_bracket_link( "manage_custom_field_edit_page.php?field_id=$t_field_id&amp;return=manage_proj_edit_page.php?project_id=$f_project_id", lang_get( 'edit_link' ) );
echo '&nbsp;';
}
print_bracket_link( "manage_proj_custom_field_remove.php?field_id=$t_field_id&amp;project_id=$f_project_id", lang_get( 'remove_link' ) );
?>
</td>
Expand Down

0 comments on commit 2425c50

Please sign in to comment.