Эх сурвалжийг харах

Adding admin setting to the global chat see #3565

Julio Montoya 13 жил өмнө
parent
commit
87bea5e5c6

+ 4 - 0
main/inc/ajax/chat.ajax.php

@@ -14,6 +14,10 @@ if (api_is_anonymous()) {
 	exit;
 }
 
+if (api_get_setting('allow_global_chat') == 'false') {
+	exit;	
+}
+
 $to_user_id = intval($_REQUEST['to']);
 $message = $_REQUEST['message'];
 

+ 5 - 4
main/inc/header.inc.php

@@ -143,10 +143,11 @@ if ($navigator_info['name']=='Internet Explorer' &&  $navigator_info['version']=
 <meta name="Generator" content="<?php echo $_configuration['software_name'].' '.substr($_configuration['system_version'],0,1);?>" />
 <script src= "<?php echo api_get_path(WEB_LIBRARY_PATH);?>javascript/jquery.menu.js" type="text/javascript"></script>
 
-
-<script src="<?php echo api_get_path(WEB_LIBRARY_PATH);?>javascript/chat/js/chat.js" type="text/javascript" ></script>
-<link rel="stylesheet" href="<?php echo api_get_path(WEB_LIBRARY_PATH);?>javascript/chat/css/chat.css" type="text/css" media="projection, screen" />
-<link rel="stylesheet" href="<?php echo api_get_path(WEB_LIBRARY_PATH);?>javascript/chat/css/screen.css" type="text/css" media="projection, screen" />
+<?php if (api_get_setting('allow_global_chat') == 'true') { ?>
+	<script src="<?php echo api_get_path(WEB_LIBRARY_PATH);?>javascript/chat/js/chat.js" type="text/javascript" ></script>
+	<link rel="stylesheet" href="<?php echo api_get_path(WEB_LIBRARY_PATH);?>javascript/chat/css/chat.css" type="text/css" media="projection, screen" />
+	<link rel="stylesheet" href="<?php echo api_get_path(WEB_LIBRARY_PATH);?>javascript/chat/css/screen.css" type="text/css" media="projection, screen" />
+<?php } ?>
 
 <script type="text/javascript">
 //<![CDATA[

+ 5 - 3
main/inc/lib/social.lib.php

@@ -700,9 +700,11 @@ class SocialManager extends UserManager {
 	  		}
 			
 			//@todo check if user is online to show the chat link
-			if ($user_id != api_get_user_id()) {
-				$user_name  =$user_info['complete_name'];				
-				echo  Display::tag('li', Display::url(Display::return_icon('chat.gif').get_lang('Chat'), 'javascript:void(0);', array('onclick' => "javascript:chatWith('".$user_id."', '".Security::remove_XSS($user_name)."')")));
+			if (api_get_setting('allow_global_chat') == 'true') {
+				if ($user_id != api_get_user_id()) {
+					$user_name  = $user_info['complete_name'];				
+					echo  Display::tag('li', Display::url(Display::return_icon('chat.gif').get_lang('Chat'), 'javascript:void(0);', array('onclick' => "javascript:chatWith('".$user_id."', '".Security::remove_XSS($user_name)."')")));
+				}
 			}
 	  		echo '</ul></div>';
 

+ 2 - 3
main/inc/lib/template.lib.php

@@ -261,7 +261,7 @@ class Template extends Smarty {
 			'bootstrap/bootstrap-dropdown.js'			
 		);
 		
-		if (1) {
+		if (api_get_setting('allow_global_chat') == 'true') {
 			$js_files[] = 'chat/js/chat.js';
 		}
 		
@@ -291,11 +291,10 @@ class Template extends Smarty {
 			$css_files[] = api_get_path(WEB_CSS_PATH).$my_style.'/learnpath.css';
 		}
 		
-		if (1) {
+		if (api_get_setting('allow_global_chat') == 'true') {
 			$css_files[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chat/css/chat.css';
 		}
 		
-		
 		$css_file_to_string = '';
 		foreach($css_files  as $css_file) {
 			$css_file_to_string .= api_get_css($css_file);

+ 4 - 1
main/install/db_main.sql

@@ -856,6 +856,7 @@ VALUES
 ('grading_model', 'grading_model', 'custom', 'Gradebook', 'false', 'GradingModelTitle', 'GradingModelComment', NULL, NULL, 1),
 ('allow_users_to_change_email_with_no_password', NULL, 'radio', 'User', 'false', 'AllowUsersToChangeEmailWithNoPasswordTitle', 'AllowUsersToChangeEmailWithNoPasswordComment', NULL, NULL, 0),
 ('show_admin_toolbar', NULL, 'radio', 'Platform', 'show_to_admin', 'ShowAdminToolbarTitle', 'ShowAdminToolbarComment', NULL, NULL, 1),
+('allow_global_chat', NULL, 'radio', 'Platform', 'true', 'AllowGlobalChatTitle', 'AllowGlobalChatComment', NULL, NULL, 1),
 ('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.16427','DokeosDatabaseVersion','', NULL, NULL, 0);
 
 /*
@@ -1168,7 +1169,9 @@ VALUES
 ('show_admin_toolbar', 'do_not_show', 'DoNotShow'),
 ('show_admin_toolbar', 'show_to_admin', 'ShowToAdminsOnly'), 
 ('show_admin_toolbar', 'show_to_admin_and_teachers', 'ShowToAdminsAndTeachers'),
-('show_admin_toolbar', 'show_to_all', 'ShowToAllUsers');
+('show_admin_toolbar', 'show_to_all', 'ShowToAllUsers'),
+('allow_global_chat', 'true', 'Yes'),
+('allow_global_chat', 'false', 'No');
 
 /*
 ('use_custom_pages','true','Yes'),

+ 6 - 1
main/install/migrate-db-1.8.8-1.9.0-pre.sql

@@ -124,7 +124,6 @@ ALTER TABLE gradebook_category MODIFY COLUMN weight FLOAT NOT NULL;
 ALTER TABLE gradebook_link MODIFY COLUMN weight FLOAT  NOT NULL;
 
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_hr_skills_management', NULL, 'radio', 'Gradebook', 'true', 'AllowHRSkillsManagementTitle', 'AllowHRSkillsManagementComment', NULL, NULL, 1);
-
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_hr_skills_management', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_hr_skills_management', 'false', 'No');
 
@@ -136,6 +135,12 @@ INSERT INTO settings_options (variable, value, display_text) VALUES ('show_admin
 INSERT INTO settings_options (variable, value, display_text) VALUES ('show_admin_toolbar', 'show_to_all', 'ShowToAllUsers');
 
 
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_global_chat', NULL, 'radio', 'Platform', 'true', 'AllowGlobalChatTitle', 'AllowGlobalChatComment', NULL, NULL, 1);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_global_chat', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_global_chat', 'false', 'No');
+
+
+
 -- Course ranking
 
 CREATE TABLE track_course_ranking (id   int unsigned not null PRIMARY KEY AUTO_INCREMENT,c_id  int unsigned not null, session_id  int unsigned not null default 0, url_id  int unsigned not null default 0, accesses int unsigned not null default 0, total_score int unsigned not null default 0, users int unsigned not null default 0, creation_date datetime not null);