From 56f4a780ad242cd2ff3d930e01ca8c370157cd85 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 25 Feb 2014 18:39:54 +0100 Subject: [PATCH] Adding option $_configuration['show_simple_session_info'] see BT#6735 --- main/inc/lib/course.lib.php | 36 +++++++++++++++++++ main/inc/lib/userportal.lib.php | 64 +++++++++++++++++++++------------ 2 files changed, 77 insertions(+), 23 deletions(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 99ce95c061..9d9becc994 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -3083,6 +3083,42 @@ class CourseManager return self::course_code_exists($wanted_course_code); } + /** + * Builds the course block in user_portal.php + * @todo use Twig + */ + public static function course_item_html_no_icon($params) + { + $html = '
'; + $html .= '
'; + $html .= '
'; + + $notifications = isset($params['notifications']) ? $params['notifications'] : null; + + $html .='

'.$params['title'].$notifications.'

'; + + if (isset($params['description'])) { + $html .= '

'.$params['description'].'

'; + } + if (!empty($params['subtitle'])) { + $html .= ''.$params['subtitle'].''; + } + if (!empty($params['teachers'])) { + $html .= '
'.Display::return_icon('teacher.png', get_lang('Teacher'), array(), ICON_SIZE_TINY).$params['teachers'].'
'; + } + if (!empty($params['coaches'])) { + $html .= '
'.Display::return_icon('teacher.png', get_lang('Coach'), array(), ICON_SIZE_TINY).$params['coaches'].'
'; + } + + $html .= '
'; + $params['right_actions'] = isset($params['right_actions']) ? $params['right_actions'] : null; + $html .= '
'.$params['right_actions'].'
'; + $html .= '
'; + $html .= '
'; + return $html; + } + + /** * Builds the course block in user_portal.php * @todo use Twig diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 3d66a44bd8..3984a9f5d5 100644 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -3,25 +3,30 @@ use \ChamiloSession as Session; -class IndexManager { - var $tpl = false; //An instance of the template engine - var $name = ''; - - var $home = ''; - var $default_home = 'home/'; - - function __construct($title) { - $this->tpl = new Template($title); - $this->home = api_get_home_path(); - $this->user_id = api_get_user_id(); - $this->load_directories_preview = false; +class IndexManager +{ + //An instance of the template engine + public $tpl = false; + public $name = ''; + public $home = ''; + public $default_home = 'home/'; + + public function __construct($title) + { + $this->tpl = new Template($title); + $this->home = api_get_home_path(); + $this->user_id = api_get_user_id(); + $this->load_directories_preview = false; - if (api_get_setting('show_documents_preview') == 'true') { - $this->load_directories_preview = true; - } - } + if (api_get_setting('show_documents_preview') == 'true') { + $this->load_directories_preview = true; + } + } - function set_login_form($setLoginForm = true) + /** + * @param bool $setLoginForm + */ + function set_login_form($setLoginForm = true) { global $loginFailed; @@ -55,8 +60,8 @@ class IndexManager { } } - - function return_exercise_block($personal_course_list) { + function return_exercise_block($personal_course_list) + { require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; $exercise_list = array(); if (!empty($personal_course_list)) { @@ -937,6 +942,8 @@ class IndexManager { * */ function return_courses_and_sessions($user_id) { + global $_configuration; + $load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false; if ($load_history) { @@ -1038,9 +1045,7 @@ class IndexManager { if ($count_courses_session > 0) { $params = array(); - $session_box = Display::get_session_title_box($session_id); - $params['icon'] = Display::return_icon('window_list.png', $session_box['title'], array('id' => 'session_img_'.$session_id), ICON_SIZE_LARGE); $extra_info = !empty($session_box['coach']) ? $session_box['coach'] : null; $extra_info .= !empty($session_box['coach']) ? ' - '.$session_box['dates'] : $session_box['dates']; @@ -1067,7 +1072,14 @@ class IndexManager { } $params['description'] = isset($session_box['description']) ? $session_box['description'] : null; - $sessions_with_no_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_courses_session); + + $parentInfo = CourseManager::course_item_html($params, true); + + if (isset($_configuration['show_simple_session_info']) && $_configuration['show_simple_session_info']) { + $params['title'] = $session_box['title']; + $parentInfo = CourseManager::course_item_html_no_icon($params); + } + $sessions_with_no_category .= CourseManager::course_item_parent($parentInfo, $html_courses_session); } } } else { @@ -1140,7 +1152,13 @@ class IndexManager { $params['right_actions'] .= ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).''; } - $html_sessions .= CourseManager::course_item_html($params, true).$html_courses_session; + $parentInfo = CourseManager::course_item_html($params, true); + if (isset($_configuration['show_simple_session_info']) && $_configuration['show_simple_session_info']) { + $params['title'] = $session_box['title']; + $parentInfo = CourseManager::course_item_html_no_icon($params); + } + + $html_sessions .= $parentInfo.$html_courses_session; } }