1<?php 2# MantisBT - A PHP based bugtracking system 3 4# MantisBT is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 2 of the License, or 7# (at your option) any later version. 8# 9# MantisBT is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17/** 18 * This page allows an authorized user to send a reminder by email to another user 19 * 20 * @package MantisBT 21 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 22 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 23 * @link http://www.mantisbt.org 24 * 25 * @uses core.php 26 * @uses access_api.php 27 * @uses bug_api.php 28 * @uses bugnote_api.php 29 * @uses config_api.php 30 * @uses constant_inc.php 31 * @uses email_api.php 32 * @uses error_api.php 33 * @uses form_api.php 34 * @uses gpc_api.php 35 * @uses helper_api.php 36 * @uses html_api.php 37 * @uses lang_api.php 38 * @uses print_api.php 39 * @uses string_api.php 40 */ 41 42require_once( 'core.php' ); 43require_api( 'access_api.php' ); 44require_api( 'bug_api.php' ); 45require_api( 'bugnote_api.php' ); 46require_api( 'config_api.php' ); 47require_api( 'constant_inc.php' ); 48require_api( 'email_api.php' ); 49require_api( 'error_api.php' ); 50require_api( 'form_api.php' ); 51require_api( 'gpc_api.php' ); 52require_api( 'helper_api.php' ); 53require_api( 'html_api.php' ); 54require_api( 'lang_api.php' ); 55require_api( 'print_api.php' ); 56require_api( 'string_api.php' ); 57 58form_security_validate( 'bug_reminder' ); 59 60$f_bug_id = gpc_get_int( 'bug_id' ); 61$f_to = gpc_get_int_array( 'to' ); 62$f_body = gpc_get_string( 'bugnote_text' ); 63$f_view_state = gpc_get_bool( 'private' ) ? VS_PRIVATE : VS_PUBLIC; 64 65$t_bug = bug_get( $f_bug_id, true ); 66if( $t_bug->project_id != helper_get_current_project() ) { 67 # in case the current project is not the same project of the bug we are viewing... 68 # ... override the current project. This to avoid problems with categories and handlers lists etc. 69 $g_project_override = $t_bug->project_id; 70} 71 72if( bug_is_readonly( $f_bug_id ) ) { 73 error_parameters( $f_bug_id ); 74 trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR ); 75} 76 77# Abort if user is not authorized to send reminders 78access_ensure_bug_level( config_get( 'bug_reminder_threshold' ), $f_bug_id ); 79 80# Ensure target users are allowed to receive reminders 81$t_receive_reminder = config_get( 'reminder_receive_threshold' ); 82foreach( $f_to as $t_recipient ) { 83 if( !access_has_bug_level( $t_receive_reminder, $f_bug_id, $t_recipient ) ) { 84 trigger_error( ERROR_USER_DOES_NOT_HAVE_REQ_ACCESS, ERROR ); 85 } 86} 87 88# Automatically add recipients to monitor list if they are above the monitor 89# threshold, option is enabled, and not reporter or handler. 90$t_reminder_recipients_monitor_bug = config_get( 'reminder_recipients_monitor_bug' ); 91$t_monitor_bug_threshold = config_get( 'monitor_bug_threshold' ); 92$t_handler = bug_get_field( $f_bug_id, 'handler_id' ); 93$t_reporter = bug_get_field( $f_bug_id, 'reporter_id' ); 94foreach( $f_to as $t_recipient ) { 95 if( ON == $t_reminder_recipients_monitor_bug 96 && access_has_bug_level( $t_monitor_bug_threshold, $f_bug_id ) 97 && $t_recipient != $t_handler 98 && $t_recipient != $t_reporter 99 ) { 100 bug_monitor( $f_bug_id, $t_recipient ); 101 } 102} 103 104$t_result = email_bug_reminder( $f_to, $f_bug_id, $f_body ); 105 106# Add reminder as bugnote if store reminders option is ON. 107if( ON == config_get( 'store_reminders' ) ) { 108 # Build list of recipients, truncated to note_attr fields's length 109 $t_attr = '|'; 110 $t_length = 0; 111 foreach( $t_result as $t_id ) { 112 $t_recipient = $t_id . '|'; 113 $t_length += strlen( $t_recipient ); 114 if( $t_length > 250 ) { 115 # Remove trailing delimiter to indicate truncation 116 $t_attr = rtrim( $t_attr, '|' ); 117 break; 118 } 119 $t_attr .= $t_recipient; 120 } 121 122 bugnote_add( $f_bug_id, $f_body, 0, $f_view_state == VS_PRIVATE, REMINDER, $t_attr, null, false ); 123 124 # Note: we won't trigger mentions here since reminders are triggered. 125} 126 127form_security_purge( 'bug_reminder' ); 128 129layout_page_header( null, string_get_bug_view_url( $f_bug_id ) ); 130layout_page_begin(); 131 132$t_redirect = string_get_bug_view_url( $f_bug_id ); 133html_operation_successful( $t_redirect ); 134 135layout_page_end(); 136