work_list_all.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. $is_allowed_to_edit = api_is_allowed_to_edit();
  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. $work_data = get_work_assignment_by_id($workId);
  21. if (!api_is_allowed_to_edit()) {
  22. api_not_allowed(true);
  23. }
  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. if (!empty($group_id)) {
  29. $group_properties = GroupManager :: get_group_properties($group_id);
  30. $show_work = false;
  31. if (api_is_allowed_to_edit(false, true)) {
  32. $show_work = true;
  33. } else {
  34. // you are not a teacher
  35. $show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
  36. }
  37. if (!$show_work) {
  38. api_not_allowed();
  39. }
  40. $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
  41. $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  42. }
  43. $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  44. $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
  45. $error_message = null;
  46. Display :: display_header(null);
  47. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  48. $item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  49. /* Delete document */
  50. if ($action == 'delete' && $item_id) {
  51. $file_deleted = deleteWorkItem($item_id, $_course);
  52. if (!$file_deleted) {
  53. Display::display_error_message(get_lang('YouAreNotAllowedToDeleteThisDocument'));
  54. } else {
  55. Display::display_confirmation_message(get_lang('TheDocumentHasBeenDeleted'));
  56. }
  57. }
  58. /* Visible */
  59. if ($is_allowed_to_edit && $action == 'make_visible') {
  60. if (!empty($item_id)) {
  61. if (isset($item_id) && $item_id == 'all') {
  62. } else {
  63. makeVisible($item_id, $courseInfo);
  64. Display::display_confirmation_message(get_lang('FileVisible'));
  65. }
  66. }
  67. }
  68. if ($is_allowed_to_edit && $action == 'make_invisible') {
  69. /* Invisible */
  70. if (!empty($item_id)) {
  71. if (isset($item_id) && $item_id == 'all') {
  72. } else {
  73. makeInvisible($item_id, $courseInfo);
  74. Display::display_confirmation_message(get_lang('FileInvisible'));
  75. }
  76. }
  77. }
  78. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  79. echo '<div class="actions">';
  80. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
  81. if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
  82. /*echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'">';
  83. echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';*/
  84. if (ADD_DOCUMENT_TO_WORK) {
  85. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  86. echo Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
  87. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  88. echo Display::return_icon('user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
  89. }
  90. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  91. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
  92. $count = get_count_work($workId);
  93. if ($count > 0) {
  94. $display_output .= '<a href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  95. Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_MEDIUM).'</a>';
  96. }
  97. echo $display_output;
  98. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  99. echo Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  100. }
  101. echo '</div>';
  102. if (!empty($my_folder_data['title'])) {
  103. echo Display::page_subheader($my_folder_data['title']);
  104. }
  105. $error_message = Session::read('error_message');
  106. if (!empty($error_message)) {
  107. echo $error_message;
  108. Session::erase('error_message');
  109. }
  110. if (!empty($my_folder_data['description'])) {
  111. echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
  112. }
  113. $check_qualification = intval($my_folder_data['qualification']);
  114. if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
  115. $type = 'simple';
  116. $columns = array(
  117. get_lang('Type'),
  118. get_lang('FirstName'),
  119. get_lang('LastName'),
  120. get_lang('Title'),
  121. get_lang('Qualification'),
  122. get_lang('Date'),
  123. get_lang('Status'),
  124. get_lang('Actions')
  125. );
  126. $column_model = array (
  127. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  128. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  129. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  130. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  131. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  132. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  133. array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'25', 'align'=>'left', 'search' => 'true'),
  134. array('name'=>'actions', 'index'=>'actions', 'width'=>'30', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', )
  135. );
  136. } else {
  137. $type = 'complex';
  138. $columns = array(
  139. get_lang('Type'),
  140. get_lang('FirstName'),
  141. get_lang('LastName'),
  142. get_lang('Title'),
  143. get_lang('Date'),
  144. get_lang('Actions')
  145. );
  146. $column_model = array (
  147. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  148. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  149. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  150. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  151. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'45', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  152. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', 'wrap_cell' => 'true')
  153. );
  154. }
  155. $extra_params = array();
  156. // Auto-width
  157. $extra_params['autowidth'] = 'true';
  158. // height auto
  159. $extra_params['height'] = 'auto';
  160. $extra_params['sortname'] = 'firstname';
  161. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type;
  162. ?>
  163. <script>
  164. $(function() {
  165. <?php
  166. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  167. ?>
  168. });
  169. </script>
  170. <?php
  171. echo $documentsAddedInWork;
  172. echo Display::grid_html('results');
  173. Display :: display_footer();