work_list.php 6.0 KB

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