listing.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Template (view in MVC pattern) used for listing course descriptions
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.course_description
  7. */
  8. // protect a course script
  9. api_protect_course_script(true);
  10. // display actions menu
  11. if (api_is_allowed_to_edit(null, true)) {
  12. $categories = array();
  13. foreach ($default_description_titles as $id => $title) {
  14. $categories[$id] = $title;
  15. }
  16. $categories[ADD_BLOCK] = get_lang('NewBloc');
  17. $i = 1;
  18. echo '<div class="actions" style="margin-bottom:30px">';
  19. ksort($categories);
  20. foreach ($categories as $id => $title) {
  21. if ($i == ADD_BLOCK) {
  22. echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
  23. Display::return_icon(
  24. $default_description_icon[$id],
  25. $title,
  26. '',
  27. ICON_SIZE_MEDIUM
  28. ).
  29. '</a>';
  30. break;
  31. } else {
  32. echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
  33. Display::return_icon(
  34. $default_description_icon[$id],
  35. $title,
  36. '',
  37. ICON_SIZE_MEDIUM
  38. ).
  39. '</a>';
  40. $i++;
  41. }
  42. }
  43. echo '</div>';
  44. }
  45. $history = isset($history) ? $history : null;
  46. // display course description list
  47. if ($history) {
  48. echo '<div>
  49. <table width="100%">
  50. <tr>
  51. <td><h3>'.get_lang('ThematicAdvanceHistory').'</h3></td>
  52. <td align="right"><a href="index.php?action=listing">';
  53. echo Display::return_icon(
  54. 'info.png',
  55. get_lang('BackToCourseDesriptionList'),
  56. array('style' => 'vertical-align:middle;'),
  57. ICON_SIZE_SMALL
  58. );
  59. echo ' '.get_lang('BackToCourseDesriptionList').'</a></td></tr></table></div>';
  60. }
  61. $user_info = api_get_user_info();
  62. if (isset($descriptions) && count($descriptions) > 0) {
  63. foreach ($descriptions as $id => $description) {
  64. if (!empty($description)) {
  65. $actions = '';
  66. if (api_is_allowed_to_edit(null, true) && !$history) {
  67. if (api_get_session_id() == $description['session_id']) {
  68. $description['title'] = $description['title'].' '.api_get_session_image(api_get_session_id(), $user_info['status']);
  69. // delete
  70. $actions .= '<a href="'.api_get_self().'?id='.$description['id'].'&'.api_get_cidreq_params(api_get_course_id(), $description['session_id']).'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding())).'\')) return false;">';
  71. $actions .= Display::return_icon(
  72. 'delete.png',
  73. get_lang('Delete'),
  74. array('style' => 'vertical-align:middle;float:right;'),
  75. ICON_SIZE_SMALL
  76. );
  77. $actions .= '</a> ';
  78. // edit
  79. $actions .= '<a href="'.api_get_self().'?id='.$description['id'].'&'.api_get_cidreq_params(api_get_course_id(), $description['session_id']).'&action=edit&description_type='.$description['description_type'].'">';
  80. $actions .= Display::return_icon(
  81. 'edit.png',
  82. get_lang('Edit'),
  83. array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),
  84. ICON_SIZE_SMALL
  85. );
  86. $actions .= '</a> ';
  87. } else {
  88. $actions .= Display::return_icon(
  89. 'edit_na.png',
  90. get_lang('EditionNotAvailableFromSession'),
  91. array('style' => 'vertical-align:middle;float:right;'),
  92. ICON_SIZE_SMALL
  93. );
  94. }
  95. }
  96. echo Display::panel(
  97. Security::remove_XSS($description['content']),
  98. "<div class='pull-right'>$actions</div>{$description['title']}",
  99. '',
  100. 'info'
  101. );
  102. }
  103. }
  104. } else {
  105. echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
  106. }