} } # Handle the reassign on feedback feature. Note that this feature generally # won't work very well with custom workflows as it makes a lot of assumptions # that may not be true. It assumes you don't have any statuses in the workflow # between 'bug_submit_status' and 'bug_feedback_status'. It assumes you only # have one feedback, assigned and submitted status. if ($t_bug_note->note && config_get('reassign_on_feedback') && $t_existing_bug->status == config_get('bug_feedback_status') && $t_updated_bug->status != $t_existing_bug->status && $t_updated_bug->handler_id != $t_current_user_id && $t_updated_bug->reporter_id == $t_current_user_id) { if ($t_updated_bug->handler_id != NO_USER) { $t_updated_bug->status = config_get('bug_assigned_status'); } else { $t_updated_bug->status = config_get('bug_submit_status'); } } # Handle automatic assignment of issues. $t_updated_bug->status = bug_get_status_for_assign($t_existing_bug->handler_id, $t_updated_bug->handler_id, $t_existing_bug->status, $t_updated_bug->status); # Allow a custom function to validate the proposed bug updates. Note that # custom functions are being deprecated in MantisBT. You should migrate to # the new plugin system instead. helper_call_custom_function('issue_update_validate', array($f_bug_id, $t_updated_bug, $t_bug_note->note)); # Allow plugins to validate/modify the update prior to it being committed. $t_updated_bug = event_signal('EVENT_UPDATE_BUG_DATA', $t_updated_bug, $t_existing_bug); # Commit the bug updates to the database. $t_text_field_update_required = $t_existing_bug->description != $t_updated_bug->description || $t_existing_bug->additional_information != $t_updated_bug->additional_information || $t_existing_bug->steps_to_reproduce != $t_updated_bug->steps_to_reproduce; $t_updated_bug->update($t_text_field_update_required, true); # Update custom field values. foreach ($t_custom_fields_to_set as $t_custom_field_to_set) { custom_field_set_value($t_custom_field_to_set['id'], $f_bug_id, $t_custom_field_to_set['value']); } # Add a bug note if there is one. if ($t_bug_note->note || helper_duration_to_minutes($t_bug_note->time_tracking) > 0) {
} else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access'); } break; case 'COPY': $f_project_id = gpc_get_int('project_id'); if (access_has_project_level(config_get('report_bug_threshold'), $f_project_id)) { # Copy everything except history bug_copy($t_bug_id, $f_project_id, true, true, false, true, true, true); } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access'); } break; case 'ASSIGN': $f_assign = gpc_get_int('assign'); $t_assign_status = bug_get_status_for_assign($t_bug->handler_id, $f_assign, $t_status); # check that new handler has rights to handle the issue, and # that current user has rights to assign the issue $t_threshold = access_get_status_threshold($t_assign_status, $t_bug->project_id); if (access_has_bug_level(config_get('update_bug_assign_threshold', config_get('update_bug_threshold')), $t_bug_id)) { if (access_has_bug_level(config_get('handle_bug_threshold'), $t_bug_id, $f_assign)) { if (bug_check_workflow($t_status, $t_assign_status)) { # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); bug_assign($t_bug_id, $f_assign, $f_bug_notetext, $f_bug_noteprivate); helper_call_custom_function('issue_update_notify', array($t_bug_id)); } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_status'); } } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_handler'); }
/** * Insert a new bug into the database * @return integer integer representing the bug identifier that was created * @access public * @uses database_api.php * @uses lang_api.php */ function create() { self::validate(true); antispam_check(); # check due_date format if (is_blank($this->due_date)) { $this->due_date = date_get_null(); } # check date submitted and last modified if (is_blank($this->date_submitted)) { $this->date_submitted = db_now(); } if (is_blank($this->last_updated)) { $this->last_updated = db_now(); } # Insert text information db_param_push(); $t_query = 'INSERT INTO {bug_text} ( description, steps_to_reproduce, additional_information ) VALUES ( ' . db_param() . ',' . db_param() . ',' . db_param() . ')'; db_query($t_query, array($this->description, $this->steps_to_reproduce, $this->additional_information)); # Get the id of the text information we just inserted # NOTE: this is guaranteed to be the correct one. # The value LAST_INSERT_ID is stored on a per connection basis. $t_text_id = db_insert_id(db_get_table('bug_text')); # check to see if we want to assign this right off $t_starting_status = config_get('bug_submit_status'); $t_original_status = $this->status; # if not assigned, check if it should auto-assigned. if (0 == $this->handler_id) { # if a default user is associated with the category and we know at this point # that that the bug was not assigned to somebody, then assign it automatically. db_param_push(); $t_query = 'SELECT user_id FROM {category} WHERE id=' . db_param(); $t_result = db_query($t_query, array($this->category_id)); $t_handler = db_result($t_result); if ($t_handler !== false && user_exists($t_handler)) { $this->handler_id = $t_handler; } } # Check if bug was pre-assigned or auto-assigned. $t_status = bug_get_status_for_assign(NO_USER, $this->handler_id, $this->status); # Insert the rest of the data db_param_push(); $t_query = 'INSERT INTO {bug} ( project_id,reporter_id, handler_id,duplicate_id, priority,severity, reproducibility,status, resolution,projection, category_id,date_submitted, last_updated,eta, bug_text_id, os, os_build,platform, version,build, profile_id, summary, view_state, sponsorship_total, sticky, fixed_in_version, target_version, due_date ) VALUES ( ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ', ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ', ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ', ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ', ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ', ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ', ' . db_param() . ',' . db_param() . ',' . db_param() . ',' . db_param() . ')'; db_query($t_query, array($this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $t_status, $this->resolution, $this->projection, $this->category_id, $this->date_submitted, $this->last_updated, $this->eta, $t_text_id, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->profile_id, $this->summary, $this->view_state, $this->sponsorship_total, $this->sticky, $this->fixed_in_version, $this->target_version, $this->due_date)); $this->id = db_insert_id(db_get_table('bug')); # log new bug history_log_event_special($this->id, NEW_BUG); # log changes, if any (compare happens in history_log_event_direct) history_log_event_direct($this->id, 'status', $t_original_status, $t_status); history_log_event_direct($this->id, 'handler_id', 0, $this->handler_id); return $this->id; }