diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index b003b04cc3..86d6aef009 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -1446,28 +1446,17 @@ function api_get_cidreq($addSessionId = true, $addGroupId = true) } /** - * Returns the current course info array. - * Note: this array is only defined if the user is inside a course. - * Array elements: - * ['name'] - * ['official_code'] - * ['sysCode'] - * ['path'] - * ['dbName'] - * ['dbNameGlu'] - * ['titular'] - * ['language'] - * ['extLink']['url' ] - * ['extLink']['name'] - * ['categoryCode'] - * ['categoryName'] + * Returns the current course info array see api_format_course_array() + * If the course_code is given, the returned array gives info about that + * particular course, if none given it gets the course info from the session. * - * Now if the course_code is given, the returned array gives info about that - * particular course, not specially the current one. - * @param string Course code - * @todo Same behaviour as api_get_user_info so that api_get_course_id becomes obsolete too. + * @param string $course_code + * @param bool $strict + * + * @return array */ -function api_get_course_info($course_code = null, $strict = false) { +function api_get_course_info($course_code = null, $strict = false) +{ if (!empty($course_code)) { $course_code = Database::escape_string($course_code); $course_table = Database::get_main_table(TABLE_MAIN_COURSE); @@ -1486,7 +1475,9 @@ function api_get_course_info($course_code = null, $strict = false) { return $_course; } global $_course; - if ($_course == '-1') $_course = array(); + if ($_course == '-1') { + $_course = array(); + } return $_course; } diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 1659dfb46f..81fd0b056a 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -3468,20 +3468,32 @@ class SessionManager } /** + * Protect a session to be edited. * @param int $id */ static function protect_session_edit($id) { api_protect_admin_script(true); $session_info = self::fetch($id); - if (!api_is_platform_admin() && api_get_setting('allow_session_admins_to_manage_all_sessions') != 'true') { + + if (empty($session_info)) { + api_not_allowed(true); + } + if (!api_is_platform_admin() && + api_get_setting('allow_session_admins_to_manage_all_sessions') != 'true' + ) { if ($session_info['session_admin_id'] != api_get_user_id()) { api_not_allowed(true); } } } - static function protect_teacher_session_edit($id) { + /** + * @param $id + * @return bool + */ + static function protect_teacher_session_edit($id) + { if (!api_is_coach($id) && !api_is_platform_admin()) { api_not_allowed(true); } else {