infocours.php 30 KB

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