work_list.php 7.0 KB

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