work_list.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../inc/global.inc.php';
  4. $current_course_tool = TOOL_STUDENTPUBLICATION;
  5. api_protect_course_script(true);
  6. require_once 'work.lib.php';
  7. $this_section = SECTION_COURSES;
  8. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  9. if (empty($workId)) {
  10. api_not_allowed(true);
  11. }
  12. $courseInfo = api_get_course_info();
  13. // Student publications are saved with the iid in a LP
  14. $origin = api_get_origin();
  15. if ($origin == 'learnpath') {
  16. $em = Database::getManager();
  17. /** @var \Chamilo\CourseBundle\Entity\CStudentPublication $work */
  18. $work = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->find($workId);
  19. if ($work) {
  20. $workId = $work->getId();
  21. }
  22. }
  23. protectWork($courseInfo, $workId);
  24. $my_folder_data = get_work_data_by_id($workId);
  25. $work_data = get_work_assignment_by_id($workId);
  26. $tool_name = get_lang('StudentPublications');
  27. $group_id = api_get_group_id();
  28. $htmlHeadXtra[] = api_get_jqgrid_js();
  29. $url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
  30. if (!empty($group_id)) {
  31. $group_properties = GroupManager :: get_group_properties($group_id);
  32. $interbreadcrumb[] = array(
  33. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  34. 'name' => get_lang('Groups')
  35. );
  36. $interbreadcrumb[] = array(
  37. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  38. 'name' => get_lang('GroupSpace').' '.$group_properties['name']
  39. );
  40. }
  41. $interbreadcrumb[] = array(
  42. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  43. 'name' => get_lang('StudentPublications')
  44. );
  45. $interbreadcrumb[] = array(
  46. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId,
  47. 'name' => $my_folder_data['title']
  48. );
  49. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  50. $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  51. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  52. $actionsRight = '';
  53. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) {
  54. $url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId;
  55. $actionsRight = Display::url(
  56. Display::return_icon(
  57. 'upload_file.png',
  58. get_lang('UploadMyAssignment'),
  59. null,
  60. ICON_SIZE_MEDIUM
  61. ).get_lang('UploadMyAssignment'),
  62. $url,
  63. array('class'=>'btn-toolbar')
  64. );
  65. }
  66. $tpl = new Template('');
  67. $content = Display::toolbarAction('toolbar-work', array($actionsLeft, $actionsRight));
  68. if (!empty($my_folder_data['title'])) {
  69. $content .= Display::page_subheader($my_folder_data['title']);
  70. }
  71. if (!empty($my_folder_data['description'])) {
  72. $contentWork = Security::remove_XSS($my_folder_data['description']);
  73. $content .= Display::panel($contentWork, get_lang('Description'));
  74. }
  75. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  76. $item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  77. switch ($action) {
  78. case 'delete':
  79. $fileDeleted = deleteWorkItem($item_id, $courseInfo);
  80. if (!$fileDeleted) {
  81. Display::addFlash(Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument')));
  82. } else {
  83. Display::addFlash(Display::return_message(get_lang('TheDocumentHasBeenDeleted')));
  84. }
  85. break;
  86. }
  87. $result = getWorkDateValidationStatus($work_data);
  88. $content .= $result['message'];
  89. $check_qualification = intval($my_folder_data['qualification']);
  90. if (!api_is_invitee()) {
  91. if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
  92. $type = 'simple';
  93. $columns = array(
  94. get_lang('Type'),
  95. get_lang('Title'),
  96. get_lang('Qualification'),
  97. get_lang('Date'),
  98. get_lang('Status'),
  99. get_lang('Actions')
  100. );
  101. $column_model = array(
  102. array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  103. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  104. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'30', 'align'=>'center', 'search' => 'true'),
  105. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  106. array('name'=>'qualificator_id', 'index'=>'qualificator_id', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  107. array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  108. );
  109. } else {
  110. $type = 'complex';
  111. $columns = array(
  112. get_lang('Type'),
  113. get_lang('Title'),
  114. get_lang('Feedback'),
  115. get_lang('Date'),
  116. get_lang('Actions')
  117. );
  118. $column_model = array(
  119. array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  120. array('name'=>'title', 'index'=>'title', 'width'=>'60', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  121. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'30', 'align'=>'center', 'search' => 'true'),
  122. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true', 'sortable'=>'false'),
  123. array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  124. );
  125. }
  126. $extra_params = array(
  127. 'autowidth' => 'true',
  128. 'height' => 'auto',
  129. 'sortname' => 'firstname'
  130. );
  131. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
  132. $content .= '
  133. <script>
  134. $(function() {
  135. '.Display::grid_js('results', $url, $columns, $column_model, $extra_params).'
  136. });
  137. </script>
  138. ';
  139. $tableWork = Display::grid_html('results');
  140. $content .= Display::panel($tableWork);
  141. }
  142. $tpl->assign('content', $content);
  143. $tpl->display_one_col_template();