From 3973d02e7cae220efaeaea67c1fa9ba49516ff4a Mon Sep 17 00:00:00 2001 From: Jeroen Latour Date: Sun, 8 Aug 2004 11:39:17 +0000 Subject: [PATCH] 0004043: [email] Preference to exclude old bugnotes from notification (Bastian Pfennigschmidt) git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2825 f5dc347c-c33d-0410-90a0-b07cc1902cb9 --- account_prefs_inc.php | 37 +++++-- account_prefs_update.php | 5 +- admin/upgrades/0_18_inc.php | 19 +++- bugnote_view_inc.php | 4 +- config_defaults_inc.php | 6 +- core/bugnote_api.php | 146 +++++++++++++++------------ core/user_pref_api.php | 50 ++++----- doc/CREDITS | 1 + doc/ChangeLog | 1 + lang/strings_chinese_simplified.txt | 10 +- lang/strings_chinese_traditional.txt | 10 +- lang/strings_croatian.txt | 10 +- lang/strings_czech.txt | 10 +- lang/strings_danish.txt | 10 +- lang/strings_dutch.txt | 10 +- lang/strings_english.txt | 12 ++- lang/strings_estonian.txt | 10 +- lang/strings_finnish.txt | 10 +- lang/strings_french.txt | 10 +- lang/strings_german.txt | 10 +- lang/strings_hungarian.txt | 10 +- lang/strings_italian.txt | 10 +- lang/strings_japanese_euc.txt | 10 +- lang/strings_japanese_sjis.txt | 10 +- lang/strings_japanese_utf8.txt | 10 +- lang/strings_korean.txt | 10 +- lang/strings_latvian.txt | 10 +- lang/strings_lithuanian.txt | 10 +- lang/strings_norwegian.txt | 10 +- lang/strings_polish.txt | 10 +- lang/strings_portuguese_brazil.txt | 10 +- lang/strings_portuguese_standard.txt | 10 +- lang/strings_romanian.txt | 10 +- lang/strings_russian.txt | 10 +- lang/strings_russian_koi8.txt | 10 +- lang/strings_serbian.txt | 10 +- lang/strings_slovak.txt | 10 +- lang/strings_slovene.txt | 4 + lang/strings_spanish.txt | 10 +- lang/strings_swedish.txt | 10 +- lang/strings_turkish.txt | 10 +- print_all_bug_page_excel.php | 6 +- print_all_bug_page_word.php | 6 +- print_bugnote_inc.php | 5 +- 44 files changed, 397 insertions(+), 205 deletions(-) diff --git a/account_prefs_inc.php b/account_prefs_inc.php index ce2dd09601..445e6b04f4 100644 --- a/account_prefs_inc.php +++ b/account_prefs_inc.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: account_prefs_inc.php,v 1.27 2004-07-11 08:22:59 vboctor Exp $ + # $Id: account_prefs_inc.php,v 1.28 2004-08-08 11:39:00 jlatour Exp $ # -------------------------------------------------------- $t_core_path = config_get( 'core_path' ); @@ -109,10 +109,19 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ + + + + + + /> + /> + + - + @@ -126,7 +135,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -140,7 +149,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -154,7 +163,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -168,7 +177,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -182,7 +191,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -196,7 +205,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -210,7 +219,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -224,7 +233,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ - + @@ -238,6 +247,14 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_ + + + + + + + + diff --git a/account_prefs_update.php b/account_prefs_update.php index ffb350a915..01dde6ca6f 100644 --- a/account_prefs_update.php +++ b/account_prefs_update.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: account_prefs_update.php,v 1.33 2004-04-01 18:42:10 narcissus Exp $ + # $Id: account_prefs_update.php,v 1.34 2004-08-08 11:39:00 jlatour Exp $ # -------------------------------------------------------- ?> email_on_bugnote_minimum_severity = gpc_get_int( 'email_on_bugnote_minimum_severity' ); $t_prefs->email_on_status_minimum_severity = gpc_get_int( 'email_on_status_minimum_severity' ); $t_prefs->email_on_priority_minimum_severity = gpc_get_int( 'email_on_priority_minimum_severity' ); + + $t_prefs->bugnote_order = gpc_get_string( 'bugnote_order' ); + $t_prefs->email_bugnote_limit = gpc_get_int( 'email_bugnote_limit' ); # prevent users from changing other user's accounts if ( $f_user_id != auth_get_current_user_id() ) { diff --git a/admin/upgrades/0_18_inc.php b/admin/upgrades/0_18_inc.php index 12f20ce869..baf4b219a3 100644 --- a/admin/upgrades/0_18_inc.php +++ b/admin/upgrades/0_18_inc.php @@ -8,7 +8,7 @@ # Changes applied to 0.18 database # -------------------------------------------------------- - # $Id: 0_18_inc.php,v 1.19 2004-08-07 01:37:43 thraxisp Exp $ + # $Id: 0_18_inc.php,v 1.20 2004-08-08 11:39:00 jlatour Exp $ # -------------------------------------------------------- ?> \ No newline at end of file +?> diff --git a/bugnote_view_inc.php b/bugnote_view_inc.php index 1f5428291d..6a6ae6cf84 100644 --- a/bugnote_view_inc.php +++ b/bugnote_view_inc.php @@ -6,7 +6,7 @@ # See the files README and LICENSE for details # -------------------------------------------------------- - # $Id: bugnote_view_inc.php,v 1.17 2004-06-29 08:38:43 int2str Exp $ + # $Id: bugnote_view_inc.php,v 1.18 2004-08-08 11:39:00 jlatour Exp $ # -------------------------------------------------------- ?> = $t_private_bugnote_threshold ) { $t_private_bugnote_visible = true; } else { @@ -242,6 +242,7 @@ function bugnote_get_all_visible_bugnotes( $p_bug_id, $p_user_access_level ) { $t_bugnotes[$t_note_index] = $t_bugnote; } } + return $t_bugnotes; } @@ -259,21 +260,40 @@ function bugnote_get_all_bugnotes( $p_bug_id ) { } if ( !isset( $g_cache_bugnotes[$p_bug_id] ) ) { - $c_bug_id = db_prepare_int( $p_bug_id ); - $t_bugnote_table = config_get( 'mantis_bugnote_table' ); + $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 = config_get( 'bugnote_order' ); + $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 ) { + ## 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 ) { + $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; + } else { + $t_bugnote_offset = -1; + } + + $t_bugnote_limit = $t_email_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"; + 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"; $t_bugnotes = array(); # BUILD bugnotes array - $result = db_query( $query ); - $count = db_num_rows( $result ); + $result = db_query( $query, $t_bugnote_limit, $t_bugnote_offset ); + $count = db_num_rows( $result ); for ( $i=0; $i < $count; $i++ ) { $row = db_fetch_array( $result ); @@ -303,8 +323,8 @@ function bugnote_date_update( $p_bugnote_id ) { $t_bugnote_table = config_get( 'mantis_bugnote_table' ); $query = "UPDATE $t_bugnote_table - SET last_modified=" . db_now() . " - WHERE id='$c_bugnote_id'"; + SET last_modified=" . db_now() . " + WHERE id='$c_bugnote_id'"; db_query( $query ); # db_query() errors if there was a problem so: @@ -314,14 +334,14 @@ function bugnote_date_update( $p_bugnote_id ) { # -------------------- # Set the bugnote text function bugnote_set_text( $p_bugnote_id, $p_bugnote_text ) { - $c_bugnote_text = db_prepare_string( $p_bugnote_text ); - $t_bug_id = bugnote_get_field( $p_bugnote_id, 'bug_id' ); - $t_bugnote_text_id = bugnote_get_field( $p_bugnote_id, 'bugnote_text_id' ); + $c_bugnote_text = db_prepare_string( $p_bugnote_text ); + $t_bug_id = bugnote_get_field( $p_bugnote_id, 'bug_id' ); + $t_bugnote_text_id = bugnote_get_field( $p_bugnote_id, 'bugnote_text_id' ); $t_bugnote_text_table = config_get( 'mantis_bugnote_text_table' ); $query = "UPDATE $t_bugnote_text_table - SET note='$c_bugnote_text' - WHERE id='$t_bugnote_text_id'"; + SET note='$c_bugnote_text' + WHERE id='$t_bugnote_text_id'"; db_query( $query ); # updated the last_updated date @@ -336,9 +356,8 @@ function bugnote_set_text( $p_bugnote_id, $p_bugnote_text ) { # -------------------- # Set the view state of the bugnote function bugnote_set_view_state( $p_bugnote_id, $p_private ) { - $c_bugnote_id = db_prepare_int( $p_bugnote_id ); - - $t_bug_id = bugnote_get_field( $p_bugnote_id, 'bug_id' ); + $c_bugnote_id = db_prepare_int( $p_bugnote_id ); + $t_bug_id = bugnote_get_field( $p_bugnote_id, 'bug_id' ); if ( $p_private ) { $t_view_state = VS_PRIVATE; @@ -350,8 +369,8 @@ function bugnote_set_view_state( $p_bugnote_id, $p_private ) { # update view_state $query = "UPDATE $t_bugnote_table - SET view_state='$t_view_state' - WHERE id='$c_bugnote_id'"; + SET view_state='$t_view_state' + WHERE id='$c_bugnote_id'"; db_query( $query ); history_log_event_special( $t_bug_id, BUGNOTE_STATE_CHANGED, bugnote_format_id( $t_view_state ), $p_bugnote_id ); @@ -367,7 +386,8 @@ function bugnote_set_view_state( $p_bugnote_id, $p_private ) { # -------------------- # Pad the bugnote id with the appropriate number of zeros for printing function bugnote_format_id( $p_bugnote_id ) { - $t_padding = config_get( 'display_bugnote_padding' ); + $t_padding = config_get( 'display_bugnote_padding' ); + return str_pad( $p_bugnote_id, $t_padding, '0', STR_PAD_LEFT ); } -?> \ No newline at end of file +?> diff --git a/core/user_pref_api.php b/core/user_pref_api.php index 0b00fcfa23..1ab502d281 100644 --- a/core/user_pref_api.php +++ b/core/user_pref_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: user_pref_api.php,v 1.17 2004-04-08 20:52:50 prescience Exp $ + # $Id: user_pref_api.php,v 1.18 2004-08-08 11:39:00 jlatour Exp $ # -------------------------------------------------------- ### User Preferences API ### @@ -22,6 +22,7 @@ class UserPreferences { var $advanced_update; var $refresh_delay; var $redirect_delay; + var $bugnote_order; var $email_on_new; var $email_on_assigned; var $email_on_feedback; @@ -40,35 +41,38 @@ class UserPreferences { var $email_on_bugnote_minimum_severity; var $email_on_status_minimum_severity; var $email_on_priority_minimum_severity; + var $email_bugnote_limit; var $language; function UserPreferences() { - $this->default_profile = 0; - $this->default_project = ALL_PROJECTS; - $this->advanced_report = config_get( 'default_advanced_report'); - $this->advanced_view = config_get( 'default_advanced_view'); - $this->advanced_update = config_get( 'default_advanced_update'); - $this->refresh_delay = config_get( 'default_refresh_delay'); - $this->redirect_delay = config_get( 'default_redirect_delay'); - $this->email_on_new = config_get( 'default_email_on_new'); - $this->email_on_assigned = config_get( 'default_email_on_assigned'); - $this->email_on_feedback = config_get( 'default_email_on_feedback'); - $this->email_on_resolved = config_get( 'default_email_on_resolved'); - $this->email_on_closed = config_get( 'default_email_on_closed'); - $this->email_on_reopened = config_get( 'default_email_on_reopened'); - $this->email_on_bugnote = config_get( 'default_email_on_bugnote'); - $this->email_on_status = config_get( 'default_email_on_status'); - $this->email_on_priority = config_get( 'default_email_on_priority'); - $this->email_on_new_minimum_severity = config_get( 'default_email_on_new_minimum_severity' ); + $this->default_profile = 0; + $this->default_project = ALL_PROJECTS; + $this->advanced_report = config_get( 'default_advanced_report'); + $this->advanced_view = config_get( 'default_advanced_view'); + $this->advanced_update = config_get( 'default_advanced_update'); + $this->refresh_delay = config_get( 'default_refresh_delay'); + $this->redirect_delay = config_get( 'default_redirect_delay'); + $this->bugnote_order = config_get( 'default_bugnote_order'); + $this->email_on_new = config_get( 'default_email_on_new'); + $this->email_on_assigned = config_get( 'default_email_on_assigned'); + $this->email_on_feedback = config_get( 'default_email_on_feedback'); + $this->email_on_resolved = config_get( 'default_email_on_resolved'); + $this->email_on_closed = config_get( 'default_email_on_closed'); + $this->email_on_reopened = config_get( 'default_email_on_reopened'); + $this->email_on_bugnote = config_get( 'default_email_on_bugnote'); + $this->email_on_status = config_get( 'default_email_on_status'); + $this->email_on_priority = config_get( 'default_email_on_priority'); + $this->email_on_new_minimum_severity = config_get( 'default_email_on_new_minimum_severity' ); $this->email_on_assigned_minimum_severity = config_get( 'default_email_on_assigned_minimum_severity' ); $this->email_on_feedback_minimum_severity = config_get( 'default_email_on_feedback_minimum_severity' ); $this->email_on_resolved_minimum_severity = config_get( 'default_email_on_resolved_minimum_severity' ); - $this->email_on_closed_minimum_severity = config_get( 'default_email_on_closed_minimum_severity' ); + $this->email_on_closed_minimum_severity = config_get( 'default_email_on_closed_minimum_severity' ); $this->email_on_reopened_minimum_severity = config_get( 'default_email_on_reopened_minimum_severity' ); - $this->email_on_bugnote_minimum_severity = config_get( 'default_email_on_bugnote_minimum_severity' ); - $this->email_on_status_minimum_severity = config_get( 'default_email_on_status_minimum_severity' ); + $this->email_on_bugnote_minimum_severity = config_get( 'default_email_on_bugnote_minimum_severity' ); + $this->email_on_status_minimum_severity = config_get( 'default_email_on_status_minimum_severity' ); $this->email_on_priority_minimum_severity = config_get( 'default_email_on_priority_minimum_severity' ); - $this->language = config_get( 'default_language'); + $this->email_bugnote_limit = config_get( 'default_email_bugnote_limit' ); + $this->language = config_get( 'default_language'); } } @@ -393,4 +397,4 @@ function user_pref_set_default( $p_user_id, $p_project_id = ALL_PROJECTS ) { return user_pref_set( $p_user_id, $t_prefs, $p_project_id ); } -?> \ No newline at end of file +?> diff --git a/doc/CREDITS b/doc/CREDITS index 49358f483c..ad6b435036 100644 --- a/doc/CREDITS +++ b/doc/CREDITS @@ -31,6 +31,7 @@ Adrian Spinei Amandeep Jawa Angelo Rossi August Zajonc +Bastian Pfenningschmidt Beorn Harris Brett Carter Brett England diff --git a/doc/ChangeLog b/doc/ChangeLog index aff8ebb213..d5d3628829 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -2,6 +2,7 @@ Mantis ChangeLog 2004.08.xx - 0.19.0xx +- 0004043: [email] Preference to exclude old bugnotes from notification (Bastian Pfennigschmidt) - 0004279: [bugtracker] My View makes bad use of available space (tazza70) - 0003689: [bugtracker] index.php is sending wrong HTTP header if not logged in (jlatour) - 0004193: [bugtracker] Broaden the ldap features to work with Active Directory (alf) diff --git a/lang/strings_chinese_simplified.txt b/lang/strings_chinese_simplified.txt index 8e6ec0803d..9fa9205b4b 100644 --- a/lang/strings_chinese_simplified.txt +++ b/lang/strings_chinese_simplified.txt @@ -11,11 +11,11 @@ # Chinese_Simplified: liaobin@jite.net # Chinese_Simplified: NetCobra,netcobra@gmail.com # ------------------------------------------------- - # $Revision: 1.46 $ + # $Revision: 1.47 $ # $Author: jlatour $ - # $Date: 2004-08-08 08:45:13 $ + # $Date: 2004-08-08 11:39:01 $ # - # $Id: strings_chinese_simplified.txt,v 1.46 2004-08-08 08:45:13 jlatour Exp $ + # $Id: strings_chinese_simplified.txt,v 1.47 2004-08-08 11:39:01 jlatour Exp $ ########################################################################### ########################################################################### @@ -348,6 +348,9 @@ $s_advanced_update = " $s_refresh_delay = "刷新延迟"; $s_redirect_delay = "重定向延时(秒"; $s_with_minimum_severity = 'With Mimimum Severity of'; +$s_bugnote_order = 'Bugnotes Sort Order'; +$s_bugnote_order_asc = 'Ascending'; +$s_bugnote_order_desc = 'Descending'; $s_email_on_new = "当新建Bug时发送Email提醒"; $s_email_on_assigned = "当指派Bug时发送Email提醒"; $s_email_on_feedback = "当反馈Bug时发送Email提醒"; @@ -357,6 +360,7 @@ $s_email_on_reopened = " $s_email_on_bugnote_added = "当添加 Bug 注解时发送Email提醒"; $s_email_on_status_change = "当状态改变时发送Email提醒"; $s_email_on_priority_change = "当优先级改变时发送Email提醒"; +$s_email_bugnote_limit = 'Email Bugnotes Limit'; $s_language = "界面语言"; $s_update_prefs_button = "更新设置"; $s_reset_prefs_button = "重置设置"; diff --git a/lang/strings_chinese_traditional.txt b/lang/strings_chinese_traditional.txt index 201db8b2b6..07be538c3b 100644 --- a/lang/strings_chinese_traditional.txt +++ b/lang/strings_chinese_traditional.txt @@ -7,11 +7,11 @@ # Chinese_Traditional: Pao-Hsi Huang, doggy8088@mail2000.com.tw # ------------------------------------------------- - # $Revision: 1.59 $ + # $Revision: 1.60 $ # $Author: jlatour $ - # $Date: 2004-08-08 08:45:13 $ + # $Date: 2004-08-08 11:39:01 $ # - # $Id: strings_chinese_traditional.txt,v 1.59 2004-08-08 08:45:13 jlatour Exp $ + # $Id: strings_chinese_traditional.txt,v 1.60 2004-08-08 11:39:01 jlatour Exp $ ########################################################################### ?> @@ -334,6 +334,9 @@ $s_advanced_update = 'Uitgebreid aanpassen'; $s_refresh_delay = 'Verversings snelheid'; $s_redirect_delay = 'Doorloop snelheid berichten'; $s_with_minimum_severity = 'With Mimimum Severity of'; +$s_bugnote_order = 'Bugnotes Sort Order'; +$s_bugnote_order_asc = 'Ascending'; +$s_bugnote_order_desc = 'Descending'; $s_email_on_new = 'E-mail nieuwe bugs'; $s_email_on_assigned = 'E-mail toegewezen bugs'; $s_email_on_feedback = 'E-mail feedback'; @@ -343,6 +346,7 @@ $s_email_on_reopened = 'E-mail heropende bugs'; $s_email_on_bugnote_added = 'E-mail toegevoegde aantekening'; $s_email_on_status_change = 'E-mail status verandering'; $s_email_on_priority_change = 'E-mail verandering prioriteit'; +$s_email_bugnote_limit = 'Email Bugnotes Limit'; $s_language = 'Taal'; $s_update_prefs_button = 'Aanpassen instellingen'; $s_reset_prefs_button = 'Begininstellingen'; diff --git a/lang/strings_english.txt b/lang/strings_english.txt index 51709b3890..eeddc4f86d 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -9,11 +9,11 @@ ########################################################################### # English strings for Mantis # ------------------------------------------------- - # $Revision: 1.196 $ - # $Author: thraxisp $ - # $Date: 2004-08-04 01:38:07 $ + # $Revision: 1.197 $ + # $Author: jlatour $ + # $Date: 2004-08-08 11:39:15 $ # - # $Id: strings_english.txt,v 1.196 2004-08-04 01:38:07 thraxisp Exp $ + # $Id: strings_english.txt,v 1.197 2004-08-08 11:39:15 jlatour Exp $ ########################################################################### ?> # Polish: Kacper Kruszewski # ------------------------------------------------- - # $Revision: 1.68 $ + # $Revision: 1.69 $ # $Author: jlatour $ - # $Date: 2004-08-08 08:45:14 $ + # $Date: 2004-08-08 11:39:17 $ # - # $Id: strings_polish.txt,v 1.68 2004-08-08 08:45:14 jlatour Exp $ + # $Id: strings_polish.txt,v 1.69 2004-08-08 11:39:17 jlatour Exp $ ########################################################################### ?> diff --git a/print_bugnote_inc.php b/print_bugnote_inc.php index 1c20e8e5b2..7c7023d2b7 100644 --- a/print_bugnote_inc.php +++ b/print_bugnote_inc.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: print_bugnote_inc.php,v 1.26 2004-03-05 01:26:16 jlatour Exp $ + # $Id: print_bugnote_inc.php,v 1.27 2004-08-08 11:39:00 jlatour Exp $ # -------------------------------------------------------- ?>