infocours.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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('checkbox', 'email_alert_manager_on_new_quiz[]', null, get_lang('SendEmailToTeacherWhenStudentStartQuiz'), ['value' => 2]);
  303. // Default
  304. $group[] = $form->createElement('checkbox', 'email_alert_manager_on_new_quiz[]', null, get_lang('SendEmailToTeacherWhenStudentEndQuiz'), ['value' => 1]);
  305. $group[] = $form->createElement('checkbox', 'email_alert_manager_on_new_quiz[]', null, get_lang('SendEmailToTeacherWhenStudentEndQuizOnlyIfOpenQuestion'), ['value' => 3]);
  306. $group[] = $form->createElement('checkbox', 'email_alert_manager_on_new_quiz[]', null, get_lang('SendEmailToTeacherWhenStudentEndQuizOnlyIfOralQuestion'), ['value' => 4]);
  307. //$group[] = $form->createElement('checkbox', 'email_alert_manager_on_new_quiz[]', null, get_lang('QuizEmailAlertDeactivate'), ['value' => 0]);
  308. //$group[] = $form->createElement('checkbox', 'email_alert_manager_on_new_quiz[]', null, get_lang('QuizEmailSendToTeacherWhenStudentEndQuiz'), ['value' => 3]);
  309. $form->addGroup($group, '', array(get_lang("Exercises")));
  310. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  311. $form->addHtml('
  312. </div>
  313. </div>
  314. ');
  315. $form->addHtml('</div>');
  316. // USER RIGHTS
  317. $form->addHtml('<div class="panel panel-default">');
  318. $form->addHtml('
  319. <div class="panel-heading" role="tab" id="heading-user-right">
  320. <h4 class="panel-title">
  321. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-user-right" aria-expanded="false" aria-controls="collapse-user-right">
  322. ');
  323. $form->addHtml(
  324. Display::return_icon('user.png', get_lang('UserRights')).' '.get_lang('UserRights')
  325. );
  326. $form->addHtml('
  327. </a>
  328. </h4>
  329. </div>
  330. ');
  331. $form->addHtml('
  332. <div id="collapse-user-right" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-user-right">
  333. <div class="panel-body">
  334. ');
  335. $group = array();
  336. $group[] = $form->createElement('radio', 'allow_user_edit_agenda', get_lang('AllowUserEditAgenda'), get_lang('AllowUserEditAgendaActivate'), 1);
  337. $group[] = $form->createElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0);
  338. $form->addGroup($group, '', array(get_lang("AllowUserEditAgenda")));
  339. $group = array();
  340. $group[] = $form->createElement('radio', 'allow_user_edit_announcement', get_lang('AllowUserEditAnnouncement'), get_lang('AllowUserEditAnnouncementActivate'), 1);
  341. $group[] = $form->createElement('radio', 'allow_user_edit_announcement', null, get_lang('AllowUserEditAnnouncementDeactivate'), 0);
  342. $form->addGroup($group, '', array(get_lang("AllowUserEditAnnouncement")));
  343. $group = array();
  344. $group[] = $form->createElement('radio', 'allow_user_image_forum', get_lang('AllowUserImageForum'), get_lang('AllowUserImageForumActivate'), 1);
  345. $group[] = $form->createElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0);
  346. $form->addGroup($group, '', array(get_lang("AllowUserImageForum")));
  347. $group = array();
  348. $group[] = $form->createElement('radio', 'allow_user_view_user_list', get_lang('AllowUserViewUserList'), get_lang('AllowUserViewUserListActivate'), 1);
  349. $group[] = $form->createElement('radio', 'allow_user_view_user_list', null, get_lang('AllowUserViewUserListDeactivate'), 0);
  350. $form->addGroup($group, '', array(get_lang("AllowUserViewUserList")));
  351. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  352. $form->addHtml('
  353. </div>
  354. </div>
  355. ');
  356. $form->addHtml('</div>');
  357. // CHAT SETTINGS
  358. $form->addHtml('<div class="panel panel-default">');
  359. $form->addHtml('
  360. <div class="panel-heading" role="tab" id="heading-chat-settings">
  361. <h4 class="panel-title">
  362. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-chat-settings" aria-expanded="false" aria-controls="collapse-chat-settings">
  363. ');
  364. $form->addHtml(
  365. Display::return_icon('chat.png', get_lang('ConfigChat'), '', ICON_SIZE_SMALL).' '.get_lang('ConfigChat')
  366. );
  367. $form->addHtml('
  368. </a>
  369. </h4>
  370. </div>
  371. ');
  372. $form->addHtml('
  373. <div id="collapse-chat-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-chat-settings">
  374. <div class="panel-body">
  375. ');
  376. $group = array();
  377. $group[] = $form->createElement('radio', 'allow_open_chat_window', get_lang('AllowOpenchatWindow'), get_lang('AllowOpenChatWindowActivate'), 1);
  378. $group[] = $form->createElement('radio', 'allow_open_chat_window', null, get_lang('AllowOpenChatWindowDeactivate'), 0);
  379. $form->addGroup($group, '', array(get_lang("AllowOpenchatWindow")));
  380. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  381. $form->addHtml('
  382. </div>
  383. </div>
  384. ');
  385. $form->addHtml('</div>');
  386. // LEARNING PATH
  387. $form->addHtml('<div class="panel panel-default">');
  388. $form->addHtml('
  389. <div class="panel-heading" role="tab" id="heading-learning-path">
  390. <h4 class="panel-title">
  391. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-learning-path" aria-expanded="false" aria-controls="collapse-learning-path">
  392. ');
  393. $form->addHtml(
  394. Display::return_icon('scorms.png', get_lang('ConfigLearnpath')).' '.get_lang('ConfigLearnpath')
  395. );
  396. $form->addHtml('
  397. </a>
  398. </h4>
  399. </div>
  400. ');
  401. $form->addHtml('
  402. <div id="collapse-learning-path" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-learning-path">
  403. <div class="panel-body">
  404. ');
  405. // Auto launch LP
  406. $group = array();
  407. $group[] = $form->createElement('radio', 'enable_lp_auto_launch', get_lang('LPAutoLaunch'), get_lang('RedirectToALearningPath'), 1);
  408. $group[] = $form->createElement('radio', 'enable_lp_auto_launch', get_lang('LPAutoLaunch'), get_lang('RedirectToTheLearningPathList'), 2);
  409. $group[] = $form->createElement('radio', 'enable_lp_auto_launch', null, get_lang('Deactivate'), 0);
  410. $form->addGroup($group, '', array(get_lang("LPAutoLaunch")));
  411. if (api_get_setting('allow_course_theme') == 'true') {
  412. // Allow theme into Learning path
  413. $group = array();
  414. $group[] = $form->createElement('radio', 'allow_learning_path_theme', get_lang('AllowLearningPathTheme'), get_lang('AllowLearningPathThemeAllow'), 1);
  415. $group[] = $form->createElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
  416. $form->addGroup($group, '', array(get_lang("AllowLearningPathTheme")));
  417. }
  418. $allowLPReturnLink = api_get_setting('allow_lp_return_link');
  419. if ($allowLPReturnLink === 'true') {
  420. $group = array(
  421. $form->createElement(
  422. 'radio',
  423. 'lp_return_link',
  424. get_lang('LpReturnLink'),
  425. get_lang('RedirectToTheLearningPathList'),
  426. 1
  427. ),
  428. $form->createElement(
  429. 'radio',
  430. 'lp_return_link',
  431. null,
  432. get_lang('RedirectToCourseHome'),
  433. 0
  434. ),
  435. $form->createElement(
  436. 'radio',
  437. 'lp_return_link',
  438. null,
  439. get_lang('RedirectToMyCourses'),
  440. 2
  441. )
  442. );
  443. $form->addGroup($group, '', array(get_lang("LpReturnLink")));
  444. }
  445. $exerciseInvisible = api_get_setting('exercise_invisible_in_session');
  446. $configureExerciseVisibility = api_get_setting('configure_exercise_visibility_in_course');
  447. if ($exerciseInvisible === 'true' &&
  448. $configureExerciseVisibility === 'true'
  449. ) {
  450. $group = array(
  451. $form->createElement(
  452. 'radio',
  453. 'exercise_invisible_in_session',
  454. get_lang('ExerciseInvisibleInSession'),
  455. get_lang('Yes'),
  456. 1
  457. ),
  458. $form->createElement(
  459. 'radio',
  460. 'exercise_invisible_in_session',
  461. null,
  462. get_lang('No'),
  463. 0
  464. )
  465. );
  466. $form->addGroup($group, '', array(get_lang("ExerciseInvisibleInSession")));
  467. }
  468. if (is_settings_editable()) {
  469. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  470. } else {
  471. // Is it allowed to edit the course settings?
  472. if (!is_settings_editable()) {
  473. $disabled_output = "disabled";
  474. }
  475. $form->freeze();
  476. }
  477. $form->addHtml('
  478. </div>
  479. </div>
  480. ');
  481. $form->addHtml('</div>');
  482. // THEMATIC ADVANCE SETTINGS
  483. $form->addHtml('<div class="panel panel-default">');
  484. $form->addHtml('
  485. <div class="panel-heading" role="tab" id="heading-advance-settings">
  486. <h4 class="panel-title">
  487. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-advance-settings" aria-expanded="false" aria-controls="collapse-advance-settings">
  488. ');
  489. $form->addHtml(
  490. Display::return_icon(
  491. 'course_progress.png',
  492. get_lang('ThematicAdvanceConfiguration')
  493. ).' '.get_lang('ThematicAdvanceConfiguration')
  494. );
  495. $form->addHtml('
  496. </a>
  497. </h4>
  498. </div>
  499. ');
  500. $form->addHtml('
  501. <div id="collapse-advance-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-advance-settings">
  502. <div class="panel-body">
  503. ');
  504. $group = array();
  505. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', get_lang('InfoAboutAdvanceInsideHomeCourse'), get_lang('DisplayAboutLastDoneAdvance'), 1);
  506. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDone'), 2);
  507. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDoneAndLastDoneAdvance'), 3);
  508. $group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DoNotDisplayAnyAdvance'), 0);
  509. $form->addGroup($group, '', array(get_lang("InfoAboutAdvanceInsideHomeCourse")));
  510. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  511. $form->addHtml('
  512. </div>
  513. </div>
  514. ');
  515. $form->addHtml('</div>');
  516. // Certificate settings
  517. if (api_get_setting('allow_public_certificates') == 'true') {
  518. $form->addHtml('<div class="panel panel-default">');
  519. $form->addHtml('
  520. <div class="panel-heading" role="tab" id="heading-certificate-settings">
  521. <h4 class="panel-title">
  522. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-certificate-settings" aria-expanded="false" aria-controls="collapse-certificate-settings">
  523. ');
  524. $form->addHtml(
  525. Display::return_icon('certificate.png', get_lang('Certificates')).' '.get_lang('Certificates')
  526. );
  527. $form->addHtml('
  528. </a>
  529. </h4>
  530. </div>
  531. ');
  532. $form->addHtml('
  533. <div id="collapse-certificate-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-certificate-settings">
  534. <div class="panel-body">
  535. ');
  536. $group = array();
  537. $group[] = $form->createElement('radio', 'allow_public_certificates', get_lang('AllowPublicCertificates'), get_lang('Yes'), 1);
  538. $group[] = $form->createElement('radio', 'allow_public_certificates', null, get_lang('No'), 0);
  539. $form->addGroup($group, '', array(get_lang('AllowPublicCertificates')));
  540. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  541. $form->addHtml('
  542. </div>
  543. </div>
  544. ');
  545. $form->addHtml('</div>');
  546. }
  547. // Forum settings
  548. $form->addHtml('<div class="panel panel-default">');
  549. $form->addHtml('
  550. <div class="panel-heading" role="tab" id="heading-forum-settings">
  551. <h4 class="panel-title">
  552. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-forum-settings" aria-expanded="false" aria-controls="collapse-forum-settings">
  553. ');
  554. $form->addHtml(
  555. Display::return_icon('forum.png', get_lang('Forum')).' '.get_lang('Forum')
  556. );
  557. $form->addHtml('
  558. </a>
  559. </h4>
  560. </div>
  561. ');
  562. $form->addHtml('
  563. <div id="collapse-forum-settings" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-forum-settings">
  564. <div class="panel-body">
  565. ');
  566. $group = array(
  567. $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('RedirectToForumList'), 1),
  568. $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('Disabled'), 2),
  569. );
  570. $form->addGroup($group, '', array(get_lang('EnableForumAutoLaunch')));
  571. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  572. $form->addHtml('
  573. </div>
  574. </div>
  575. ');
  576. $form->addHtml('</div>');
  577. // Plugin course settings
  578. $appPlugin = new AppPlugin();
  579. $appPlugin->add_course_settings_form($form);
  580. $form->addHtml('</div>');
  581. // Get all the course information
  582. $all_course_information = CourseManager::get_course_information($_course['sysCode']);
  583. // Set the default values of the form
  584. $values = array();
  585. $values['title'] = $_course['name'];
  586. $values['category_code'] = $_course['categoryCode'];
  587. $values['course_language'] = $_course['language'];
  588. $values['department_name'] = $_course['extLink']['name'];
  589. $values['department_url'] = $_course['extLink']['url'];
  590. $values['visibility'] = $_course['visibility'];
  591. $values['subscribe'] = $_course['subscribe'];
  592. $values['unsubscribe'] = $_course['unsubscribe'];
  593. $values['course_registration_password'] = $all_course_information['registration_code'];
  594. $values['legal'] = $all_course_information['legal'];
  595. $values['activate_legal'] = $all_course_information['activate_legal'];
  596. $courseSettings = CourseManager::getCourseSettingVariables($appPlugin);
  597. foreach ($courseSettings as $setting) {
  598. $result = api_get_course_setting($setting);
  599. if ($result != '-1') {
  600. $values[$setting] = $result;
  601. }
  602. }
  603. $form->setDefaults($values);
  604. // Validate form
  605. if ($form->validate() && is_settings_editable()) {
  606. $updateValues = $form->getSubmitValues();
  607. // update course picture
  608. $picture = $_FILES['picture'];
  609. if (!empty($picture['name'])) {
  610. $picture_uri = CourseManager::update_course_picture(
  611. $_course,
  612. $picture['name'],
  613. $picture['tmp_name'],
  614. $updateValues['picture_crop_result']
  615. );
  616. }
  617. $visibility = $updateValues['visibility'];
  618. $deletePicture = isset($updateValues['delete_picture']) ? $updateValues['delete_picture'] : '';
  619. if ($deletePicture) {
  620. CourseManager::deleteCoursePicture($course_code);
  621. }
  622. global $_configuration;
  623. $urlId = api_get_current_access_url_id();
  624. if (isset($_configuration[$urlId]) &&
  625. isset($_configuration[$urlId]['hosting_limit_active_courses']) &&
  626. $_configuration[$urlId]['hosting_limit_active_courses'] > 0
  627. ) {
  628. $courseInfo = api_get_course_info_by_id($courseId);
  629. // Check if
  630. if ($courseInfo['visibility'] == COURSE_VISIBILITY_HIDDEN &&
  631. $visibility != $courseInfo['visibility']
  632. ) {
  633. $num = CourseManager::countActiveCourses($urlId);
  634. if ($num >= $_configuration[$urlId]['hosting_limit_active_courses']) {
  635. api_warn_hosting_contact('hosting_limit_active_courses');
  636. Display::addFlash(
  637. Display::return_message(get_lang('PortalActiveCoursesLimitReached'))
  638. );
  639. $url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.api_get_cidreq();
  640. header("Location: $url");
  641. exit;
  642. }
  643. }
  644. }
  645. $pdf_export_watermark_path = isset($_FILES['pdf_export_watermark_path']) ? $_FILES['pdf_export_watermark_path'] : null;
  646. if (!empty($pdf_export_watermark_path['name'])) {
  647. $pdf_export_watermark_path_result = PDF::upload_watermark(
  648. $pdf_export_watermark_path['name'],
  649. $pdf_export_watermark_path['tmp_name'],
  650. $course_code
  651. );
  652. unset($updateValues['pdf_export_watermark_path']);
  653. }
  654. // Variables that will be saved in the TABLE_MAIN_COURSE table
  655. $update_in_course_table = array(
  656. 'title',
  657. 'course_language',
  658. 'category_code',
  659. 'department_name',
  660. 'department_url',
  661. 'visibility',
  662. 'subscribe',
  663. 'unsubscribe',
  664. 'tutor_name',
  665. 'course_registration_password',
  666. 'legal',
  667. 'activate_legal'
  668. );
  669. $activeLegal = isset($updateValues['activate_legal']) ? $updateValues['activate_legal'] : 0;
  670. $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
  671. $params = [
  672. 'title' => $updateValues['title'],
  673. 'course_language' => $updateValues['course_language'],
  674. 'category_code' => $updateValues['category_code'],
  675. 'department_name' => $updateValues['department_name'],
  676. 'department_url' => $updateValues['department_url'],
  677. 'visibility' => $updateValues['visibility'],
  678. 'subscribe' => $updateValues['subscribe'],
  679. 'unsubscribe' => $updateValues['unsubscribe'],
  680. 'legal' => $updateValues['legal'],
  681. 'activate_legal' => $activeLegal,
  682. 'registration_code' => $updateValues['course_registration_password'],
  683. ];
  684. Database::update($table_course, $params, ['id = ?' => $courseId]);
  685. // Insert/Updates course_settings table
  686. foreach ($courseSettings as $setting) {
  687. $value = isset($updateValues[$setting]) ? $updateValues[$setting] : null;
  688. CourseManager::saveCourseConfigurationSetting(
  689. $appPlugin,
  690. $setting,
  691. $value,
  692. api_get_course_int_id()
  693. );
  694. }
  695. $appPlugin->saveCourseSettingsHook($updateValues);
  696. $cidReset = true;
  697. $cidReq = $course_code;
  698. Display::addFlash(Display::return_message(get_lang('Updated')));
  699. require '../inc/local.inc.php';
  700. $url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.api_get_cidreq();
  701. header("Location: $url");
  702. exit;
  703. }
  704. if ($show_delete_watermark_text_message) {
  705. Display::addFlash(Display::return_message(get_lang('FileDeleted'), 'normal'));
  706. }
  707. /* Header */
  708. Display::display_header($nameTools, MODULE_HELP_NAME);
  709. // Display the form
  710. echo '<div id="course_settings">';
  711. $form->display();
  712. echo '</div>';
  713. Display::display_footer();