infocours.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Code to display the course settings form (for the course admin)
  5. * and activate the changes.
  6. *
  7. * See ./inc/conf/course_info.conf.php for settings
  8. * @todo Move $canBeEmpty from course_info.conf.php to config-settings
  9. * @todo Take those config settings into account in this script
  10. * @author Patrick Cool <patrick.cool@UGent.be>
  11. * @author Roan Embrechts, refactoring
  12. * and improved course visibility|subscribe|unsubscribe options
  13. * @package chamilo.course_info
  14. */
  15. /* INIT SECTION */
  16. // Language files that need to be included
  17. $language_file = array('create_course', 'course_info', 'admin');
  18. require_once '../inc/global.inc.php';
  19. $this_section = SECTION_COURSES;
  20. $nameTools = get_lang('ModifInfo');
  21. /* Libraries */
  22. require_once api_get_path(INCLUDE_PATH).'conf/course_info.conf.php';
  23. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  24. require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';
  25. /* Constants and variables */
  26. define('MODULE_HELP_NAME', 'Settings');
  27. define('COURSE_CHANGE_PROPERTIES', 'COURSE_CHANGE_PROPERTIES');
  28. $TABLECOURSE = Database :: get_main_table(TABLE_MAIN_COURSE);
  29. $TABLEFACULTY = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  30. $TABLELANGUAGES = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
  31. $currentCourseID = $_course['sysCode'];
  32. $currentCourseRepository = $_course['path'];
  33. $is_allowedToEdit = $is_courseAdmin || $is_platformAdmin;
  34. $course_code = $_course['sysCode'];
  35. $course_access_settings = CourseManager :: get_access_settings($course_code);
  36. //LOGIC FUNCTIONS
  37. function is_settings_editable() {
  38. return $GLOBALS['course_info_is_editable'];
  39. }
  40. /* MAIN CODE */
  41. if (!$is_allowedToEdit) {
  42. api_not_allowed(true);
  43. }
  44. $show_delete_watermark_text_message = false;
  45. if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
  46. if (isset($_GET['delete_watermark'])) {
  47. PDF::delete_watermark($course_code);
  48. $show_delete_watermark_text_message = true;
  49. }
  50. }
  51. $table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  52. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  53. $tbl_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
  54. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  55. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  56. // Get all course categories
  57. $sql = "SELECT code,name FROM ".$table_course_category." WHERE auth_course_child ='TRUE' OR code = '".Database::escape_string($_course['categoryCode'])."' ORDER BY tree_pos";
  58. $res = Database::query($sql);
  59. $s_select_course_tutor_name = "SELECT tutor_name FROM $tbl_course WHERE code='$course_code'";
  60. $q_tutor = Database::query($s_select_course_tutor_name);
  61. $s_tutor = Database::result($q_tutor, 0, 'tutor_name');
  62. $target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
  63. $s_sql_course_titular = "SELECT DISTINCT username, lastname, firstname FROM $tbl_user as user, $tbl_course_user as course_rel_user WHERE (course_rel_user.status='1') AND user.user_id=course_rel_user.user_id AND course_code='".$course_code."' ORDER BY ".$target_name." ASC";
  64. $q_result_titulars = Database::query($s_sql_course_titular);
  65. if (Database::num_rows($q_result_titulars) == 0) {
  66. $sql = "SELECT username, lastname, firstname FROM $tbl_user as user, $tbl_admin as admin WHERE admin.user_id=user.user_id ORDER BY ".$target_name." ASC";
  67. $q_result_titulars = Database::query($sql);
  68. }
  69. $a_profs[0] = '-- '.get_lang('NoManager').' --';
  70. while ($a_titulars = Database::fetch_array($q_result_titulars)) {
  71. $s_username = $a_titulars['username'];
  72. $s_lastname = $a_titulars['lastname'];
  73. $s_firstname = $a_titulars['firstname'];
  74. if (api_get_person_name($s_firstname, $s_lastname) == $s_tutor) {
  75. $s_selected_tutor = api_get_person_name($s_firstname, $s_lastname);
  76. }
  77. $s_disabled_select_titular = '';
  78. if (!$is_courseAdmin) {
  79. $s_disabled_select_titular = 'disabled=disabled';
  80. }
  81. $a_profs[api_get_person_name($s_firstname, $s_lastname)] = api_get_person_name($s_lastname, $s_firstname).' ('.$s_username.')';
  82. }
  83. while ($cat = Database::fetch_array($res)) {
  84. $categories[$cat['code']] = '('.$cat['code'].') '.$cat['name'];
  85. ksort($categories);
  86. }
  87. $linebreak = '<div class="row"><div class="label"></div><div class="formw" style="border-bottom:1px dashed grey"></div></div>';
  88. // Build the form
  89. $form = new FormValidator('update_course');
  90. // COURSE SETTINGS
  91. //$form->addElement('html', '<div class="sectiontitle"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="coursesettings" id="coursesettings"></a>'.Display::return_icon('settings.png', get_lang('CourseSettings'),'','22').' '.get_lang('CourseSettings').'</div>');
  92. $form->addElement('html', '<div> <h3>'.Display::return_icon('settings.png', get_lang('CourseSettings'),'','22').' '.get_lang('CourseSettings').'</h3><div>');
  93. $image_html = '';
  94. // Sending image
  95. if ($form->validate() && is_settings_editable()) {
  96. // update course picture
  97. $picture = $_FILES['picture'];
  98. if (!empty($picture['name'])) {
  99. $picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']);
  100. }
  101. }
  102. // Display course picture
  103. $course_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository; // course path
  104. if (file_exists($course_path.'/course-pic85x85.png')) {
  105. $course_web_path = api_get_path(WEB_COURSE_PATH).$currentCourseRepository; // course web path
  106. $course_medium_image = $course_web_path.'/course-pic85x85.png?'.rand(1,1000); // redimensioned image 85x85
  107. $image_html = '<div class="row"><div class="formw"><img src="'.$course_medium_image.'" /></div></div>';
  108. }
  109. $form->addElement('html', $image_html);
  110. $visual_code=$form->addElement('text', 'visual_code', get_lang('Code'));
  111. $visual_code->freeze();
  112. $form->applyFilter('visual_code', 'strtoupper');
  113. //$form->add_textfield('tutor_name', get_lang('Professors'), true, array ('size' => '60'));
  114. $prof = &$form->addElement('select', 'tutor_name', get_lang('Teacher'), $a_profs, array('style'=>'width:350px', 'class'=>'chzn-select', 'id'=>'tutor_name'));
  115. $form->applyFilter('tutor_name', 'html_filter');
  116. $prof -> setSelected($s_selected_tutor);
  117. $form->add_textfield('title', get_lang('Title'), true, array('size' => '60'));
  118. //$form->applyFilter('title', 'html_filter');
  119. $form->applyFilter('title', 'trim');
  120. $form->addElement('select', 'category_code', get_lang('Fac'), $categories, array('style'=>'width:350px', 'class'=>'chzn-select', 'id'=>'category_code'));
  121. $form->add_textfield('department_name', get_lang('Department'), false, array('size' => '60'));
  122. //$form->applyFilter('department_name', 'html_filter');
  123. $form->applyFilter('department_name', 'trim');
  124. $form->add_textfield('department_url', get_lang('DepartmentUrl'), false, array('size' => '60'));
  125. //$form->applyFilter('department_url', 'html_filter');
  126. $form->addRule('tutor_name', get_lang('ThisFieldIsRequired'), 'required');
  127. $form->addElement('select_language', 'course_language', get_lang('Ln'));
  128. $form->addElement('static', null, '&nbsp;', get_lang('TipLang'));
  129. // Picture
  130. $form->addElement('file', 'picture', get_lang('AddPicture'));
  131. $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
  132. $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
  133. if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
  134. $url = PDF::get_watermark($course_code);
  135. $form->add_textfield('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60'));
  136. $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
  137. if ($url != false) {
  138. $delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
  139. $form->addElement('html', '<div class="row"><div class="formw"><a href="'.$url.'">'.$url.' '.$delete_url.'</a></div></div>');
  140. }
  141. $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
  142. }
  143. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  144. $form->addElement('html', '</div></div>');
  145. // COURSE ACCESS
  146. //$form->addElement('html', '<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="coursesaccess" id="coursesaccess"></a>'.Display::return_icon('course.png', get_lang('CourseAccess'),'','22').' '.get_lang('CourseAccess').'</div>');
  147. $form->addElement('html', '<div> <h3>'.Display::return_icon('course.png', get_lang('CourseAccess'),'','22').' '.get_lang('CourseAccess').'</h3><div>');
  148. $form->addElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
  149. $form->addElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
  150. $form->addElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
  151. $form->addElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
  152. $form->addElement('static', null, null, get_lang("CourseAccessConfigTip"));
  153. $form->addElement('html', $linebreak);
  154. $form->addElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
  155. $form->addElement('radio', 'subscribe', null, get_lang('Denied'), 0);
  156. $form->addElement('html', $linebreak);
  157. $form->addElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
  158. $form->addElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
  159. $form->addElement('html', $linebreak);
  160. $form->add_textfield('course_registration_password', get_lang('CourseRegistrationPassword'), false, array('size' => '60'));
  161. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  162. $form->addElement('html', '</div></div>');
  163. // EMAIL NOTIFICATIONS
  164. //$form->addElement('html', '<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="emailnotifications" id="emailnotifications"></a>'.Display::return_icon('mail.png', get_lang('EmailNotifications'),'','22').' '.get_lang('EmailNotifications').'</div>');
  165. $form->addElement('html', '<div> <h3>'.Display::return_icon('mail.png', get_lang('EmailNotifications'),'','22').' '.get_lang('EmailNotifications').'</h3><div>');
  166. $form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', get_lang('NewUserEmailAlert'), get_lang('NewUserEmailAlertEnable'), 1);
  167. $form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null, get_lang('NewUserEmailAlertToTeacharAndTutor'), 2);
  168. $form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null, get_lang('NewUserEmailAlertDisable'), 0);
  169. $form->addElement('html', $linebreak);
  170. $form->addElement('radio', 'email_alert_students_on_new_homework', get_lang('NewHomeworkEmailAlert'), get_lang('NewHomeworkEmailAlertEnable'), 1);
  171. $form->addElement('radio', 'email_alert_students_on_new_homework', null, get_lang('NewHomeworkEmailAlertDisable'), 0);
  172. $form->addElement('html', $linebreak);
  173. $form->addElement('radio', 'email_alert_manager_on_new_doc', get_lang('WorkEmailAlert'), get_lang('WorkEmailAlertActivate'), 1);
  174. $form->addElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertDeactivate'), 0);
  175. $form->addElement('html', $linebreak);
  176. $form->addElement('radio', 'email_alert_on_new_doc_dropbox', get_lang('DropboxEmailAlert'), get_lang('DropboxEmailAlertActivate'), 1);
  177. $form->addElement('radio', 'email_alert_on_new_doc_dropbox', null, get_lang('DropboxEmailAlertDeactivate'), 0);
  178. $form->addElement('html', $linebreak);
  179. $form->addElement('radio', 'email_alert_manager_on_new_quiz', get_lang('QuizEmailAlert'), get_lang('QuizEmailAlertActivate'), 1);
  180. $form->addElement('radio', 'email_alert_manager_on_new_quiz', null, get_lang('QuizEmailAlertDeactivate'), 0);
  181. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  182. $form->addElement('html', '</div></div>');
  183. // USER RIGHTS
  184. //$form->addElement('html', '<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="userrights" id="userrights"></a>'.Display::return_icon('user.png', get_lang('UserRights'),'','22').' '.get_lang('UserRights').'</div>');
  185. $form->addElement('html', '<div> <h3>'.Display::return_icon('user.png', get_lang('UserRights'),'','22').' '.get_lang('UserRights').'</h3><div>');
  186. $form->addElement('radio', 'allow_user_edit_agenda', get_lang('AllowUserEditAgenda'), get_lang('AllowUserEditAgendaActivate'), 1);
  187. $form->addElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0);
  188. $form->addElement('html', $linebreak);
  189. $form->addElement('radio', 'allow_user_edit_announcement', get_lang('AllowUserEditAnnouncement'), get_lang('AllowUserEditAnnouncementActivate'), 1);
  190. $form->addElement('radio', 'allow_user_edit_announcement', null, get_lang('AllowUserEditAnnouncementDeactivate'), 0);
  191. $form->addElement('html', $linebreak);
  192. $form->addElement('radio', 'allow_user_image_forum', get_lang('AllowUserImageForum'), get_lang('AllowUserImageForumActivate'), 1);
  193. $form->addElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0);
  194. $form->addElement('html', $linebreak);
  195. $form->addElement('radio', 'allow_user_view_user_list', get_lang('AllowUserViewUserList'), get_lang('AllowUserViewUserListActivate'), 1);
  196. $form->addElement('radio', 'allow_user_view_user_list', null, get_lang('AllowUserViewUserListDeactivate'), 0);
  197. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  198. $form->addElement('html', '</div></div>');
  199. // CHAT SETTINGS
  200. //$form->addElement('html', '<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="chatsettings" id="chatsettings"></a>'.Display::return_icon('chat.png', get_lang('ConfigChat'),'','22').' '.get_lang('ConfigChat').'</div>');
  201. $form->addElement('html', '<div> <h3>'.Display::return_icon('chat.png', get_lang('ConfigChat'),'','22').' '.get_lang('ConfigChat').'</h3><div>');
  202. $form->addElement('radio', 'allow_open_chat_window', get_lang('AllowOpenchatWindow'), get_lang('AllowOpenChatWindowActivate'), 1);
  203. $form->addElement('radio', 'allow_open_chat_window', null, get_lang('AllowOpenChatWindowDeactivate'), 0);
  204. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  205. $form->addElement('html', '</div></div>');
  206. // LEARNING PATH
  207. //$form->addElement('html','<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="learnpath" id="learnpath"></a>'.Display::return_icon('scorms.png', get_lang('ConfigLearnpath'),'','22').' '.get_lang('ConfigLearnpath').'</div><div style="clear:both;"></div>');
  208. $form->addElement('html', '<div> <h3>'.Display::return_icon('scorms.png', get_lang('ConfigLearnpath'),'','22').' '.get_lang('ConfigLearnpath').'</h3><div>');
  209. //Auto launch LP
  210. $form->addElement('radio', 'enable_lp_auto_launch', get_lang('LPAutoLaunch'), get_lang('RedirectToALearningPath'), 1);
  211. $form->addElement('radio', 'enable_lp_auto_launch', get_lang('LPAutoLaunch'), get_lang('RedirectToTheLearningPathList'), 2);
  212. $form->addElement('radio', 'enable_lp_auto_launch', null, get_lang('Deactivate'), 0);
  213. $form -> addElement('html', $linebreak);
  214. if (api_get_setting('allow_course_theme') == 'true') {
  215. // Allow theme into Learning path
  216. $form->addElement('radio', 'allow_learning_path_theme', get_lang('AllowLearningPathTheme'), get_lang('AllowLearningPathThemeAllow'), 1);
  217. $form->addElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
  218. $form->addElement('select_theme', 'course_theme', get_lang('Theme'), '', array('class'=>'chzn-select', 'id'=>'theme'));
  219. $form->applyFilter('course_theme', 'trim');
  220. }
  221. if (is_settings_editable()) {
  222. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  223. } else {
  224. // Is it allowed to edit the course settings?
  225. if (!is_settings_editable())
  226. $disabled_output = "disabled";
  227. $form->freeze();
  228. }
  229. $form->addElement('html', '</div></div>');
  230. // THEMATIC ADVANCE SETTINGS
  231. //$form->addElement('html', '<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="thematicadvance" id="thematicadvance"></a>'.Display::return_icon('course_progress.png', get_lang('ThematicAdvanceConfiguration'),'','22').' '.get_lang('ThematicAdvanceConfiguration').'</div>');
  232. $form->addElement('html', '<div> <h3>'.Display::return_icon('course_progress.png', get_lang('ThematicAdvanceConfiguration'),'','22').' '.get_lang('ThematicAdvanceConfiguration').'</h3><div>');
  233. $form->addElement('radio', 'display_info_advance_inside_homecourse', get_lang('InfoAboutAdvanceInsideHomeCourse'), get_lang('DisplayAboutLastDoneAdvance'), 1);
  234. $form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDone'), 2);
  235. $form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDoneAndLastDoneAdvance'), 3);
  236. $form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DoNotDisplayAnyAdvance'), 0);
  237. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  238. $form->addElement('html', '</div></div>');
  239. // Get all the course information
  240. $all_course_information = CourseManager::get_course_information($_course['sysCode']);
  241. // Set the default values of the form
  242. $values['title'] = $_course['name'];
  243. $values['visual_code'] = $_course['official_code'];
  244. $values['category_code'] = $_course['categoryCode'];
  245. //$values['tutor_name'] = $_course['titular'];
  246. $values['course_language'] = $_course['language'];
  247. $values['department_name'] = $_course['extLink']['name'];
  248. $values['department_url'] = $_course['extLink']['url'];
  249. $values['visibility'] = $_course['visibility'];
  250. $values['subscribe'] = $course_access_settings['subscribe'];
  251. $values['unsubscribe'] = $course_access_settings['unsubscribe'];
  252. $values['course_registration_password'] = $all_course_information['registration_code'];
  253. // Get send_mail_setting (auth)from table
  254. $values['email_alert_to_teacher_on_new_user_in_course']= api_get_course_setting('email_alert_to_teacher_on_new_user_in_course');
  255. // Get send_mail_setting (work)from table
  256. $values['email_alert_manager_on_new_doc'] = api_get_course_setting('email_alert_manager_on_new_doc');
  257. // Get send_mail_setting (dropbox) from table
  258. $values['email_alert_on_new_doc_dropbox'] = api_get_course_setting('email_alert_on_new_doc_dropbox');
  259. // Get send_mail_setting (work)from table
  260. $values['email_alert_manager_on_new_quiz'] = api_get_course_setting('email_alert_manager_on_new_quiz');
  261. // Get allow_user_edit_agenda from table
  262. $values['allow_user_edit_agenda'] = api_get_course_setting('allow_user_edit_agenda');
  263. // Get allow_user_edit_announcement from table
  264. $values['allow_user_edit_announcement'] = api_get_course_setting('allow_user_edit_announcement');
  265. // Get allow_user_image_forum from table
  266. $values['allow_user_image_forum'] = api_get_course_setting('allow_user_image_forum');
  267. // Get allow_open_chat_window from table
  268. $values['allow_open_chat_window'] = api_get_course_setting('allow_open_chat_window');
  269. // Get course_theme from table
  270. $values['course_theme'] = api_get_course_setting('course_theme');
  271. // Get allow_learning_path_theme from table
  272. $values['allow_learning_path_theme'] = api_get_course_setting('allow_learning_path_theme');
  273. //Get allow show user list
  274. $values['allow_user_view_user_list'] = api_get_course_setting('allow_user_view_user_list');
  275. //Get allow show user list
  276. $values['display_info_advance_inside_homecourse'] = api_get_course_setting('display_info_advance_inside_homecourse');
  277. $values['email_alert_students_on_new_homework'] = api_get_course_setting('email_alert_students_on_new_homework');
  278. $values['enable_lp_auto_launch'] = api_get_course_setting('enable_lp_auto_launch');
  279. $values['pdf_export_watermark_text'] = api_get_course_setting('pdf_export_watermark_text');
  280. $form->setDefaults($values);
  281. // Validate form
  282. if ($form->validate() && is_settings_editable()) {
  283. $update_values = $form->exportValues();
  284. /*
  285. // update course picture
  286. $picture = $_FILES['picture'];
  287. if (!empty($picture['name'])) {
  288. $picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']);
  289. }*/
  290. $pdf_export_watermark_path = $_FILES['pdf_export_watermark_path'];
  291. if (!empty($pdf_export_watermark_path['name'])) {
  292. $pdf_export_watermark_path_result = PDF::upload_watermark($pdf_export_watermark_path['name'], $pdf_export_watermark_path['tmp_name'], $course_code);
  293. unset($update_values['pdf_export_watermark_path']);
  294. }
  295. //Variables that will be saved in the TABLE_MAIN_COURSE table
  296. $update_in_course_table = array('title','visual_code', 'course_language','category_code','department_name', 'department_url','visibility', 'subscribe', 'unsubscribe','tutor_name','course_registration_password');
  297. foreach ($update_values as $index =>$value) {
  298. $update_values[$index] = Database::escape_string($value);
  299. }
  300. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  301. $sql = "UPDATE $table_course SET
  302. title = '".Security::remove_XSS($update_values['title'])."',
  303. visual_code = '".$update_values['visual_code']."',
  304. course_language = '".$update_values['course_language']."',
  305. category_code = '".$update_values['category_code']."',
  306. department_name = '".Security::remove_XSS($update_values['department_name'])."',
  307. department_url = '".Security::remove_XSS($update_values['department_url'])."',
  308. visibility = '".$update_values['visibility']."',
  309. subscribe = '".$update_values['subscribe']."',
  310. unsubscribe = '".$update_values['unsubscribe']."',
  311. tutor_name = '".$update_values['tutor_name']."',
  312. registration_code = '".$update_values['course_registration_password']."'
  313. WHERE code = '".$course_code."'";
  314. Database::query($sql);
  315. // Update course_settings table - this assumes those records exist, otherwise triggers an error
  316. $table_course_setting = Database::get_course_table(TABLE_COURSE_SETTING);
  317. foreach($update_values as $key =>$value) {
  318. //We do not update variables that were already saved in the TABLE_MAIN_COURSE table
  319. if (!in_array($key, $update_in_course_table)) {
  320. Database::update($table_course_setting, array('value' => $update_values[$key]), array('variable = ? ' =>$key));
  321. }
  322. }
  323. $cidReset = true;
  324. $cidReq = $course_code;
  325. require '../inc/local.inc.php';
  326. header('Location: infocours.php?action=show_message&amp;cidReq='.$course_code);
  327. exit;
  328. }
  329. /* Header */
  330. $htmlHeadXtra[] = api_get_jquery_ui_js();
  331. Display :: display_header($nameTools, MODULE_HELP_NAME);
  332. if ($show_delete_watermark_text_message) {
  333. Display :: display_normal_message(get_lang('FileDeleted'));
  334. }
  335. //api_display_tool_title($nameTools);
  336. if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
  337. Display :: display_normal_message(get_lang('ModifDone'));
  338. }
  339. // actions bar
  340. /*
  341. echo '<div class="actions">';
  342. echo '<a href="#coursesettings">'.Display::return_icon('settings.png', get_lang('CourseSettings'),'','32').'</a>';
  343. echo '<a href="#coursesaccess">'.Display::return_icon('course.png', get_lang('CourseAccess'),'','32').'</a>';
  344. echo '<a href="#emailnotifications">'.Display::return_icon('mail.png', get_lang('EmailNotifications'),'','32').'</a>';
  345. echo '<a href="#userrights">'.Display::return_icon('user.png', get_lang('UserRights'),'','32').'</a>';
  346. echo '<a href="#chatsettings">'.Display::return_icon('chat.png', get_lang('ConfigChat'),'','32').'</a>';
  347. if (api_get_setting('allow_course_theme') == 'true') {
  348. echo '<a href="#learnpath">'.Display::return_icon('scorms.png', get_lang('ConfigLearnpath'),'','32').'</a>';
  349. }
  350. echo '<a href="#thematicadvance">'.Display::return_icon('course_progress.png', get_lang('ThematicAdvanceConfiguration'),'','32').'</a>';
  351. echo '</div>';
  352. */
  353. echo '<script>
  354. $(function() {
  355. $("#course_settings").accordion({
  356. autoHeight: false,
  357. header: "div> h3"
  358. });
  359. });
  360. </script>';
  361. // Display the form
  362. echo '<div id="course_settings">';
  363. $form->display();
  364. echo '</div>';
  365. Display::display_footer();