diff --git a/main/auth/courses.php b/main/auth/courses.php
index 561d7736b0..f3f5b70a80 100644
--- a/main/auth/courses.php
+++ b/main/auth/courses.php
@@ -1,4 +1,4 @@
- 0) {
- CourseManager::email_to_tutor($_user['user_id'],$course_code);
+ $send = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course',$course_code);
+ if ($send == 1) {
+ CourseManager::email_to_tutor($_user['user_id'],$course_code,$send_to_tutor_also=false);
+ } else if ($send == 2){
+ CourseManager::email_to_tutor($_user['user_id'],$course_code,$send_to_tutor_also=true);
}
return get_lang('EnrollToCourseSuccessful');
diff --git a/main/course_info/infocours.php b/main/course_info/infocours.php
index 7f8326a2d5..57e19e4add 100644
--- a/main/course_info/infocours.php
+++ b/main/course_info/infocours.php
@@ -1,4 +1,4 @@
-add_textfield('course_registration_password', get_lang('CourseRegistratio
$form->addElement('html','
'.get_lang('EmailNotifications').'
');
-$form->addElement('radio', 'email_alert_tutor_on_new_user_in_course', get_lang('NewUserEmailAlert'), get_lang('NewUserEmailAlertActivate'), 1);
-$form->addElement('radio', 'email_alert_tutor_on_new_user_in_course', null, get_lang('NewUserEmailAlertDeactivate'), 0);
+$form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', get_lang('NewUserEmailAlert'), get_lang('NewUserEmailAlertEnable'), 1);
+$form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null,get_lang('NewUserEmailAlertToTeacharAndTutor'),2);
+$form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null, get_lang('NewUserEmailAlertDisable'), 0);
$form -> addElement('html',$linebreak);
$form->addElement('radio', 'email_alert_manager_on_new_doc', get_lang('WorkEmailAlert'), get_lang('WorkEmailAlertActivate'), 1);
@@ -265,7 +266,7 @@ $values['subscribe'] = $course_access_settings['subscribe'];
$values['unsubscribe'] = $course_access_settings['unsubscribe'];
$values['course_registration_password'] = $all_course_information['registration_code'];
// get send_mail_setting (auth)from table
-$values['email_alert_tutor_on_new_user_in_course'] = api_get_course_setting('email_alert_tutor_on_new_user_in_course');
+$values['email_alert_to_teacher_on_new_user_in_course'] = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course');
// get send_mail_setting (work)from table
$values['email_alert_manager_on_new_doc'] = api_get_course_setting('email_alert_manager_on_new_doc');
// get send_mail_setting (dropbox) from table
@@ -312,8 +313,8 @@ if ($form->validate() && is_settings_editable())
//update course_settings table - this assumes those records exist, otherwise triggers an error
$table_course_setting = Database::get_course_table(TABLE_COURSE_SETTING);
- if($update_values['email_alert_tutor_on_new_user_in_course'] != $values['email_alert_tutor_on_new_user_in_course']){
- $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_tutor_on_new_user_in_course']." WHERE variable = 'email_alert_tutor_on_new_user_in_course' ";
+ if($update_values['email_alert_to_teacher_on_new_user_in_course'] != $values['email_alert_to_teacher_on_new_user_in_course']){
+ $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_to_teacher_on_new_user_in_course']." WHERE variable = 'email_alert_to_teacher_on_new_user_in_course' ";
api_sql_query($sql,__FILE__,__LINE__);
}
if($update_values['email_alert_manager_on_new_doc'] != $values['email_alert_manager_on_new_doc']){
diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php
index 5e29fbbb2f..b77a7a3d97 100644
--- a/main/inc/lib/add_course.lib.inc.php
+++ b/main/inc/lib/add_course.lib.inc.php
@@ -2008,7 +2008,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('course_theme','','theme')", __FILE__, __LINE__);
api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_learning_path_theme','1','theme')", __FILE__, __LINE__);
api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_open_chat_window',0,'chat')", __FILE__, __LINE__);
- api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_tutor_on_new_user_in_course',0,'registration')", __FILE__, __LINE__);
+ api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_to_teacher_on_new_user_in_course',0,'registration')", __FILE__, __LINE__);
/*
-----------------------------------------------------------
Course homepage tools for platform admin only
diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php
index 00a148051d..5d39d2101b 100644
--- a/main/inc/lib/course.lib.php
+++ b/main/inc/lib/course.lib.php
@@ -1830,9 +1830,10 @@ class CourseManager
* @author Carlos Vargas , Dokeos Latino
* @param int $user_id the id of the user
* @param string $course_code the course code
+ * @param string $send_to_tutor_also
* @return string we return the message that is displayed when the action is succesfull
*/
- function email_to_tutor($user_id,$course_code) {
+ function email_to_tutor($user_id,$course_code,$send_to_tutor_also=false) {
$TABLECOURS=Database::get_main_table(TABLE_MAIN_COURSE);
$TABLE_USER= Database::get_main_table(TABLE_MAIN_USER);
@@ -1842,10 +1843,16 @@ class CourseManager
$student = Database::fetch_array($result_me);
$information = CourseManager::get_course_information($course_code);
$name_course=$information['title'];
- $sql="SELECT * FROM ".$TABLECOURSUSER." WHERE course_code='".$course_code."' AND tutor_id=1";
+ $sql="SELECT * FROM ".$TABLECOURSUSER." WHERE course_code='".$course_code."'";
+ if($send_to_tutor_also=true){
+ $sql.=" AND tutor_id=1";
+ } else {
+ $sql.=" AND status=1";
+ }
+
$result = api_sql_query($sql,__FILE__,__LINE__);
while ($row = Database::fetch_array($result)) {
- $sql_tutor="SELECT * FROM ".$TABLE_USER." WHERE user_id='".$row['user_id']."'";
+ $sql_tutor="SELECT * FROM ".$TABLE_USER." WHERE user_id='".$row['user_id']."'";
$result_tutor=api_sql_query($sql_tutor,__FILE__,__LINE__);
$tutor=Database::fetch_array($result_tutor);
$emailto = $tutor['email'];
diff --git a/main/install/migrate-db-1.8.5-1.8.6-pre.sql b/main/install/migrate-db-1.8.5-1.8.6-pre.sql
index 2aa31ca93f..7749110f4e 100644
--- a/main/install/migrate-db-1.8.5-1.8.6-pre.sql
+++ b/main/install/migrate-db-1.8.5-1.8.6-pre.sql
@@ -143,4 +143,5 @@ CREATE TABLE calendar_event_attachment ( id int NOT NULL auto_increment, path va
ALTER TABLE glossary ADD display_order int;
CREATE TABLE calendar_event_attachment ( id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, agenda_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id) );
CREATE TABLE notebook (notebook_id int unsigned NOT NULL auto_increment,user_id int unsigned NOT NULL,course varchar(40) not null,session_id int NOT NULL default 0,title varchar(255) NOT NULL,description text NOT NULL,creation_date datetime NOT NULL default '0000-00-00 00:00:00',update_date datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY (notebook_id));
-INSERT INTO course_setting(variable,value,category) VALUES ('allow_open_chat_window',0,'chat');
\ No newline at end of file
+INSERT INTO course_setting(variable,value,category) VALUES ('allow_open_chat_window',0,'chat');
+INSERT INTO course_setting(variable,value,category) VALUES ('email_alert_to_teacher_on_new_user_in_course',0,'registration');
\ No newline at end of file