/** * Returns a courses list for the current user. * * @return string list of courses (HTML format) * @deprecated use UserCourseList and CourseTreeView instead */ function render_user_course_list() { // Get the list of personnal courses marked as contening new events $date = Claroline::getInstance()->notification->get_notification_date(claro_get_current_user_id()); $modified_course = Claroline::getInstance()->notification->get_notified_courses($date, claro_get_current_user_id()); // Get all the user's courses $userCourseList = claro_get_user_course_list(); // Use the course id as array index, exclude disable courses // and flag hot courses $reorganizedUserCourseList = array(); $tempSessionCourses = array(); foreach ($userCourseList as $course) { // Do not include "disable", "pending", "trash" or "date" courses // (if we're not in the date limits) $curdate = claro_mktime(); $courseIsEnable = (bool) ($course['status'] == 'enable' || $course['status'] == 'date' && (!isset($course['creationDate']) || strtotime($course['creationDate']) <= $curdate) && (!isset($course['expirationDate']) || strtotime($course['expirationDate']) >= $curdate)); // Flag hot courses $course['hot'] = (bool) in_array($course['sysCode'], $modified_course); if (!isset($reorganizedUserCourseList[$course['courseId']]) && $courseIsEnable) { // If it's not a session course, include it in the final list if (empty($course['sourceCourseId'])) { $reorganizedUserCourseList[$course['courseId']] = $course; } else { $tempSessionCourses[$course['sourceCourseId']][] = $course; } } } unset($userCourseList); // Merge courses and their session courses (if any) foreach ($tempSessionCourses as $sourceCourseId => $sessionCourses) { /* * Sometimes, a session course could not find its associated source * course in the user course list. Simply because, for some reason, * this user isn't registered to the source course anymore, but is * still registered in the session course. */ if (!empty($reorganizedUserCourseList[$sourceCourseId])) { $reorganizedUserCourseList[$sourceCourseId]['sessionCourses'] = $sessionCourses; } else { foreach ($sessionCourses as $course) { $reorganizedUserCourseList[$course['courseId']] = $course; } } } unset($tempSessionCourses); // Now, $reorganizedUserCourseList contains all user's courses and, for // each course, its eventual session courses. // Display $out = ''; // Courses organized by categories if (get_conf('userCourseListGroupByCategories')) { // Get all the categories names (used to build trails) $categoryList = ClaroCategory::getAllCategories(0, 0, 1); // Get the categories informations for these courses $userCategoryList = ClaroCategory::getCoursesCategories($reorganizedUserCourseList); // Use the category id as array index $reorganizedUserCategoryList = array(); foreach ($userCategoryList as $category) { // Flag root courses and put it aside $reorganizedUserCourseList[$category['courseId']]['rootCourse'] = 0; if ($category['rootCourse']) { $reorganizedUserCourseList[$category['courseId']]['rootCourse'] = 1; } if (!isset($reorganizedUserCategoryList[$category['categoryId']])) { $reorganizedUserCategoryList[$category['categoryId']] = $category; //We won't need that key anymore unset($reorganizedUserCategoryList[$category['categoryId']]['courseId']); } // Initialise the category's course list $reorganizedUserCategoryList[$category['categoryId']]['courseList'] = array(); } // Place courses in the right categories and build categories' trails $currentCategoryId = null; foreach ($userCategoryList as $category) { // Build the full trail for each category (excepted root category) if ($category['categoryId'] == 0) { $trail = $category['name']; } else { $trail = build_category_trail($categoryList, $category['categoryId']); } $reorganizedUserCategoryList[$category['categoryId']]['trail'] = $trail; // Put root courses aside if ($reorganizedUserCourseList[$category['courseId']]['rootCourse']) { $reorganizedUserCategoryList[$category['categoryId']]['rootCourse'] = $reorganizedUserCourseList[$category['courseId']]; } else { // Do not include source courses (only display session courses) // (excepted if the user is manager of the course) if (!$reorganizedUserCourseList[$category['courseId']]['isSourceCourse'] || $reorganizedUserCourseList[$category['courseId']]['isCourseManager']) { $reorganizedUserCategoryList[$category['categoryId']]['courseList'][] = $reorganizedUserCourseList[$category['courseId']]; } } } unset($userCategoryList); if (count($reorganizedUserCategoryList) > 0) { $out .= '<dl class="courseList">'; foreach ($reorganizedUserCategoryList as $category) { if (!empty($category['courseList']) || !empty($category['rootCourse'])) { $out .= '<dt>' . "\n" . '<h4 id="' . $category['categoryId'] . '">' . $category['trail'] . (!empty($category['rootCourse']) ? ' [<a href="' . get_path('url') . '/claroline/course/index.php?cid=' . claro_htmlspecialchars($category['rootCourse']['sysCode']) . '">' . get_lang('Infos') . '</a>]' : '') . '</h4>' . "\n" . '</dt>' . "\n"; if (!empty($category['courseList'])) { foreach ($category['courseList'] as $course) { $out .= render_course_in_dl_list($course, $course['hot']); } } else { $out .= '<dt>' . get_lang('There are no courses in this category') . '</dt>'; } } } } $out .= '</dl>'; } else { if (count($reorganizedUserCourseList) > 0) { $out .= '<dl class="courseList">'; foreach ($reorganizedUserCourseList as $course) { $displayIconAccess = $course['isCourseManager'] || claro_is_platform_admin() ? true : false; $out .= render_course_in_dl_list($course, $course['hot'], $displayIconAccess); } $out .= '</dl>' . "\n"; } } return $out; }
$pagerSortKey = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'name'; $pagerSortDir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : SORT_ASC; // Parse command $userData = user_get_properties($uidToEdit); if (false === $userData || $uidToEdit != $userData['user_id']) { $dialogBox->error(get_lang('Not valid user id')); } if ('unsubscribe' == $cmd) { if (is_null($courseId)) { $dialogBox->error(get_lang('Not valid course code')); } else { $do = 'rem_user'; } } if ('rqRmAll' == $cmd) { $courseList = claro_get_user_course_list($uidToEdit); $ok = true; foreach ($courseList as $course) { if (!user_remove_from_course($uidToEdit, $course['sysCode'], true, false)) { $ok = false; $dialogBox->error(get_lang('The user has not been successfully unregistered for course ' . $course['sysCode'])); } } if ($ok) { $dialogBox->success(get_lang('The user has been successfully unregistered for all courses')); } } // Execute command if ('rem_user' == $do) { if (user_remove_from_course($uidToEdit, $courseId, true, false)) { $dialogBox->success(get_lang('The user has been successfully unregistered'));