work_list.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. require_once '../inc/global.inc.php';
  5. $current_course_tool = TOOL_STUDENTPUBLICATION;
  6. api_protect_course_script(true);
  7. // Including necessary files
  8. require_once 'work.lib.php';
  9. $this_section = SECTION_COURSES;
  10. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  11. $origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : '';
  12. if (empty($workId)) {
  13. api_not_allowed(true);
  14. }
  15. $courseInfo = api_get_course_info();
  16. protectWork($courseInfo, $workId);
  17. $my_folder_data = get_work_data_by_id($workId);
  18. $work_data = get_work_assignment_by_id($workId);
  19. $tool_name = get_lang('StudentPublications');
  20. $group_id = api_get_group_id();
  21. $htmlHeadXtra[] = api_get_jqgrid_js();
  22. $url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
  23. if (!empty($group_id)) {
  24. $group_properties = GroupManager :: get_group_properties($group_id);
  25. $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'));
  26. $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  27. }
  28. $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  29. $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
  30. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  31. Display :: display_header(null);
  32. echo '<div class="actions">';
  33. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'">'.
  34. Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
  35. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee() ) {
  36. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin.'">';
  37. echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';
  38. }
  39. echo '</div>';
  40. if (!empty($my_folder_data['title'])) {
  41. echo Display::page_subheader($my_folder_data['title']);
  42. }
  43. $error_message = Session::read('error_message');
  44. if (!empty($error_message)) {
  45. echo $error_message;
  46. Session::erase('error_message');
  47. }
  48. if (!empty($my_folder_data['description'])) {
  49. echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.
  50. Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
  51. }
  52. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  53. $item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  54. switch ($action) {
  55. case 'delete':
  56. $fileDeleted = deleteWorkItem($item_id, $courseInfo);
  57. if (!$fileDeleted) {
  58. Display::display_error_message(get_lang('YouAreNotAllowedToDeleteThisDocument'));
  59. } else {
  60. Display::display_confirmation_message(get_lang('TheDocumentHasBeenDeleted'));
  61. }
  62. break;
  63. }
  64. $result = getWorkDateValidationStatus($work_data);
  65. echo $result['message'];
  66. $check_qualification = intval($my_folder_data['qualification']);
  67. if (!api_is_invitee()) {
  68. if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
  69. $type = 'simple';
  70. $columns = array(
  71. get_lang('Type'),
  72. get_lang('Title'),
  73. get_lang('Qualification'),
  74. get_lang('Date'),
  75. get_lang('Status'),
  76. get_lang('Actions')
  77. );
  78. $column_model = array(
  79. array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  80. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  81. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
  82. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  83. array('name'=>'qualificator_id', 'index'=>'qualificator_id', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  84. array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  85. );
  86. } else {
  87. $type = 'complex';
  88. $columns = array(
  89. get_lang('Type'),
  90. get_lang('Title'),
  91. get_lang('Feedback'),
  92. get_lang('Date'),
  93. get_lang('Actions')
  94. );
  95. $column_model = array(
  96. array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  97. array('name'=>'title', 'index'=>'title', 'width'=>'60', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  98. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
  99. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true', 'sortable'=>'false'),
  100. array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  101. );
  102. }
  103. $extra_params = array(
  104. 'autowidth' => 'true',
  105. 'height' => 'auto',
  106. 'sortname' => 'firstname'
  107. );
  108. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type;
  109. ?>
  110. <script>
  111. $(function() {
  112. <?php
  113. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  114. ?>
  115. });
  116. </script>
  117. <?php
  118. echo Display::grid_html('results');
  119. }
  120. Display :: display_footer();