Skip to content

Commit

Permalink
The bugnote limit was not read from the settings of the user the mail…
Browse files Browse the repository at this point in the history
… is sent to, but from the settings of the user who sent the mail.

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2834 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Jeroen Latour committed Aug 8, 2004
1 parent 552ac62 commit 3f72dc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 9 additions & 11 deletions core/bugnote_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bugnote_api.php,v 1.27 2004-08-08 11:39:00 jlatour Exp $
# $Id: bugnote_api.php,v 1.28 2004-08-08 20:30:19 jlatour Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -226,8 +226,8 @@ function bugnote_get_field( $p_bugnote_id, $p_field_name ) {
#
# Return BugnoteData class object with raw values from the tables except the field
# last_modified - it is UNIX_TIMESTAMP.
function bugnote_get_all_visible_bugnotes( $p_bug_id, $p_user_access_level ) {
$t_all_bugnotes = bugnote_get_all_bugnotes( $p_bug_id );
function bugnote_get_all_visible_bugnotes( $p_bug_id, $p_user_access_level, $p_user_bugnote_order, $p_user_bugnote_limit ) {
$t_all_bugnotes = bugnote_get_all_bugnotes( $p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit );
$t_private_bugnote_threshold = config_get( 'private_bugnote_threshold' );

if ( $p_user_access_level >= $t_private_bugnote_threshold ) {
Expand All @@ -252,7 +252,7 @@ function bugnote_get_all_visible_bugnotes( $p_bug_id, $p_user_access_level ) {
# Return BugnoteData class object with raw values from the tables except the field
# last_modified - it is UNIX_TIMESTAMP.
# The data is not filtered by VIEW_STATE !!
function bugnote_get_all_bugnotes( $p_bug_id ) {
function bugnote_get_all_bugnotes( $p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit ) {
global $g_cache_bugnotes;

if ( !isset( $g_cache_bugnotes ) ) {
Expand All @@ -263,32 +263,30 @@ function bugnote_get_all_bugnotes( $p_bug_id ) {
$c_bug_id = db_prepare_int( $p_bug_id );
$t_bugnote_table = config_get( 'mantis_bugnote_table' );
$t_bugnote_text_table = config_get( 'mantis_bugnote_text_table' );
$t_bugnote_order = current_user_get_pref( 'bugnote_order' );
$t_email_bugnote_limit = current_user_get_pref( 'email_bugnote_limit' );

if ( 0 == $t_email_bugnote_limit ) {
if ( 0 == $p_user_bugnote_limit ) {
## Show all bugnotes
$t_bugnote_limit = -1;
$t_bugnote_offset = -1;
} else {
## Use offset only if order is ASC to get the last bugnotes
if ( 'ASC' == $t_bugnote_order ) {
if ( 'ASC' == $p_user_bugnote_order ) {
$result = db_query( "SELECT COUNT(*) AS row_count FROM $t_bugnote_table WHERE bug_id = '$c_bug_id'" );
$row = db_fetch_array( $result );

$t_bugnote_offset = $row['row_count'] - $t_email_bugnote_limit;
$t_bugnote_offset = $row['row_count'] - $p_user_bugnote_limit;
} else {
$t_bugnote_offset = -1;
}

$t_bugnote_limit = $t_email_bugnote_limit;
$t_bugnote_limit = $p_user_bugnote_limit;
}

$query = "SELECT b.*, t.note
FROM $t_bugnote_table AS b
LEFT JOIN $t_bugnote_text_table AS t ON b.bugnote_text_id = t.id
WHERE b.bug_id = '$c_bug_id'
ORDER BY b.date_submitted $t_bugnote_order";
ORDER BY b.date_submitted $p_user_bugnote_order";
$t_bugnotes = array();

# BUILD bugnotes array
Expand Down
6 changes: 4 additions & 2 deletions core/email_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: email_api.php,v 1.90 2004-07-29 10:51:30 thraxisp Exp $
# $Id: email_api.php,v 1.91 2004-08-08 20:30:19 jlatour Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -911,6 +911,8 @@ function email_format_attribute( $p_visible_bug_data, $attribute_id ) {
function email_build_visible_bug_data( $p_user_id, $p_bug_id, $p_message_id ) {
$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
$t_user_access_level = user_get_access_level( $p_user_id, $t_project_id );
$t_user_bugnote_order = user_pref_get_pref ( $p_user_id, 'bugnote_order' );
$t_user_bugnote_limit = user_pref_get_pref ( $p_user_id, 'email_bugnote_limit' );

$row = bug_get_extended_row( $p_bug_id );
$t_bug_data = array();
Expand Down Expand Up @@ -955,7 +957,7 @@ function email_build_visible_bug_data( $p_user_id, $p_bug_id, $p_message_id ) {
$t_bug_data['set_category'] = '[' . $t_bug_data['email_project'] . '] ' . $row['category'];

$t_bug_data['custom_fields'] = custom_field_get_linked_fields( $p_bug_id, $t_user_access_level );
$t_bug_data['bugnotes'] = bugnote_get_all_visible_bugnotes( $p_bug_id, $t_user_access_level );
$t_bug_data['bugnotes'] = bugnote_get_all_visible_bugnotes( $p_bug_id, $t_user_access_level, $t_user_bugnote_order, $t_user_bugnote_limit );

# put history data
if ( ON == config_get( 'history_default_visible' ) && $t_user_access_level >= config_get( 'view_history_threshold' ) ) {
Expand Down

0 comments on commit 3f72dc6

Please sign in to comment.