View Issue Details

IDProjectCategoryView StatusLast Update
0010268mantisbtbugtrackerpublic2009-06-23 15:29
Reporterdhx Assigned Todhx  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Product Versiongit trunk 
Target Version1.2.0rc1 
Summary0010268: Add new stick/unstick button to html_buttons_view_bug_page
Description

The attached patch (license = public domain) consists of a new bug_stick.php file (similar to bug_monitor.php) as well as some modifications to existing code to show a new "Stick" or "Unstick" button when viewing a bug report. Previously there was no way to stick/unstick a bug without using the bug_actiongroups drop down box.

Tagsbuttons, stick, unstick
Attached Files
html_buttons_view_bug_page_stick_unstick.diff (2,737 bytes)   
diff --git a/core/html_api.php b/core/html_api.php
index e60deae..0c75a39 100644
--- a/core/html_api.php
+++ b/core/html_api.php
@@ -1321,6 +1321,22 @@ function html_button_bug_unmonitor( $p_bug_id ) {
 }
 
 # --------------------
+# 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 ) {
 	if( access_has_bug_level( config_get( 'delete_bug_threshold' ), $p_bug_id ) ) {
@@ -1344,6 +1360,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 '<table><tr class="vcenter">';
 	if( !$t_readonly ) {
@@ -1364,16 +1381,27 @@ function html_buttons_view_bug_page( $p_bug_id ) {
 	}
 
 	# MONITOR/UNMONITOR button
-	echo '<td class="center">';
 	if( !current_user_is_anonymous() ) {
+		echo '<td class=center">';
 		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 '</td>';
 	}
-	echo '</td>';
 
+	# STICK/UNSTICK button
+	if ( access_has_bug_level( $t_sticky, $p_bug_id ) ) {
+		echo '<td class="center">';
+		if ( !bug_get_field( $p_bug_id, 'sticky' ) ) {
+			html_button_bug_stick( $p_bug_id );
+		} else {
+			html_button_bug_unstick( $p_bug_id );
+		}
+		echo '</td>';
+	}
+	
 	if( !$t_readonly ) {
 		# CREATE CHILD button
 		echo '<td class="center">';
diff --git a/lang/strings_english.txt b/lang/strings_english.txt
index d5204ae..b9d609d 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...';
 
bug_stick.php (1,774 bytes)   
<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

	/**
	 * 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 );
?>
bug_stick.php (1,774 bytes)   
10268.patch (5,872 bytes)   
From 229a6848f6eb8a8847fa85c763b45451556b708f Mon Sep 17 00:00:00 2001
From: David Hicks <hickseydr@optusnet.com.au>
Date: Sun, 29 Mar 2009 23:22:31 +1100
Subject: [PATCH] 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.

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
---
 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 0000000..1527222
--- /dev/null
+++ b/bug_stick.php
@@ -0,0 +1,52 @@
+<?php
+# MantisBT - a php based bugtracking system
+
+# MantisBT is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# MantisBT is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
+
+	/**
+	 * 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 8549c5e..18689cf 100644
--- a/core/html_api.php
+++ b/core/html_api.php
@@ -1328,6 +1328,22 @@ function html_button_bug_unmonitor( $p_bug_id ) {
 }
 
 # --------------------
+# 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 ) {
 	if( access_has_bug_level( config_get( 'delete_bug_threshold' ), $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 '<table><tr class="vcenter">';
 	if( !$t_readonly ) {
@@ -1371,15 +1388,26 @@ function html_buttons_view_bug_page( $p_bug_id ) {
 	}
 
 	# MONITOR/UNMONITOR button
-	echo '<td class="center">';
 	if( !current_user_is_anonymous() ) {
+		echo '<td class=center">';
 		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 '</td>';
+	}
+
+	# STICK/UNSTICK button
+	if ( access_has_bug_level( $t_sticky, $p_bug_id ) ) {
+		echo '<td class="center">';
+		if ( !bug_get_field( $p_bug_id, 'sticky' ) ) {
+			html_button_bug_stick( $p_bug_id );
+		} else {
+			html_button_bug_unstick( $p_bug_id );
+		}
+		echo '</td>';
 	}
-	echo '</td>';
 
 	if( !$t_readonly ) {
 		# CREATE CHILD button
diff --git a/lang/strings_english.txt b/lang/strings_english.txt
index 74baa1f..34825e2 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...';
 
-- 
1.6.2

10268.patch (5,872 bytes)   

Activities

dhx

dhx

2009-03-29 08:29

reporter   ~0021261

Please find attached a formatted patch.

dhx

dhx

2009-03-30 02:32

reporter   ~0021269

This can also be pulled from branch '10268' at git://git.mantisforge.org/mantisbt/dhx.git

Related Changesets

MantisBT: master 8a246a48

2009-06-16 18:02

dhx


Details Diff
Merge branch '10268' Affected Issues
0010268

MantisBT: master 1a96b94b

2009-06-16 18:13

dhx


Details Diff
No need to specify core path anymore

As per c36df5bbf23c7ec573a00f5feca8a16bdf53d198
Affected Issues
0010268
mod - bug_stick.php Diff File