/** * 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; }
/** * 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; }