diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index e83dc314b1..67a5d3d5b0 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -6007,3 +6007,13 @@ function api_check_user_access_to_legal($course_visibility) { $course_visibility_list = array(COURSE_VISIBILITY_OPEN_WORLD, COURSE_VISIBILITY_OPEN_PLATFORM); return in_array($course_visibility, $course_visibility_list) || api_is_drh(); } + +/** + * Checks if the global chat is enabled or not + * + * @return bool + */ +function api_is_global_chat_enabled(){ + $global_chat_is_enabled = !api_is_anonymous() && api_get_setting('allow_global_chat') == 'true' && api_get_setting('allow_social_tool') == 'true'; + return $global_chat_is_enabled; +} \ No newline at end of file diff --git a/main/inc/lib/online.inc.php b/main/inc/lib/online.inc.php index 00ddb2cd9c..f1bdd9096e 100644 --- a/main/inc/lib/online.inc.php +++ b/main/inc/lib/online.inc.php @@ -62,7 +62,7 @@ function online_logout($user_id = null, $logout_redirect = false) { } //Changing global chat status to offline - if (api_get_setting('allow_global_chat') == 'true') { + if (api_is_global_chat_enabled()) { $chat = new Chat(); $chat->set_user_status(0); } diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index e8122b99e8..2eef6e2100 100644 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -664,7 +664,7 @@ class SocialManager extends UserManager { } //@todo check if user is online and if it's a friend to show the chat link - if (api_get_setting('allow_global_chat') == 'true' && $user_friend_relation == USER_RELATION_TYPE_FRIEND) { + if (api_is_global_chat_enabled() && $user_friend_relation == USER_RELATION_TYPE_FRIEND) { if ($user_id != api_get_user_id()) { //Only show chat if I'm available to talk if ($current_user_info['user_is_online_in_chat'] == 1) { diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index daf4018b93..e005b01ea7 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -459,14 +459,13 @@ class Template { 'email_links.lib.js.php', 'bootstrap/bootstrap.js', ); - - if (api_get_setting('allow_global_chat') == 'true') { - if (!api_is_anonymous()) { - //Do not include the global chat in LP - if ($this->show_learnpath == false && $this->show_footer == true && $this->hide_global_chat == false) { - $js_files[] = 'chat/js/chat.js'; - } - } + + + if (api_is_global_chat_enabled()) { + //Do not include the global chat in LP + if ($this->show_learnpath == false && $this->show_footer == true && $this->hide_global_chat == false) { + $js_files[] = 'chat/js/chat.js'; + } } if (api_get_setting('accessibility_font_resize') == 'true') { @@ -487,8 +486,7 @@ class Template { $css_files = array( api_get_path(WEB_LIBRARY_PATH) . 'javascript/thickbox.css', - api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css', - //api_get_path(WEB_LIBRARY_PATH) . 'javascript/dtree/dtree.css', not used anymore + api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css' ); if ($this->show_learnpath) { @@ -496,7 +494,7 @@ class Template { $css_files[] = api_get_path(WEB_CSS_PATH) . $this->theme . '/scorm.css'; } - if (api_get_setting('allow_global_chat') == 'true') { + if (api_is_global_chat_enabled()) { $css_files[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css'; } @@ -596,7 +594,7 @@ class Template { $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&&uid='.api_get_user_id()); //Profile link - if (api_get_setting('allow_social_tool')=='true') { + if (api_get_setting('allow_social_tool') == 'true') { $profile_link = ''.get_lang('Profile').''; } else { $profile_link = ''.get_lang('Profile').'';