Jelajahi Sumber

[svn r15828] Coachs can register users to the session and platform. (Added the platform setting validation ) (see FS#2700)

Julio Montoya 16 tahun lalu
induk
melakukan
e908568f66

+ 5 - 3
main/install/dokeos_main.sql

@@ -559,8 +559,8 @@ VALUES
 ('extendedprofile_registrationrequired', 'myteach', 'checkbox','User','false', 'ExtendedProfileRegistrationRequiredTitle','ExtendedProfileRegistrationRequiredComment', NULL, 'MyTeach'),
 ('extendedprofile_registrationrequired', 'mypersonalopenarea', 'checkbox','User','false', 'ExtendedProfileRegistrationRequiredTitle','ExtendedProfileRegistrationRequiredComment', NULL, 'MyPersonalOpenArea'),
 ('ldap_filled_tutor_field_value', NULL, 'textfield', 'LDAP', '', 'LDAPFilledTutorFieldValueTitle', 'LDAPFilledTutorFieldValueComment', NULL, ''),
-('registration','phone','textfield','User','false','RegistrationRequiredFormsTitle','RegistrationRequiredFormsComment',NULL,'Phone');
-
+('registration','phone','textfield','User','false','RegistrationRequiredFormsTitle','RegistrationRequiredFormsComment',NULL,'Phone'),
+('add_users_by_coach',NULL,'radio','Platform','false','AddUsersByCoachTitle','AddUsersByCoachComment',NULL,NULL);
 
 UNLOCK TABLES;
 /*!40000 ALTER TABLE settings_current ENABLE KEYS */;
@@ -698,7 +698,9 @@ VALUES
 ('ldap_version', '2', 'LDAPVersion2'),
 ('ldap_version', '3', 'LDAPVersion3'),
 ('visio_use_rtmpt','true','Yes'),
-('visio_use_rtmpt','false','No');
+('visio_use_rtmpt','false','No'),
+('add_users_by_coach', 'true', 'Yes'),
+('add_users_by_coach', 'false', 'No');
 
 UNLOCK TABLES;
 

+ 3 - 0
main/install/migrate-db-1.8.5-1.8.6-pre.sql

@@ -14,6 +14,9 @@
 -- xxMAINxx
 INSERT INTO settings_current (variable, subkey,type,category,selected_value,title,comment,scope,subkeytext)VALUES ('registration', 'phone', 'textfield', 'User', 'false', 'RegistrationRequiredFormsTitle','RegistrationRequiredFormsComment', NULL, 'Phone');
 ALTER TABLE php_session CHANGE session_value session_value MEDIUMTEXT NOT NULL;
+INSERT INTO settings_current (variable, subkey,type,category,selected_value,title,comment,scope,subkeytext)VALUES ('add_users_by_coach',NULL,'radio','Platform','false','AddUsersByCoachTitle','AddUsersByCoachComment',NULL,NULL);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('add_users_by_coach', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('add_users_by_coach', 'false', 'No');
 
 -- xxSTATSxx
 

+ 16 - 13
main/mySpace/course.php

@@ -43,21 +43,24 @@ function count_courses()
  //checking if the current coach is the admin coach
 $show_import_icon=false;
 
-if(!api_is_platform_admin())
-{
-	$sql = 'SELECT id_coach FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
-	$rs = api_sql_query($sql,__FILE__,__LINE__);
-	if(Database::result($rs,0,0)!=$_user['user_id'])	
-	{
-		api_not_allowed(true);  
-	}
-	else
-	{
-		$show_import_icon=true;	
-	}
+if (api_get_setting('add_users_by_coach')=='true')
+{
+	if(!api_is_platform_admin())
+	{
+		$sql = 'SELECT id_coach FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
+		$rs = api_sql_query($sql,__FILE__,__LINE__);
+		if(Database::result($rs,0,0)!=$_user['user_id'])	
+		{
+			api_not_allowed(true);  
+		}
+		else
+		{
+			$show_import_icon=true;	
+		}
+	}
 }
 
- Display :: display_header($nameTools);
+Display :: display_header($nameTools);
 
 
 // Database Table Definitions 

+ 2 - 2
main/mySpace/session.php

@@ -22,7 +22,7 @@
 ==============================================================================
 */
 /*
- * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
+ * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
  * Somes fixes by Julio Montoya
  */
 ob_start();
@@ -106,7 +106,7 @@ if($nb_sessions > 0)
 	echo '<div align="right">
 			<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
 			<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
-		  </div>';
+		  </div>';
 	$table = new SortableTable('tracking', 'count_sessions_coached');
 	$table -> set_header(0, get_lang('Title'));
 	$table -> set_header(1, get_lang('Status'));

+ 20 - 13
main/mySpace/user_import.php

@@ -239,7 +239,7 @@ function get_user_creator($users,$CourseList, $id_session)
 		{	
 			if ($creator_id != api_get_user_id())
 			{
-				$user['error'] = get_lang('UserAlreadyRegisterByOtherCreator');
+				$user['error'] = get_lang('UserAlreadyRegisteredByOtherCreator');
 				$errors[] = $user;
 			}
 		}	
@@ -579,22 +579,29 @@ if (!api_is_coach())
 }
 */
 //checking if the current coach is the admin coach
-if(!api_is_platform_admin())
+if (api_get_setting('add_users_by_coach')=='true')
 {
-	if (isset($_REQUEST['id_session']))
+	if(!api_is_platform_admin())
 	{
-		$id_session=$_REQUEST['id_session'];
-		$sql = 'SELECT id_coach FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
-		$rs = api_sql_query($sql,__FILE__,__LINE__);
-		if(mysql_result($rs,0,0)!=$_user['user_id'])	
+		if (isset($_REQUEST['id_session']))
 		{
-			api_not_allowed(true);  
+			$id_session=$_REQUEST['id_session'];
+			$sql = 'SELECT id_coach FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
+			$rs = api_sql_query($sql,__FILE__,__LINE__);
+			if(mysql_result($rs,0,0)!=$_user['user_id'])	
+			{
+				api_not_allowed(true);  
+			}
 		}
+		else
+		{
+				api_not_allowed(true);  
+		}	
 	}
-	else
-	{
-			api_not_allowed(true);  
-	}	
+}
+else
+{
+	api_not_allowed(true);  
 }
 
 set_time_limit(0);
@@ -642,7 +649,7 @@ if ($_POST['formSent'] AND $_FILES['import_file']['size'] !== 0)
 				header('Location: course.php?id_session='.$id_session.'&action=error_message&message='.urlencode(get_lang('NoSessionId')));
 			}
 		}
-	} 
+	}
 	else
 	{
 		header('Location: course.php?id_session='.$id_session.'&action=error_message&message='.urlencode(get_lang('NoUsersRead')));