Skip to content

Commit

Permalink
Merge branch '10268'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Jun 16, 2009
2 parents 79f5bc2 + d7d911b commit 8a246a4
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
52 changes: 52 additions & 0 deletions 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 );
?>
38 changes: 36 additions & 2 deletions core/html_api.php
Expand Up @@ -1519,6 +1519,28 @@ 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
* @param int $p_bug_id
* @return null
*/
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
* @param int $p_bug_id
* @return null
*/
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
* @param int $p_bug_id
Expand Down Expand Up @@ -1552,6 +1574,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 ) {
Expand All @@ -1572,15 +1595,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
Expand Down
4 changes: 4 additions & 0 deletions lang/strings_english.txt
Expand Up @@ -610,6 +610,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...';

Expand Down

0 comments on commit 8a246a4

Please sign in to comment.