work_missing.php 3.9 KB

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