listing.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 messages
  11. if ($messages['edit'] || $messages['add']) {
  12. Display :: display_confirmation_message(get_lang('CourseDescriptionUpdated'));
  13. } else if ($messages['destroy']) {
  14. Display :: display_confirmation_message(get_lang('CourseDescriptionDeleted'));
  15. }
  16. // display actions menu
  17. if (api_is_allowed_to_edit(null,true)) {
  18. $categories = array ();
  19. foreach ($default_description_titles as $id => $title) {
  20. $categories[$id] = $title;
  21. }
  22. $categories[ADD_BLOCK] = get_lang('NewBloc');
  23. $i=1;
  24. echo '<div class="actions" style="margin-bottom:30px">';
  25. ksort($categories);
  26. foreach ($categories as $id => $title) {
  27. if ($i==ADD_BLOCK) {
  28. echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>';
  29. break;
  30. } else {
  31. echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>';
  32. $i++;
  33. }
  34. }
  35. echo '</div>';
  36. }
  37. // display course description list
  38. if ($history) {
  39. echo '<div><table width="100%"><tr><td><h3>'.get_lang('ThematicAdvanceHistory').'</h3></td><td align="right"><a href="index.php?action=listing">'.Display::return_icon('info.png',get_lang('BackToCourseDesriptionList'),array('style'=>'vertical-align:middle;'),ICON_SIZE_SMALL).' '.get_lang('BackToCourseDesriptionList').'</a></td></tr></table></div>';
  40. }
  41. $user_info = api_get_user_info();
  42. if (isset($descriptions) && count($descriptions) > 0) {
  43. foreach ($descriptions as $id => $description) {
  44. echo '<div class="sectiontitle">';
  45. if (api_is_allowed_to_edit(null,true) && !$history) {
  46. if (api_get_session_id() == $description['session_id']) {
  47. $description['title'] = $description['title'].' '.api_get_session_image(api_get_session_id(), $user_info['status']);
  48. //delete
  49. echo '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
  50. echo Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
  51. echo '</a> ';
  52. //edit
  53. echo '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=edit&description_type='.$description['description_type'].'">';
  54. echo Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),ICON_SIZE_SMALL);
  55. echo '</a> ';
  56. } else {
  57. echo Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
  58. }
  59. }
  60. echo $description['title'];
  61. echo '</div>';
  62. echo '<div class="sectioncomment">';
  63. echo $description['content'];
  64. echo '</div>';
  65. }
  66. } else {
  67. echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
  68. }