$t_lang_additional_information = lang_get('additional_information'); $t_lang_bug_notes_title = lang_get('bug_notes_title'); $t_lang_system_profile = lang_get('system_profile'); $t_lang_attached_files = lang_get('attached_files'); $t_lang_tags = lang_get('tags'); $t_fields = config_get('bug_view_page_fields'); $t_fields = columns_filter_disabled($t_fields); $t_show_tags = in_array('tags', $t_fields) && access_has_global_level(config_get('tag_view_threshold')); $t_current_user_id = auth_get_current_user_id(); $t_user_bugnote_order = user_pref_get_pref($t_current_user_id, 'bugnote_order'); for ($j = 0; $j < $t_row_count; $j++) { $t_bug = $t_result[$j]; $t_id = $t_bug->id; if ($j % 50 == 0) { # to save ram as report will list data once, clear cache after 50 bugs bug_text_clear_cache(); bug_clear_cache(); bugnote_clear_cache(); } # display the available and selected bugs if (in_array($t_id, $f_bug_arr) || !$f_show_flag) { if ($t_count_exported > 0) { echo '<br style="mso-special-character: line-break; page-break-before: always" />'; } $t_count_exported++; $t_last_updated = date($g_short_date_format, $t_bug->last_updated); # grab the project name $t_project_name = project_get_field($t_bug->project_id, 'name'); $t_category_name = category_full_name($t_bug->category_id, false); ?> <br />
/** * 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; }
function bug_update($p_bug_id, $p_bug_data, $p_update_extended = false, $p_bypass_mail = false) { $c_bug_id = db_prepare_int($p_bug_id); $c_bug_data = bug_prepare_db($p_bug_data); # Summary cannot be blank if (is_blank($c_bug_data->summary)) { error_parameters(lang_get('summary')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } if ($p_update_extended) { # Description field cannot be empty if (is_blank($c_bug_data->description)) { error_parameters(lang_get('description')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } } if (!is_blank($p_bug_data->duplicate_id) && $p_bug_data->duplicate_id != 0 && $p_bug_id == $p_bug_data->duplicate_id) { trigger_error(ERROR_BUG_DUPLICATE_SELF, ERROR); # never returns } $t_old_data = bug_get($p_bug_id, true); $t_bug_table = config_get('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\tSET project_id='{$c_bug_data->project_id}',\n\t\t\t\t\treporter_id='{$c_bug_data->reporter_id}',\n\t\t\t\t\thandler_id='{$c_bug_data->handler_id}',\n\t\t\t\t\tduplicate_id='{$c_bug_data->duplicate_id}',\n\t\t\t\t\tpriority='{$c_bug_data->priority}',\n\t\t\t\t\tseverity='{$c_bug_data->severity}',\n\t\t\t\t\treproducibility='{$c_bug_data->reproducibility}',\n\t\t\t\t\tstatus='{$c_bug_data->status}',\n\t\t\t\t\tresolution='{$c_bug_data->resolution}',\n\t\t\t\t\tprojection='{$c_bug_data->projection}',\n\t\t\t\t\tcategory='{$c_bug_data->category}',\n\t\t\t\t\teta='{$c_bug_data->eta}',\n\t\t\t\t\tos='{$c_bug_data->os}',\n\t\t\t\t\tos_build='{$c_bug_data->os_build}',\n\t\t\t\t\tplatform='{$c_bug_data->platform}',\n\t\t\t\t\tversion='{$c_bug_data->version}',\n\t\t\t\t\tbuild='{$c_bug_data->build}',\n\t\t\t\t\tfixed_in_version='{$c_bug_data->fixed_in_version}',"; $t_roadmap_updated = false; if (access_has_project_level(config_get('roadmap_update_threshold'))) { $query .= "\n\t\t\t\t\ttarget_version='{$c_bug_data->target_version}',"; $t_roadmap_updated = true; } $query .= "\n\t\t\t\t\tview_state='{$c_bug_data->view_state}',\n\t\t\t\t\tsummary='{$c_bug_data->summary}',\n\t\t\t\t\tsponsorship_total='{$c_bug_data->sponsorship_total}',\n\t\t\t\t\tsticky='{$c_bug_data->sticky}'\n\t\t\t\tWHERE id='{$c_bug_id}'"; db_query($query); bug_clear_cache($p_bug_id); # log changes history_log_event_direct($p_bug_id, 'project_id', $t_old_data->project_id, $p_bug_data->project_id); history_log_event_direct($p_bug_id, 'reporter_id', $t_old_data->reporter_id, $p_bug_data->reporter_id); history_log_event_direct($p_bug_id, 'handler_id', $t_old_data->handler_id, $p_bug_data->handler_id); history_log_event_direct($p_bug_id, 'duplicate_id', $t_old_data->duplicate_id, $p_bug_data->duplicate_id); history_log_event_direct($p_bug_id, 'priority', $t_old_data->priority, $p_bug_data->priority); history_log_event_direct($p_bug_id, 'severity', $t_old_data->severity, $p_bug_data->severity); history_log_event_direct($p_bug_id, 'reproducibility', $t_old_data->reproducibility, $p_bug_data->reproducibility); history_log_event_direct($p_bug_id, 'status', $t_old_data->status, $p_bug_data->status); history_log_event_direct($p_bug_id, 'resolution', $t_old_data->resolution, $p_bug_data->resolution); history_log_event_direct($p_bug_id, 'projection', $t_old_data->projection, $p_bug_data->projection); history_log_event_direct($p_bug_id, 'category', $t_old_data->category, $p_bug_data->category); history_log_event_direct($p_bug_id, 'eta', $t_old_data->eta, $p_bug_data->eta); history_log_event_direct($p_bug_id, 'os', $t_old_data->os, $p_bug_data->os); history_log_event_direct($p_bug_id, 'os_build', $t_old_data->os_build, $p_bug_data->os_build); history_log_event_direct($p_bug_id, 'platform', $t_old_data->platform, $p_bug_data->platform); history_log_event_direct($p_bug_id, 'version', $t_old_data->version, $p_bug_data->version); history_log_event_direct($p_bug_id, 'build', $t_old_data->build, $p_bug_data->build); history_log_event_direct($p_bug_id, 'fixed_in_version', $t_old_data->fixed_in_version, $p_bug_data->fixed_in_version); if ($t_roadmap_updated) { history_log_event_direct($p_bug_id, 'target_version', $t_old_data->target_version, $p_bug_data->target_version); } history_log_event_direct($p_bug_id, 'view_state', $t_old_data->view_state, $p_bug_data->view_state); history_log_event_direct($p_bug_id, 'summary', $t_old_data->summary, $p_bug_data->summary); history_log_event_direct($p_bug_id, 'sponsorship_total', $t_old_data->sponsorship_total, $p_bug_data->sponsorship_total); history_log_event_direct($p_bug_id, 'sticky', $t_old_data->sticky, $p_bug_data->sticky); # Update extended info if requested if ($p_update_extended) { $t_bug_text_table = config_get('mantis_bug_text_table'); $t_bug_text_id = bug_get_field($p_bug_id, 'bug_text_id'); $query = "UPDATE {$t_bug_text_table}\n\t\t\t\t\t\tSET description='{$c_bug_data->description}',\n\t\t\t\t\t\t\tsteps_to_reproduce='{$c_bug_data->steps_to_reproduce}',\n\t\t\t\t\t\t\tadditional_information='{$c_bug_data->additional_information}'\n\t\t\t\t\t\tWHERE id='{$t_bug_text_id}'"; db_query($query); bug_text_clear_cache($p_bug_id); if ($t_old_data->description != $p_bug_data->description) { history_log_event_special($p_bug_id, DESCRIPTION_UPDATED); } if ($t_old_data->steps_to_reproduce != $p_bug_data->steps_to_reproduce) { history_log_event_special($p_bug_id, STEP_TO_REPRODUCE_UPDATED); } if ($t_old_data->additional_information != $p_bug_data->additional_information) { history_log_event_special($p_bug_id, ADDITIONAL_INFO_UPDATED); } } # Update the last update date bug_update_date($p_bug_id); if (false == $p_bypass_mail) { # allow bypass if user is sending mail separately $t_action_prefix = 'email_notification_title_for_action_bug_'; $t_status_prefix = 'email_notification_title_for_status_bug_'; # status changed if ($t_old_data->status != $p_bug_data->status) { $t_status = get_enum_to_string(config_get('status_enum_string'), $p_bug_data->status); $t_status = str_replace(' ', '_', $t_status); email_generic($p_bug_id, $t_status, $t_status_prefix . $t_status); return true; } # bug assigned if ($t_old_data->handler_id != $p_bug_data->handler_id) { email_generic($p_bug_id, 'owner', $t_action_prefix . 'assigned'); return true; } # @@@ handle priority change if it requires special handling # generic update notification email_generic($p_bug_id, 'updated', $t_action_prefix . 'updated'); } return true; }