Skip to content

Commit

Permalink
Track temporary filter to save filter
Browse files Browse the repository at this point in the history
  • Loading branch information
cproensa authored and atrol committed Mar 4, 2018
1 parent 1fc514b commit 41f94f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions core/filter_api.php
Expand Up @@ -2585,15 +2585,19 @@ function filter_draw_selection_area( $p_page_number, $p_for_screen = true, $p_ex

if( access_has_project_level( config_get( 'stored_query_create_threshold' ) ) ) { ?>
<form class="form-inline pull-left" method="post" name="save_query" action="query_store_page.php">
<?php # CSRF protection not required here - form does not result in modifications ?>
<?php # CSRF protection not required here - form does not result in modifications
if( filter_is_temporary( $t_filter ) ) {
echo '<input type="hidden" name="filter" value="' . filter_get_temporary_key( $t_filter ) . '" />';
}
?>
<input type="submit" name="save_query_button" class="btn btn-primary btn-white btn-sm btn-round"
value="<?php echo lang_get( 'save_query' )?>" />
</form>
<?php
}
if( count( $t_stored_queries_arr ) > 0 ) { ?>
<form id="filter-queries-form" class="form-inline pull-left padding-left-8" method="get" name="list_queries<?php echo $t_form_name_suffix;?>" action="view_all_set.php">
<?php # CSRF protection not required here - form does not result in modifications ?>
<?php # CSRF protection not required here - form does not result in modifications?>
<input type="hidden" name="type" value="3" />
<select name="source_query_id">
<option value="-1"></option>
Expand Down
1 change: 0 additions & 1 deletion query_store.php
Expand Up @@ -90,7 +90,6 @@
}

# Get the filter in use
# @TODO cproensa maybe we should pass the exact (current) filter id
$t_filter = current_user_get_bug_filter();

# named filters must not reference source query id
Expand Down
14 changes: 11 additions & 3 deletions query_store_page.php
Expand Up @@ -66,8 +66,11 @@
</h4>
</div>
<?php
$t_current_filter_id = filter_db_get_project_current( helper_get_current_project() );
$t_query_to_store = filter_db_get_filter_string( $t_current_filter_id );
$t_filter = current_user_get_bug_filter();
# We are comparing filters as serialized stringsd
# filter_serialize will remove runtime properties, so they can compare
# @TODO cproensa, implement a better method to compare filters? is it used besides here?
$t_query_to_store = filter_serialize( $t_filter );
$t_query_arr = filter_db_get_available_queries();

# Let's just see if any of the current filters are the
Expand All @@ -87,7 +90,12 @@
<div class="widget-body">
<div class="widget-main center">
<form method="post" action="query_store.php" class="form-inline">
<?php echo form_security_field( 'query_store' ) ?>
<?php
echo form_security_field( 'query_store' );
if( filter_is_temporary( $t_filter ) ) {
echo '<input type="hidden" name="filter" value="' . filter_get_temporary_key( $t_filter ) . '" />';
}
?>
<div class="space-10"></div>
<label class="bold inline"> <?php echo lang_get( 'query_name_label' ) . lang_get( 'word_separator' ); ?> </label>
<input type="text" name="query_name" class="input-sm" />
Expand Down

0 comments on commit 41f94f5

Please sign in to comment.