';
+
+ foreach ($listUserCategories as $userCategoryId => $userCatTitle) {
+ // add user category
+ $userCategoryHtml = '';
+ if ($userCategoryId != 0) {
+ $userCategoryHtml = '
';
+ }
+ $userCategoryHtml .= self::getHtmlForUserCategory($userCategoryId, $userCatTitle);
+ // look for course in this userCat in session courses : $listCoursesInSession
+ $htmlCategory = '';
+ if (isset($listCoursesInSession[$userCategoryId])) {
+ // list of courses in this user cat
+ foreach ($listCoursesInSession[$userCategoryId]['courseInUserCatList'] as $i => $listCourse) {
+ // add course
+ $listCoursesAlreadyDisplayed[$listCourse['courseId']] = 1;
+ if ($userCategoryId == 0) {
+ $htmlCategory .= '
';
+ } else {
+ $htmlCategory .= '
';
+ }
+ $htmlCategory .= self::getHtmlForCourse($listCourse['courseId'], $listCourse['title'], $listCourse['courseCode'], $userCategoryId, 1, $loadDirs);
+ // list of session category
+ $htmlSessionCategory = '
';
+ foreach ($listCourse['sessionCatList'] as $j => $listCategorySession) {
+ // add session category
+ $htmlSessionCategory .= self::getHtmlSessionCatagory($listCategorySession['catSessionId'], $listCategorySession['catSessionName']);
+ // list of session
+ $htmlSession = ''; // start
+ foreach ($listCategorySession['sessionList'] as $k => $listSession) {
+ // add session
+ $htmlSession .= '
';
+ $htmlSession .= self::getHtmlForSession($listSession['sessionId'], $listSession['sessionName'], $listCategorySession['catSessionId'], $listCourse['courseCode']);
+ $htmlSession .= '
';
+ }
+ $htmlSession .= ''; // end session block
+ $htmlSessionCategory .= $htmlSession;
+ }
+ $htmlSessionCategory .= '
'; // end session cat block
+ $htmlCategory .= $htmlSessionCategory .'
' ;
+ $htmlCategory .= ''; // end course block
+ }
+ $userCategoryHtml .= $htmlCategory;
+ }
+
+ // look for courses in this userCat in not in session courses : $listCoursesInfo
+ // if course not already added
+ $htmlCategory = '';
+ foreach ($listCoursesInfo as $i => $listCourse) {
+ if ($listCourse['userCatId'] == $userCategoryId && !isset($listCoursesAlreadyDisplayed[$listCourse['id']])) {
+ if ($userCategoryId != 0) {
+ $htmlCategory .= '
';
+ } else {
+ $htmlCategory .= '
';
+ }
+ $htmlCategory .= self::getHtmlForCourse($listCourse['id'], $listCourse['title'], $listCourse['code'], $userCategoryId, 0, $loadDirs);
+ $htmlCategory .= '
';
+ }
+ }
+ $htmlCategory .= '';
+ $userCategoryHtml .= $htmlCategory; // end user cat block
+ if ($userCategoryId != 0) {
+ $userCategoryHtml .= '
';
+ }
+ $html .= $userCategoryHtml; //
+ }
+ $html .= '
';
+
+ return $html.$special_courses;
+ }
+
+ /**
+ * Return HTML code for personnal user course category
+ * @param $id
+ * @param $title
+ * @return string
+ */
+ private static function getHtmlForUserCategory($id, $title)
+ {
+ if ($id == 0) {
+ return '';
+ }
+ $icon = Display::return_icon('folder_yellow.png', $title, array('class' => 'sessionView', 'width' => 24), ICON_SIZE_LARGE);
+ return "
$icon$title
";
+ }
+
+ /**
+ * return HTML code for course display in session view
+ * @param $id
+ * @param $title
+ * @param $code
+ * @param $userCategoryId
+ * @param bool $displayButton
+ * @param $loadDirs
+ * @return string
+ */
+ private static function getHtmlForCourse($id, $title, $code, $userCategoryId, $displayButton = false, $loadDirs)
+ {
+ //
+ //
+ $class = 'session-view-lvl-6';
+ if ($userCategoryId != 0 && !$displayButton) {
+ $class = 'session-view-lvl-7';
+ }
+
+ $class2 = 'session-view-lvl-6';
+ if ($displayButton || $userCategoryId != 0) {
+ $class2 = 'session-view-lvl-7';
+ }
+
+ $button = '';
+ if ($displayButton) {
+ $button = '
';
+ }
+
+ $icon = Display::return_icon('blackboard.png', $title, array('class' => 'sessionView', 'width' => 24), ICON_SIZE_LARGE);
+ $courseLink = api_get_path(WEB_COURSE_PATH).$code.'/?id_session=0';
+
+ // get html course params
+ $tabParams = CourseManager::getCourseParamsForDisplay($id, $loadDirs); // ['right_actions'] ['teachers'] ['notifications']
+ // teacher list
+ if (!empty($tabParams['teachers'])) {
+ $teachers = '
'.$tabParams['teachers'].'
';
+ }
+ // notification
+ if (!empty($tabParams['right_actions'])) {
+ $rightActions = '
'.$tabParams['right_actions'].'
';
+ }
+ return "
$button
$icon$title".$tabParams['notifications']."$rightActions
$teachers";
+ }
+
+ /**
+ * return HTML code for session category
+ * @param $id
+ * @param $title
+ * @return string
+ */
+ private static function getHtmlSessionCatagory($id, $title)
+ {
+ if ($id == 0) {
+ return '';
+ }
+ $icon = Display::return_icon('folder_blue.png', $title, array('class' => 'sessionView', 'width' => 24), ICON_SIZE_LARGE);
+ return "
$icon$title
";
+ }
+
+ /**
+ * return HTML code for session
+ * @param $id
+ * @param $title
+ * @param $categotySessionId
+ * @param $courseCode
+ * @return string
+ */
+ private static function getHtmlForSession($id, $title, $categotySessionId, $courseCode)
+ {
+ $html = '';
+
+ if ($categotySessionId == 0) {
+ $class1 = 'session-view-lvl-2'; // session
+ $class2 = 'session-view-lvl-4'; // got to course in session link
+ } else {
+ $class1 = 'session-view-lvl-3'; // session
+ $class2 = 'session-view-lvl-5'; // got to course in session link
+ }
+
+ $icon = Display::return_icon('blackboard_blue.png', $title, array('class' => 'sessionView', 'width' => 24), ICON_SIZE_LARGE);
+ $courseLink = api_get_path(WEB_COURSE_PATH).$courseCode.'/?id_session='.$id;
+
+ $html .= "
$icon$title";
+ $html .= '
';
+ return '
'.$html.'
';
+ }
+
+ /**
+ * @param $listA
+ * @param $listB
+ * @return int
+ */
+ private static function compareByCourse($listA, $listB)
+ {
+ if ($listA['userCatTitle'] == $listB['userCatTitle']) {
+ if ($listA['title'] == $listB['title']) {
+ return 0;
+ } else if($listA['title'] > $listB['title']) {
+ return 1;
+ } else {
+ return -1;
+ }
+ } else if ($listA['userCatTitle'] > $listB['userCatTitle']) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * @param $listA
+ * @param $listB
+ * @return int
+ */
+ public static function compareListUserCategory($listA, $listB)
+ {
+ if ($listA['title'] == $listB['title']) {
+ return 0;
+ } else if($listA['title'] > $listB['title']) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * @param $view
+ * @param $userId
+ */
+ public static function setDefaultMyCourseView($view, $userId)
+ {
+ setcookie('defaultMyCourseView'.$userId, $view);
+ }
+
}
diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php
index 000a7bd157..34dc4e1119 100755
--- a/main/install/configuration.dist.php
+++ b/main/install/configuration.dist.php
@@ -301,4 +301,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['limit_session_admin_role'] = false;
// Show session description
//$_configuration['show_session_description'] = false;
-
+// Show Default view and Session view link in My Courses tab
+//$_configuration['my_courses_view_by_session'] = false;
\ No newline at end of file
diff --git a/main/template/default/layout/footer.tpl b/main/template/default/layout/footer.tpl
index d3fdb29c11..cc965846ea 100755
--- a/main/template/default/layout/footer.tpl
+++ b/main/template/default/layout/footer.tpl
@@ -143,6 +143,25 @@
});
{% endraw %}
+ /**
+ * Generic function to replace the depreceted jQuery toggle function
+ * @param inId : id of block to hide / unhide
+ * @param inIdTxt : id of the button
+ * @param inTxtHide : text one of the button
+ * @param inTxtUnhide : text two of the button
+ * @todo : allow to detect if text is from a button or from a
+ */
+ function hideUnhide(inId, inIdTxt, inTxtHide, inTxtUnhide)
+ {
+ if ($('#'+inId).css("display") == "none") {
+ $('#'+inId).show(400);
+ $('#'+inIdTxt).attr("value", inTxtUnhide);
+ } else {
+ $('#'+inId).hide(400);
+ $('#'+inIdTxt).attr("value", inTxtHide);
+ }
+ }
+
{{ execution_stats }}
diff --git a/user_portal.php b/user_portal.php
index eb17ec6a5c..5dffb7b4f7 100755
--- a/user_portal.php
+++ b/user_portal.php
@@ -123,6 +123,36 @@ if ($load_dirs) {
';
}
+// @todo : replace $_configuration with setting parameter
+$displayMyCourseViewbySessionLink = (isset($_configuration['my_courses_view_by_session']) && $_configuration['my_courses_view_by_session']);
+
+if ($displayMyCourseViewbySessionLink) {
+ $htmlHeadXtra[] = '
+
+';
+}
+
/* Sniffing system */
//store posts to sessions
@@ -145,9 +175,27 @@ if (isset($_SESSION['sniff_navigator']) && $_SESSION['sniff_navigator']!="checke
$controller = new IndexManager(get_lang('MyCourses'));
-
// Main courses and session list
-$courses_and_sessions = $controller->return_courses_and_sessions($user_id);
+if (isset($_COOKIE['defaultMyCourseView'.$user_id]) && $_COOKIE['defaultMyCourseView'.$user_id] == IndexManager::VIEW_BY_SESSION && $displayMyCourseViewbySessionLink) {
+ $courses_and_sessions = $controller->returnCoursesAndSessionsViewBySession($user_id);
+ IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_SESSION, $user_id);
+} else {
+ $courses_and_sessions = $controller->return_courses_and_sessions($user_id);
+ IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_DEFAULT, $user_id);
+}
+
+// if teacher, session coach or admin, display the button to change te course view
+// @todo : replace $_configuration with setting parameter
+if ($displayMyCourseViewbySessionLink && (api_is_drh() || api_is_course_coach() || api_is_platform_admin() || api_is_session_admin() || api_is_teacher())) {
+ $courses_and_sessions = "
+
+ ".get_lang('myCoursesDefaultView')."
+ -
+
+ ".get_lang('myCoursesSessionView')."
+
".$courses_and_sessions;
+}
+
//Show the chamilo mascot
if (empty($courses_and_sessions) && !isset($_GET['history'])) {