work_list.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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(
  26. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  27. 'name' => get_lang('Groups'),
  28. );
  29. $interbreadcrumb[] = array(
  30. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  31. 'name' => get_lang('GroupSpace').' '.$group_properties['name'],
  32. );
  33. }
  34. $interbreadcrumb[] = array(
  35. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  36. 'name' => get_lang('StudentPublications'),
  37. );
  38. $interbreadcrumb[] = array(
  39. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId,
  40. 'name' => $my_folder_data['title'],
  41. );
  42. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  43. Display :: display_header(null);
  44. $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'">'.
  45. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  46. $actionsRight = '';
  47. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) {
  48. $url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin;
  49. $actionsRight = Display::toolbarButton(get_lang('UploadMyAssignment'), $url, 'upload', 'success');
  50. }
  51. echo Display::toolbarAction('toolbar-work', array(0 => $actionsLeft . $actionsRight));
  52. if (!empty($my_folder_data['title'])) {
  53. echo Display::page_subheader($my_folder_data['title']);
  54. }
  55. if (!empty($my_folder_data['description'])) {
  56. $contentWork = Security::remove_XSS($my_folder_data['description']);
  57. $html = '';
  58. $html .= Display::panel($contentWork, get_lang('Description'));
  59. echo $html;
  60. }
  61. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  62. $item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  63. switch ($action) {
  64. case 'delete':
  65. $fileDeleted = deleteWorkItem($item_id, $courseInfo);
  66. if (!$fileDeleted) {
  67. Display::addFlash(Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument')));
  68. } else {
  69. Display::addFlash(Display::return_message(get_lang('TheDocumentHasBeenDeleted')));
  70. }
  71. break;
  72. }
  73. $result = getWorkDateValidationStatus($work_data);
  74. echo $result['message'];
  75. $check_qualification = intval($my_folder_data['qualification']);
  76. if (!api_is_invitee()) {
  77. if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
  78. $type = 'simple';
  79. $columns = array(
  80. get_lang('Type'),
  81. get_lang('Title'),
  82. get_lang('Qualification'),
  83. get_lang('Date'),
  84. get_lang('Status'),
  85. get_lang('Actions')
  86. );
  87. $column_model = array(
  88. array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  89. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  90. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
  91. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  92. array('name'=>'qualificator_id', 'index'=>'qualificator_id', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  93. array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  94. );
  95. } else {
  96. $type = 'complex';
  97. $columns = array(
  98. get_lang('Type'),
  99. get_lang('Title'),
  100. get_lang('Feedback'),
  101. get_lang('Date'),
  102. get_lang('Actions')
  103. );
  104. $column_model = array(
  105. array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  106. array('name'=>'title', 'index'=>'title', 'width'=>'60', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  107. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
  108. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true', 'sortable'=>'false'),
  109. array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  110. );
  111. }
  112. $extra_params = array(
  113. 'autowidth' => 'true',
  114. 'height' => 'auto',
  115. 'sortname' => 'firstname'
  116. );
  117. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type;
  118. ?>
  119. <script>
  120. $(function() {
  121. <?php
  122. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  123. ?>
  124. });
  125. </script>
  126. <?php
  127. $html = '';
  128. $tableWork = Display::grid_html('results');
  129. $html = Display::panel($tableWork);
  130. echo $html;
  131. }
  132. Display :: display_footer();