diff --git a/index.php b/index.php index 8044d059fa..ed04ff91c9 100755 --- a/index.php +++ b/index.php @@ -1,11 +1,12 @@ logout($redirect); } - -/* Table definitions */ - -/* Constants and CONFIGURATION parameters */ -/** @todo these configuration settings should move to the Chamilo config settings. */ - -/** Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world. */ -$_setting['display_courses_to_anonymous_users'] = 'true'; - -/* LOGIN */ - /** * Registers in the track_e_default table (view in important activities in admin * interface) a possible attempted break in, sending auth data through get. @@ -65,7 +55,7 @@ if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) { } // Delete session item necessary to check for legal terms -if (api_get_setting('allow_terms_conditions') == 'true') { +if (api_get_setting('allow_terms_conditions') === 'true') { Session::erase('term_and_condition'); } //If we are not logged in and customapages activated @@ -87,28 +77,26 @@ if (!api_get_user_id() && CustomPages::enabled()) { if (!empty($_POST['submitAuth'])) { // The user has been already authenticated, we are now to find the last login of the user. if (isset ($_user['user_id'])) { - $track_login_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); - $sql_last_login = "SELECT UNIX_TIMESTAMP(login_date) - FROM $track_login_table - WHERE login_user_id = '".$_user['user_id']."' - ORDER BY login_date DESC LIMIT 1"; - $result_last_login = Database::query($sql_last_login); + $track_login_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); + $sql = "SELECT UNIX_TIMESTAMP(login_date) + FROM $track_login_table + WHERE login_user_id = '".$_user['user_id']."' + ORDER BY login_date DESC LIMIT 1"; + $result_last_login = Database::query($sql); if (!$result_last_login) { if (Database::num_rows($result_last_login) > 0) { $user_last_login_datetime = Database::fetch_array($result_last_login); $user_last_login_datetime = $user_last_login_datetime[0]; - Session::write('user_last_login_datetime',$user_last_login_datetime); + Session::write('user_last_login_datetime', $user_last_login_datetime); } } - //Event::event_login(); } - // End login -- if ($_POST['submitAuth']) } else { // Only if login form was not sent because if the form is sent the user was already on the page. Event::event_open(); } -if (api_get_setting('display_categories_on_homepage') == 'true') { +if (api_get_setting('display_categories_on_homepage') === 'true') { $controller->tpl->assign('course_category_block', $controller->return_courses_in_categories()); } @@ -175,7 +163,7 @@ if (isset($_GET['firstpage'])) { api_set_firstpage_parameter($_GET['firstpage']); // if we are already logged, go directly to course if (api_user_is_login()) { - echo ""; + echo ""; } } else { api_delete_firstpage_parameter(); diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 8757009e02..f1e2601c5d 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1655,16 +1655,25 @@ function api_get_cidreq($addSessionId = true, $addGroupId = true) return $url; } +/** + * get gradebook in session + */ function api_is_in_gradebook() { return Session::read('in_gradebook', false); } +/** + * set gradebook session + */ function api_set_in_gradebook() { Session::write('in_gradebook', true); } +/** + * remove gradebook session + */ function api_remove_in_gradebook() { Session::erase('in_gradebook'); diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 7c29d3674c..31c522e3e3 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -41,7 +41,7 @@ class IndexManager } }*/ - if (api_get_setting('show_documents_preview') == 'true') { + if (api_get_setting('show_documents_preview') === 'true') { $this->load_directories_preview = true; } } @@ -55,11 +55,14 @@ class IndexManager $this->tpl->setLoginForm($setLoginForm); } + /** + * @param array $personal_course_list + */ function return_exercise_block($personal_course_list) { $exercise_list = array(); if (!empty($personal_course_list)) { - foreach($personal_course_list as $course_item) { + foreach ($personal_course_list as $course_item) { $course_code = $course_item['c']; $session_id = $course_item['id_session']; @@ -68,7 +71,7 @@ class IndexManager $session_id ); - foreach($exercises as $exercise_item) { + foreach ($exercises as $exercise_item) { $exercise_item['course_code'] = $course_code; $exercise_item['session_id'] = $session_id; $exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC'); @@ -79,14 +82,21 @@ class IndexManager if (!empty($exercise_list)) { $exercise_list = msort($exercise_list, 'tms'); $my_exercise = $exercise_list[0]; - $url = Display::url($my_exercise['title'], api_get_path(WEB_CODE_PATH).'exercise/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id']); + $url = Display::url( + $my_exercise['title'], + api_get_path(WEB_CODE_PATH).'exercise/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id'] + ); $this->tpl->assign('exercise_url', $url); $this->tpl->assign('exercise_end_date', api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT)); } } } - function return_announcements($show_slide = true) + /** + * @param bool $show_slide + * @return null|string + */ + public function return_announcements($show_slide = true) { //// Display System announcements $hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected'); @@ -131,7 +141,7 @@ class IndexManager * Alias for the online_logout() function * @param bool $redirect Whether to ask online_logout to redirect to index.php or not */ - function logout($redirect = true) + public function logout($redirect = true) { online_logout($this->user_id, true); } @@ -142,7 +152,7 @@ class IndexManager * @param string $category * @return boolean */ - function category_has_open_courses($category) + public function category_has_open_courses($category) { $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); @@ -164,7 +174,7 @@ class IndexManager return false; } - function return_teacher_link() + public function return_teacher_link() { $html = ''; $show_menu = false; diff --git a/main/user/add_users_to_session.php b/main/user/add_users_to_session.php index bd89e4b20f..c3f8c51c40 100755 --- a/main/user/add_users_to_session.php +++ b/main/user/add_users_to_session.php @@ -197,7 +197,6 @@ if ($allowTutors == 'true') { $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return)); } else { - global $nosessionUsersList; $return .= ' - -
@@ -610,7 +608,6 @@ if ($allowTutors == 'true') {
+ $htmlHeadXtra[] = '