courses_list.php 15 KB

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