/** * gets Unix timestamp from date string * @param string $p_date A valid date/time string (see http://php.net/manual/en/datetime.formats.php) * @return false|int a timestamp on success, null date when $p_date is blank or false on failure. * @access public */ function date_strtotime($p_date) { if (is_blank($p_date)) { return date_get_null(); } return strtotime($p_date); }
/** * @param string $name * @param string $value * @private */ public function __set($name, $value) { switch ($name) { case 'date_order': if( !is_numeric($value) ) { if( $value == '' ) { $value = date_get_null(); } else { $value = strtotime( $value ); if ( $value === false ) { trigger_error( ERROR_INVALID_DATE_FORMAT, ERROR ); } } } } $this->$name = $value; }
$f_target_version = gpc_get_string('target_version', ''); $f_profile_id = gpc_get_int('profile_id', 0); $f_handler_id = gpc_get_int('handler_id', 0); $f_category_id = gpc_get_int('category_id', 0); $f_reproducibility = gpc_get_int('reproducibility', (int) config_get('default_bug_reproducibility')); $f_eta = gpc_get_int('eta', (int) config_get('default_bug_eta')); $f_severity = gpc_get_int('severity', (int) config_get('default_bug_severity')); $f_priority = gpc_get_int('priority', (int) config_get('default_bug_priority')); $f_summary = gpc_get_string('summary', ''); $f_description = gpc_get_string('description', ''); $f_steps_to_reproduce = gpc_get_string('steps_to_reproduce', config_get('default_bug_steps_to_reproduce')); $f_additional_info = gpc_get_string('additional_info', config_get('default_bug_additional_info')); $f_view_state = gpc_get_int('view_state', (int) config_get('default_bug_view_status')); $f_due_date = gpc_get_string('due_date', ''); if ($f_due_date == '') { $f_due_date = date_get_null(); } $t_changed_project = false; } $f_report_stay = gpc_get_bool('report_stay', false); $f_copy_notes_from_parent = gpc_get_bool('copy_notes_from_parent', false); $f_copy_attachments_from_parent = gpc_get_bool('copy_attachments_from_parent', false); $t_fields = config_get('bug_report_page_fields'); $t_fields = columns_filter_disabled($t_fields); $t_show_category = in_array('category_id', $t_fields); $t_show_reproducibility = in_array('reproducibility', $t_fields); $t_show_eta = in_array('eta', $t_fields); $t_show_severity = in_array('severity', $t_fields); $t_show_priority = in_array('priority', $t_fields); $t_show_steps_to_reproduce = in_array('steps_to_reproduce', $t_fields); $t_show_handler = in_array('handler', $t_fields) && access_has_project_level(config_get('update_bug_assign_threshold'));
/** * checks if date is null * @param int $p_date * @return bool * @access public */ function date_is_null($p_date) { return $p_date == date_get_null(); }
$t_bug_data->view_state = gpc_get_int('view_state', config_get('default_bug_view_status')); $t_bug_data->category_id = gpc_get_int('category_id', 0); $t_bug_data->reproducibility = gpc_get_int('reproducibility', config_get('default_bug_reproducibility')); $t_bug_data->severity = gpc_get_int('severity', config_get('default_bug_severity')); $t_bug_data->priority = gpc_get_int('priority', config_get('default_bug_priority')); $t_bug_data->projection = gpc_get_int('projection', config_get('default_bug_projection')); $t_bug_data->eta = gpc_get_int('eta', config_get('default_bug_eta')); $t_bug_data->resolution = gpc_get_string('resolution', config_get('default_bug_resolution')); $t_bug_data->status = gpc_get_string('status', config_get('bug_submit_status')); $t_bug_data->summary = trim(gpc_get_string('summary')); $t_bug_data->description = gpc_get_string('description'); $t_bug_data->steps_to_reproduce = gpc_get_string('steps_to_reproduce', config_get('default_bug_steps_to_reproduce')); $t_bug_data->additional_information = gpc_get_string('additional_info', config_get('default_bug_additional_info')); $t_bug_data->due_date = gpc_get_string('due_date', ''); if (is_blank($t_bug_data->due_date)) { $t_bug_data->due_date = date_get_null(); } $f_files = gpc_get_file('ufile', null); /** @todo (thraxisp) Note that this always returns a structure */ $f_report_stay = gpc_get_bool('report_stay', false); $f_copy_notes_from_parent = gpc_get_bool('copy_notes_from_parent', false); $f_copy_attachments_from_parent = gpc_get_bool('copy_attachments_from_parent', false); if (access_has_project_level(config_get('roadmap_update_threshold'), $t_bug_data->project_id)) { $t_bug_data->target_version = gpc_get_string('target_version', ''); } # if a profile was selected then let's use that information if (0 != $t_bug_data->profile_id) { if (profile_is_global($t_bug_data->profile_id)) { $row = user_get_profile_row(ALL_USERS, $t_bug_data->profile_id); } else { $row = user_get_profile_row($t_bug_data->reporter_id, $t_bug_data->profile_id);
/** * Update Issue in database * * Created By KGB * @param string $p_username The name of the user trying to add the issue. * @param string $p_password The password of the user. * @param integer $p_issue_id The issue id of the existing issue being updated. * @param stdClass $p_issue A IssueData structure containing information about the new issue. * @return integer The id of the created issue. */ function mc_issue_update($p_username, $p_password, $p_issue_id, stdClass $p_issue) { global $g_project_override; $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!bug_exists($p_issue_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Issue \'' . $p_issue_id . '\' does not exist.'); } if (bug_is_readonly($p_issue_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Issue \'' . $p_issue_id . '\' is readonly'); } $t_project_id = bug_get_field($p_issue_id, 'project_id'); if (!mci_has_readwrite_access($t_user_id, $t_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $g_project_override = $t_project_id; # ensure that helper_get_current_project() calls resolve to this project id $p_issue = SoapObjectsFactory::unwrapObject($p_issue); $t_project_id = mci_get_project_id($p_issue['project']); $t_reporter_id = isset($p_issue['reporter']) ? mci_get_user_id($p_issue['reporter']) : $t_user_id; $t_handler_id = isset($p_issue['handler']) ? mci_get_user_id($p_issue['handler']) : 0; $t_project = $p_issue['project']; $t_summary = isset($p_issue['summary']) ? $p_issue['summary'] : ''; $t_description = isset($p_issue['description']) ? $p_issue['description'] : ''; if ($t_project_id == 0 || !project_exists($t_project_id)) { if ($t_project_id == 0) { return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $t_project['name'] . '\' does not exist.'); } return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $t_project_id . '\' does not exist.'); } if (!access_has_bug_level(config_get('update_bug_threshold'), $p_issue_id, $t_user_id)) { return mci_soap_fault_access_denied($t_user_id, 'Not enough rights to update issues'); } $t_category = isset($p_issue['category']) ? $p_issue['category'] : null; $t_category_id = translate_category_name_to_id($t_category, $t_project_id); if ($t_category_id == 0 && !config_get('allow_no_category')) { if (isset($p_issue['category']) && !is_blank($p_issue['category'])) { return SoapObjectsFactory::newSoapFault('Client', 'Category field must be supplied.'); } else { $t_project_name = project_get_name($t_project_id); return SoapObjectsFactory::newSoapFault('Client', 'Category \'' . $p_issue['category'] . '\' not found for project \'' . $t_project_name . '\'.'); } } if (isset($p_issue['version']) && !is_blank($p_issue['version']) && !version_get_id($p_issue['version'], $t_project_id)) { $t_error_when_version_not_found = config_get('webservice_error_when_version_not_found'); if ($t_error_when_version_not_found == ON) { $t_project_name = project_get_name($t_project_id); return SoapObjectsFactory::newSoapFault('Client', 'Version \'' . $p_issue['version'] . '\' does not exist in project \'' . $t_project_name . '\'.'); } else { $t_version_when_not_found = config_get('webservice_version_when_not_found'); $p_issue['version'] = $t_version_when_not_found; } } if (is_blank($t_summary)) { return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field \'summary\' is missing.'); } if (is_blank($t_description)) { return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field \'description\' is missing.'); } # fields which we expect to always be set $t_bug_data = bug_get($p_issue_id, true); $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $t_reporter_id; $t_access_check_result = mci_issue_handler_access_check($t_user_id, $t_project_id, $t_bug_data->handler_id, $t_handler_id); if ($t_access_check_result !== true) { return $t_access_check_result; } $t_bug_data->handler_id = $t_handler_id; $t_bug_data->category_id = $t_category_id; $t_bug_data->summary = $t_summary; $t_bug_data->description = $t_description; # fields which might not be set if (isset($p_issue['steps_to_reproduce'])) { $t_bug_data->steps_to_reproduce = $p_issue['steps_to_reproduce']; } if (isset($p_issue['additional_information'])) { $t_bug_data->additional_information = $p_issue['additional_information']; } if (isset($p_issue['priority'])) { $t_bug_data->priority = mci_get_priority_id($p_issue['priority']); } if (isset($p_issue['severity'])) { $t_bug_data->severity = mci_get_severity_id($p_issue['severity']); } if (isset($p_issue['status'])) { $t_bug_data->status = mci_get_status_id($p_issue['status']); } if (isset($p_issue['reproducibility'])) { $t_bug_data->reproducibility = mci_get_reproducibility_id($p_issue['reproducibility']); } if (isset($p_issue['resolution'])) { $t_bug_data->resolution = mci_get_resolution_id($p_issue['resolution']); } if (isset($p_issue['projection'])) { $t_bug_data->projection = mci_get_projection_id($p_issue['projection']); } if (isset($p_issue['eta'])) { $t_bug_data->eta = mci_get_eta_id($p_issue['eta']); } if (isset($p_issue['view_state'])) { $t_bug_data->view_state = mci_get_view_state_id($p_issue['view_state']); } if (isset($p_issue['date_submitted'])) { $t_bug_data->date_submitted = $p_issue['date_submitted']; } if (isset($p_issue['date_updated'])) { $t_bug_data->last_updated = $p_issue['last_updated']; } if (isset($p_issue['profile_id'])) { $t_bug_data->profile_id = $p_issue['profile_id']; } if (isset($p_issue['os'])) { $t_bug_data->os = $p_issue['os']; } if (isset($p_issue['os_build'])) { $t_bug_data->os_build = $p_issue['os_build']; } if (isset($p_issue['build'])) { $t_bug_data->build = $p_issue['build']; } if (isset($p_issue['platform'])) { $t_bug_data->platform = $p_issue['platform']; } if (isset($p_issue['version'])) { $t_bug_data->version = $p_issue['version']; } if (isset($p_issue['fixed_in_version'])) { $t_bug_data->fixed_in_version = $p_issue['fixed_in_version']; } if (isset($p_issue['sticky']) && access_has_bug_level(config_get('set_bug_sticky_threshold'), $t_bug_data->id)) { $t_bug_data->sticky = $p_issue['sticky']; } if (isset($p_issue['due_date']) && access_has_global_level(config_get('due_date_update_threshold'))) { $t_bug_data->due_date = SoapObjectsFactory::parseDateTimeString($p_issue['due_date']); } else { $t_bug_data->due_date = date_get_null(); } if (access_has_project_level(config_get('roadmap_update_threshold'), $t_bug_data->project_id, $t_user_id)) { $t_bug_data->target_version = isset($p_issue['target_version']) ? $p_issue['target_version'] : ''; } $t_set_custom_field_error = mci_issue_set_custom_fields($p_issue_id, $p_issue['custom_fields'], true); if ($t_set_custom_field_error != null) { return $t_set_custom_field_error; } if (isset($p_issue['monitors'])) { mci_issue_set_monitors($p_issue_id, $t_user_id, $p_issue['monitors']); } if (isset($p_issue['notes']) && is_array($p_issue['notes'])) { $t_bugnotes = bugnote_get_all_visible_bugnotes($p_issue_id, 'DESC', 0); $t_bugnotes_by_id = array(); foreach ($t_bugnotes as $t_bugnote) { $t_bugnotes_by_id[$t_bugnote->id] = $t_bugnote; } foreach ($p_issue['notes'] as $t_note) { $t_note = SoapObjectsFactory::unwrapObject($t_note); if (isset($t_note['view_state'])) { $t_view_state = $t_note['view_state']; } else { $t_view_state = config_get('default_bugnote_view_status'); } if (isset($t_note['id']) && (int) $t_note['id'] > 0) { $t_bugnote_id = (int) $t_note['id']; $t_view_state_id = mci_get_enum_id_from_objectref('view_state', $t_view_state); if (array_key_exists($t_bugnote_id, $t_bugnotes_by_id)) { $t_bugnote_changed = false; if ($t_bugnote->note !== $t_note['text']) { bugnote_set_text($t_bugnote_id, $t_note['text']); $t_bugnote_changed = true; } if ($t_bugnote->view_state != $t_view_state_id) { bugnote_set_view_state($t_bugnote_id, $t_view_state_id == VS_PRIVATE); $t_bugnote_changed = true; } if (isset($t_note['time_tracking']) && $t_note['time_tracking'] != $t_bugnote->time_tracking) { bugnote_set_time_tracking($t_bugnote_id, mci_get_time_tracking_from_note($p_issue_id, $t_note)); $t_bugnote_changed = true; } if ($t_bugnote_changed) { bugnote_date_update($t_bugnote_id); } } } else { $t_view_state_id = mci_get_enum_id_from_objectref('view_state', $t_view_state); $t_note_type = isset($t_note['note_type']) ? (int) $t_note['note_type'] : BUGNOTE; $t_note_attr = isset($t_note['note_type']) ? $t_note['note_attr'] : ''; bugnote_add($p_issue_id, $t_note['text'], mci_get_time_tracking_from_note($p_issue_id, $t_note), $t_view_state_id == VS_PRIVATE, $t_note_type, $t_note_attr, $t_user_id, false); } } # The issue has been cached earlier in the bug_get() call. Flush the cache since it is # now stale. Otherwise, the email notification will be based on the cached data. bugnote_clear_cache($p_issue_id); } if (isset($p_issue['tags']) && is_array($p_issue['tags'])) { mci_tag_set_for_issue($p_issue_id, $p_issue['tags'], $t_user_id); } # submit the issue log_event(LOG_WEBSERVICE, 'updating issue \'' . $p_issue_id . '\''); return $t_bug_data->update(true, true); }
/** * 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; }
/** * Update Issue in database * * Created By KGB * @param string $p_username The name of the user trying to add the issue. * @param string $p_password The password of the user. * @param Array $p_issue A IssueData structure containing information about the new issue. * @return integer The id of the created issue. */ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) { global $g_project_override; $t_user_id = mci_check_login( $p_username, $p_password ); if( $t_user_id === false ) { return mci_soap_fault_login_failed(); } if( !bug_exists( $p_issue_id ) ) { return new soap_fault( 'Client', '', "Issue '$p_issue_id' does not exist." ); } $t_project_id = bug_get_field( $p_issue_id, 'project_id' ); if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) { return mci_soap_fault_access_denied( $t_user_id ); } $g_project_override = $t_project_id; // ensure that helper_get_current_project() calls resolve to this project id $t_project_id = mci_get_project_id( $p_issue['project'] ); $t_reporter_id = isset( $p_issue['reporter'] ) ? mci_get_user_id( $p_issue['reporter'] ) : $t_user_id ; $t_handler_id = isset( $p_issue['handler'] ) ? mci_get_user_id( $p_issue['handler'] ) : 0; $t_project = $p_issue['project']; $t_summary = isset( $p_issue['summary'] ) ? $p_issue['summary'] : ''; $t_description = isset( $p_issue['description'] ) ? $p_issue['description'] : ''; if(( $t_project_id == 0 ) || !project_exists( $t_project_id ) ) { if( $t_project_id == 0 ) { return new soap_fault( 'Client', '', "Project '" . $t_project['name'] . "' does not exist." ); } return new soap_fault( 'Client', '', "Project '$t_project_id' does not exist." ); } if( !access_has_bug_level( config_get( 'update_bug_threshold' ), $p_issue_id, $t_user_id ) ) { return mci_soap_fault_access_denied( $t_user_id, "Not enough rights to update issues" ); } if(( $t_handler_id != 0 ) && !user_exists( $t_handler_id ) ) { return new soap_fault( 'Client', '', "User '$t_handler_id' does not exist." ); } $t_category = isset ( $p_issue['category'] ) ? $p_issue['category'] : null; $t_category_id = translate_category_name_to_id( $t_category, $t_project_id ); if ( $t_category_id == 0 && !config_get( 'allow_no_category' ) ) { if ( isset( $p_issue['category'] ) && !is_blank( $p_issue['category'] ) ) { return new soap_fault( 'Client', '', "Category field must be supplied." ); } else { return new soap_fault( 'Client', '', "Category '" . $p_issue['category'] . "' not found for project '$t_project_name'." ); } } if ( isset( $p_issue['version'] ) && !is_blank( $p_issue['version'] ) && !version_get_id( $p_issue['version'], $t_project_id ) ) { $t_error_when_version_not_found = config_get( 'mc_error_when_version_not_found' ); if( $t_error_when_version_not_found == ON ) { $t_project_name = project_get_name( $t_project_id ); return new soap_fault( 'Client', '', "Version '" . $p_issue['version'] . "' does not exist in project '$t_project_name'." ); } else { $t_version_when_not_found = config_get( 'mc_version_when_not_found' ); $p_issue['version'] = $t_version_when_not_found; } } if ( is_blank( $t_summary ) ) { return new soap_fault( 'Client', '', "Mandatory field 'summary' is missing." ); } if ( is_blank( $t_description ) ) { return new soap_fault( 'Client', '', "Mandatory field 'description' is missing." ); } // fields which we expect to always be set $t_bug_data = bug_get( $p_issue_id, true ); $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $t_reporter_id; $t_bug_data->handler_id = $t_handler_id; $t_bug_data->category_id = $t_category_id; $t_bug_data->summary = $t_summary; $t_bug_data->description = $t_description; // fields which might not be set if ( isset ( $p_issue['steps_to_reproduce'] ) ) $t_bug_data->steps_to_reproduce = $p_issue['steps_to_reproduce']; if ( isset ( $p_issue['additional_information'] ) ) $t_bug_data->additional_information = $p_issue['additional_information']; if ( isset( $p_issue['priority'] ) ) $t_bug_data->priority = mci_get_priority_id( $p_issue['priority'] ); if ( isset( $p_issue['severity'] ) ) $t_bug_data->severity = mci_get_severity_id( $p_issue['severity'] ); if ( isset( $p_issue['status'] ) ) $t_bug_data->status = mci_get_status_id ( $p_issue['status'] ); if ( isset ( $p_issue['reproducibility'] ) ) $t_bug_data->reproducibility = mci_get_reproducibility_id( $p_issue['reproducibility'] ); if ( isset ( $p_issue['resolution'] ) ) $t_bug_data->resolution = mci_get_resolution_id( $p_issue['resolution'] ); if ( isset ( $p_issue['projection'] ) ) $t_bug_data->projection = mci_get_projection_id( $p_issue['projection'] ); if ( isset ( $p_issue['eta'] ) ) $t_bug_data->eta = mci_get_eta_id( $p_issue['eta'] ); if ( isset ( $p_issue['view_state'] ) ) $t_bug_data->view_state = mci_get_view_state_id( $p_issue['view_state'] ); if ( isset ( $p_issue['date_submitted'] ) ) $t_bug_data->date_submitted = $p_issue['date_submitted']; if ( isset ( $p_issue['date_updated'] ) ) $t_bug_data->last_updated = $p_issue['last_updated']; if ( isset ( $p_issue['os'] ) ) $t_bug_data->os = $p_issue['os']; if ( isset ( $p_issue['os_build'] ) ) $t_bug_data->os_build = $p_issue['os_build']; if ( isset ( $p_issue['build'] ) ) $t_bug_data->build = $p_issue['build']; if ( isset ( $p_issue['platform'] ) ) $t_bug_data->platform = $p_issue['platform']; if ( isset ( $p_issue['version'] ) ) $t_bug_data->version = $p_issue['version']; if ( isset ( $p_issue['fixed_in_version'] ) ) $t_bug_data->fixed_in_version = $p_issue['fixed_in_version']; if ( isset( $p_issue['due_date'] ) && access_has_global_level( config_get( 'due_date_update_threshold' ) ) ) { $t_bug_data->due_date = mci_iso8601_to_timestamp( $p_issue['due_date'] ); } else { $t_bug_data->due_date = date_get_null(); } if( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id, $t_user_id ) ) { $t_bug_data->target_version = isset( $p_issue['target_version'] ) ? $p_issue['target_version'] : ''; } mci_issue_set_custom_fields( $p_issue_id, $p_issue['custom_fields'], true ); if ( isset ( $p_issue['monitors'] ) ) mci_issue_set_monitors( $p_issue_id , $t_user_id, $p_issue['monitors'] ); if ( isset( $p_issue['notes'] ) && is_array( $p_issue['notes'] ) ) { foreach ( $p_issue['notes'] as $t_note ) { if ( isset( $t_note['view_state'] ) ) { $t_view_state = $t_note['view_state']; } else { $t_view_state = config_get( 'default_bugnote_view_status' ); } if ( isset( $t_note['id'] ) && ( (int)$t_note['id'] > 0 ) ) { $t_bugnote_id = (integer)$t_note['id']; $t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state ); if ( bugnote_exists( $t_bugnote_id ) ) { bugnote_set_text( $t_bugnote_id, $t_note['text'] ); bugnote_set_view_state( $t_bugnote_id, $t_view_state_id == VS_PRIVATE ); bugnote_date_update( $t_bugnote_id ); if ( isset( $t_note['time_tracking'] ) ) bugnote_set_time_tracking( $t_bugnote_id, mci_get_time_tracking_from_note( $p_issue_id, $t_note ) ); } } else { $t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state ); $note_type = isset ( $t_note['note_type'] ) ? (int) $t_note['note_type'] : BUGNOTE; $note_attr = isset ( $t_note['note_type'] ) ? $t_note['note_attr'] : ''; bugnote_add( $p_issue_id, $t_note['text'], mci_get_time_tracking_from_note( $p_issue_id, $t_note ), $t_view_state_id == VS_PRIVATE, $note_type, $note_attr, $t_user_id, FALSE ); } } } # submit the issue return $t_bug_data->update( /* update_extended */ true, /* bypass_email */ true ); }
private function add_bug(&$p_email, $p_overwrite_project_id = FALSE) { $this->show_memory_usage('Start add bug'); //Merge References and In-Reply-To headers into one array $t_references = $p_email['References']; $t_references[] = $p_email['In-Reply-To']; if ($this->_mail_add_bugnotes) { $t_bug_id = $this->mail_is_a_bugnote($p_email['Subject'], $t_references); } else { $t_bug_id = FALSE; } if ($t_bug_id !== FALSE && !bug_is_readonly($t_bug_id)) { // @TODO@ Disabled for now until we find a good solution on how to handle the reporters possible lack of access permissions // access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $f_bug_id ); $t_description = $p_email['X-Mantis-Body']; $t_description = $this->identify_replies($t_description); $t_description = $this->strip_signature($t_description); $t_description = $this->add_additional_info('note', $p_email, $t_description); $t_project_id = bug_get_field($t_bug_id, 'project_id'); ERP_set_temporary_overwrite('project_override', $t_project_id); # Event integration # Core mantis event already exists within bugnote_add function $t_description = event_signal('EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id); if (bug_is_resolved($t_bug_id)) { # Reopen issue and add a bug note bug_reopen($t_bug_id, $t_description); } elseif (!is_blank($t_description)) { # Add a bug note bugnote_add($t_bug_id, $t_description); } } elseif ($this->_mail_add_bug_reports) { // @TODO@ Disabled for now until we find a good solution on how to handle the reporters possible lack of access permissions // access_ensure_project_level( config_get('report_bug_threshold' ) ); $f_master_bug_id = $t_bug_id !== FALSE && bug_is_readonly($t_bug_id) ? $t_bug_id : 0; $this->fix_empty_fields($p_email); $t_project_id = $p_overwrite_project_id === FALSE ? $this->_mailbox['project_id'] : $p_overwrite_project_id; ERP_set_temporary_overwrite('project_override', $t_project_id); $t_bug_data = new BugData(); $t_bug_data->build = ''; $t_bug_data->platform = ''; $t_bug_data->os = ''; $t_bug_data->os_build = ''; $t_bug_data->version = ''; $t_bug_data->profile_id = 0; $t_bug_data->handler_id = 0; $t_bug_data->view_state = (int) config_get('default_bug_view_status'); $t_bug_data->category_id = (int) $this->_mailbox['global_category_id']; $t_bug_data->reproducibility = (int) config_get('default_bug_reproducibility'); $t_bug_data->severity = (int) config_get('default_bug_severity'); $t_bug_data->priority = (int) ($this->_mail_use_bug_priority ? $p_email['Priority'] : config_get('default_bug_priority')); $t_bug_data->projection = (int) config_get('default_bug_projection'); $t_bug_data->eta = (int) config_get('default_bug_eta'); $t_bug_data->resolution = config_get('default_bug_resolution'); $t_bug_data->status = config_get('bug_submit_status'); $t_bug_data->summary = $p_email['Subject']; $t_description = $p_email['X-Mantis-Body']; $t_description = $this->strip_signature($t_description); $t_description = $this->add_additional_info('issue', $p_email, $t_description); $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = config_get('default_bug_steps_to_reproduce'); $t_bug_data->additional_information = config_get('default_bug_additional_info'); $t_bug_data->due_date = date_get_null(); $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $p_email['Reporter_id']; // This function might do stuff that EmailReporting cannot handle. Disabled //helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); // @TODO@ Disabled for now but possibly needed for other future features # Validate the custom fields before adding the bug. /* $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); foreach( $t_related_custom_field_ids as $t_id ) { $t_def = custom_field_get_definition( $t_id ); # Produce an error if the field is required but wasn't posted if ( !gpc_isset_custom_field( $t_id, $t_def['type'] ) && ( $t_def['require_report'] || $t_def['type'] == CUSTOM_FIELD_TYPE_ENUM || $t_def['type'] == CUSTOM_FIELD_TYPE_LIST || $t_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST || $t_def['type'] == CUSTOM_FIELD_TYPE_RADIO ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_EMPTY_FIELD, ERROR ); } if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL ) ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); } }*/ # Allow plugins to pre-process bug data $t_bug_data = event_signal('EVENT_REPORT_BUG_DATA', $t_bug_data); $t_bug_data = event_signal('EVENT_ERP_REPORT_BUG_DATA', $t_bug_data); # Create the bug $t_bug_id = $t_bug_data->create(); // @TODO@ Disabled for now but possibly needed for other future features # Handle custom field submission /* foreach( $t_related_custom_field_ids as $t_id ) { # Do not set custom field value if user has no write access. if( !custom_field_has_write_access( $t_id, $t_bug_id ) ) { continue; } $t_def = custom_field_get_definition( $t_id ); if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ), false ) ) { { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); } }*/ // Lets link a readonly already existing bug to the newly created one if ($f_master_bug_id > 0) { $f_rel_type = BUG_RELATED; # update master bug last updated bug_update_date($f_master_bug_id); # Add the relationship relationship_add($t_bug_id, $f_master_bug_id, $f_rel_type); # Add log line to the history (both issues) history_log_event_special($f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $t_bug_id); history_log_event_special($t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id); # Send the email notification email_relationship_added($f_master_bug_id, $t_bug_id, relationship_get_complementary_type($f_rel_type)); } helper_call_custom_function('issue_create_notify', array($t_bug_id)); # Allow plugins to post-process bug data with the new bug ID event_signal('EVENT_REPORT_BUG', array($t_bug_data, $t_bug_id)); email_new_bug($t_bug_id); } else { // Not allowed to add issues and not allowed / able to add notes. Need to stop processing $this->custom_error('Not allowed to create a new issue. Email ignored'); return; } $this->custom_error('Reporter: ' . $p_email['Reporter_id'] . ' - ' . $p_email['From_parsed']['email'] . ' --> Issue ID: #' . $t_bug_id, FALSE); $this->show_memory_usage('Finished add bug'); $this->show_memory_usage('Start processing attachments'); # Add files if ($this->_allow_file_upload) { if (count($p_email['X-Mantis-Parts']) > 0) { $t_rejected_files = NULL; while ($t_part = array_shift($p_email['X-Mantis-Parts'])) { $t_file_rejected = $this->add_file($t_bug_id, $t_part); if ($t_file_rejected !== TRUE) { $t_rejected_files .= $t_file_rejected; } } if ($t_rejected_files !== NULL) { $t_part = array('name' => 'Rejected files.txt', 'ctype' => 'text/plain', 'body' => 'List of rejected files' . "\n\n" . $t_rejected_files); $t_reject_rejected_files = $this->add_file($t_bug_id, $t_part); if ($t_reject_rejected_files !== TRUE) { $t_part['body'] .= $t_reject_rejected_files; $this->custom_error('Failed to add "' . $t_part['name'] . '" to the issue. See below for all errors.' . "\n" . $t_part['body']); } } } } //Add the users in Cc and To list in mail header $this->add_monitors($t_bug_id, $p_email); //Add the message-id to the database $this->add_msg_id($t_bug_id, $p_email['Message-ID']); ERP_set_temporary_overwrite('project_override', NULL); $this->show_memory_usage('Finished processing attachments'); }
function save_bug($p_project_id, $p_user_id) { require 'ProfileAcraExt.php'; $t_project_id = $p_project_id; global $g_cache_current_user_id; $g_cache_current_user_id = $p_user_id; $t_bug_data = new BugData(); $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $p_user_id; $t_bug_data->build = gpc_get_string('APP_VERSION_CODE', ''); $t_bug_data->platform = "Android"; $t_bug_data->os = gpc_get_string('ANDROID_VERSION', ''); //gpc_get_string( 'os', '' ); $t_os_build = gpc_get_string('BUILD', ''); if (preg_match('/DISPLAY\\s*=\\s*(.*)/', $t_os_build, $t_match)) { var_dump($t_match); $t_os_build = $t_match[1]; } else { $t_os_build = gpc_get_string('ANDROID_VERSION', ''); } $t_bug_data->os_build = $t_os_build; //gpc_get_string( 'os_build', '' ); $t_bug_data->version = gpc_get_string('APP_VERSION_NAME', ''); $t_bug_data->profile_id = profile_create_unique(ALL_USERS, $t_bug_data->platform, $t_bug_data->os, $t_bug_data->os_build, ""); $t_bug_data->handler_id = gpc_get_int('handler_id', 0); $t_bug_data->view_state = gpc_get_int('view_state', config_get('default_bug_view_status', 'VS_PRIVATE', 'acra_reporter')); $t_bug_data->category_id = $this->get_category_id($p_project_id); //gpc_get_int( 'category_id', 0 ); $t_bug_data->reproducibility = 10; //gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) ); $t_bug_data->severity = CRASH; //gpc_get_int( 'severity', config_get( 'default_bug_severity' ) ); $t_bug_data->priority = HIGH; //gpc_get_int( 'priority', config_get( 'default_bug_priority' ) ); $t_bug_data->projection = gpc_get_int('projection', config_get('default_bug_projection')); $t_bug_data->eta = gpc_get_int('eta', config_get('default_bug_eta')); $t_bug_data->resolution = OPEN; //gpc_get_string('resolution', config_get( 'default_bug_resolution' ) ); $t_bug_data->status = NEW_; //gpc_get_string( 'status', config_get( 'bug_submit_status' ) ); $t_bug_data->description = gpc_get_string('STACK_TRACE'); //gpc_get_string( 'description' ); $t_bug_data->summary = get_bug_summary_by_version(gpc_get_string('APP_VERSION_NAME', ''), $t_bug_data->description, $t_project_id); $t_bug_data->steps_to_reproduce = gpc_get_string('LOGCAT', ""); $t_bug_data->additional_information = gpc_get_string('CRASH_CONFIGURATION', ""); $t_bug_data->due_date = gpc_get_string('USER_CRASH_DATE', ''); if (is_blank($t_bug_data->due_date)) { $t_bug_data->due_date = date_get_null(); } $f_files = gpc_get_file('ufile', null); /** @todo (thraxisp) Note that this always returns a structure */ $f_report_stay = gpc_get_bool('report_stay', false); $f_copy_notes_from_parent = gpc_get_bool('copy_notes_from_parent', false); helper_call_custom_function('issue_create_validate', array($t_bug_data)); # Validate the custom fields before adding the bug. $t_related_custom_field_ids = custom_field_get_linked_ids($t_bug_data->project_id); foreach ($t_related_custom_field_ids as $t_id) { $t_def = custom_field_get_definition($t_id); # Produce an error if the field is required but wasn't posted if (!gpc_isset_custom_field($t_id, $t_def['type']) && $t_def['require_report']) { error_parameters(lang_get_defaulted(custom_field_get_field($t_id, 'name'))); trigger_error(ERROR_EMPTY_FIELD, ERROR); } if (!custom_field_validate($t_id, gpc_get_custom_field("custom_field_{$t_id}", $t_def['type'], NULL))) { error_parameters(lang_get_defaulted(custom_field_get_field($t_id, 'name'))); trigger_error(ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR); } } # Allow plugins to pre-process bug data $t_bug_data = event_signal('EVENT_REPORT_BUG_DATA', $t_bug_data); # Ensure that resolved bugs have a handler if ($t_bug_data->handler_id == NO_USER && $t_bug_data->status >= config_get('bug_resolved_status_threshold')) { $t_bug_data->handler_id = $this->get_user_id(); } # Create the bug $t_bug_id = $t_bug_data->create(); # Mark the added issue as visited so that it appears on the last visited list. last_visited_issue($t_bug_id); # Handle the file upload if ($f_files != null) { $t_files = helper_array_transpose($f_files); if ($t_files != null) { foreach ($t_files as $t_file) { if (!empty($t_file['name'])) { file_add($t_bug_id, $t_file, 'bug'); } } } } # Handle custom field submission foreach ($t_related_custom_field_ids as $t_id) { # Do not set custom field value if user has no write access if (!custom_field_has_write_access($t_id, $t_bug_id)) { continue; } $t_def = custom_field_get_definition($t_id); if (!custom_field_set_value($t_id, $t_bug_id, gpc_get_custom_field("custom_field_{$t_id}", $t_def['type'], $t_def['default_value']), false)) { error_parameters(lang_get_defaulted(custom_field_get_field($t_id, 'name'))); trigger_error(ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR); } } $f_master_bug_id = gpc_get_int('m_id', 0); $f_rel_type = gpc_get_int('rel_type', -1); if ($f_master_bug_id > 0) { # it's a child generation... let's create the relationship and add some lines in the history # update master bug last updated bug_update_date($f_master_bug_id); # Add log line to record the cloning action history_log_event_special($t_bug_id, BUG_CREATED_FROM, '', $f_master_bug_id); history_log_event_special($f_master_bug_id, BUG_CLONED_TO, '', $t_bug_id); if ($f_rel_type >= 0) { # Add the relationship relationship_add($t_bug_id, $f_master_bug_id, $f_rel_type); # Add log line to the history (both issues) history_log_event_special($f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $t_bug_id); history_log_event_special($t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id); # update relationship target bug last updated bug_update_date($t_bug_id); # Send the email notification email_relationship_added($f_master_bug_id, $t_bug_id, relationship_get_complementary_type($f_rel_type)); } # copy notes from parent if ($f_copy_notes_from_parent) { $t_parent_bugnotes = bugnote_get_all_bugnotes($f_master_bug_id); foreach ($t_parent_bugnotes as $t_parent_bugnote) { $t_private = $t_parent_bugnote->view_state == VS_PRIVATE; bugnote_add($t_bug_id, $t_parent_bugnote->note, $t_parent_bugnote->time_tracking, $t_private, $t_parent_bugnote->note_type, $t_parent_bugnote->note_attr, $t_parent_bugnote->reporter_id, FALSE, FALSE); } } } helper_call_custom_function('issue_create_notify', array($t_bug_id)); # Allow plugins to post-process bug data with the new bug ID event_signal('EVENT_REPORT_BUG', array($t_bug_data, $t_bug_id)); email_new_bug($t_bug_id); // log status and resolution changes if they differ from the default if ($t_bug_data->status != config_get('bug_submit_status')) { history_log_event($t_bug_id, 'status', config_get('bug_submit_status')); } if ($t_bug_data->resolution != config_get('default_bug_resolution')) { history_log_event($t_bug_id, 'resolution', config_get('default_bug_resolution')); } return $t_bug_id; }
/** * Update Issue in database * * Created By KGB * @param string $p_username The name of the user trying to add the issue. * @param string $p_password The password of the user. * @param Array $p_issue A IssueData structure containing information about the new issue. * @return integer The id of the created issue. */ function mc_issue_update($p_username, $p_password, $p_issue_id, $p_issue) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!bug_exists($p_issue_id)) { return new soap_fault('Client', '', "Issue '{$p_issue_id}' does not exist."); } $t_project_id = bug_get_field($p_issue_id, 'project_id'); if (!mci_has_readwrite_access($t_user_id, $t_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_project_id = mci_get_project_id($p_issue['project']); $t_handler_id = isset($p_issue['handler']) ? mci_get_user_id($p_issue['handler']) : 0; $t_priority_id = isset($p_issue['priority']) ? mci_get_priority_id($p_issue['priority']) : config_get('default_bug_priority'); $t_severity_id = isset($p_issue['severity']) ? mci_get_severity_id($p_issue['severity']) : config_get('default_bug_severity'); $t_status_id = isset($p_issue['status']) ? mci_get_status_id($p_issue['status']) : config_get('bug_submit_status'); $t_reproducibility_id = isset($p_issue['reproducibility']) ? mci_get_reproducibility_id($p_issue['reproducibility']) : config_get('default_bug_reproducibility'); $t_resolution_id = isset($p_issue['resolution']) ? mci_get_resolution_id($p_issue['resolution']) : config_get('default_bug_resolution'); $t_projection_id = isset($p_issue['projection']) ? mci_get_projection_id($p_issue['projection']) : config_get('default_bug_resolution'); $t_eta_id = isset($p_issue['eta']) ? mci_get_eta_id($p_issue['eta']) : config_get('default_bug_eta'); $t_view_state_id = isset($p_issue['view_state']) ? mci_get_view_state_id($p_issue['view_state']) : config_get('default_bug_view_status'); $t_reporter_id = isset($p_issue['reporter']) ? mci_get_user_id($p_issue['reporter']) : 0; $t_project = $p_issue['project']; $t_summary = isset($p_issue['summary']) ? $p_issue['summary'] : ''; $t_description = isset($p_issue['description']) ? $p_issue['description'] : ''; $t_additional_information = isset($p_issue['additional_information']) ? $p_issue['additional_information'] : ''; $t_steps_to_reproduce = isset($p_issue['steps_to_reproduce']) ? $p_issue['steps_to_reproduce'] : ''; $t_build = isset($p_issue['build']) ? $p_issue['build'] : ''; $t_platform = isset($p_issue['platform']) ? $p_issue['platform'] : ''; $t_os = isset($p_issue['os']) ? $p_issue['os'] : ''; $t_os_build = isset($p_issue['os_build']) ? $p_issue['os_build'] : ''; $t_sponsorship_total = isset($p_issue['sponsorship_total']) ? $p_issue['sponsorship_total'] : 0; if ($t_reporter_id == 0) { $t_reporter_id = $t_user_id; } if ($t_project_id == 0 || !project_exists($t_project_id)) { if ($t_project_id == 0) { return new soap_fault('Client', '', "Project '" . $t_project['name'] . "' does not exist."); } return new soap_fault('Client', '', "Project '{$t_project_id}' does not exist."); } if (!access_has_bug_level(config_get('update_bug_threshold'), $p_issue_id, $t_user_id)) { return mci_soap_fault_access_denied($t_user_id, "Not enough rights to update issues"); } if ($t_handler_id != 0 && !user_exists($t_handler_id)) { return new soap_fault('Client', '', "User '{$t_handler_id}' does not exist."); } $t_category = isset($p_issue['category']) ? $p_issue['category'] : null; $t_category_id = translate_category_name_to_id($t_category, $t_project_id); if ($t_category_id == 0 && !config_get('allow_no_category')) { if (isset($p_issue['category']) && !is_blank($p_issue['category'])) { return new soap_fault('Client', '', "Category field must be supplied."); } else { return new soap_fault('Client', '', "Category '" . $p_issue['category'] . "' not found for project '{$t_project_name}'."); } } if (isset($p_issue['version']) && !is_blank($p_issue['version']) && !version_get_id($p_issue['version'], $t_project_id)) { $t_error_when_version_not_found = config_get('mc_error_when_version_not_found'); if ($t_error_when_version_not_found == ON) { $t_project_name = project_get_name($t_project_id); return new soap_fault('Client', '', "Version '" . $p_issue['version'] . "' does not exist in project '{$t_project_name}'."); } else { $t_version_when_not_found = config_get('mc_version_when_not_found'); $p_issue['version'] = $t_version_when_not_found; } } if (is_blank($t_summary)) { return new soap_fault('Client', '', "Mandatory field 'summary' is missing."); } if (is_blank($t_description)) { return new soap_fault('Client', '', "Mandatory field 'description' is missing."); } if ($t_priority_id == 0) { $t_priority_id = config_get('default_bug_priority'); } if ($t_severity_id == 0) { $t_severity_id = config_get('default_bug_severity'); } if ($t_view_state_id == 0) { $t_view_state_id = config_get('default_bug_view_status'); } if ($t_reproducibility_id == 0) { $t_reproducibility_id = config_get('default_bug_reproducibility'); } $t_bug_data = new BugData(); $t_bug_data->id = $p_issue_id; $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $t_reporter_id; $t_bug_data->handler_id = $t_handler_id; $t_bug_data->priority = $t_priority_id; $t_bug_data->severity = $t_severity_id; $t_bug_data->reproducibility = $t_reproducibility_id; $t_bug_data->status = $t_status_id; $t_bug_data->resolution = $t_resolution_id; $t_bug_data->projection = $t_projection_id; $t_bug_data->category_id = $t_category_id; $t_bug_data->date_submitted = isset($v_date_submitted) ? $v_date_submitted : ''; $t_bug_data->last_updated = isset($v_last_updated) ? $v_last_updated : ''; $t_bug_data->eta = $t_eta_id; $t_bug_data->os = $t_os; $t_bug_data->os_build = $t_os_build; $t_bug_data->platform = $t_platform; $t_bug_data->version = isset($p_issue['version']) ? $p_issue['version'] : ''; $t_bug_data->fixed_in_version = isset($p_issue['fixed_in_version']) ? $p_issue['fixed_in_version'] : ''; $t_bug_data->build = $t_build; $t_bug_data->view_state = $t_view_state_id; $t_bug_data->summary = $t_summary; $t_bug_data->sponsorship_total = $t_sponsorship_total; if (isset($p_issue['due_date']) && access_has_global_level(config_get('due_date_update_threshold'))) { $t_bug_data->due_date = mci_iso8601_to_timestamp($p_issue['due_date']); } else { $t_bug_data->due_date = date_get_null(); } if (access_has_project_level(config_get('roadmap_update_threshold'), $t_bug_data->project_id, $t_user_id)) { $t_bug_data->target_version = isset($p_issue['target_version']) ? $p_issue['target_version'] : ''; } # omitted: # var $bug_text_id # $t_bug_data->profile_id; # extended info $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = isset($t_steps_to_reproduce) ? $t_steps_to_reproduce : ''; $t_bug_data->additional_information = isset($t_additional_information) ? $t_additional_information : ''; # submit the issue $t_is_success = $t_bug_data->update(true, true); mci_issue_set_custom_fields($p_issue_id, $p_issue['custom_fields'], true); if (isset($p_issue['notes']) && is_array($p_issue['notes'])) { foreach ($p_issue['notes'] as $t_note) { if (isset($t_note['view_state'])) { $t_view_state = $t_note['view_state']; } else { $t_view_state = config_get('default_bugnote_view_status'); } if (isset($t_note['id']) && (int) $t_note['id'] > 0) { $t_bugnote_id = (int) $t_note['id']; if (bugnote_exists($t_bugnote_id)) { bugnote_set_text($t_bugnote_id, $t_note['text']); bugnote_set_view_state($t_bugnote_id, $t_view_state_id == VS_PRIVATE); bugnote_date_update($t_bugnote_id); if (isset($t_note['time_tracking'])) { bugnote_set_time_tracking($t_bugnote_id, mci_get_time_tracking_from_note($p_issue_id, $t_note)); } } } else { $t_view_state_id = mci_get_enum_id_from_objectref('view_state', $t_view_state); bugnote_add($p_issue_id, $t_note['text'], mci_get_time_tracking_from_note($p_issue_id, $t_note), $t_view_state_id == VS_PRIVATE, BUGNOTE, '', $t_user_id, FALSE); } } } return $t_is_success; }