/** * Update a bug from the given data structure * If the third parameter is true, also update the longer strings table * @param bool p_update_extended * @param bool p_bypass_email Default false, set to true to avoid generating emails (if sending elsewhere) * @return bool (always true) * @access public */ function update($p_update_extended = false, $p_bypass_mail = false) { self::validate($p_update_extended); $c_bug_id = $this->id; if (is_blank($this->due_date)) { $this->due_date = date_get_null(); } $t_old_data = bug_get($this->id, true); $t_bug_table = db_get_table('mantis_bug_table'); # Update all fields # Ignore date_submitted and last_updated since they are pulled out # as unix timestamps which could confuse the history log and they # shouldn't get updated like this anyway. If you really need to change # them use bug_set_field() $query = "UPDATE {$t_bug_table}\n\t\t\t\t\tSET project_id=" . db_param() . ', reporter_id=' . db_param() . ",\n\t\t\t\t\t\thandler_id=" . db_param() . ', duplicate_id=' . db_param() . ",\n\t\t\t\t\t\tpriority=" . db_param() . ', severity=' . db_param() . ",\n\t\t\t\t\t\treproducibility=" . db_param() . ', status=' . db_param() . ",\n\t\t\t\t\t\tresolution=" . db_param() . ', projection=' . db_param() . ",\n\t\t\t\t\t\tcategory_id=" . db_param() . ', eta=' . db_param() . ",\n\t\t\t\t\t\tos=" . db_param() . ', os_build=' . db_param() . ",\n\t\t\t\t\t\tplatform=" . db_param() . ', version=' . db_param() . ",\n\t\t\t\t\t\tbuild=" . db_param() . ', fixed_in_version=' . db_param() . ','; $t_fields = array($this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $this->status, $this->resolution, $this->projection, $this->category_id, $this->eta, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->fixed_in_version); $t_roadmap_updated = false; if (access_has_project_level(config_get('roadmap_update_threshold'))) { $query .= "\n\t\t\t\t\t\ttarget_version=" . db_param() . ","; $t_fields[] = $this->target_version; $t_roadmap_updated = true; } $query .= "\n\t\t\t\t\t\tview_state=" . db_param() . ",\n\t\t\t\t\t\tsummary=" . db_param() . ",\n\t\t\t\t\t\tsponsorship_total=" . db_param() . ",\n\t\t\t\t\t\tsticky=" . db_param() . ",\n\t\t\t\t\t\tdue_date=" . db_param() . "\n\t\t\t\t\tWHERE id=" . db_param(); $t_fields[] = $this->view_state; $t_fields[] = $this->summary; $t_fields[] = $this->sponsorship_total; $t_fields[] = (bool) $this->sticky; $t_fields[] = $this->due_date; $t_fields[] = $this->id; db_query_bound($query, $t_fields); bug_clear_cache($this->id); # log changes history_log_event_direct($c_bug_id, 'project_id', $t_old_data->project_id, $this->project_id); history_log_event_direct($c_bug_id, 'reporter_id', $t_old_data->reporter_id, $this->reporter_id); history_log_event_direct($c_bug_id, 'handler_id', $t_old_data->handler_id, $this->handler_id); history_log_event_direct($c_bug_id, 'priority', $t_old_data->priority, $this->priority); history_log_event_direct($c_bug_id, 'severity', $t_old_data->severity, $this->severity); history_log_event_direct($c_bug_id, 'reproducibility', $t_old_data->reproducibility, $this->reproducibility); history_log_event_direct($c_bug_id, 'status', $t_old_data->status, $this->status); history_log_event_direct($c_bug_id, 'resolution', $t_old_data->resolution, $this->resolution); history_log_event_direct($c_bug_id, 'projection', $t_old_data->projection, $this->projection); history_log_event_direct($c_bug_id, 'category', category_full_name($t_old_data->category_id, false), category_full_name($this->category_id, false)); history_log_event_direct($c_bug_id, 'eta', $t_old_data->eta, $this->eta); history_log_event_direct($c_bug_id, 'os', $t_old_data->os, $this->os); history_log_event_direct($c_bug_id, 'os_build', $t_old_data->os_build, $this->os_build); history_log_event_direct($c_bug_id, 'platform', $t_old_data->platform, $this->platform); history_log_event_direct($c_bug_id, 'version', $t_old_data->version, $this->version); history_log_event_direct($c_bug_id, 'build', $t_old_data->build, $this->build); history_log_event_direct($c_bug_id, 'fixed_in_version', $t_old_data->fixed_in_version, $this->fixed_in_version); if ($t_roadmap_updated) { history_log_event_direct($c_bug_id, 'target_version', $t_old_data->target_version, $this->target_version); } history_log_event_direct($c_bug_id, 'view_state', $t_old_data->view_state, $this->view_state); history_log_event_direct($c_bug_id, 'summary', $t_old_data->summary, $this->summary); history_log_event_direct($c_bug_id, 'sponsorship_total', $t_old_data->sponsorship_total, $this->sponsorship_total); history_log_event_direct($c_bug_id, 'sticky', $t_old_data->sticky, $this->sticky); history_log_event_direct($c_bug_id, 'due_date', $t_old_data->due_date != date_get_null() ? $t_old_data->due_date : null, $this->due_date != date_get_null() ? $this->due_date : null); # Update extended info if requested if ($p_update_extended) { $t_bug_text_table = db_get_table('mantis_bug_text_table'); $t_bug_text_id = bug_get_field($c_bug_id, 'bug_text_id'); $query = "UPDATE {$t_bug_text_table}\n\t\t\t\t\t\t\tSET description=" . db_param() . ",\n\t\t\t\t\t\t\t\tsteps_to_reproduce=" . db_param() . ",\n\t\t\t\t\t\t\t\tadditional_information=" . db_param() . "\n\t\t\t\t\t\t\tWHERE id=" . db_param(); db_query_bound($query, array($this->description, $this->steps_to_reproduce, $this->additional_information, $t_bug_text_id)); bug_text_clear_cache($c_bug_id); $t_current_user = auth_get_current_user_id(); if ($t_old_data->description != $this->description) { if (bug_revision_count($c_bug_id, REV_DESCRIPTION) < 1) { $t_revision_id = bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_DESCRIPTION, $t_old_data->description, 0, $t_old_data->date_submitted); } $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_DESCRIPTION, $this->description); history_log_event_special($c_bug_id, DESCRIPTION_UPDATED, $t_revision_id); } if ($t_old_data->steps_to_reproduce != $this->steps_to_reproduce) { if (bug_revision_count($c_bug_id, REV_STEPS_TO_REPRODUCE) < 1) { $t_revision_id = bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_STEPS_TO_REPRODUCE, $t_old_data->steps_to_reproduce, 0, $t_old_data->date_submitted); } $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_STEPS_TO_REPRODUCE, $this->steps_to_reproduce); history_log_event_special($c_bug_id, STEP_TO_REPRODUCE_UPDATED, $t_revision_id); } if ($t_old_data->additional_information != $this->additional_information) { if (bug_revision_count($c_bug_id, REV_ADDITIONAL_INFO) < 1) { $t_revision_id = bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_ADDITIONAL_INFO, $t_old_data->additional_information, 0, $t_old_data->date_submitted); } $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_ADDITIONAL_INFO, $this->additional_information); history_log_event_special($c_bug_id, ADDITIONAL_INFO_UPDATED, $t_revision_id); } } # Update the last update date bug_update_date($c_bug_id); # allow bypass if user is sending mail separately if (false == $p_bypass_mail) { # bug assigned if ($t_old_data->handler_id != $this->handler_id) { email_generic($c_bug_id, 'owner', 'email_notification_title_for_action_bug_assigned'); return true; } # status changed if ($t_old_data->status != $this->status) { $t_status = MantisEnum::getLabel(config_get('status_enum_string'), $this->status); $t_status = str_replace(' ', '_', $t_status); email_generic($c_bug_id, $t_status, 'email_notification_title_for_status_bug_' . $t_status); return true; } # @todo handle priority change if it requires special handling # generic update notification email_generic($c_bug_id, 'updated', 'email_notification_title_for_action_bug_updated'); } return true; }
/** * Set the bugnote text * @param int $p_bugnote_id bugnote id * @param string $p_bugnote_text bugnote text * @return bool * @access public */ function bugnote_set_text($p_bugnote_id, $p_bugnote_text) { $t_old_text = bugnote_get_text($p_bugnote_id); if ($t_old_text == $p_bugnote_text) { return true; } $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 = db_get_table('mantis_bugnote_text_table'); # insert an 'original' revision if needed if (bug_revision_count($t_bug_id, REV_BUGNOTE, $p_bugnote_id) < 1) { $t_user_id = bugnote_get_field($p_bugnote_id, 'reporter_id'); $t_timestamp = bugnote_get_field($p_bugnote_id, 'last_modified'); bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $t_old_text, $p_bugnote_id, $t_timestamp); } $query = "UPDATE {$t_bugnote_text_table}\n\t\t\tSET note=" . db_param() . " WHERE id=" . db_param(); db_query_bound($query, array($p_bugnote_text, $t_bugnote_text_id)); # updated the last_updated date bugnote_date_update($p_bugnote_id); bug_update_date($t_bug_id); # insert a new revision $t_user_id = auth_get_current_user_id(); $t_revision_id = bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $p_bugnote_text, $p_bugnote_id); # log new bugnote history_log_event_special($t_bug_id, BUGNOTE_UPDATED, bugnote_format_id($p_bugnote_id), $t_revision_id); return true; }
/** * Set the bugnote text * @param integer $p_bugnote_id A bugnote identifier. * @param string $p_bugnote_text The bugnote text to set. * @return boolean * @access public */ function bugnote_set_text($p_bugnote_id, $p_bugnote_text) { $t_old_text = bugnote_get_text($p_bugnote_id); if ($t_old_text == $p_bugnote_text) { return true; } # MySQL 4-bytes UTF-8 chars workaround #21101 $p_bugnote_text = db_mysql_fix_utf8($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'); # insert an 'original' revision if needed if (bug_revision_count($t_bug_id, REV_BUGNOTE, $p_bugnote_id) < 1) { $t_user_id = bugnote_get_field($p_bugnote_id, 'reporter_id'); $t_timestamp = bugnote_get_field($p_bugnote_id, 'last_modified'); bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $t_old_text, $p_bugnote_id, $t_timestamp); } db_param_push(); $t_query = 'UPDATE {bugnote_text} SET note=' . db_param() . ' WHERE id=' . db_param(); db_query($t_query, array($p_bugnote_text, $t_bugnote_text_id)); # updated the last_updated date bugnote_date_update($p_bugnote_id); bug_update_date($t_bug_id); # insert a new revision $t_user_id = auth_get_current_user_id(); $t_revision_id = bug_revision_add($t_bug_id, $t_user_id, REV_BUGNOTE, $p_bugnote_text, $p_bugnote_id); # log new bugnote history_log_event_special($t_bug_id, BUGNOTE_UPDATED, bugnote_format_id($p_bugnote_id), $t_revision_id); return true; }