infocours.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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');
  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(LIBRARY_PATH).'course.lib.php';
  23. require_once api_get_path(INCLUDE_PATH).'conf/course_info.conf.php';
  24. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.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. $TABLECOURSEHOME = Database :: get_course_table(TABLE_TOOL_LIST);
  31. $TABLELANGUAGES = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
  32. $TABLEBBCONFIG = Database :: get_course_table(TOOL_FORUM_CONFIG_TABLE);
  33. $currentCourseID = $_course['sysCode'];
  34. $currentCourseRepository = $_course['path'];
  35. $is_allowedToEdit = $is_courseAdmin || $is_platformAdmin;
  36. $course_setting_table = Database::get_course_table(TABLE_COURSE_SETTING);
  37. $course_code = $_course['sysCode'];
  38. $course_access_settings = CourseManager :: get_access_settings($course_code);
  39. /* LOGIC FUNCTIONS */
  40. function is_settings_editable() {
  41. return $GLOBALS['course_info_is_editable'];
  42. }
  43. /* MAIN CODE */
  44. if (!$is_allowedToEdit) {
  45. api_not_allowed(true);
  46. }
  47. $table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
  48. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  49. $tbl_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
  50. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  51. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  52. // Get all course categories
  53. $sql = "SELECT code,name FROM ".$table_course_category." WHERE auth_course_child ='TRUE' OR code = '".Database::escape_string($_course['categoryCode'])."' ORDER BY tree_pos";
  54. $res = Database::query($sql);
  55. $s_select_course_tutor_name = "SELECT tutor_name FROM $tbl_course WHERE code='$course_code'";
  56. $q_tutor = Database::query($s_select_course_tutor_name);
  57. $s_tutor = Database::result($q_tutor, 0, 'tutor_name');
  58. $target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
  59. $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";
  60. $q_result_titulars = Database::query($s_sql_course_titular);
  61. if (Database::num_rows($q_result_titulars) == 0) {
  62. $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";
  63. $q_result_titulars = Database::query($sql);
  64. }
  65. $a_profs[0] = '-- '.get_lang('NoManager').' --';
  66. while ($a_titulars = Database::fetch_array($q_result_titulars)) {
  67. $s_username = $a_titulars['username'];
  68. $s_lastname = $a_titulars['lastname'];
  69. $s_firstname = $a_titulars['firstname'];
  70. if (api_get_person_name($s_firstname, $s_lastname) == $s_tutor) {
  71. $s_selected_tutor = api_get_person_name($s_firstname, $s_lastname);
  72. }
  73. $s_disabled_select_titular = '';
  74. if (!$is_courseAdmin) {
  75. $s_disabled_select_titular = 'disabled=disabled';
  76. }
  77. $a_profs[api_get_person_name($s_firstname, $s_lastname)] = api_get_person_name($s_lastname, $s_firstname).' ('.$s_username.')';
  78. }
  79. while ($cat = Database::fetch_array($res)) {
  80. $categories[$cat['code']] = '('.$cat['code'].') '.$cat['name'];
  81. ksort($categories);
  82. }
  83. $linebreak = '<div class="row"><div class="label"></div><div class="formw" style="border-bottom:1px dashed grey"></div></div>';
  84. // Build the form
  85. $form = new FormValidator('update_course');
  86. // COURSE SETTINGS
  87. $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.gif', get_lang('CourseSettings')).' '.get_lang('CourseSettings').'</div>');
  88. $visual_code=$form->addElement('text', 'visual_code', get_lang('Code'));
  89. $visual_code->freeze();
  90. $form->applyFilter('visual_code', 'strtoupper');
  91. //$form->add_textfield('tutor_name', get_lang('Professors'), true, array ('size' => '60'));
  92. $prof = &$form->addElement('select', 'tutor_name', get_lang('Professors'), $a_profs);
  93. $form->applyFilter('tutor_name', 'html_filter');
  94. $prof -> setSelected($s_selected_tutor);
  95. $form->add_textfield('title', get_lang('Title'), true, array('size' => '60'));
  96. //$form->applyFilter('title', 'html_filter');
  97. $form->applyFilter('title', 'trim');
  98. $form->addElement('select', 'category_code', get_lang('Fac'), $categories);
  99. $form->add_textfield('department_name', get_lang('Department'), false, array('size' => '60'));
  100. //$form->applyFilter('department_name', 'html_filter');
  101. $form->applyFilter('department_name', 'trim');
  102. $form->add_textfield('department_url', get_lang('DepartmentUrl'), false, array('size' => '60'));
  103. //$form->applyFilter('department_url', 'html_filter');
  104. $form->addRule('tutor_name', get_lang('ThisFieldIsRequired'), 'required');
  105. $form->addElement('select_language', 'course_language', get_lang('Ln'));
  106. $form->addElement('static', null, '&nbsp;', get_lang('TipLang'));
  107. // Picture
  108. $form->addElement('file', 'picture', get_lang('AddPicture'));
  109. $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
  110. $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
  111. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  112. // COURSE ACCESS
  113. $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.gif', get_lang('CourseAccess')).' '.get_lang('CourseAccess').'</div>');
  114. $form->addElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
  115. $form->addElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
  116. $form->addElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
  117. $form->addElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
  118. $form->addElement('static', null, null, get_lang("CourseAccessConfigTip"));
  119. $form -> addElement('html', $linebreak);
  120. $form->addElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
  121. $form->addElement('radio', 'subscribe', null, get_lang('Denied'), 0);
  122. $form -> addElement('html', $linebreak);
  123. $form->addElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
  124. $form->addElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
  125. $form -> addElement('html', $linebreak);
  126. $form->add_textfield('course_registration_password', get_lang('CourseRegistrationPassword'), false, array('size' => '60'));
  127. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  128. // EMAIL NOTIFICATIONS
  129. $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')).' '.get_lang('EmailNotifications').'</div>');
  130. $form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', get_lang('NewUserEmailAlert'), get_lang('NewUserEmailAlertEnable'), 1);
  131. $form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null, get_lang('NewUserEmailAlertToTeacharAndTutor'), 2);
  132. $form->addElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null, get_lang('NewUserEmailAlertDisable'), 0);
  133. $form -> addElement('html', $linebreak);
  134. $form->addElement('radio', 'email_alert_students_on_new_homework', get_lang('NewHomeworkEmailAlert'), get_lang('NewHomeworkEmailAlertEnable'), 1);
  135. $form->addElement('radio', 'email_alert_students_on_new_homework', null, get_lang('NewHomeworkEmailAlertDisable'), 0);
  136. $form->addElement('html', $linebreak);
  137. $form->addElement('radio', 'email_alert_manager_on_new_doc', get_lang('WorkEmailAlert'), get_lang('WorkEmailAlertActivate'), 1);
  138. $form->addElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertDeactivate'), 0);
  139. $form -> addElement('html', $linebreak);
  140. $form->addElement('radio', 'email_alert_on_new_doc_dropbox', get_lang('DropboxEmailAlert'), get_lang('DropboxEmailAlertActivate'), 1);
  141. $form->addElement('radio', 'email_alert_on_new_doc_dropbox', null, get_lang('DropboxEmailAlertDeactivate'), 0);
  142. $form -> addElement('html', $linebreak);
  143. $form->addElement('radio', 'email_alert_manager_on_new_quiz', get_lang('QuizEmailAlert'), get_lang('QuizEmailAlertActivate'), 1);
  144. $form->addElement('radio', 'email_alert_manager_on_new_quiz', null, get_lang('QuizEmailAlertDeactivate'), 0);
  145. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  146. // USER RIGHTS
  147. $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('members.gif', get_lang('UserRights')).' '.get_lang('UserRights').'</div>');
  148. $form->addElement('radio', 'allow_user_edit_agenda', get_lang('AllowUserEditAgenda'), get_lang('AllowUserEditAgendaActivate'), 1);
  149. $form->addElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0);
  150. $form -> addElement('html', $linebreak);
  151. $form->addElement('radio', 'allow_user_edit_announcement', get_lang('AllowUserEditAnnouncement'), get_lang('AllowUserEditAnnouncementActivate'), 1);
  152. $form->addElement('radio', 'allow_user_edit_announcement', null, get_lang('AllowUserEditAnnouncementDeactivate'), 0);
  153. $form -> addElement('html', $linebreak);
  154. $form->addElement('radio', 'allow_user_image_forum', get_lang('AllowUserImageForum'), get_lang('AllowUserImageForumActivate'), 1);
  155. $form->addElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0);
  156. $form -> addElement('html', $linebreak);
  157. $form->addElement('radio', 'allow_user_view_user_list', get_lang('AllowUserViewUserList'), get_lang('AllowUserViewUserListActivate'), 1);
  158. $form->addElement('radio', 'allow_user_view_user_list', null, get_lang('AllowUserViewUserListDeactivate'), 0);
  159. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  160. // CHAT SETTINGS
  161. $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.gif', get_lang('ConfigChat')).' '.get_lang('ConfigChat').'</div>');
  162. $form->addElement('radio', 'allow_open_chat_window', get_lang('AllowOpenchatWindow'), get_lang('AllowOpenChatWindowActivate'), 1);
  163. $form->addElement('radio', 'allow_open_chat_window', null, get_lang('AllowOpenChatWindowDeactivate'), 0);
  164. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  165. // COURSE THEME PICKER
  166. if (api_get_setting('allow_course_theme') == 'true') {
  167. $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="theme" id="theme"></a>'.Display::return_icon('theme.gif', get_lang('Theming')).' '.get_lang('Theming').'</div><div style="clear:both;"></div>');
  168. // Allow Learning path
  169. $form->addElement('radio', 'allow_learning_path_theme', get_lang('AllowLearningPathTheme'), get_lang('AllowLearningPathThemeAllow'), 1);
  170. $form->addElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
  171. $form -> addElement('html', $linebreak);
  172. $form->addElement('select_theme', 'course_theme', get_lang('Theme'));
  173. $form->applyFilter('course_theme', 'trim');
  174. $form -> addElement('html', $linebreak);
  175. }
  176. if (is_settings_editable()) {
  177. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  178. } else {
  179. // Is it allowed to edit the course settings?
  180. if (!is_settings_editable())
  181. $disabled_output = "disabled";
  182. $form->freeze();
  183. }
  184. // THEMATIC SETTINGS
  185. $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('attendance.gif', get_lang('ConfigChat')).' '.get_lang('ThematicAdvanceConfiguration').'</div>');
  186. $form->addElement('radio', 'display_info_advance_inside_homecourse', get_lang('InfoAboutAdvanceInsideHomeCourse'), get_lang('DisplayAboutLastDoneAdvance'), 1);
  187. $form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDone'), 2);
  188. $form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDoneAndLastDoneAdvance'), 3);
  189. $form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DoNotDisplayAnyAdvance'), 0);
  190. $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
  191. // Get all the course information
  192. $all_course_information = CourseManager::get_course_information($_course['sysCode']);
  193. // Set the default values of the form
  194. $values['title'] = $_course['name'];
  195. $values['visual_code'] = $_course['official_code'];
  196. $values['category_code'] = $_course['categoryCode'];
  197. //$values['tutor_name'] = $_course['titular'];
  198. $values['course_language'] = $_course['language'];
  199. $values['department_name'] = $_course['extLink']['name'];
  200. $values['department_url'] = $_course['extLink']['url'];
  201. $values['visibility'] = $_course['visibility'];
  202. $values['subscribe'] = $course_access_settings['subscribe'];
  203. $values['unsubscribe'] = $course_access_settings['unsubscribe'];
  204. $values['course_registration_password'] = $all_course_information['registration_code'];
  205. // Get send_mail_setting (auth)from table
  206. $values['email_alert_to_teacher_on_new_user_in_course'] = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course');
  207. // Get send_mail_setting (work)from table
  208. $values['email_alert_manager_on_new_doc'] = api_get_course_setting('email_alert_manager_on_new_doc');
  209. // Get send_mail_setting (dropbox) from table
  210. $values['email_alert_on_new_doc_dropbox'] = api_get_course_setting('email_alert_on_new_doc_dropbox');
  211. // Get send_mail_setting (work)from table
  212. $values['email_alert_manager_on_new_quiz'] = api_get_course_setting('email_alert_manager_on_new_quiz');
  213. // Get allow_user_edit_agenda from table
  214. $values['allow_user_edit_agenda'] = api_get_course_setting('allow_user_edit_agenda');
  215. // Get allow_user_edit_announcement from table
  216. $values['allow_user_edit_announcement'] = api_get_course_setting('allow_user_edit_announcement');
  217. // Get allow_user_image_forum from table
  218. $values['allow_user_image_forum'] = api_get_course_setting('allow_user_image_forum');
  219. // Get allow_open_chat_window from table
  220. $values['allow_open_chat_window'] = api_get_course_setting('allow_open_chat_window');
  221. // Get course_theme from table
  222. $values['course_theme'] = api_get_course_setting('course_theme');
  223. // Get allow_learning_path_theme from table
  224. $values['allow_learning_path_theme'] = api_get_course_setting('allow_learning_path_theme');
  225. //Get allow show user list
  226. $values['allow_user_view_user_list'] = api_get_course_setting('allow_user_view_user_list');
  227. //Get allow show user list
  228. $values['display_info_advance_inside_homecourse'] = api_get_course_setting('display_info_advance_inside_homecourse');
  229. $values['email_alert_students_on_new_homework'] = api_get_course_setting('email_alert_students_on_new_homework');
  230. $form->setDefaults($values);
  231. // Validate form
  232. if ($form->validate() && is_settings_editable()) {
  233. $update_values = $form->exportValues();
  234. // update course picture
  235. $picture = $_FILES['picture'];
  236. if (!empty($picture['name'])) {
  237. $picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']);
  238. }
  239. foreach ($update_values as $index => & $value) {
  240. $update_values[$index] = Database::escape_string($value);
  241. }
  242. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  243. $sql = "UPDATE $table_course SET
  244. title = '".Security::remove_XSS($update_values['title'])."',
  245. visual_code = '".$update_values['visual_code']."',
  246. course_language = '".$update_values['course_language']."',
  247. category_code = '".$update_values['category_code']."',
  248. department_name = '".Security::remove_XSS($update_values['department_name'])."',
  249. department_url = '".Security::remove_XSS($update_values['department_url'])."',
  250. visibility = '".$update_values['visibility']."',
  251. subscribe = '".$update_values['subscribe']."',
  252. unsubscribe = '".$update_values['unsubscribe']."',
  253. tutor_name = '".$update_values['tutor_name']."',
  254. registration_code = '".$update_values['course_registration_password']."'
  255. WHERE code = '".$course_code."'";
  256. Database::query($sql);
  257. // Update course_settings table - this assumes those records exist, otherwise triggers an error
  258. $table_course_setting = Database::get_course_table(TABLE_COURSE_SETTING);
  259. if ($update_values['email_alert_to_teacher_on_new_user_in_course'] != $values['email_alert_to_teacher_on_new_user_in_course']) {
  260. $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' ";
  261. Database::query($sql);
  262. }
  263. if ($update_values['email_alert_manager_on_new_doc'] != $values['email_alert_manager_on_new_doc']) {
  264. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_doc']." WHERE variable = 'email_alert_manager_on_new_doc' ";
  265. Database::query($sql);
  266. }
  267. if ($update_values['email_alert_on_new_doc_dropbox'] != $values['email_alert_on_new_doc_dropbox']) {
  268. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_on_new_doc_dropbox']." WHERE variable = 'email_alert_on_new_doc_dropbox' ";
  269. Database::query($sql);
  270. }
  271. if ($update_values['email_alert_manager_on_new_quiz'] != $values['email_alert_manager_on_new_quiz']) {
  272. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_manager_on_new_quiz']." WHERE variable = 'email_alert_manager_on_new_quiz' ";
  273. Database::query($sql);
  274. }
  275. if ($update_values['allow_user_edit_agenda'] != $values['allow_user_edit_agenda']) {
  276. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_edit_agenda']." WHERE variable = 'allow_user_edit_agenda' ";
  277. Database::query($sql);
  278. }
  279. if ($update_values['allow_user_edit_announcement'] != $values['allow_user_edit_announcement']) {
  280. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_edit_announcement']." WHERE variable = 'allow_user_edit_announcement' ";
  281. Database::query($sql);
  282. }
  283. if ($update_values['allow_user_image_forum'] != $values['allow_user_image_forum']) {
  284. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_image_forum']." WHERE variable = 'allow_user_image_forum' ";
  285. Database::query($sql);
  286. }
  287. if ($update_values['allow_open_chat_window'] != $values['allow_open_chat_window']) {
  288. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_open_chat_window']." WHERE variable = 'allow_open_chat_window' ";
  289. Database::query($sql);
  290. }
  291. if ($update_values['course_theme'] != $values['course_theme']) {
  292. $sql = "UPDATE $table_course_setting SET value = '".$update_values['course_theme']."' WHERE variable = 'course_theme' ";
  293. Database::query($sql);
  294. }
  295. if ($update_values['allow_learningpath_theme'] != $values['allow_learning_path_theme']) {
  296. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_learning_path_theme']." WHERE variable = 'allow_learning_path_theme' ";
  297. Database::query($sql);
  298. }
  299. if ($update_values['allow_user_view_user_list'] != $values['allow_user_view_user_list']) {
  300. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['allow_user_view_user_list']." WHERE variable = 'allow_user_view_user_list' ";
  301. Database::query($sql);
  302. }
  303. if ($update_values['display_info_advance_inside_homecourse'] != $values['display_info_advance_inside_homecourse']) {
  304. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['display_info_advance_inside_homecourse']." WHERE variable = 'display_info_advance_inside_homecourse' ";
  305. Database::query($sql);
  306. }
  307. if ($update_values['email_alert_students_on_new_homework'] != $values['email_alert_students_on_new_homework']) {
  308. $sql = "UPDATE $table_course_setting SET value = ".(int)$update_values['email_alert_students_on_new_homework']." WHERE variable = 'email_alert_students_on_new_homework' ";
  309. Database::query($sql);
  310. }
  311. $cidReset = true;
  312. $cidReq = $course_code;
  313. require '../inc/local.inc.php';
  314. header('Location: infocours.php?action=show_message&amp;cidReq='.$course_code);
  315. exit;
  316. }
  317. /* Header */
  318. Display :: display_header($nameTools, MODULE_HELP_NAME);
  319. //api_display_tool_title($nameTools);
  320. if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
  321. Display :: display_normal_message(get_lang('ModifDone'));
  322. }
  323. // actions bar
  324. echo '<div class="actions">';
  325. echo '<a href="#coursesettings">'.Display::return_icon('settings.gif', get_lang('CourseSettings')).' '.get_lang('CourseSettings').'</a>';
  326. echo '<a href="#coursesaccess">'.Display::return_icon('course.gif', get_lang('CourseAccess')).' '.get_lang('CourseAccess').'</a>';
  327. echo '<a href="#emailnotifications">'.Display::return_icon('mail.png', get_lang('EmailNotifications')).' '.get_lang('EmailNotifications').'</a>';
  328. echo '<a href="#userrights">'.Display::return_icon('members.gif', get_lang('UserRights')).' '.get_lang('UserRights').'</a>';
  329. echo '<a href="#chatsettings">'.Display::return_icon('chat.gif', get_lang('ConfigChat')).' '.get_lang('ConfigChat').'</a>';
  330. if (api_get_setting('allow_course_theme') == 'true') {
  331. echo '<a href="#theme">'.Display::return_icon('theme.gif', get_lang('Theming')).' '.get_lang('Theming').'</a>';
  332. }
  333. echo '</div>';
  334. // display course picture
  335. $course_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository; // course path
  336. if (file_exists($course_path.'/course-pic85x85.png')) {
  337. $course_web_path = api_get_path(WEB_COURSE_PATH).$currentCourseRepository; // course web path
  338. $course_medium_image = $course_web_path.'/course-pic85x85.png'; // redimensioned image 85x85
  339. echo '<div id="course-picture"><img src="'.$course_medium_image.'" /></div>';
  340. }
  341. // Display the form
  342. $form->display();
  343. // @todo this code is out dated should
  344. if ($showDiskQuota && $currentCourseDiskQuota != '') {
  345. ?>
  346. <table>
  347. <tr>
  348. <td><?php echo get_lang("DiskQuota"); ?>&nbsp;:</td>
  349. <td><?php echo $currentCourseDiskQuota; ?> <?php echo $byteUnits[0] ?></td>
  350. </tr>
  351. <?php
  352. }
  353. if ($showLastEdit && $currentCourseLastEdit != "" && $currentCourseLastEdit != "0000-00-00 00:00:00")
  354. {
  355. ?>
  356. <tr>
  357. <td><?php echo get_lang('LastEdit'); ?>&nbsp;:</td>
  358. <td><?php echo api_convert_and_format_date($currentCourseLastEdit, null, date_default_timezone_get()); ?></td>
  359. </tr>
  360. <?php
  361. }
  362. if ($showLastVisit && $currentCourseLastVisit != "" && $currentCourseLastVisit != "0000-00-00 00:00:00")
  363. {
  364. ?>
  365. <tr>
  366. <td><?php echo get_lang('LastVisit'); ?>&nbsp;:</td>
  367. <td><?php echo api_convert_and_format_date($currentCourseLastVisit, null, date_default_timezone_get()); ?></td>
  368. </tr>
  369. <?php
  370. }
  371. if ($showCreationDate && $currentCourseCreationDate != "" && $currentCourseCreationDate != "0000-00-00 00:00:00")
  372. {
  373. ?>
  374. <tr>
  375. <td><?php echo get_lang('CreationDate'); ?>&nbsp;:</td>
  376. <td><?php echo api_convert_and_format_date($currentCourseCreationDate, null, date_default_timezone_get()); ?></td>
  377. </tr>
  378. <?php
  379. }
  380. if ($showExpirationDate && $currentCourseExpirationDate != "" && $currentCourseExpirationDate != "0000-00-00 00:00:00")
  381. {
  382. ?>
  383. <tr>
  384. <td><?php echo get_lang('ExpirationDate'); ?>&nbsp;:</td>
  385. <td>
  386. <?php
  387. echo api_convert_and_format_date($currentCourseExpirationDate, null, date_default_timezone_get());
  388. echo "<br />".get_lang('OrInTime')." : ";
  389. $nbJour = (strtotime($currentCourseExpirationDate) - time()) / (60 * 60 * 24);
  390. $nbAnnees = round($nbJour / 365);
  391. $nbJour = round($nbJour - $nbAnnees * 365);
  392. switch ($nbAnnees)
  393. {
  394. case "1" :
  395. echo $nbAnnees, " an ";
  396. break;
  397. case "0" :
  398. break;
  399. default :
  400. echo $nbAnnees, " ans ";
  401. };
  402. switch ($nbJour)
  403. {
  404. case "1" :
  405. echo $nbJour, " jour ";
  406. break;
  407. case "0" :
  408. break;
  409. default :
  410. echo $nbJour, " jours ";
  411. }
  412. if ($canReportExpirationDate)
  413. {
  414. echo " -&gt; <a href=\"".$urlScriptToReportExpirationDate."\">".get_lang('PostPone')."</a>";
  415. }
  416. ?>
  417. </td>
  418. </tr>
  419. </table>
  420. <?php
  421. }
  422. /* FOOTER */
  423. Display::display_footer();