courses_list.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for courses
  5. * @author Christian Fasanando <christian1827@gmail.com> - Beeznest
  6. * @package chamilo.auth
  7. */
  8. // Access rights: anonymous users can't do anything usefull here.
  9. api_block_anonymous_users();
  10. $stok = Security::get_token();
  11. $courses_without_category = isset($courses_in_category[0]) ? $courses_in_category[0] : null;
  12. ?>
  13. <!-- Actions: The menu with the different options in cathe course management -->
  14. <div id="actions" class="actions">
  15. <?php if ($action != 'createcoursecategory') { ?>
  16. <a href="<?php echo api_get_self(); ?>?action=createcoursecategory"><?php echo Display::return_icon('new_folder.png', get_lang('CreateCourseCategory'),'','32'); ?></a>
  17. <?php } ?>
  18. </div>
  19. <?php
  20. if (!empty($message)) {
  21. Display::display_confirmation_message($message, false);
  22. }
  23. // COURSES WITH CATEGORIES
  24. if (!empty($user_course_categories)) {
  25. foreach ($user_course_categories as $row) {
  26. echo Display::page_subheader($row['title']);
  27. echo '<a name="category'.$row['id'].'"></a>';
  28. if (isset($_GET['categoryid']) && $_GET['categoryid'] == $row['id']) { ?>
  29. <!-- We display the edit form for the category -->
  30. <form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
  31. <input type="hidden" name="edit_course_category" value="<?php echo $row['id']; ?>" />
  32. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  33. <input type="text" name="title_course_category" value="<?php echo $row['title']; ?>" />
  34. <button class="save" type="submit" name="submit_edit_course_category"><?php echo get_lang('Ok'); ?></button>
  35. </form>
  36. <?php } ?>
  37. <!-- display category icons -->
  38. <?php
  39. $max_category_key = count($user_course_categories);
  40. if ($action != 'unsubscribe') { ?>
  41. <a href="courses.php?action=sortmycourses&amp;categoryid=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>#category<?php echo $row['id']; ?>">
  42. <?php echo Display::display_icon('edit.png', get_lang('Edit'),'',22); ?>
  43. </a>
  44. <?php if ($row['id'] != $user_course_categories[0]['id']) { ?>
  45. <a href="courses.php?action=<?php echo $action ?>&amp;move=up&amp;category=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
  46. <?php echo Display::return_icon('up.png', get_lang('Up'),'',22); ?>
  47. </a>
  48. <?php } else { ?>
  49. <?php echo Display::return_icon('up_na.png', get_lang('Up'),'',22); ?>
  50. <?php } ?>
  51. <?php if ($row['id'] != $user_course_categories[$max_category_key - 1]['id']) { ?>
  52. <a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;category=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
  53. <?php echo Display::return_icon('down.png', get_lang('Down'),'',22); ?>
  54. </a>
  55. <?php } else { ?>
  56. <?php echo Display::return_icon('down_na.png', get_lang('Down'),'',22); ?>
  57. <?php } ?>
  58. <a href="courses.php?action=deletecoursecategory&amp;id=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
  59. <?php echo Display::display_icon('delete.png', get_lang('Delete'), array('onclick' => "javascript: if (!confirm('".addslashes(api_htmlentities(get_lang("CourseCategoryAbout2bedeleted"), ENT_QUOTES, api_get_system_encoding()))."')) return false;"),22) ?>
  60. </a>
  61. <?php }
  62. echo '<br /><br />';
  63. // Show the courses inside this category
  64. echo '<table class="data_table">';
  65. $number_of_courses = isset($courses_in_category[$row['id']]) ? count($courses_in_category[$row['id']]) : 0;
  66. $key = 0;
  67. if (!empty($courses_in_category[$row['id']])) {
  68. foreach ($courses_in_category[$row['id']] as $course) {
  69. ?>
  70. <tr>
  71. <td>
  72. <a name="course<?php echo $course['code']; ?>"></a>
  73. <strong><?php echo $course['title']; ?></strong><br />
  74. <?php
  75. if (api_get_setting('course.display_coursecode_in_courselist') == 'true') {
  76. echo $course['visual_code'];
  77. }
  78. if (api_get_setting('course.display_coursecode_in_courselist') == 'true' &&
  79. api_get_setting('course.display_teacher_in_courselist') == 'true'
  80. ) {
  81. echo " - ";
  82. }
  83. if (api_get_setting('course.display_teacher_in_courselist') == 'true') {
  84. echo $course['tutor'];
  85. }
  86. ?>
  87. </td>
  88. <td valign="top">
  89. <!-- edit -->
  90. <?php
  91. if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
  92. $edit_course = Security::remove_XSS($_GET['edit']); ?>
  93. <form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
  94. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  95. <input type="hidden" name="course_2_edit_category" value="<?php echo $edit_course; ?>" />
  96. <select name="course_categories">
  97. <option value="0"><?php echo get_lang("NoCourseCategory"); ?></option>
  98. <?php foreach ($user_course_categories as $row) { ?>
  99. <option value="<?php echo $row['id'] ?>"><?php echo $row['title']; ?></option>
  100. <?php } ?>
  101. </select>
  102. <button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok'); ?></button>
  103. </form>
  104. <?php } ?>
  105. <div style="float:left;width:110px;">
  106. <?php
  107. if (api_get_setting(
  108. 'course.show_courses_descriptions_in_catalog'
  109. ) == 'true') {
  110. $icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
  111. ?>
  112. <a href="<?php echo api_get_path(WEB_CODE_PATH); ?>inc/ajax/course_home.ajax.php?a=show_course_information&code=<?php echo $course['code'] ?>" data-title="<?php echo $icon_title ?>" title="<?php echo $icon_title ?>" class="ajax">
  113. <?php echo Display::return_icon('info.png', $icon_title,'','22') ?>
  114. <?php } ?>
  115. </a>
  116. <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) { ?>
  117. <?php echo Display::display_icon('edit_na.png', get_lang('Edit'),'',22); ?>
  118. <?php } else { ?>
  119. <a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
  120. <?php echo Display::display_icon('edit.png', get_lang('Edit'),'',22); ?>
  121. </a>
  122. <?php } ?>
  123. <?php if ($key > 0) { ?>
  124. <a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
  125. <?php echo Display::display_icon('up.png', get_lang('Up'),'',22); ?>
  126. </a>
  127. <?php } else { ?>
  128. <?php echo Display::display_icon('up_na.png', get_lang('Up'),'',22); ?>
  129. <?php } ?>
  130. <?php if ($key < $number_of_courses - 1) { ?>
  131. <a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
  132. <?php echo Display::display_icon('down.png', get_lang('Down'),'',22); ?>
  133. </a>
  134. <?php } else { ?>
  135. <?php echo Display::display_icon('down_na.png', get_lang('Down'),'',22); ?>
  136. <?php } ?>
  137. </div>
  138. <div style="float:left; margin-right:10px;">
  139. <?php if ($course['status'] != 1) {
  140. if ($course['unsubscr'] == 1) {
  141. ?>
  142. <form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding()))?>')) return false">
  143. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  144. <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
  145. <button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
  146. <?php echo get_lang('Unsubscribe'); ?>
  147. </button>
  148. </form>
  149. </div>
  150. <?php }
  151. }
  152. $key++;
  153. }
  154. echo '</table>';
  155. }
  156. }
  157. }
  158. echo Display::page_subheader(get_lang('NoCourseCategory'));
  159. echo '<table class="data_table">';
  160. // COURSES WITHOUT CATEGORY
  161. if (!empty($courses_without_category)) {
  162. $number_of_courses = count($courses_without_category);
  163. $key = 0;
  164. foreach ($courses_without_category as $course) {
  165. echo '<tr>';
  166. ?>
  167. <td>
  168. <a name="course<?php echo $course['code']; ?>"></a>
  169. <strong><?php echo $course['title']; ?></strong><br />
  170. <?php
  171. if (api_get_setting('course.display_coursecode_in_courselist') == 'true') { echo $course['visual_code']; }
  172. if (api_get_setting('course.display_coursecode_in_courselist') == 'true' && api_get_setting('course.display_teacher_in_courselist') == 'true') { echo " - "; }
  173. if (api_get_setting('course.display_teacher_in_courselist') == 'true') { echo $course['tutor']; }
  174. ?>
  175. </td>
  176. <td valign="top">
  177. <!-- the edit icon OR the edit dropdown list -->
  178. <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
  179. $edit_course = Security::remove_XSS($_GET['edit']);
  180. ?>
  181. <div style="float:left;">
  182. <form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
  183. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  184. <input type="hidden" name="course_2_edit_category" value="<?php echo $edit_course; ?>" />
  185. <select name="course_categories">
  186. <option value="0"><?php echo get_lang("NoCourseCategory"); ?></option>
  187. <?php foreach ($user_course_categories as $row) { ?>
  188. <option value="<?php echo $row['id']; ?>"><?php echo $row['title']; ?></option>
  189. <?php } ?>
  190. </select>
  191. <button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok') ?></button>
  192. </form><br />
  193. </div>
  194. <?php } ?>
  195. <div style="float:left; width:110px">
  196. <?php
  197. if (api_get_setting(
  198. 'course.show_courses_descriptions_in_catalog'
  199. ) == 'true'
  200. ) {
  201. $icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
  202. ?>
  203. <a href="<?php echo api_get_path(WEB_CODE_PATH); ?>inc/ajax/course_home.ajax.php?a=show_course_information&code=<?php echo $course['code'] ?>" data-title="<?php echo $icon_title ?>" title="<?php echo $icon_title ?>" class="ajax">
  204. <?php echo Display::return_icon('info.png', $icon_title, '','22'); ?>
  205. </a>
  206. <?php } ?>
  207. <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) { ?>
  208. <?php echo Display::display_icon('edit_na.png', get_lang('Edit'),'',22); ?>
  209. <?php } else { ?>
  210. <a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
  211. <?php echo Display::display_icon('edit.png', get_lang('Edit'),'',22); ?>
  212. </a>
  213. <?php } ?>
  214. <!-- up /down icons-->
  215. <?php if ($key > 0) { ?>
  216. <a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
  217. <?php echo Display::display_icon('up.png', get_lang('Up'),'',22) ?>
  218. </a>
  219. <?php } else {
  220. echo Display::display_icon('up_na.png', get_lang('Up'),'',22);
  221. }
  222. if ($key < $number_of_courses - 1) { ?>
  223. <a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
  224. <?php echo Display::display_icon('down.png', get_lang('Down'),'',22); ?>
  225. </a>
  226. <?php } else {
  227. echo Display::display_icon('down_na.png', get_lang('Down'),'',22);
  228. }?>
  229. </div>
  230. <div style="float:left; margin-right:10px;">
  231. <!-- cancel subscrioption-->
  232. <?php if ($course['status'] != 1) {
  233. if ($course['unsubscr'] == 1) {
  234. ?>
  235. <!-- changed link to submit to avoid action by the search tool indexer -->
  236. <form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())) ?>')) return false;">
  237. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  238. <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
  239. <button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
  240. <?php echo get_lang('Unsubscribe'); ?>
  241. </button>
  242. </form>
  243. </div>
  244. <?php }
  245. }
  246. ?>
  247. </td>
  248. </tr>
  249. <?php
  250. $key++;
  251. }
  252. }
  253. ?>
  254. </table>