/** * Get all issues matching the specified filter. * * @param string $p_username The name of the user trying to access the filters. * @param string $p_password The password of the user. * @param integer $p_filter_id The id of the filter to apply. * @param integer $p_page_number Start with the given page number (zero-based) * @param integer $p_per_page Number of issues to display per page * @return Array that represents an IssueDataArray structure */ function mc_filter_get_issues($p_username, $p_password, $p_project_id, $p_filter_id, $p_page_number, $p_per_page) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } $t_lang = mci_get_user_lang($t_user_id); if (!mci_has_readonly_access($t_user_id, $p_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_page_count = 0; $t_bug_count = 0; $t_filter = filter_db_get_filter($p_filter_id); $t_filter_detail = explode('#', $t_filter, 2); if (!isset($t_filter_detail[1])) { return new soap_fault('Server', '', 'Invalid Filter'); } $t_filter = unserialize($t_filter_detail[1]); $t_filter = filter_ensure_valid_filter($t_filter); $t_result = array(); $t_rows = filter_get_bug_rows($p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter, $p_project_id); foreach ($t_rows as $t_issue_data) { $t_result[] = mci_issue_data_as_array($t_issue_data, $t_user_id, $t_lang); } return $t_result; }
/** * Get all projects accessible by the given user. * * @param string $p_username The name of the user trying to access the project list. * @param string $p_password The password of the user. * @return Array suitable to be converted into a ProjectDataArray */ function mc_projects_get_user_accessible($p_username, $p_password) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!mci_has_readonly_access($t_user_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_lang = mci_get_user_lang($t_user_id); $t_result = array(); foreach (user_get_accessible_projects($t_user_id) as $t_project_id) { $t_project_row = project_cache_row($t_project_id); $t_project = array(); $t_project['id'] = $t_project_id; $t_project['name'] = $t_project_row['name']; $t_project['status'] = mci_enum_get_array_by_id($t_project_row['status'], 'project_status', $t_lang); $t_project['enabled'] = $t_project_row['enabled']; $t_project['view_state'] = mci_enum_get_array_by_id($t_project_row['view_state'], 'project_view_state', $t_lang); $t_project['access_min'] = mci_enum_get_array_by_id($t_project_row['access_min'], 'access_levels', $t_lang); $t_project['file_path'] = array_key_exists('file_path', $t_project_row) ? $t_project_row['file_path'] : ""; $t_project['description'] = array_key_exists('description', $t_project_row) ? $t_project_row['description'] : ""; $t_project['subprojects'] = mci_user_get_accessible_subprojects($t_user_id, $t_project_id, $t_lang); $t_result[] = $t_project; } return $t_result; }
/** * Get all issues matching the specified filter. * * @param string $p_username The name of the user trying to access the filters. * @param string $p_password The password of the user. * @param integer $p_filter_id The id of the filter to apply. * @param integer $p_page_number Start with the given page number (zero-based) * @param integer $p_per_page Number of issues to display per page * @return Array that represents an IssueDataArray structure */ function mc_filter_get_issues($p_username, $p_password, $p_project_id, $p_filter_id, $p_page_number, $p_per_page) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } $t_lang = mci_get_user_lang($t_user_id); if (!mci_has_readonly_access($t_user_id, $p_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_orig_page_number = $p_page_number < 1 ? 1 : $p_page_number; $t_page_count = 0; $t_bug_count = 0; $t_filter = filter_db_get_filter($p_filter_id); $t_filter_detail = explode('#', $t_filter, 2); if (!isset($t_filter_detail[1])) { return SoapObjectsFactory::newSoapFault('Server', 'Invalid Filter'); } $t_filter = unserialize($t_filter_detail[1]); $t_filter = filter_ensure_valid_filter($t_filter); $t_result = array(); $t_rows = filter_get_bug_rows($p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter, $p_project_id); // the page number was moved back, so we have exceeded the actual page number, see bug #12991 if ($t_orig_page_number > $p_page_number) { return $t_result; } foreach ($t_rows as $t_issue_data) { $t_result[] = mci_issue_data_as_array($t_issue_data, $t_user_id, $t_lang); } return $t_result; }
/** * Explode a configuration enumeration name into an array structure that can * be safely converted into an ObjectRef structure. * * @param string $p_enumeration_name The name of the enumeration to convert * @return Array The converted enumeration */ function mci_explode_to_objectref($p_enumeration_name) { $t_config_var_name = $p_enumeration_name . '_enum_string'; $t_config_var_value = config_get($t_config_var_name); $t_translated_values = lang_get($t_config_var_name, mci_get_user_lang(auth_get_current_user_id())); $t_enum_values = MantisEnum::getValues($t_config_var_value); $t_result = array(); foreach ($t_enum_values as $t_key) { $t_translated = MantisEnum::getLocalizedLabel($t_config_var_value, $t_translated_values, $t_key); $t_result[] = array('id' => $t_key, 'name' => $t_translated); } return $t_result; }
/** * Gets the sub-projects that are accessible to the specified user / project. * @param integer $p_user_id User id. * @param integer $p_parent_project_id Parent Project id. * @param string $p_lang Language string. * @return array */ function mci_user_get_accessible_subprojects($p_user_id, $p_parent_project_id, $p_lang = null) { if ($p_lang === null) { $t_lang = mci_get_user_lang($p_user_id); } else { $t_lang = $p_lang; } $t_result = array(); foreach (user_get_accessible_subprojects($p_user_id, $p_parent_project_id) as $t_subproject_id) { $t_subproject_row = project_cache_row($t_subproject_id); $t_subproject = array(); $t_subproject['id'] = $t_subproject_id; $t_subproject['name'] = $t_subproject_row['name']; $t_subproject['status'] = mci_enum_get_array_by_id($t_subproject_row['status'], 'project_status', $t_lang); $t_subproject['enabled'] = $t_subproject_row['enabled']; $t_subproject['view_state'] = mci_enum_get_array_by_id($t_subproject_row['view_state'], 'project_view_state', $t_lang); $t_subproject['access_min'] = mci_enum_get_array_by_id($t_subproject_row['access_min'], 'access_levels', $t_lang); $t_subproject['file_path'] = array_key_exists('file_path', $t_subproject_row) ? $t_subproject_row['file_path'] : ''; $t_subproject['description'] = array_key_exists('description', $t_subproject_row) ? $t_subproject_row['description'] : ''; $t_subproject['subprojects'] = mci_user_get_accessible_subprojects($p_user_id, $t_subproject_id, $t_lang); $t_result[] = $t_subproject; } return $t_result; }
/** * Get all issues header matching the ids. * * @param string $p_username The name of the user trying to access the filters. * @param string $p_password The password of the user. * @param IntegerArray $p_issue_ids Number of issues to display per page. * @return array that represents an IssueHeaderDataArray structure */ function mc_issues_get_header($p_username, $p_password, $p_issue_ids) { 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(); } $t_lang = mci_get_user_lang($t_user_id); $t_result = array(); foreach ($p_issue_ids as $t_id) { if (mci_check_access_to_bug($t_user_id, $t_id) === false) { continue; } log_event(LOG_WEBSERVICE, 'getting details for issue \'' . $t_id . '\''); $t_issue_data = bug_get($t_id, true); $t_result[] = mci_issue_data_as_header_array($t_issue_data, $t_user_id, $t_lang); } return $t_result; }
/** * Get all issues matching the custom filter. * * @param string $p_username The name of the user trying to access the filters. * @param string $p_password The password of the user. * @param FilterSearchData $p_filter_search The custom filter. * @param integer $p_page_number Start with the given page number (zero-based). * @param integer $p_per_page Number of issues to display per page. * @return array that represents an IssueDataArray structure */ function mc_filter_search_issues($p_username, $p_password, $p_filter_search, $p_page_number, $p_per_page) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } $t_rows = mci_filter_search_get_rows($t_user_id, $p_filter_search, $p_page_number, $p_per_page); $t_lang = mci_get_user_lang($t_user_id); $t_result = array(); foreach ($t_rows as $t_issue_data) { $t_result[] = mci_issue_data_as_array($t_issue_data, $t_user_id, $t_lang); } return $t_result; }
/** * 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 ); }
/** * Get an appropriate enumeration. (Should become an internal function.) * * @param string $p_username The name of the user trying to access the enumeration. * @param string $p_password The password of the user. * @param string $p_enumeration The enumeration to get. * @return string The requested enumeration. */ function mc_enum_get($p_username, $p_password, $p_enumeration) { if (!mci_validate_enum_access($p_username, $p_password)) { return new soap_fault('Client', '', 'Access Denied'); } // safe to call directly after login checks $t_user_id = auth_get_current_user_id(); $t_lang = mci_get_user_lang($t_user_id); return lang_get($p_enumeration . '_enum_string', $t_lang); }
/** * Get an appropriate enumeration. (Should become an internal function.) * * @param string $p_username The name of the user trying to access the enumeration. * @param string $p_password The password of the user. * @param string $p_enumeration The enumeration to get. * @return string The requested enumeration. */ function mc_enum_get($p_username, $p_password, $p_enumeration) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return new soap_fault('Client', '', 'Access Denied'); } if (!mci_has_readonly_access($t_user_id)) { return new soap_fault('Client', '', 'Access Denied'); } $t_lang = mci_get_user_lang($t_user_id); return lang_get($p_enumeration . '_enum_string', $t_lang); }
/** * Get all issues matching the specified filter. * * @param string $p_username The name of the user trying to access the filters. * @param string $p_password The password of the user. * @param integer $p_filter_id The id of the filter to apply. * @param integer $p_page_number Start with the given page number (zero-based) * @param integer $p_per_page Number of issues to display per page * @return Array that represents an IssueDataArray structure */ function mc_filter_get_issues($p_username, $p_password, $p_project_id, $p_filter_id, $p_page_number, $p_per_page) { $t_user_id = mci_check_login($p_username, $p_password); $t_lang = mci_get_user_lang($t_user_id); if ($t_user_id === false) { return new soap_fault('Client', '', 'Access Denied'); } if (!mci_has_readonly_access($t_user_id, $p_project_id)) { return new soap_fault('Client', '', 'Access Denied'); } $t_page_count = 0; $t_bug_count = 0; $t_filter = filter_db_get_filter($p_filter_id); $t_filter_detail = explode('#', $t_filter, 2); if (!isset($t_filter_detail[1])) { return new soap_fault('Server', '', 'Invalid Filter'); } $t_filter = unserialize($t_filter_detail[1]); $t_filter = filter_ensure_valid_filter($t_filter); $t_result = array(); $t_rows = filter_get_bug_rows($p_page_number, $p_per_page, $t_page_count, $t_bug_count, $t_filter, $p_project_id); foreach ($t_rows as $t_issue_data) { $t_id = $t_issue_data['id']; $t_issue = array(); $t_issue['id'] = $t_id; $t_issue['view_state'] = mci_enum_get_array_by_id($t_issue_data['view_state'], 'view_state', $t_lang); $t_issue['last_updated'] = timestamp_to_iso8601($t_issue_data['last_updated']); $t_issue['project'] = mci_project_as_array_by_id($t_issue_data['project_id']); $t_issue['category'] = mci_null_if_empty($t_issue_data['category']); $t_issue['priority'] = mci_enum_get_array_by_id($t_issue_data['priority'], 'priority', $t_lang); $t_issue['severity'] = mci_enum_get_array_by_id($t_issue_data['severity'], 'severity', $t_lang); $t_issue['status'] = mci_enum_get_array_by_id($t_issue_data['status'], 'status', $t_lang); $t_issue['reporter'] = mci_account_get_array_by_id($t_issue_data['reporter_id']); $t_issue['summary'] = $t_issue_data['summary']; $t_issue['version'] = mci_null_if_empty($t_issue_data['version']); $t_issue['build'] = mci_null_if_empty($t_issue_data['build']); $t_issue['platform'] = mci_null_if_empty($t_issue_data['platform']); $t_issue['os'] = mci_null_if_empty($t_issue_data['os']); $t_issue['os_build'] = mci_null_if_empty($t_issue_data['os_build']); $t_issue['reproducibility'] = mci_enum_get_array_by_id($t_issue_data['reproducibility'], 'reproducibility', $t_lang); $t_issue['date_submitted'] = timestamp_to_iso8601($t_issue_data['date_submitted']); $t_issue['sponsorship_total'] = $t_issue_data['sponsorship_total']; if (!empty($t_issue_data['handler_id'])) { $t_issue['handler'] = mci_account_get_array_by_id($t_issue_data['handler_id']); } $t_issue['projection'] = mci_enum_get_array_by_id($t_issue_data['projection'], 'projection', $t_lang); $t_issue['eta'] = mci_enum_get_array_by_id($t_issue_data['eta'], 'eta', $t_lang); $t_issue['resolution'] = mci_enum_get_array_by_id($t_issue_data['resolution'], 'resolution', $t_lang); $t_issue['fixed_in_version'] = mci_null_if_empty($t_issue_data['fixed_in_version']); $t_issue['description'] = bug_get_text_field($t_id, 'description'); $t_steps_to_reproduce = bug_get_text_field($t_id, 'steps_to_reproduce'); $t_issue['steps_to_reproduce'] = mci_null_if_empty($t_steps_to_reproduce); $t_additional_information = bug_get_text_field($t_id, 'additional_information'); $t_issue['additional_information'] = mci_null_if_empty($t_additional_information); $t_issue['attachments'] = mci_issue_get_attachments($t_issue_data['id']); $t_issue['relationships'] = mci_issue_get_relationships($t_issue_data['id'], $t_user_id); $t_issue['notes'] = mci_issue_get_notes($t_issue_data['id']); $t_issue['custom_fields'] = mci_issue_get_custom_fields($t_issue_data['id']); $t_result[] = $t_issue; } return $t_result; }
/** * 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; }