infocours.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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 and improved course visibility|subscribe|unsubscribe options
  12. * @author Julio Montoya <gugli100@gmail.com> Jquery support + lots of fixes
  13. * @package chamilo.course_info
  14. */
  15. require_once __DIR__.'/../inc/global.inc.php';
  16. $current_course_tool = TOOL_COURSE_SETTING;
  17. $this_section = SECTION_COURSES;
  18. $nameTools = get_lang('ModifInfo');
  19. api_protect_course_script(true);
  20. api_block_anonymous_users();
  21. $_course = api_get_course_info();
  22. /* Constants and variables */
  23. define('MODULE_HELP_NAME', 'Settings');
  24. define('COURSE_CHANGE_PROPERTIES', 'COURSE_CHANGE_PROPERTIES');
  25. $currentCourseRepository = $_course['path'];
  26. $is_allowedToEdit = $is_courseAdmin || $is_platformAdmin;
  27. $course_code = api_get_course_id();
  28. $courseId = api_get_course_int_id();
  29. function is_settings_editable()
  30. {
  31. return isset($GLOBALS['course_info_is_editable']) && $GLOBALS['course_info_is_editable'];
  32. }
  33. /* MAIN CODE */
  34. if (!$is_allowedToEdit) {
  35. api_not_allowed(true);
  36. }
  37. $htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css');
  38. $htmlHeadXtra[] = api_get_asset('cropper/dist/cropper.min.js');
  39. $show_delete_watermark_text_message = false;
  40. if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
  41. if (isset($_GET['delete_watermark'])) {
  42. PDF::delete_watermark($course_code);
  43. $show_delete_watermark_text_message = true;
  44. }
  45. }
  46. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  47. $tbl_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
  48. $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  49. $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
  50. $sql = "SELECT tutor_name FROM $tbl_course WHERE id = $courseId";
  51. $q_tutor = Database::query($sql);
  52. $s_tutor = Database::result($q_tutor, 0, 'tutor_name');
  53. $target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
  54. $sql = "SELECT DISTINCT username, lastname, firstname
  55. FROM $tbl_user as user, $tbl_course_user as course_rel_user
  56. WHERE (course_rel_user.status='1') AND user.user_id=course_rel_user.user_id AND c_id ='".$courseId."'
  57. ORDER BY ".$target_name." ASC";
  58. $q_result_titulars = Database::query($sql);
  59. if (Database::num_rows($q_result_titulars) == 0) {
  60. $sql = "SELECT username, lastname, firstname FROM $tbl_user as user, $tbl_admin as admin
  61. WHERE admin.user_id=user.user_id ORDER BY ".$target_name." ASC";
  62. $q_result_titulars = Database::query($sql);
  63. }
  64. $a_profs[0] = '-- '.get_lang('NoManager').' --';
  65. while ($a_titulars = Database::fetch_array($q_result_titulars)) {
  66. $s_username = $a_titulars['username'];
  67. $s_lastname = $a_titulars['lastname'];
  68. $s_firstname = $a_titulars['firstname'];
  69. if (api_get_person_name($s_firstname, $s_lastname) == $s_tutor) {
  70. $s_selected_tutor = api_get_person_name($s_firstname, $s_lastname);
  71. }
  72. $s_disabled_select_titular = '';
  73. if (!api_is_course_admin()) {
  74. $s_disabled_select_titular = 'disabled=disabled';
  75. }
  76. $a_profs[api_get_person_name($s_firstname, $s_lastname)] = api_get_person_name($s_lastname, $s_firstname).' ('.$s_username.')';
  77. }
  78. $categories = CourseCategory::getCategoriesCanBeAddedInCourse($_course['categoryCode']);
  79. // Build the form
  80. $form = new FormValidator('update_course', 'post', api_get_self().'?'.api_get_cidreq());
  81. $form->addHtml('<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">');
  82. // COURSE SETTINGS
  83. $form->addHtml('<div class="panel panel-default">');
  84. $form->addHtml('
  85. <div class="panel-heading" role="tab" id="heading-course-settings">
  86. <h4 class="panel-title">
  87. <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-course-settings" aria-expanded="true" aria-controls="collapse-course-settings">
  88. ');
  89. $form->addHtml(
  90. Display::return_icon('settings.png', get_lang('CourseSettings')).' '.get_lang('CourseSettings')
  91. );
  92. $form->addHtml('
  93. </a>
  94. </h4>
  95. </div>
  96. ');
  97. $form->addHtml('
  98. <div id="collapse-course-settings" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading-course-settings">
  99. <div class="panel-body">
  100. ');
  101. $image = '';
  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 = '<div class="row"><label class="col-md-2 control-label">'.get_lang('Image').'</label>
  108. <div class="col-md-8"><img src="'.$course_medium_image.'" /></div></div>';
  109. }
  110. $form->addHtml($image);
  111. $form->addText('title', get_lang('Title'), true);
  112. $form->applyFilter('title', 'html_filter');
  113. $form->applyFilter('title', 'trim');
  114. $form->addElement(
  115. 'select',
  116. 'category_code',
  117. get_lang('Fac'),
  118. $categories,
  119. ['style'=>'width:350px', 'id'=>'category_code']
  120. );
  121. $form->addSelectLanguage(
  122. 'course_language',
  123. array(get_lang('Ln'), get_lang('TipLang'))
  124. );
  125. $group = array(
  126. $form->createElement('radio', 'show_course_in_user_language', null, get_lang('Yes'), 1),
  127. $form->createElement('radio', 'show_course_in_user_language', null, get_lang('No'), 2),
  128. );
  129. $form->addGroup($group, '', array(get_lang("ShowCourseInUserLanguage")));
  130. $form->addText('department_name', get_lang('Department'), false);
  131. $form->applyFilter('department_name', 'html_filter');
  132. $form->applyFilter('department_name', 'trim');
  133. $form->addText('department_url', get_lang('DepartmentUrl'), false);
  134. $form->applyFilter('department_url', 'html_filter');
  135. // Picture
  136. $form->addFile(
  137. 'picture',
  138. get_lang('AddPicture'),
  139. array('id' => 'picture', 'class' => 'picture-form', 'crop_image' => true)
  140. );
  141. $allowed_picture_types = api_get_supported_image_extensions(false);
  142. $form->addRule(
  143. 'picture',
  144. get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
  145. 'filetype',
  146. $allowed_picture_types
  147. );
  148. $form->addElement('checkbox', 'delete_picture', null, get_lang('DeletePicture'));
  149. if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
  150. $url = PDF::get_watermark($course_code);
  151. $form->addText('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60'));
  152. $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
  153. if ($url != false) {
  154. $delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png', get_lang('DelImage')).'</a>';
  155. $form->addElement('html', '<div class="row"><div class="formw"><a href="'.$url.'">'.$url.' '.$delete_url.'</a></div></div>');
  156. }
  157. $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
  158. }
  159. if (api_get_setting('allow_course_theme') == 'true') {
  160. $group = array();
  161. $group[] = $form->createElement(
  162. 'SelectTheme',
  163. 'course_theme',
  164. null,
  165. array('id' => 'course_theme_id')
  166. );
  167. $form->addGroup($group, '', array(get_lang("Stylesheets")));
  168. }
  169. $form->addElement('label', get_lang('DocumentQuota'), format_file_size(DocumentManager::get_course_quota()));
  170. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  171. $form->addHtml('
  172. </div>
  173. </div>
  174. ');
  175. $form->addHtml('</div>');
  176. // COURSE ACCESS
  177. $form->addHtml('<div class="panel panel-default">');
  178. $form->addHtml('
  179. <div class="panel-heading" role="tab" id="heading-course-access">
  180. <h4 class="panel-title">
  181. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-course-access" aria-expanded="false" aria-controls="collapse-course-access">
  182. ');
  183. $form->addElement(
  184. 'html',
  185. Display::return_icon('course.png', get_lang('CourseAccess')).' '.get_lang('CourseAccess')
  186. );
  187. $form->addHtml('
  188. </a>
  189. </h4>
  190. </div>
  191. ');
  192. $form->addHtml('
  193. <div id="collapse-course-access" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-course-access">
  194. <div class="panel-body">
  195. ');
  196. $group = array();
  197. $group[] = $form->createElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
  198. $group[] = $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
  199. $group[] = $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
  200. $group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
  201. // The "hidden" visibility is only available to portal admins
  202. if (api_is_platform_admin()) {
  203. $group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
  204. }
  205. $form->addGroup($group, '', array(get_lang("CourseAccess"), get_lang("CourseAccessConfigTip")));
  206. $url = api_get_path(WEB_CODE_PATH)."auth/inscription.php?c=$course_code&e=1";
  207. $url = Display::url($url, $url);
  208. $form->addElement('label', get_lang('DirectLink'), sprintf(get_lang('CourseSettingsRegisterDirectLink'), $url));
  209. $group = array();
  210. $group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
  211. $group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
  212. $form->addGroup($group, '', array(get_lang("Subscription")));
  213. $group = array();
  214. $group[] = $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
  215. $group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
  216. $form->addGroup($group, '', array(get_lang("Unsubscription")));
  217. $form->addText('course_registration_password', get_lang('CourseRegistrationPassword'), false, array('size' => '60'));
  218. $form->addElement('checkbox', 'activate_legal', array(null, get_lang('ShowALegalNoticeWhenEnteringTheCourse')), get_lang('ActivateLegal'));
  219. $form->addElement('textarea', 'legal', get_lang('CourseLegalAgreement'), array('rows' => 8));
  220. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  221. $form->addHtml('
  222. </div>
  223. </div>
  224. ');
  225. $form->addHtml('</div>');
  226. // Documents
  227. $form->addHtml('<div class="panel panel-default">');
  228. $form->addHtml('
  229. <div class="panel-heading" role="tab" id="heading-documents">
  230. <h4 class="panel-title">
  231. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-documents" aria-expanded="false" aria-controls="collapse-documents">
  232. ');
  233. $form->addHtml(
  234. Display::return_icon('folder.png', get_lang('Documents')).' '.get_lang('Documents')
  235. );
  236. $form->addHtml('
  237. </a>
  238. </h4>
  239. </div>
  240. ');
  241. $form->addHtml('
  242. <div id="collapse-documents" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-documents">
  243. <div class="panel-body">
  244. ');
  245. if (api_get_setting('documents_default_visibility_defined_in_course') == 'true') {
  246. $group = array(
  247. $form->createElement('radio', 'documents_default_visibility', null, get_lang('Visible'), 'visible'),
  248. $form->createElement('radio', 'documents_default_visibility', null, get_lang('Invisible'), 'invisible')
  249. );
  250. $form->addGroup($group, '', array(get_lang('DocumentsDefaultVisibility')));
  251. }
  252. $group = array(
  253. $form->createElement('radio', 'show_system_folders', null, get_lang('Yes'), 1),
  254. $form->createElement('radio', 'show_system_folders', null, get_lang('No'), 2)
  255. );
  256. $form->addGroup($group, '', array(get_lang('ShowSystemFolders')));
  257. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  258. $form->addHtml('
  259. </div>
  260. </div>
  261. ');
  262. $form->addHtml('</div>');
  263. // EMAIL NOTIFICATIONS
  264. $form->addHtml('<div class="panel panel-default">');
  265. $form->addHtml('
  266. <div class="panel-heading" role="tab" id="heading-email-notifications">
  267. <h4 class="panel-title">
  268. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-email-notifications" aria-expanded="false" aria-controls="collapse-email-notifications">
  269. ');
  270. $form->addHtml(
  271. Display::return_icon('mail.png', get_lang('EmailNotifications')).' '.get_lang('EmailNotifications')
  272. );
  273. $form->addHtml('
  274. </a>
  275. </h4>
  276. </div>
  277. ');
  278. $form->addHtml('
  279. <div id="collapse-email-notifications" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-email-notifications">
  280. <div class="panel-body">
  281. ');
  282. $group = array();
  283. $group[] = $form->createElement('radio', 'email_alert_to_teacher_on_new_user_in_course', get_lang('NewUserEmailAlert'), get_lang('NewUserEmailAlertEnable'), 1);
  284. $group[] = $form->createElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null, get_lang('NewUserEmailAlertToTeacharAndTutor'), 2);
  285. $group[] = $form->createElement('radio', 'email_alert_to_teacher_on_new_user_in_course', null, get_lang('NewUserEmailAlertDisable'), 0);
  286. $form->addGroup($group, '', array(get_lang("NewUserEmailAlert")));
  287. $group = array();
  288. $group[] = $form->createElement('radio', 'email_alert_students_on_new_homework', get_lang('NewHomeworkEmailAlert'), get_lang('NewHomeworkEmailAlertEnable'), 1);
  289. $group[] = $form->createElement('radio', 'email_alert_students_on_new_homework', null, get_lang('NewHomeworkEmailAlertDisable'), 0);
  290. $form->addGroup($group, '', array(get_lang("NewHomeworkEmailAlert")));
  291. $group = array();
  292. $group[] = $form->createElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertActivateOnlyForTeachers'), 3);
  293. $group[] = $form->createElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertActivateOnlyForStudents'), 2);
  294. $group[] = $form->createElement('radio', 'email_alert_manager_on_new_doc', get_lang('WorkEmailAlert'), get_lang('WorkEmailAlertActivate'), 1);
  295. $group[] = $form->createElement('radio', 'email_alert_manager_on_new_doc', null, get_lang('WorkEmailAlertDeactivate'), 0);
  296. $form->addGroup($group, '', array(get_lang("WorkEmailAlert")));
  297. $group = array();
  298. $group[] = $form->createElement('radio', 'email_alert_on_new_doc_dropbox', get_lang('DropboxEmailAlert'), get_lang('DropboxEmailAlertActivate'), 1);
  299. $group[] = $form->createElement('radio', 'email_alert_on_new_doc_dropbox', null, get_lang('DropboxEmailAlertDeactivate'), 0);
  300. $form->addGroup($group, '', array(get_lang("DropboxEmailAlert")));
  301. $group = array();
  302. $group[] = $form->createElement('radio', 'email_alert_manager_on_new_quiz', get_lang('QuizEmailAlert'), get_lang('QuizEmailAlertActivate'), 1);
  303. $group[] = $form->createElement('radio', 'email_alert_manager_on_new_quiz', null, get_lang('QuizEmailAlertDeactivate'), 0);
  304. $form->addGroup($group, '', array(get_lang("QuizEmailAlert")));
  305. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  306. $form->addHtml('
  307. </div>
  308. </div>
  309. ');
  310. $form->addHtml('</div>');
  311. // USER RIGHTS
  312. $form->addHtml('<div class="panel panel-default">');
  313. $form->addHtml('
  314. <div class="panel-heading" role="tab" id="heading-user-right">
  315. <h4 class="panel-title">
  316. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-user-right" aria-expanded="false" aria-controls="collapse-user-right">
  317. ');
  318. $form->addHtml(
  319. Display::return_icon('user.png', get_lang('UserRights')).' '.get_lang('UserRights')
  320. );
  321. $form->addHtml('
  322. </a>
  323. </h4>
  324. </div>
  325. ');
  326. $form->addHtml('
  327. <div id="collapse-user-right" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-user-right">
  328. <div class="panel-body">
  329. ');
  330. $group = array();
  331. $group[] = $form->createElement('radio', 'allow_user_edit_agenda', get_lang('AllowUserEditAgenda'), get_lang('AllowUserEditAgendaActivate'), 1);
  332. $group[] = $form->createElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0);
  333. $form->addGroup($group, '', array(get_lang("AllowUserEditAgenda")));
  334. $group = array();
  335. $group[] = $form->createElement('radio', 'allow_user_edit_announcement', get_lang('AllowUserEditAnnouncement'), get_lang('AllowUserEditAnnouncementActivate'), 1);
  336. $group[] = $form->createElement('radio', 'allow_user_edit_announcement', null, get_lang('AllowUserEditAnnouncementDeactivate'), 0);
  337. $form->addGroup($group, '', array(get_lang("AllowUserEditAnnouncement")));
  338. $group = array();
  339. $group[] = $form->createElement('radio', 'allow_user_image_forum', get_lang('AllowUserImageForum'), get_lang('AllowUserImageForumActivate'), 1);
  340. $group[] = $form->createElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0);
  341. $form->addGroup($group, '', array(get_lang("AllowUserImageForum")));
  342. $group = array();
  343. $group[] = $form->createElement('radio', 'allow_user_view_user_list', get_lang('AllowUserViewUserList'), get_lang('AllowUserViewUserListActivate'), 1);
  344. $group[] = $form->createElement('radio', 'allow_user_view_user_list', null, get_lang('AllowUserViewUserListDeactivate'), 0);
  345. $form->addGroup($group, '', array(get_lang("AllowUserViewUserList")));
  346. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  347. $form->addHtml('
  348. </div>
  349. </div>
  350. ');
  351. $form->addHtml('</div>');
  352. // CHAT SETTINGS
  353. $form->addHtml('<div class="panel panel-default">');
  354. $form->addHtml('
  355. <div class="panel-heading" role="tab" id="heading-chat-settings">
  356. <h4 class="panel-title">
  357. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-chat-settings" aria-expanded="false" aria-controls="collapse-chat-settings">
  358. ');
  359. $form->addHtml(
  360. Display::return_icon('chat.png', get_lang('ConfigChat'), '', ICON_SIZE_SMALL).' '.get_lang('ConfigChat')
  361. );
  362. $form->addHtml('
  363. </a>
  364. </h4>
  365. </div>
  366. ');
  367. $form->addHtml('
  368. <div id="collapse-chat-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-chat-settings">
  369. <div class="panel-body">
  370. ');
  371. $group = array();
  372. $group[] = $form->createElement('radio', 'allow_open_chat_window', get_lang('AllowOpenchatWindow'), get_lang('AllowOpenChatWindowActivate'), 1);
  373. $group[] = $form->createElement('radio', 'allow_open_chat_window', null, get_lang('AllowOpenChatWindowDeactivate'), 0);
  374. $form->addGroup($group, '', array(get_lang("AllowOpenchatWindow")));
  375. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  376. $form->addHtml('
  377. </div>
  378. </div>
  379. ');
  380. $form->addHtml('</div>');
  381. // LEARNING PATH
  382. $form->addHtml('<div class="panel panel-default">');
  383. $form->addHtml('
  384. <div class="panel-heading" role="tab" id="heading-learning-path">
  385. <h4 class="panel-title">
  386. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-learning-path" aria-expanded="false" aria-controls="collapse-learning-path">
  387. ');
  388. $form->addHtml(
  389. Display::return_icon('scorms.png', get_lang('ConfigLearnpath')).' '.get_lang('ConfigLearnpath')
  390. );
  391. $form->addHtml('
  392. </a>
  393. </h4>
  394. </div>
  395. ');
  396. $form->addHtml('
  397. <div id="collapse-learning-path" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-learning-path">
  398. <div class="panel-body">
  399. ');
  400. // Auto launch LP
  401. $group = array();
  402. $group[] = $form->createElement('radio', 'enable_lp_auto_launch', get_lang('LPAutoLaunch'), get_lang('RedirectToALearningPath'), 1);
  403. $group[] = $form->createElement('radio', 'enable_lp_auto_launch', get_lang('LPAutoLaunch'), get_lang('RedirectToTheLearningPathList'), 2);
  404. $group[] = $form->createElement('radio', 'enable_lp_auto_launch', null, get_lang('Deactivate'), 0);
  405. $form->addGroup($group, '', array(get_lang("LPAutoLaunch")));
  406. if (api_get_setting('allow_course_theme') == 'true') {
  407. // Allow theme into Learning path
  408. $group = array();
  409. $group[] = $form->createElement('radio', 'allow_learning_path_theme', get_lang('AllowLearningPathTheme'), get_lang('AllowLearningPathThemeAllow'), 1);
  410. $group[] = $form->createElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
  411. $form->addGroup($group, '', array(get_lang("AllowLearningPathTheme")));
  412. }
  413. $allowLPReturnLink = api_get_setting('allow_lp_return_link');
  414. if ($allowLPReturnLink === 'true') {
  415. $group = array(
  416. $form->createElement(
  417. 'radio',
  418. 'lp_return_link',
  419. get_lang('LpReturnLink'),
  420. get_lang('RedirectToTheLearningPathList'),
  421. 1
  422. ),
  423. $form->createElement(
  424. 'radio',
  425. 'lp_return_link',
  426. null,
  427. get_lang('RedirectToCourseHome'),
  428. 0
  429. ),
  430. $form->createElement(
  431. 'radio',
  432. 'lp_return_link',
  433. null,
  434. get_lang('RedirectToMyCourses'),
  435. 2
  436. )
  437. );
  438. $form->addGroup($group, '', array(get_lang("LpReturnLink")));
  439. }
  440. $exerciseInvisible = api_get_setting('exercise_invisible_in_session');
  441. $configureExerciseVisibility = api_get_setting('configure_exercise_visibility_in_course');
  442. if ($exerciseInvisible === 'true' &&
  443. $configureExerciseVisibility === 'true'
  444. ) {
  445. $group = array(
  446. $form->createElement(
  447. 'radio',
  448. 'exercise_invisible_in_session',
  449. get_lang('ExerciseInvisibleInSession'),
  450. get_lang('Yes'),
  451. 1
  452. ),
  453. $form->createElement(
  454. 'radio',
  455. 'exercise_invisible_in_session',
  456. null,
  457. get_lang('No'),
  458. 0
  459. )
  460. );
  461. $form->addGroup($group, '', array(get_lang("ExerciseInvisibleInSession")));
  462. }
  463. if (is_settings_editable()) {
  464. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  465. } else {
  466. // Is it allowed to edit the course settings?
  467. if (!is_settings_editable()) {
  468. $disabled_output = "disabled";
  469. }
  470. $form->freeze();
  471. }
  472. $form->addHtml('
  473. </div>
  474. </div>
  475. ');
  476. $form->addHtml('</div>');
  477. // THEMATIC ADVANCE SETTINGS
  478. $form->addHtml('<div class="panel panel-default">');
  479. $form->addHtml('
  480. <div class="panel-heading" role="tab" id="heading-advance-settings">
  481. <h4 class="panel-title">
  482. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-advance-settings" aria-expanded="false" aria-controls="collapse-advance-settings">
  483. ');
  484. $form->addHtml(
  485. Display::return_icon(
  486. 'course_progress.png',
  487. get_lang('ThematicAdvanceConfiguration')
  488. ).' '.get_lang('ThematicAdvanceConfiguration')
  489. );
  490. $form->addHtml('
  491. </a>
  492. </h4>
  493. </div>
  494. ');
  495. $form->addHtml('
  496. <div id="collapse-advance-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-advance-settings">
  497. <div class="panel-body">
  498. ');
  499. $group = array();
  500. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', get_lang('InfoAboutAdvanceInsideHomeCourse'), get_lang('DisplayAboutLastDoneAdvance'), 1);
  501. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDone'), 2);
  502. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDoneAndLastDoneAdvance'), 3);
  503. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DoNotDisplayAnyAdvance'), 0);
  504. $form->addGroup($group, '', array(get_lang("InfoAboutAdvanceInsideHomeCourse")));
  505. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  506. $form->addHtml('
  507. </div>
  508. </div>
  509. ');
  510. $form->addHtml('</div>');
  511. // Certificate settings
  512. if (api_get_setting('allow_public_certificates') == 'true') {
  513. $form->addHtml('<div class="panel panel-default">');
  514. $form->addHtml('
  515. <div class="panel-heading" role="tab" id="heading-certificate-settings">
  516. <h4 class="panel-title">
  517. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-certificate-settings" aria-expanded="false" aria-controls="collapse-certificate-settings">
  518. ');
  519. $form->addHtml(
  520. Display::return_icon('certificate.png', get_lang('Certificates')).' '.get_lang('Certificates')
  521. );
  522. $form->addHtml('
  523. </a>
  524. </h4>
  525. </div>
  526. ');
  527. $form->addHtml('
  528. <div id="collapse-certificate-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-certificate-settings">
  529. <div class="panel-body">
  530. ');
  531. $group = array();
  532. $group[] = $form->createElement('radio', 'allow_public_certificates', get_lang('AllowPublicCertificates'), get_lang('Yes'), 1);
  533. $group[] = $form->createElement('radio', 'allow_public_certificates', null, get_lang('No'), 0);
  534. $form->addGroup($group, '', array(get_lang('AllowPublicCertificates')));
  535. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  536. $form->addHtml('
  537. </div>
  538. </div>
  539. ');
  540. $form->addHtml('</div>');
  541. }
  542. // Forum settings
  543. $form->addHtml('<div class="panel panel-default">');
  544. $form->addHtml('
  545. <div class="panel-heading" role="tab" id="heading-forum-settings">
  546. <h4 class="panel-title">
  547. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-forum-settings" aria-expanded="false" aria-controls="collapse-forum-settings">
  548. ');
  549. $form->addHtml(
  550. Display::return_icon('forum.png', get_lang('Forum')).' '.get_lang('Forum')
  551. );
  552. $form->addHtml('
  553. </a>
  554. </h4>
  555. </div>
  556. ');
  557. $form->addHtml('
  558. <div id="collapse-forum-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-forum-settings">
  559. <div class="panel-body">
  560. ');
  561. $group = array(
  562. $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('RedirectToForumList'), 1),
  563. $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('Disabled'), 2),
  564. );
  565. $form->addGroup($group, '', array(get_lang('EnableForumAutoLaunch')));
  566. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  567. $form->addHtml('
  568. </div>
  569. </div>
  570. ');
  571. $form->addHtml('</div>');
  572. // Plugin course settings
  573. $appPlugin = new AppPlugin();
  574. $appPlugin->add_course_settings_form($form);
  575. $form->addHtml('</div>');
  576. // Get all the course information
  577. $all_course_information = CourseManager::get_course_information($_course['sysCode']);
  578. // Set the default values of the form
  579. $values = array();
  580. $values['title'] = $_course['name'];
  581. $values['category_code'] = $_course['categoryCode'];
  582. $values['course_language'] = $_course['language'];
  583. $values['department_name'] = $_course['extLink']['name'];
  584. $values['department_url'] = $_course['extLink']['url'];
  585. $values['visibility'] = $_course['visibility'];
  586. $values['subscribe'] = $_course['subscribe'];
  587. $values['unsubscribe'] = $_course['unsubscribe'];
  588. $values['course_registration_password'] = $all_course_information['registration_code'];
  589. $values['legal'] = $all_course_information['legal'];
  590. $values['activate_legal'] = $all_course_information['activate_legal'];
  591. $courseSettings = CourseManager::getCourseSettingVariables($appPlugin);
  592. foreach ($courseSettings as $setting) {
  593. $result = api_get_course_setting($setting);
  594. if ($result != '-1') {
  595. $values[$setting] = $result;
  596. }
  597. }
  598. $form->setDefaults($values);
  599. // Validate form
  600. if ($form->validate() && is_settings_editable()) {
  601. $updateValues = $form->getSubmitValues();
  602. // update course picture
  603. $picture = $_FILES['picture'];
  604. if (!empty($picture['name'])) {
  605. $picture_uri = CourseManager::update_course_picture(
  606. $_course,
  607. $picture['name'],
  608. $picture['tmp_name'],
  609. $updateValues['picture_crop_result']
  610. );
  611. }
  612. $visibility = $updateValues['visibility'];
  613. $deletePicture = isset($updateValues['delete_picture']) ? $updateValues['delete_picture'] : '';
  614. if ($deletePicture) {
  615. CourseManager::deleteCoursePicture($course_code);
  616. }
  617. global $_configuration;
  618. $urlId = api_get_current_access_url_id();
  619. if (isset($_configuration[$urlId]) &&
  620. isset($_configuration[$urlId]['hosting_limit_active_courses']) &&
  621. $_configuration[$urlId]['hosting_limit_active_courses'] > 0
  622. ) {
  623. $courseInfo = api_get_course_info_by_id($courseId);
  624. // Check if
  625. if ($courseInfo['visibility'] == COURSE_VISIBILITY_HIDDEN &&
  626. $visibility != $courseInfo['visibility']
  627. ) {
  628. $num = CourseManager::countActiveCourses($urlId);
  629. if ($num >= $_configuration[$urlId]['hosting_limit_active_courses']) {
  630. api_warn_hosting_contact('hosting_limit_active_courses');
  631. Display::addFlash(
  632. Display::return_message(get_lang('PortalActiveCoursesLimitReached'))
  633. );
  634. $url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.api_get_cidreq();
  635. header("Location: $url");
  636. exit;
  637. }
  638. }
  639. }
  640. $pdf_export_watermark_path = isset($_FILES['pdf_export_watermark_path']) ? $_FILES['pdf_export_watermark_path'] : null;
  641. if (!empty($pdf_export_watermark_path['name'])) {
  642. $pdf_export_watermark_path_result = PDF::upload_watermark(
  643. $pdf_export_watermark_path['name'],
  644. $pdf_export_watermark_path['tmp_name'],
  645. $course_code
  646. );
  647. unset($updateValues['pdf_export_watermark_path']);
  648. }
  649. // Variables that will be saved in the TABLE_MAIN_COURSE table
  650. $update_in_course_table = array(
  651. 'title',
  652. 'course_language',
  653. 'category_code',
  654. 'department_name',
  655. 'department_url',
  656. 'visibility',
  657. 'subscribe',
  658. 'unsubscribe',
  659. 'tutor_name',
  660. 'course_registration_password',
  661. 'legal',
  662. 'activate_legal'
  663. );
  664. $activeLegal = isset($updateValues['activate_legal']) ? $updateValues['activate_legal'] : 0;
  665. $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
  666. $params = [
  667. 'title' => $updateValues['title'],
  668. 'course_language' => $updateValues['course_language'],
  669. 'category_code' => $updateValues['category_code'],
  670. 'department_name' => $updateValues['department_name'],
  671. 'department_url' => $updateValues['department_url'],
  672. 'visibility' => $updateValues['visibility'],
  673. 'subscribe' => $updateValues['subscribe'],
  674. 'unsubscribe' => $updateValues['unsubscribe'],
  675. 'legal' => $updateValues['legal'],
  676. 'activate_legal' => $activeLegal,
  677. 'registration_code' => $updateValues['course_registration_password'],
  678. ];
  679. Database::update($table_course, $params, ['id = ?' => $courseId]);
  680. // Insert/Updates course_settings table
  681. foreach ($courseSettings as $setting) {
  682. $value = isset($updateValues[$setting]) ? $updateValues[$setting] : null;
  683. CourseManager::saveCourseConfigurationSetting(
  684. $appPlugin,
  685. $setting,
  686. $value,
  687. api_get_course_int_id()
  688. );
  689. }
  690. $appPlugin->saveCourseSettingsHook($updateValues);
  691. $cidReset = true;
  692. $cidReq = $course_code;
  693. Display::addFlash(Display::return_message(get_lang('Updated')));
  694. require '../inc/local.inc.php';
  695. $url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.api_get_cidreq();
  696. header("Location: $url");
  697. exit;
  698. }
  699. /* Header */
  700. Display :: display_header($nameTools, MODULE_HELP_NAME);
  701. if ($show_delete_watermark_text_message) {
  702. Display::addFlash(Display::return_message(get_lang('FileDeleted'), 'normal'));
  703. }
  704. // Display the form
  705. echo '<div id="course_settings">';
  706. $form->display();
  707. echo '</div>';
  708. Display::display_footer();