listing.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>';
  24. break;
  25. } else {
  26. echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
  27. Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>';
  28. $i++;
  29. }
  30. }
  31. echo '</div>';
  32. }
  33. $history = isset($history) ? $history : null;
  34. // display course description list
  35. if ($history) {
  36. echo '<div>
  37. <table width="100%">
  38. <tr>
  39. <td><h3>'.get_lang('ThematicAdvanceHistory').'</h3></td>
  40. <td align="right"><a href="index.php?action=listing">'.
  41. Display::return_icon('info.png',get_lang('BackToCourseDesriptionList'), array('style'=>'vertical-align:middle;'),ICON_SIZE_SMALL).' '.get_lang('BackToCourseDesriptionList').'</a></td></tr></table></div>';
  42. }
  43. $user_info = api_get_user_info();
  44. if (isset($descriptions) && count($descriptions) > 0) {
  45. foreach ($descriptions as $id => $description) {
  46. if (!empty($description)) {
  47. $actions = '';
  48. if (api_is_allowed_to_edit(null,true) && !$history) {
  49. if (api_get_session_id() == $description['session_id']) {
  50. $description['title'] = $description['title'].' '.api_get_session_image(api_get_session_id(), $user_info['status']);
  51. // delete
  52. $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;">';
  53. $actions .= Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
  54. $actions .= '</a> ';
  55. // edit
  56. $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'].'">';
  57. $actions .= Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),ICON_SIZE_SMALL);
  58. $actions .= '</a> ';
  59. } else {
  60. $actions .= Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
  61. }
  62. }
  63. echo Display::panel(
  64. $description['content'],
  65. $description['title'].$actions,
  66. '',
  67. 'info'
  68. );
  69. }
  70. }
  71. } else {
  72. echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
  73. }