From 229a6848f6eb8a8847fa85c763b45451556b708f Mon Sep 17 00:00:00 2001 From: David Hicks Date: Sun, 29 Mar 2009 23:22:31 +1100 Subject: [PATCH 1/2] Add Stick/Unstick button to html_buttons_view_bug_page Currently there is no way to stick/unstick a bug when you're viewing a bug. At present you need to go to View Issues, select a checkbox for each bug you want to stick/unstick and confirm those changes. This patch adds a new Stick/Unstick button to the view bug pages (both simple and advanced modes) next to the existing Monitor Issue button. If the bug is currently stuck, the button will read "Unstick". If the ticket is currently not stuck, the button will read "Stick". Clicking on the button will automatically perform the required stick/unstick action without further confirmation, and will redirect the user back to the bug view page. --- bug_stick.php | 52 ++++++++++++++++++++++++++++++++++++++++ core/html_api.php | 32 +++++++++++++++++++++++-- lang/strings_english.txt | 4 ++++ 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 bug_stick.php diff --git a/bug_stick.php b/bug_stick.php new file mode 100644 index 0000000000..1527222764 --- /dev/null +++ b/bug_stick.php @@ -0,0 +1,52 @@ +. + + /** + * This file sticks or unsticks a bug to the top of the view page + * + * @package MantisBT + * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + * @copyright Copyright (C) 2002 - 2009 MantisBT Team - mantisbt-dev@lists.sourceforge.net + * @link http://www.mantisbt.org + */ + + /** + * MantisBT Core API's + */ + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path.'bug_api.php' ); + + # helper_ensure_post(); + + $f_bug_id = gpc_get_int( 'bug_id' ); + $t_bug = bug_get( $f_bug_id, true ); + $f_action = gpc_get_string( 'action' ); + + if( $t_bug->project_id != helper_get_current_project() ) { + # in case the current project is not the same project of the bug we are viewing... + # ... override the current project. This to avoid problems with categories and handlers lists etc. + $g_project_override = $t_bug->project_id; + } + + access_ensure_bug_level( config_get( 'set_bug_sticky_threshold' ), $f_bug_id ); + + bug_set_field( $f_bug_id, 'sticky', 'stick' == $f_action ); + + print_successful_redirect_to_bug( $f_bug_id ); +?> diff --git a/core/html_api.php b/core/html_api.php index 8549c5eb44..18689cfaf1 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -1327,6 +1327,22 @@ function html_button_bug_unmonitor( $p_bug_id ) { html_button( 'bug_monitor.php', lang_get( 'unmonitor_bug_button' ), array( 'bug_id' => $p_bug_id, 'action' => 'delete' ) ); } +# -------------------- +# Print a button to stick the given bug +function html_button_bug_stick( $p_bug_id ) { + if ( access_has_bug_level( config_get( 'set_bug_sticky_threshold' ), $p_bug_id ) ) { + html_button( 'bug_stick.php', lang_get( 'stick_bug_button' ), array( 'bug_id' => $p_bug_id, 'action' => 'stick' ) ); + } +} + +# -------------------- +# Print a button to unstick the given bug +function html_button_bug_unstick( $p_bug_id ) { + if ( access_has_bug_level( config_get( 'set_bug_sticky_threshold' ), $p_bug_id ) ) { + html_button( 'bug_stick.php', lang_get( 'unstick_bug_button' ), array( 'bug_id' => $p_bug_id, 'action' => 'unstick' ) ); + } +} + # -------------------- # Print a button to delete the given bug function html_button_bug_delete( $p_bug_id ) { @@ -1351,6 +1367,7 @@ function html_buttons_view_bug_page( $p_bug_id ) { $t_resolved = config_get( 'bug_resolved_status_threshold' ); $t_status = bug_get_field( $p_bug_id, 'status' ); $t_readonly = bug_is_readonly( $p_bug_id ); + $t_sticky = config_get( 'set_bug_sticky_threshold' ); echo ''; if( !$t_readonly ) { @@ -1371,15 +1388,26 @@ function html_buttons_view_bug_page( $p_bug_id ) { } # MONITOR/UNMONITOR button - echo ''; + } + + # STICK/UNSTICK button + if ( access_has_bug_level( $t_sticky, $p_bug_id ) ) { + echo ''; } - echo ''; if( !$t_readonly ) { # CREATE CHILD button diff --git a/lang/strings_english.txt b/lang/strings_english.txt index 74baa1fc86..34825e265f 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -603,6 +603,10 @@ $s_reminder_store = 'This note will be stored with the issue.'; # bug_set_sponsorship.php $s_confirm_sponsorship = 'Please confirm you want to sponsor issue %1$d for %2$s.'; +# bug_stick.php +$s_stick_bug_button = 'Stick'; +$s_unstick_bug_button = 'Unstick'; + # bug_update.php $s_bug_updated_msg = 'Issue has been successfully updated...'; From d7d911b0a3afdb39ac99b3b247948b614c713410 Mon Sep 17 00:00:00 2001 From: David Hicks Date: Wed, 22 Apr 2009 20:21:30 +1000 Subject: [PATCH 2/2] Remove trailing white space --- bug_stick.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bug_stick.php b/bug_stick.php index 1527222764..8762b3fcee 100644 --- a/bug_stick.php +++ b/bug_stick.php @@ -44,7 +44,7 @@ $g_project_override = $t_bug->project_id; } - access_ensure_bug_level( config_get( 'set_bug_sticky_threshold' ), $f_bug_id ); + access_ensure_bug_level( config_get( 'set_bug_sticky_threshold' ), $f_bug_id ); bug_set_field( $f_bug_id, 'sticky', 'stick' == $f_action );
'; if( !current_user_is_anonymous() ) { + echo ''; if( user_is_monitoring_bug( auth_get_current_user_id(), $p_bug_id ) ) { html_button_bug_unmonitor( $p_bug_id ); } else { html_button_bug_monitor( $p_bug_id ); } + echo ''; + if ( !bug_get_field( $p_bug_id, 'sticky' ) ) { + html_button_bug_stick( $p_bug_id ); + } else { + html_button_bug_unstick( $p_bug_id ); + } + echo '