/** * Get the complete course tree of a specific user. * * @param int user id * @return CourseTreeView */ public static function getUserCourseTreeView($userId) { // CourseListIterator $courseList = new UserCourseList($userId); $courseListIterator = $courseList->getIterator(); // User rights $privilegeList = new CourseUserPrivilegesList($userId); $privilegeList->load(); // Hot courses $notifiedCourseList = new NotifiedCourseList($userId); // User categories $userCategoryList = ClaroCategory::getUserCategories($userId); // Selected category $selectedCategoryId = isset($_REQUEST['viewCategory']) ? (int) $_REQUEST['viewCategory'] : null; // Course tree $courseTree = new CourseTree($courseListIterator); // View $courseTreeView = new CourseTreeView($courseTree->getRootNode(), $privilegeList, $notifiedCourseList, $userCategoryList, $selectedCategoryId, null); return $courseTreeView; }
*/ // Load Claroline kernel require_once dirname(__FILE__) . '/../../inc/claro_init_global.inc.php'; require_once dirname(__FILE__) . '/../../inc/lib/courselist.lib.php'; require_once dirname(__FILE__) . '/../../inc/lib/course/courselist.lib.php'; require_once dirname(__FILE__) . '/../../inc/lib/class.lib.php'; if (!claro_is_platform_admin()) { claro_die(get_lang('Not allowed')); } $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; if ($action == 'getUserCourseList') { $userId = isset($_REQUEST['userId']) ? (int) $_REQUEST['userId'] : null; $courseList = array(); if (!is_null($userId)) { $courseList = new UserCourseList($userId); $courseListIterator = $courseList->getIterator(); //We only need courses codes if (!empty($courseListIterator)) { $coursesCodeList = array(); foreach ($courseListIterator as $course) { $coursesCodeList[] = $course->officialCode; } } else { $coursesCodeList[] = get_lang("No course"); } } else { $coursesCodeList[] = get_lang("No user id"); } echo implode(', ', $coursesCodeList); } elseif ($action == 'getUserCategoryList') { // Get table name