work_missing.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. // Including necessary files
  7. require_once 'work.lib.php';
  8. $this_section = SECTION_COURSES;
  9. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  10. $group_id = api_get_group_id();
  11. $user_id = api_get_user_id();
  12. if (empty($workId)) {
  13. api_not_allowed(true);
  14. }
  15. $my_folder_data = get_work_data_by_id($workId);
  16. if (empty($my_folder_data)) {
  17. api_not_allowed(true);
  18. }
  19. if (!api_is_allowed_to_edit(null, true)) {
  20. api_not_allowed(true);
  21. }
  22. // User with no works
  23. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
  24. switch ($action) {
  25. case 'send_mail':
  26. $check = Security::check_token('get');
  27. if ($check) {
  28. $mails_sent_to = send_reminder_users_without_publication(
  29. $my_folder_data
  30. );
  31. if (empty($mails_sent_to)) {
  32. Display::addFlash(Display::return_message(get_lang('NoResults'), 'warning'));
  33. } else {
  34. Display::addFlash(Display::return_message(
  35. get_lang('MessageHasBeenSent').' '.implode(', ', $mails_sent_to),
  36. 'success'
  37. ));
  38. }
  39. Security::clear_token();
  40. }
  41. break;
  42. }
  43. $token = Security::get_token();
  44. if (!empty($group_id)) {
  45. $group_properties = GroupManager::get_group_properties($group_id);
  46. $show_work = false;
  47. if (api_is_allowed_to_edit(false, true)) {
  48. $show_work = true;
  49. } else {
  50. // you are not a teacher
  51. $show_work = GroupManager::user_has_access(
  52. $user_id,
  53. $group_properties['iid'],
  54. GroupManager::GROUP_TOOL_WORK
  55. );
  56. }
  57. if (!$show_work) {
  58. api_not_allowed();
  59. }
  60. $interbreadcrumb[] = [
  61. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  62. 'name' => get_lang('Groups'),
  63. ];
  64. $interbreadcrumb[] = [
  65. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id,
  66. 'name' => get_lang('GroupSpace').' '.$group_properties['name'],
  67. ];
  68. }
  69. $interbreadcrumb[] = [
  70. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  71. 'name' => get_lang('StudentPublications'),
  72. ];
  73. $interbreadcrumb[] = [
  74. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
  75. 'name' => $my_folder_data['title'],
  76. ];
  77. if (isset($_GET['list']) && $_GET['list'] == 'with') {
  78. $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UsersWithTask')];
  79. } else {
  80. $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UsersWithoutTask')];
  81. }
  82. Display::display_header(null);
  83. echo '<div class="actions">';
  84. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?id='.$workId.'&'.api_get_cidreq().'">'.
  85. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  86. $output = '';
  87. if (!empty($workId)) {
  88. if (empty($_GET['list']) or Security::remove_XSS($_GET['list']) == 'with') {
  89. $output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$workId.'&list=without">'.
  90. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM).
  91. "</a>";
  92. } else {
  93. if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'send_mail')) {
  94. $output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$workId.'&list=without&action=send_mail&sec_token='.$token.'">'.
  95. Display::return_icon('mail_send.png', get_lang('ReminderMessage'), '', ICON_SIZE_MEDIUM).
  96. "</a>";
  97. } else {
  98. $output .= Display::return_icon('mail_send_na.png', get_lang('ReminderMessage'), '', ICON_SIZE_MEDIUM);
  99. }
  100. }
  101. }
  102. echo $output;
  103. echo '</div>';
  104. display_list_users_without_publication($workId);