courses_list.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. &nbsp;<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('display_coursecode_in_courselist') == 'true') {
  76. echo $course['visual_code'];
  77. }
  78. if (api_get_setting('display_coursecode_in_courselist') == 'true' &&
  79. api_get_setting('display_teacher_in_courselist') == 'true'
  80. ) {
  81. echo " - ";
  82. }
  83. if (api_get_setting('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('show_courses_descriptions_in_catalog') == 'true') {
  108. $icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
  109. ?>
  110. <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">
  111. <?php echo Display::return_icon('info.png', $icon_title,'','22') ?>
  112. <?php } ?>
  113. </a>
  114. <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) { ?>
  115. <?php echo Display::display_icon('edit_na.png', get_lang('Edit'),'',22); ?>
  116. <?php } else { ?>
  117. <a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
  118. <?php echo Display::display_icon('edit.png', get_lang('Edit'),'',22); ?>
  119. </a>
  120. <?php } ?>
  121. <?php if ($key > 0) { ?>
  122. <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; ?>">
  123. <?php echo Display::display_icon('up.png', get_lang('Up'),'',22); ?>
  124. </a>
  125. <?php } else { ?>
  126. <?php echo Display::display_icon('up_na.png', get_lang('Up'),'',22); ?>
  127. <?php } ?>
  128. <?php if ($key < $number_of_courses - 1) { ?>
  129. <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; ?>">
  130. <?php echo Display::display_icon('down.png', get_lang('Down'),'',22); ?>
  131. </a>
  132. <?php } else { ?>
  133. <?php echo Display::display_icon('down_na.png', get_lang('Down'),'',22); ?>
  134. <?php } ?>
  135. </div>
  136. <div style="float:left; margin-right:10px;">
  137. <?php if ($course['status'] != 1) {
  138. if ($course['unsubscr'] == 1) {
  139. ?>
  140. <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">
  141. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  142. <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
  143. <button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
  144. <?php echo get_lang('Unsubscribe'); ?>
  145. </button>
  146. </form>
  147. </div>
  148. <?php }
  149. }
  150. $key++;
  151. }
  152. echo '</table>';
  153. }
  154. }
  155. }
  156. echo Display::page_subheader(get_lang('NoCourseCategory'));
  157. echo '<table class="data_table">';
  158. // COURSES WITHOUT CATEGORY
  159. if (!empty($courses_without_category)) {
  160. $number_of_courses = count($courses_without_category);
  161. $key = 0;
  162. foreach ($courses_without_category as $course) {
  163. echo '<tr>';
  164. ?>
  165. <td>
  166. <a name="course<?php echo $course['code']; ?>"></a>
  167. <strong><?php echo $course['title']; ?></strong><br />
  168. <?php
  169. if (api_get_setting('display_coursecode_in_courselist') == 'true') { echo $course['visual_code']; }
  170. if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { echo " - "; }
  171. if (api_get_setting('display_teacher_in_courselist') == 'true') { echo $course['tutor']; }
  172. ?>
  173. </td>
  174. <td valign="top">
  175. <!-- the edit icon OR the edit dropdown list -->
  176. <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
  177. $edit_course = Security::remove_XSS($_GET['edit']);
  178. ?>
  179. <div style="float:left;">
  180. <form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
  181. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  182. <input type="hidden" name="course_2_edit_category" value="<?php echo $edit_course; ?>" />
  183. <select name="course_categories">
  184. <option value="0"><?php echo get_lang("NoCourseCategory"); ?></option>
  185. <?php foreach ($user_course_categories as $row) { ?>
  186. <option value="<?php echo $row['id']; ?>"><?php echo $row['title']; ?></option>
  187. <?php } ?>
  188. </select>
  189. <button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok') ?></button>
  190. </form><br />
  191. </div>
  192. <?php } ?>
  193. <div style="float:left; width:110px">
  194. <?php
  195. if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
  196. $icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
  197. ?>
  198. <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">
  199. <?php echo Display::return_icon('info.png', $icon_title, '','22'); ?>
  200. </a>
  201. <?php } ?>
  202. <?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) { ?>
  203. <?php echo Display::display_icon('edit_na.png', get_lang('Edit'),'',22); ?>
  204. <?php } else { ?>
  205. <a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
  206. <?php echo Display::display_icon('edit.png', get_lang('Edit'),'',22); ?>
  207. </a>
  208. <?php } ?>
  209. <!-- up /down icons-->
  210. <?php if ($key > 0) { ?>
  211. <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; ?>">
  212. <?php echo Display::display_icon('up.png', get_lang('Up'),'',22) ?>
  213. </a>
  214. <?php } else {
  215. echo Display::display_icon('up_na.png', get_lang('Up'),'',22);
  216. }
  217. if ($key < $number_of_courses - 1) { ?>
  218. <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; ?>">
  219. <?php echo Display::display_icon('down.png', get_lang('Down'),'',22); ?>
  220. </a>
  221. <?php } else {
  222. echo Display::display_icon('down_na.png', get_lang('Down'),'',22);
  223. }?>
  224. </div>
  225. <div style="float:left; margin-right:10px;">
  226. <!-- cancel subscrioption-->
  227. <?php if ($course['status'] != 1) {
  228. if ($course['unsubscr'] == 1) {
  229. ?>
  230. <!-- changed link to submit to avoid action by the search tool indexer -->
  231. <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;">
  232. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  233. <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
  234. <button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
  235. <?php echo get_lang('Unsubscribe'); ?>
  236. </button>
  237. </form>
  238. </div>
  239. <?php }
  240. }
  241. ?>
  242. </td>
  243. </tr>
  244. <?php
  245. $key++;
  246. }
  247. }
  248. ?>
  249. </table>