public function get($request) { /* * Returns a Response with a representation of the note list. * * @param $request - The Request we're responding to */ $this->bug_id = BugnoteList::get_bug_id_from_url($request->url); # Access checking and note gathering is based on Mantis's # email_build_visible_bug_data(). $project_id = bug_get_field($this->bug_id, 'project_id'); $user_id = auth_get_current_user_id(); $access_level = user_get_access_level($user_id, $project_id); if (!access_has_bug_level(VIEWER, $this->bug_id)) { throw new HTTPException(403, "Access denied"); } $visible_notes = bugnote_get_all_visible_bugnotes($this->bug_id, $access_level, 'ASC', 0); $visible_note_ids = array(); foreach ($visible_notes as $n) { $visible_note_ids[] = (int) $n->id; } # Apply conditions and sorts $sql_to_add = $this->_build_sql_from_querystring($request->query); $note_ids = array(); if ($sql_to_add) { $mantis_bugnote_table = config_get('mantis_bugnote_table'); $query = "SELECT n.id FROM {$mantis_bugnote_table} n {$sql_to_add};"; $result = db_query($query); foreach ($result as $r) { if (in_array((int) $r[0], $visible_note_ids)) { $note_ids[] = (int) $r[0]; } } } else { $note_ids = $visible_note_ids; } $this->rsrc_data = array(); $this->rsrc_data['results'] = array(); foreach ($note_ids as $n) { $config = get_config(); $this->rsrc_data['results'][] = Bugnote::get_url_from_mantis_id($n); } $resp = new Response(); $resp->status = 200; $resp->body = $this->_repr($request); return $resp; }
require_api('lang_api.php'); require_api('prepare_api.php'); require_api('print_api.php'); require_api('string_api.php'); require_api('user_api.php'); # grab the user id currently logged in $t_user_id = auth_get_current_user_id(); #precache access levels if (isset($g_project_override)) { access_cache_matrix_project($g_project_override); } else { access_cache_matrix_project(helper_get_current_project()); } # get the bugnote data $t_bugnote_order = current_user_get_pref('bugnote_order'); $t_bugnotes = bugnote_get_all_visible_bugnotes($f_bug_id, $t_bugnote_order, 0, $t_user_id); #precache users $t_bugnote_users = array(); foreach ($t_bugnotes as $t_bugnote) { $t_bugnote_users[] = $t_bugnote->reporter_id; } user_cache_array_rows($t_bugnote_users); $num_notes = count($t_bugnotes); ?> <?php # Bugnotes BEGIN ?> <a id="bugnotes"></a><br /> <?php
/** * Build the bug raw data visible for specified user to be translated and sent by email to the user * (Filter the bug data according to user access level) * return array with bug data. See usage in email_format_bug_message(...) * @param int $p_user_id * @param int $p_bug_id * @param string $p_message_id * @return array */ function email_build_visible_bug_data($p_user_id, $p_bug_id, $p_message_id) { $t_project_id = bug_get_field($p_bug_id, 'project_id'); $t_user_access_level = user_get_access_level($p_user_id, $t_project_id); $t_user_bugnote_order = user_pref_get_pref($p_user_id, 'bugnote_order'); $t_user_bugnote_limit = user_pref_get_pref($p_user_id, 'email_bugnote_limit'); $row = bug_get_extended_row($p_bug_id); $t_bug_data = array(); $t_bug_data['email_bug'] = $p_bug_id; if ($p_message_id !== 'email_notification_title_for_action_bug_deleted') { $t_bug_data['email_bug_view_url'] = string_get_bug_view_url_with_fqdn($p_bug_id); } if (access_compare_level($t_user_access_level, config_get('view_handler_threshold'))) { if (0 != $row['handler_id']) { $t_bug_data['email_handler'] = user_get_name($row['handler_id']); } else { $t_bug_data['email_handler'] = ''; } } $t_bug_data['email_reporter'] = user_get_name($row['reporter_id']); $t_bug_data['email_project_id'] = $row['project_id']; $t_bug_data['email_project'] = project_get_field($row['project_id'], 'name'); $t_category_name = category_full_name($row['category_id'], false); $t_bug_data['email_category'] = $t_category_name; $t_bug_data['email_date_submitted'] = $row['date_submitted']; $t_bug_data['email_last_modified'] = $row['last_updated']; $t_bug_data['email_status'] = $row['status']; $t_bug_data['email_severity'] = $row['severity']; $t_bug_data['email_priority'] = $row['priority']; $t_bug_data['email_reproducibility'] = $row['reproducibility']; $t_bug_data['email_resolution'] = $row['resolution']; $t_bug_data['email_fixed_in_version'] = $row['fixed_in_version']; if (!is_blank($row['target_version']) && access_compare_level($t_user_access_level, config_get('roadmap_view_threshold'))) { $t_bug_data['email_target_version'] = $row['target_version']; } $t_bug_data['email_summary'] = $row['summary']; $t_bug_data['email_description'] = $row['description']; $t_bug_data['email_additional_information'] = $row['additional_information']; $t_bug_data['email_steps_to_reproduce'] = $row['steps_to_reproduce']; $t_bug_data['set_category'] = '[' . $t_bug_data['email_project'] . '] ' . $t_category_name; $t_bug_data['custom_fields'] = custom_field_get_linked_fields($p_bug_id, $t_user_access_level); $t_bug_data['bugnotes'] = bugnote_get_all_visible_bugnotes($p_bug_id, $t_user_bugnote_order, $t_user_bugnote_limit, $p_user_id); # put history data if (ON == config_get('history_default_visible') && access_compare_level($t_user_access_level, config_get('view_history_threshold'))) { $t_bug_data['history'] = history_get_raw_events_array($p_bug_id, $p_user_id); } # Sponsorship Information if (config_get('enable_sponsorship') == ON && access_has_bug_level(config_get('view_sponsorship_total_threshold'), $p_bug_id, $p_user_id)) { $t_sponsorship_ids = sponsorship_get_all_ids($p_bug_id); $t_bug_data['sponsorship_total'] = sponsorship_get_amount($t_sponsorship_ids); if (access_has_bug_level(config_get('view_sponsorship_details_threshold'), $p_bug_id, $p_user_id)) { $t_bug_data['sponsorships'] = array(); foreach ($t_sponsorship_ids as $id) { $t_bug_data['sponsorships'][] = sponsorship_get($id); } } } $t_bug_data['relations'] = relationship_get_summary_text($p_bug_id); return $t_bug_data; }
/** * 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); }
/** * Get all visible notes for a specific issue * * @param integer $p_issue_id The id of the issue to retrieve the notes for * @return Array that represents an IssueNoteData structure */ function mci_issue_get_notes( $p_issue_id ) { $t_user_id = auth_get_current_user_id(); $t_lang = mci_get_user_lang( $t_user_id ); $t_project_id = bug_get_field( $p_issue_id, 'project_id' ); $t_user_bugnote_order = 'ASC'; // always get the notes in ascending order for consistency to the calling application. $t_has_time_tracking_access = access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $p_issue_id ); $t_result = array(); foreach( bugnote_get_all_visible_bugnotes( $p_issue_id, $t_user_bugnote_order, 0 ) as $t_value ) { $t_bugnote = array(); $t_bugnote['id'] = $t_value->id; $t_bugnote['reporter'] = mci_account_get_array_by_id( $t_value->reporter_id ); $t_bugnote['date_submitted'] = timestamp_to_iso8601( $t_value->date_submitted ); $t_bugnote['last_modified'] = timestamp_to_iso8601( $t_value->last_modified ); $t_bugnote['text'] = $t_value->note; $t_bugnote['view_state'] = mci_enum_get_array_by_id( $t_value->view_state, 'view_state', $t_lang ); $t_bugnote['time_tracking'] = $t_has_time_tracking_access ? $t_value->time_tracking : 0; $t_bugnote['note_type'] = $t_value->note_type; $t_bugnote['note_attr'] = $t_value->note_attr; $t_result[] = $t_bugnote; } return (count( $t_result ) == 0 ? null : $t_result ); }
/** * Build a string that captures all the notes visible to the logged in user along with their * metadata. The string will contain information about each note including reporter, timestamp, * time tracking, view state. This will result in multi-line string with "\n" as the line * separator. * * @param integer $p_bug_id A bug identifier. * @param integer $p_user_bugnote_order Sort order. * @param integer $p_user_bugnote_limit Number of bugnotes to display to user. * @param integer $p_user_id An user identifier. * @return string The string containing all visible notes. * @access public */ function bugnote_get_all_visible_as_string($p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit, $p_user_id = null) { $t_notes = bugnote_get_all_visible_bugnotes($p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit, $p_user_id); $t_date_format = config_get('normal_date_format'); $t_show_time_tracking = access_has_bug_level(config_get('time_tracking_view_threshold'), $p_bug_id); $t_output = ''; foreach ($t_notes as $t_note) { $t_note_string = '@' . user_get_name($t_note->reporter_id); if ($t_note->view_state != VS_PUBLIC) { $t_note_string .= ' (' . lang_get('private') . ')'; } $t_note_string .= ' ' . date($t_date_format, $t_note->date_submitted); if ($t_show_time_tracking && $t_note->note_type == TIME_TRACKING) { $t_time_tracking_hhmm = db_minutes_to_hhmm($t_note->time_tracking); $t_note_string .= ' ' . lang_get('time_tracking_time_spent') . ' ' . $t_time_tracking_hhmm; } $t_note_string .= "\n" . $t_note->note . "\n"; if (!empty($t_output)) { $t_output .= "---\n"; } $t_output .= $t_note_string; } return $t_output; }
$c_filesize = number_format($t_attachment['size']); $c_date_added = date($t_date_format, $t_attachment['date_added']); echo $c_filename . ' (' . $c_filesize . ' ' . lang_get('bytes') . ') <span class="italic-small">' . $c_date_added . '</span><br />' . string_display_links($t_path . $c_download_url); if ($t_attachment['preview'] && $t_attachment['type'] == 'image' && $f_type_page == 'html') { echo '<br /><img src="', $c_download_url, '" alt="', $t_attachment['alt'], '" /><br />'; } } ?> </td> </tr> <tr><td colspan="6" class="print"> </td></tr> <?php $t_user_bugnote_limit = 0; $t_bugnotes = bugnote_get_all_visible_bugnotes($t_id, $t_user_bugnote_order, $t_user_bugnote_limit); ?> <tr><td class="print" colspan="6"> <table class="width100" cellspacing="1"> <?php # no bugnotes if (0 == count($t_bugnotes)) { ?> <tr> <td class="print" colspan="2"> <?php echo $t_lang_no_bugnotes_msg; ?> </td> </tr> <?php
/** * Get all visible notes for a specific issue * * @param integer $p_issue_id The id of the issue to retrieve the notes for * @return Array that represents an IssueNoteData structure */ function mci_issue_get_notes($p_issue_id) { $t_user_id = auth_get_current_user_id(); $t_lang = mci_get_user_lang($t_user_id); $t_project_id = bug_get_field($p_issue_id, 'project_id'); $t_user_access_level = user_get_access_level($t_user_id, $t_project_id); $t_user_bugnote_order = 'ASC'; // always get the notes in ascending order for consistency to the calling application. $t_result = array(); foreach (bugnote_get_all_visible_bugnotes($p_issue_id, $t_user_access_level, $t_user_bugnote_order, 0) as $t_value) { $t_bugnote = array(); $t_bugnote['id'] = $t_value->id; $t_bugnote['reporter'] = mci_account_get_array_by_id($t_value->reporter_id); $t_bugnote['date_submitted'] = timestamp_to_iso8601($t_value->date_submitted); $t_bugnote['last_modified'] = timestamp_to_iso8601($t_value->last_modified); $t_bugnote['text'] = $t_value->note; $t_bugnote['view_state'] = mci_enum_get_array_by_id($t_value->view_state, 'view_state', $t_lang); $t_result[] = $t_bugnote; } return $t_result; }
/** * 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 { $t_project_name = project_get_name($t_project_id); 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['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 = 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'])) { $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) { 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); $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); } } } 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 return $t_bug_data->update(true, true); }