diff --git a/main/auth/courses.php b/main/auth/courses.php index 505106ee7f..561d7736b0 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); + } return get_lang('EnrollToCourseSuccessful'); } diff --git a/main/course_info/infocours.php b/main/course_info/infocours.php index 141f1d8fd8..7f8326a2d5 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('html',$linebreak); + $form->addElement('radio', 'email_alert_manager_on_new_doc', get_lang('WorkEmailAlert'), get_lang('WorkEmailAlertActivate'), 1); $form->addElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertDeactivate'), 0); $form -> addElement('html',$linebreak); @@ -259,6 +264,8 @@ $values['visibility'] = $_course['visibility']; $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'); // 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 @@ -305,6 +312,10 @@ 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' "; + api_sql_query($sql,__FILE__,__LINE__); + } if($update_values['email_alert_manager_on_new_doc'] != $values['email_alert_manager_on_new_doc']){ $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_doc']." WHERE variable = 'email_alert_manager_on_new_doc' "; api_sql_query($sql,__FILE__,__LINE__); diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index a77d70dea7..9dc7a55d52 100644 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -2018,6 +2018,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc course_setting table (courseinfo tool) ----------------------------------------------------------- */ + api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_tutor_on_new_user_in_course',0,'auth')", __FILE__, __LINE__); api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_manager_on_new_doc',0,'work')", __FILE__, __LINE__); api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_on_new_doc_dropbox',0,'dropbox')", __FILE__, __LINE__); api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_edit_agenda',0,'agenda')", __FILE__, __LINE__); diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 1ef1cba0a9..97abf8ec04 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -483,10 +483,16 @@ function api_get_course_path($course_code=null) { /** * Gets a course setting from the current course_setting table. Try always using integer values. * @param string The name of the setting we want from the table + * @param string Optional: course code * @return mixed The value of that setting in that table. Return -1 if not found. */ -function api_get_course_setting($setting_name) { - $table = Database::get_course_table(TABLE_COURSE_SETTING); +function api_get_course_setting($setting_name, $course_code = null) { + if (!empty($course_code)) { + $c = api_get_course_info($course_code); + $table = Database::get_course_table(TABLE_COURSE_SETTING,$c['dbName']); + } else { + $table = Database::get_course_table(TABLE_COURSE_SETTING); + } $setting_name = mysql_real_escape_string($setting_name); $sql = "SELECT * FROM $table WHERE variable = '$setting_name'"; $res = api_sql_query($sql,__FILE__,__LINE__); diff --git a/main/install/migrate-db-1.6.x-1.8.0-pre.sql b/main/install/migrate-db-1.6.x-1.8.0-pre.sql index c2eb8dd47f..78b2432564 100644 --- a/main/install/migrate-db-1.6.x-1.8.0-pre.sql +++ b/main/install/migrate-db-1.6.x-1.8.0-pre.sql @@ -309,6 +309,7 @@ UPDATE tool SET link = 'newscorm/lp_controller.php' WHERE link = 'scorm/scormdoc INSERT INTO tool(name,link,image,visibility,admin,address,added_tool,target,category) VALUES ('blog_management','blog/blog_admin.php','blog_admin.gif',0,'1','squaregrey.gif',0,'_self','admin'); INSERT INTO tool(name,link,image,visibility,admin,address,added_tool,target,category) VALUES ('survey','survey/survey_list.php','survey.gif',0,'1','',0,'_self','admin'); INSERT INTO tool(name,link,image,visibility,admin,address,added_tool,target,category) VALUES ('course_maintenance','course_info/maintenance.php','backup.gif',0,'1','',0,'_self', 'admin'); +INSERT INTO course_setting(variable,value,category) VALUES ('email_alert_tutor_on_new_user_in_course',0,'auth'); INSERT INTO course_setting(variable,value,category) VALUES ('email_alert_manager_on_new_doc',0,'work'); INSERT INTO course_setting(variable,value,category) VALUES ('email_alert_on_new_doc_dropbox',0,'dropbox'); INSERT INTO course_setting(variable,value,category) VALUES ('allow_user_edit_agenda',0,'agenda');