View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009301 | mantisbt | filters | public | 2008-06-25 16:45 | 2017-01-31 04:02 |
Reporter | bbryant | Assigned To | cproensa | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Target Version | 2.1.0 | Fixed in Version | 2.1.0 | ||
Summary | 0009301: Add support for updating a current filter | ||||
Description | This patch adds support for modifying a filter instead of having to go through multiple steps to change a filter and retain the same filter name. | ||||
Tags | patch | ||||
Attached Files | update_filters.patch (3,308 bytes)
Index: query_store_page.php =================================================================== --- query_store_page.php +++ query_store_page.php @@ -43,10 +43,34 @@ print "<br />$t_error_msg<br /><br />"; } - print lang_get( 'query_name' ) . ': '; + //print lang_get( 'query_name' ) . ': '; ?> - <form method="POST" action="query_store.php"> - <input type="text" name="query_name"><br /> + <form method="POST" action="query_store.php" name="query"> + <table cellspacing="0" cellpadding="2"> + <tr> + <td> + <?php print lang_get( 'query_name' ) . ': '; ?> + </td> + <td> + <input type="text" name="query_name"> + </td> + </tr> + <tr> + <td> + <?php print lang_get( 'query_existing' ) . ': '; ?> + </td> + <td> + <select name="query_existing" onchange="javascript: document.forms.query.query_name.disabled = !!this.options[this.selectedIndex].length;"> + <option value=""></option> + <?php + foreach ($t_query_arr as $t_id => $t_name) { + echo "<option value=\"{$t_id}\">{$t_name}</option>\r\n"; + } + ?> + </select> + </td> + </tr> + </table> <?php if ( access_has_project_level( config_get( 'stored_query_create_shared_threshold' ) ) ) { print '<input type="checkbox" name="is_public" value="on"> '; Index: query_store.php =================================================================== --- query_store.php +++ query_store.php @@ -19,27 +19,38 @@ auth_ensure_user_authenticated(); compress_enable(); - $f_query_name = strip_tags( gpc_get_string( 'query_name' ) ); + $f_query_id = gpc_get_int( 'query_existing' ); $f_is_public = gpc_get_bool( 'is_public' ); $f_all_projects = gpc_get_bool( 'all_projects' ); - $t_query_redirect_url = 'query_store_page.php'; + $f_query_name = null; - # We can't have a blank name - if ( is_blank( $f_query_name ) ) { - $t_query_redirect_url = $t_query_redirect_url . '?error_msg=' - . urlencode( lang_get( 'query_blank_name' ) ); - print_header_redirect( $t_query_redirect_url ); - } - - # Check and make sure they don't already have a - # query with the same name - $t_query_arr = filter_db_get_available_queries(); - foreach( $t_query_arr as $t_id => $t_name ) { - if ( $f_query_name == $t_name ) { + if (!$f_query_id) { + $f_query_name = strip_tags( gpc_get_string( 'query_name' ) ); + + # We can't have a blank name + if ( is_blank( $f_query_name ) ) { $t_query_redirect_url = $t_query_redirect_url . '?error_msg=' - . urlencode( lang_get( 'query_dupe_name' ) ); + . urlencode( lang_get( 'query_blank_name' ) ); print_header_redirect( $t_query_redirect_url ); + } + + # Check and make sure they don't already have a + # query with the same name + $t_query_arr = filter_db_get_available_queries(); + foreach( $t_query_arr as $t_id => $t_name ) { + if ( $f_query_name == $t_name ) { + $t_query_redirect_url = $t_query_redirect_url . '?error_msg=' + . urlencode( lang_get( 'query_dupe_name' ) ); + print_header_redirect( $t_query_redirect_url ); + exit; + } + } + } else { + if (!($f_query_name = filter_get_field($f_query_id, "name"))) { + $t_query_redirect_url = $t_query_redirect_url . '?error_msg=' . + urlencode( lang_get( 'query_invalid_id' ) ); + print_header_redirect( $t_query_redirect_url ); exit; } } filter.patch (4,925 bytes)
diff --git a/lang/strings_english.txt b/lang/strings_english.txt index cff3989..09b2299 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -1235,6 +1235,7 @@ $s_query_name_too_long = 'You cannot store a filter name with more than 64 chara $s_query_store_error = 'There was an error saving this filter.'; $s_open_queries = 'Manage Filters'; $s_query_delete_msg = 'Are you sure you wish to delete this filter?'; +$s_query_select = 'Select Filter'; # bug_view_advanced_page.php $s_view_simple_link = 'View Simple'; diff --git a/lang/strings_french.txt b/lang/strings_french.txt index 9c6f9af..87a4e80 100644 --- a/lang/strings_french.txt +++ b/lang/strings_french.txt @@ -972,6 +972,7 @@ $s_query_name_too_long = 'Vous ne pouvez pas sauvegarder un filtre avec un nom d $s_query_store_error = 'Une erreur s\'est produite durant la sauvegarde de ce filtre.'; $s_open_queries = 'Gérer les filtres'; $s_query_delete_msg = 'Êtes-vous certain de vouloir supprimer ce filtre ?'; +$s_query_select = 'Sélectionner le filtre'; $s_view_simple_link = 'Rapport simplifié'; $s_product_build = 'Build'; $s_system_profile = 'Description du système'; diff --git a/query_store.php b/query_store.php index 1dc7ede..4650b4a 100644 --- a/query_store.php +++ b/query_store.php @@ -37,7 +37,12 @@ auth_ensure_user_authenticated(); compress_enable(); - $f_query_name = strip_tags( gpc_get_string( 'query_name' ) ); + if( gpc_isset( 'query_name' ) ) { + $f_query_name = strip_tags( gpc_get_string( 'query_name' ) ); + } elseif( gpc_isset( 'modified_filter_id' ) ) { + $f_query_name = strip_tags( gpc_get_string( 'modified_filter_id' ) ); + } + $f_is_public = gpc_get_bool( 'is_public' ); $f_all_projects = gpc_get_bool( 'all_projects' ); @@ -59,13 +64,15 @@ # Check and make sure they don't already have a # query with the same name - $t_query_arr = filter_db_get_available_queries(); - foreach( $t_query_arr as $t_id => $t_name ) { - if ( $f_query_name == $t_name ) { - $t_query_redirect_url = $t_query_redirect_url . '?error_msg=' - . urlencode( lang_get( 'query_dupe_name' ) ); - print_header_redirect( $t_query_redirect_url ); - exit; + if( !gpc_isset( 'modified_filter_id' ) && gpc_isset( 'query_name' ) ) { + $t_query_arr = filter_db_get_available_queries(); + foreach( $t_query_arr as $t_id => $t_name ) { + if ( $f_query_name == $t_name ) { + $t_query_redirect_url = $t_query_redirect_url . '?error_msg=' + . urlencode( lang_get( 'query_dupe_name' ) ); + print_header_redirect( $t_query_redirect_url ); + exit; + } } } diff --git a/query_store_page.php b/query_store_page.php index e7be5cf..d3ce126 100644 --- a/query_store_page.php +++ b/query_store_page.php @@ -62,7 +62,53 @@ ?> <form method="post" action="query_store.php"> <?php echo form_security_field( 'query_store' ) ?> - <input type="text" name="query_name" /><br /> + <input type="text" name="query_name" id="query_name"<?php + if( ON == config_get( 'use_javascript' ) ) { + echo ' onkeyup="select_disable();"'; + } + ?> /><br /><br /> + <?php + $t_curr_user_filter_arr = array(); + $t_curr_user_filter_arr = filter_db_get_available_queries(); + ?> + <?php if( count( $t_curr_user_filter_arr ) > 0 ): ?> + + <?php if( ON == config_get( 'use_javascript' ) ): ?> + <script type="text/javascript"> + function textbox_disable() { + if((document.getElementById('modified_filter_id').value) != " ") { + document.getElementById('query_name').value = ""; + document.getElementById('query_name').disabled = true; + } else { + document.getElementById('query_name').disabled = false; + } + } + function select_disable() { + if((document.getElementById('query_name').value) != "") { + document.getElementById("modified_filter_id").value = " "; + document.getElementById('modified_filter_id').disabled = true; + } else { + document.getElementById('modified_filter_id').disabled = false; + } + } + </script> + <?php endif ?> + + <select name="modified_filter_id" id="modified_filter_id"<?php + if( ON == config_get( 'use_javascript' ) ) { + echo ' onchange="textbox_disable();"'; + } + ?>> + <option value=" "><?php echo lang_get( 'query_select' ) ?></option><?php + foreach( $t_curr_user_filter_arr as $t_query_id => $t_modi_query_name ) { + if( filter_db_can_delete_filter( $t_query_id ) ) { + echo '<option value="' . $t_modi_query_name . '">' . $t_modi_query_name . '</option>'; + } + } + ?> + </select> + <?php endif ?> + <br /><br /> <?php if ( access_has_project_level( config_get( 'stored_query_create_shared_threshold' ) ) ) { print '<input type="checkbox" name="is_public" value="on" /> '; @@ -78,6 +124,6 @@ <?php # CSRF protection not required here - form does not result in modifications ?> <input type="submit" class="button" value="<?php print lang_get( 'go_back' ); ?>" /> </form> + </div> <?php - echo '</div>'; html_page_bottom(); | ||||
hi, i made also a patch to manage the filter in 0009213. |
|
Hi bbryant, seems to be a simple fix and good enough for an intermediate version. |
|
Hi, we are also interested in this evolution in our company. Someone (whose name is Kavita Maurya) made almost the same evolution than the one posted in this issue. |
|
Thanks for the updated patch Stéphane. The 1.2.x branch is closed for new features (it's in a bugfix only mode). It may be possible to rewrite this patch for the 1.3.x (master) branch however quite a few things have changed. Primarily, we no longer allow script tags, href="javascript:" URLs and onXYZ attributes in MantisBT's XHTML output. Rather, we use jQuery in javascript/common.js instead. Thus most of MantisBT's JavaScript from 1.2.x has been completely rewritten in the 1.3.x branch based on jQuery. This patch would need a similar rewrite. Hope this information is useful. |
|
Unassigned after having been assigned for a long time without progress. |
|