infocours.php 32 KB

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