/** * Add a bugnote to a bug * return the ID of the new bugnote * @param int $p_bug_id bug id * @param string $p_bugnote_text bugnote text * @param string $p_time_tracking hh:mm string * @param bool $p_private whether bugnote is private * @param int $p_type bugnote type * @param string $p_attr * @param int $p_user_id user id * @param bool $p_send_email generate email? * @return false|int false or indicating bugnote id added * @access public */ function bugnote_add($p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_private = false, $p_type = BUGNOTE, $p_attr = '', $p_user_id = null, $p_send_email = TRUE, $p_log_history = TRUE) { $c_bug_id = db_prepare_int($p_bug_id); $c_time_tracking = helper_duration_to_minutes($p_time_tracking); $c_type = db_prepare_int($p_type); if (REMINDER !== $p_type) { # Check if this is a time-tracking note $t_time_tracking_enabled = config_get('time_tracking_enabled'); if (ON == $t_time_tracking_enabled && $c_time_tracking > 0) { $t_time_tracking_without_note = config_get('time_tracking_without_note'); if (is_blank($p_bugnote_text) && OFF == $t_time_tracking_without_note) { error_parameters(lang_get('bugnote')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $c_type = TIME_TRACKING; } else { if (is_blank($p_bugnote_text)) { # This is not time tracking (i.e. it's a normal bugnote) # @todo should we not trigger an error in this case ? return false; } } } $t_bugnote_text_table = db_get_table('mantis_bugnote_text_table'); $t_bugnote_table = db_get_table('mantis_bugnote_table'); # Event integration $t_bugnote_text = event_signal('EVENT_BUGNOTE_DATA', $p_bugnote_text, $c_bug_id); # insert bugnote text $query = 'INSERT INTO ' . $t_bugnote_text_table . ' ( note ) VALUES ( ' . db_param() . ' )'; db_query_bound($query, array($t_bugnote_text)); # retrieve bugnote text id number $t_bugnote_text_id = db_insert_id($t_bugnote_text_table); # get user information if ($p_user_id === null) { $c_user_id = auth_get_current_user_id(); } else { $c_user_id = db_prepare_int($p_user_id); } # Check for private bugnotes. # @@@ VB: Should we allow users to report private bugnotes, and possibly see only their own private ones if ($p_private && access_has_bug_level(config_get('private_bugnote_threshold'), $p_bug_id, $c_user_id)) { $t_view_state = VS_PRIVATE; } else { $t_view_state = VS_PUBLIC; } # insert bugnote info $query = "INSERT INTO {$t_bugnote_table}\n\t\t\t\t(bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr, time_tracking )\n\t\t\tVALUES\n\t\t\t\t(" . db_param() . ', ' . db_param() . ',' . db_param() . ', ' . db_param() . ', ' . db_param() . ',' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )'; db_query_bound($query, array($c_bug_id, $c_user_id, $t_bugnote_text_id, $t_view_state, db_now(), db_now(), $c_type, $p_attr, $c_time_tracking)); # get bugnote id $t_bugnote_id = db_insert_id($t_bugnote_table); # update bug last updated bug_update_date($p_bug_id); # log new bug if (TRUE == $p_log_history) { history_log_event_special($p_bug_id, BUGNOTE_ADDED, bugnote_format_id($t_bugnote_id)); } # if it was FEEDBACK its NEW_ now if (config_get('reassign_on_feedback') && bug_get_field($p_bug_id, 'status') == config_get('bug_feedback_status') && bug_get_field($p_bug_id, 'reporter_id') == $c_user_id) { if (bug_get_field($p_bug_id, 'handler_id') == 0) { bug_set_field($p_bug_id, 'status', config_get('bug_submit_status')); } else { bug_set_field($p_bug_id, 'status', config_get('bug_assigned_status')); } } # Event integration event_signal('EVENT_BUGNOTE_ADD', array($p_bug_id, $t_bugnote_id)); # only send email if the text is not blank, otherwise, it is just recording of time without a comment. if (TRUE == $p_send_email && !is_blank($t_bugnote_text)) { email_bugnote_add($p_bug_id); } return $t_bugnote_id; }
/** * Add a bugnote to a bug * return the ID of the new bugnote * @param integer $p_bug_id A bug identifier. * @param string $p_bugnote_text The bugnote text to add. * @param string $p_time_tracking Time tracking value - hh:mm string. * @param boolean $p_private Whether bugnote is private. * @param integer $p_type The bugnote type. * @param string $p_attr Bugnote Attribute. * @param integer $p_user_id A user identifier. * @param boolean $p_send_email Whether to generate email. * @param integer $p_date_submitted Date submitted (defaults to now()). * @param integer $p_last_modified Last modification date (defaults to now()). * @param boolean $p_skip_bug_update Skip bug last modification update (useful when importing bugs/bugnotes). * @param boolean $p_log_history Log changes to bugnote history (defaults to true). * @return boolean|integer false or indicating bugnote id added * @access public */ function bugnote_add($p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_private = false, $p_type = BUGNOTE, $p_attr = '', $p_user_id = null, $p_send_email = true, $p_date_submitted = 0, $p_last_modified = 0, $p_skip_bug_update = false, $p_log_history = true) { $c_bug_id = (int) $p_bug_id; $c_time_tracking = helper_duration_to_minutes($p_time_tracking); $c_type = (int) $p_type; $c_date_submitted = $p_date_submitted <= 0 ? db_now() : (int) $p_date_submitted; $c_last_modified = $p_last_modified <= 0 ? db_now() : (int) $p_last_modified; antispam_check(); if (REMINDER !== $p_type) { # Check if this is a time-tracking note $t_time_tracking_enabled = config_get('time_tracking_enabled'); if (ON == $t_time_tracking_enabled && $c_time_tracking > 0) { $t_time_tracking_without_note = config_get('time_tracking_without_note'); if (is_blank($p_bugnote_text) && OFF == $t_time_tracking_without_note) { error_parameters(lang_get('bugnote')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $c_type = TIME_TRACKING; } else { if (is_blank($p_bugnote_text)) { # This is not time tracking (i.e. it's a normal bugnote) # @todo should we not trigger an error in this case ? return false; } } } # Event integration $t_bugnote_text = event_signal('EVENT_BUGNOTE_DATA', $p_bugnote_text, $c_bug_id); # insert bugnote text $t_query = 'INSERT INTO {bugnote_text} ( note ) VALUES ( ' . db_param() . ' )'; db_query($t_query, array($t_bugnote_text)); # retrieve bugnote text id number $t_bugnote_text_id = db_insert_id(db_get_table('bugnote_text')); # get user information if ($p_user_id === null) { $p_user_id = auth_get_current_user_id(); } # Check for private bugnotes. if ($p_private && access_has_bug_level(config_get('set_view_status_threshold'), $p_bug_id, $p_user_id)) { $t_view_state = VS_PRIVATE; } else { $t_view_state = VS_PUBLIC; } # insert bugnote info $t_query = 'INSERT INTO {bugnote} (bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr, time_tracking) VALUES (' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )'; $t_params = array($c_bug_id, $p_user_id, $t_bugnote_text_id, $t_view_state, $c_date_submitted, $c_last_modified, $c_type, $p_attr, $c_time_tracking); db_query($t_query, $t_params); # get bugnote id $t_bugnote_id = db_insert_id(db_get_table('bugnote')); # update bug last updated if (!$p_skip_bug_update) { bug_update_date($p_bug_id); } # log new bug if (true == $p_log_history) { history_log_event_special($p_bug_id, BUGNOTE_ADDED, bugnote_format_id($t_bugnote_id)); } # Event integration event_signal('EVENT_BUGNOTE_ADD', array($p_bug_id, $t_bugnote_id)); # only send email if the text is not blank, otherwise, it is just recording of time without a comment. if (true == $p_send_email && !is_blank($t_bugnote_text)) { email_bugnote_add($p_bug_id); } return $t_bugnote_id; }
/** * Add a bugnote to a bug * return the ID of the new bugnote * @param int $p_bug_id bug id * @param string $p_bugnote_text bugnote text * @param string $p_time_tracking hh:mm string * @param bool $p_private whether bugnote is private * @param int $p_type bugnote type * @param string $p_attr * @param int $p_user_id user id * @param bool $p_send_email generate email? * @param int $p_date_submitted date submitted (defaults to now()) * @param int $p_last_modified last modification date (defaults to now()) * @param bool $p_skip_bug_update skip bug last modification update (useful when importing bugs/bugnotes) * @return false|int false or indicating bugnote id added * @access public */ function bugnote_add($p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_private = false, $p_type = 0, $p_attr = '', $p_user_id = null, $p_send_email = TRUE, $p_date_submitted = 0, $p_last_modified = 0, $p_skip_bug_update = FALSE) { $c_bug_id = db_prepare_int($p_bug_id); $c_time_tracking = helper_duration_to_minutes($p_time_tracking); $c_private = db_prepare_bool($p_private); $c_type = db_prepare_int($p_type); $c_date_submitted = $p_date_submitted <= 0 ? db_now() : db_prepare_int($p_date_submitted); $c_last_modified = $p_last_modified <= 0 ? db_now() : db_prepare_int($p_last_modified); $t_bugnote_text_table = db_get_table('bugnote_text'); $t_bugnote_table = db_get_table('bugnote'); $t_time_tracking_enabled = config_get('time_tracking_enabled'); $t_time_tracking_without_note = config_get('time_tracking_without_note'); if (ON == $t_time_tracking_enabled && $c_time_tracking > 0) { if (is_blank($p_bugnote_text) && OFF == $t_time_tracking_without_note) { error_parameters(lang_get('bugnote')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $c_type = TIME_TRACKING; } else { if (is_blank($p_bugnote_text)) { return false; } } $t_bugnote_text = $p_bugnote_text; # Event integration $t_bugnote_text = event_signal('EVENT_BUGNOTE_DATA', $t_bugnote_text, $c_bug_id); # insert bugnote text $query = 'INSERT INTO ' . $t_bugnote_text_table . ' ( note ) VALUES ( ' . db_param() . ' )'; db_query_bound($query, array($t_bugnote_text)); # retrieve bugnote text id number $t_bugnote_text_id = db_insert_id($t_bugnote_text_table); # get user information if ($p_user_id === null) { $c_user_id = auth_get_current_user_id(); } else { $c_user_id = db_prepare_int($p_user_id); } # Check for private bugnotes. if ($c_private && access_has_bug_level(config_get('set_view_status_threshold'), $p_bug_id, $c_user_id)) { $t_view_state = VS_PRIVATE; } else { $t_view_state = VS_PUBLIC; } # insert bugnote info $query = "INSERT INTO {$t_bugnote_table}\n\t\t\t\t(bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr, time_tracking )\n\t\t\tVALUES\n\t\t\t\t(" . db_param() . ', ' . db_param() . ',' . db_param() . ', ' . db_param() . ', ' . db_param() . ',' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )'; db_query_bound($query, array($c_bug_id, $c_user_id, $t_bugnote_text_id, $t_view_state, $c_date_submitted, $c_last_modified, $c_type, $p_attr, $c_time_tracking)); # get bugnote id $t_bugnote_id = db_insert_id($t_bugnote_table); # update bug last updated if (!$p_skip_bug_update) { bug_update_date($p_bug_id); } # log new bug history_log_event_special($p_bug_id, BUGNOTE_ADDED, bugnote_format_id($t_bugnote_id)); # Event integration event_signal('EVENT_BUGNOTE_ADD', array($p_bug_id, $t_bugnote_id)); # only send email if the text is not blank, otherwise, it is just recording of time without a comment. if (TRUE == $p_send_email && !is_blank($t_bugnote_text)) { email_bugnote_add($p_bug_id); } return $t_bugnote_id; }
if (empty($_POST['id'])) { $agilemantis_tasks->setConfirmationStatus($agilemantis_tasks->us_id); } # add warning flag if current developer has no capacity if ($noCapacity == true) { $addlink = '&warning=2'; } # add warning flag if task is resolved if ($task_resolved == true) { $addlink = '&warning=3'; email_bugnote_add($agilemantis_tasks->us_id); } # add warning flag if task is closed if ($task_closed == true) { $addlink = '&warning=4'; email_bugnote_add($agilemantis_tasks->us_id); } # return directly to Taskboard, Task Page or Sprint Backlog if ($_POST['fromSprintBacklog'] == 1 && $_POST['fromTaskPage'] == 1) { $additional = '&fromSprintBacklog=1'; header("Location: " . plugin_page('task_page.php&us_id=' . $agilemantis_tasks->us_id . $addlink . $additional)); } if ($_POST['fromSprintBacklog'] && $_POST['fromTaskPage'] != 1) { header("Location: " . plugin_page('sprint_backlog.php') . "&sprintName=" . urlencode($_POST['sprintName']) . $addlink); } if ($_POST['fromTaskboard']) { header("Location: " . plugin_page('taskboard.php') . "&sprintName=" . urlencode($_POST['sprintName']) . $addlink); } if (empty($_POST['fromSprintBacklog']) && empty($_POST['fromTaskboard'])) { header("Location: " . plugin_page('task_page.php&us_id=' . $agilemantis_tasks->us_id . $addlink)); }
function bugnote_add($p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_private = false, $p_type = 0, $p_attr = '', $p_user_id = null, $p_send_email = TRUE) { $c_bug_id = db_prepare_int($p_bug_id); $c_bugnote_text = db_prepare_string($p_bugnote_text); $c_time_tracking = db_prepare_time($p_time_tracking); $c_private = db_prepare_bool($p_private); $c_type = db_prepare_int($p_type); $c_attr = db_prepare_string($p_attr); $t_bugnote_text_table = config_get('mantis_bugnote_text_table'); $t_bugnote_table = config_get('mantis_bugnote_table'); $t_time_tracking_enabled = config_get('time_tracking_enabled'); $t_time_tracking_without_note = config_get('time_tracking_without_note'); if (ON == $t_time_tracking_enabled && $c_time_tracking > 0) { if (is_blank($p_bugnote_text) && OFF == $t_time_tracking_without_note) { error_parameters(lang_get('bugnote')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $c_type = TIME_TRACKING; } else { if (is_blank($p_bugnote_text)) { return false; } } # insert bugnote text $query = "INSERT INTO {$t_bugnote_text_table}\r\n\t\t \t\t( note )\r\n\t\t \t VALUES\r\n\t\t \t\t( '{$c_bugnote_text}' )"; db_query($query); # retrieve bugnote text id number $t_bugnote_text_id = db_insert_id($t_bugnote_text_table); # get user information if ($p_user_id === null) { $c_user_id = auth_get_current_user_id(); } else { $c_user_id = db_prepare_int($p_user_id); } # Check for private bugnotes. # @@@ VB: Should we allow users to report private bugnotes, and possibly see only their own private ones if ($p_private && access_has_bug_level(config_get('private_bugnote_threshold'), $p_bug_id, $c_user_id)) { $t_view_state = VS_PRIVATE; } else { $t_view_state = VS_PUBLIC; } # insert bugnote info $query = "INSERT INTO {$t_bugnote_table}\r\n\t\t\t\t\t(bug_id, reporter_id, bugnote_text_id, view_state, date_submitted, last_modified, note_type, note_attr, time_tracking )\r\n\t\t \t VALUES\r\n\t\t\t\t\t('{$c_bug_id}', '{$c_user_id}','{$t_bugnote_text_id}', '{$t_view_state}', " . db_now() . "," . db_now() . ", '{$c_type}', '{$c_attr}', '{$c_time_tracking}' )"; db_query($query); # get bugnote id $t_bugnote_id = db_insert_id($t_bugnote_table); # update bug last updated bug_update_date($p_bug_id); # log new bug history_log_event_special($p_bug_id, BUGNOTE_ADDED, bugnote_format_id($t_bugnote_id)); # only send email if the text is not blank, otherwise, it is just recording of time without a comment. if ($p_send_email && !is_blank($p_bugnote_text)) { email_bugnote_add($p_bug_id); } return $t_bugnote_id; }
# This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details # -------------------------------------------------------- # $Id: bugnote_add.php,v 1.46 2005/07/25 16:34:10 thraxisp Exp $ # -------------------------------------------------------- # Insert the bugnote into the database then redirect to the bug page require_once 'core.php'; $t_core_path = config_get('core_path'); require_once $t_core_path . 'bug_api.php'; require_once $t_core_path . 'bugnote_api.php'; $f_bug_id = gpc_get_int('bug_id'); $f_private = gpc_get_bool('private'); $f_bugnote_text = gpc_get_string('bugnote_text', ''); if (bug_is_readonly($f_bug_id)) { error_parameters($f_bug_id); trigger_error(ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR); } access_ensure_bug_level(config_get('add_bugnote_threshold'), $f_bug_id); $t_bug = bug_get($f_bug_id, true); 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; } $f_bugnote_text = trim($f_bugnote_text); # check for blank bugnote if (!is_blank($f_bugnote_text)) { bugnote_add($f_bug_id, $f_bugnote_text, $f_private); email_bugnote_add($f_bug_id); } print_successful_redirect_to_bug($f_bug_id);