work_list.php 6.0 KB

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