work_missing.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /* Configuration settings */
  7. api_protect_course_script(true);
  8. // Including necessary files
  9. require_once 'work.lib.php';
  10. $this_section = SECTION_COURSES;
  11. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  12. $group_id = api_get_group_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($my_folder_data);
  30. if (empty($mails_sent_to)) {
  31. $error_message = Display::return_message(get_lang('NoResults'), 'warning');
  32. } else {
  33. $error_message = Display::return_message(get_lang('MessageHasBeenSent').' '.implode(', ', $mails_sent_to), 'success');
  34. }
  35. if (!empty($error_message)) {
  36. Session::write('error_message', $error_message);
  37. }
  38. Security::clear_token();
  39. }
  40. break;
  41. }
  42. $token = Security::get_token();
  43. if (!empty($group_id)) {
  44. $group_properties = GroupManager::get_group_properties($group_id);
  45. $show_work = false;
  46. if (api_is_allowed_to_edit(false, true)) {
  47. $show_work = true;
  48. } else {
  49. // you are not a teacher
  50. $show_work = GroupManager::user_has_access(
  51. $user_id,
  52. $group_id,
  53. GroupManager::GROUP_TOOL_WORK
  54. );
  55. }
  56. if (!$show_work) {
  57. api_not_allowed();
  58. }
  59. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group.php', 'name' => get_lang('Groups'));
  60. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  61. }
  62. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  63. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
  64. if (isset($_GET['list']) && $_GET['list'] == 'with') {
  65. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UsersWithTask'));
  66. } else {
  67. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UsersWithoutTask'));
  68. }
  69. Display :: display_header(null);
  70. echo '<div class="actions">';
  71. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?id='.$workId.'&'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
  72. if (!empty($workId)) {
  73. if (empty($_GET['list']) or Security::remove_XSS($_GET['list']) == 'with') {
  74. $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$workId.'&amp;curdirpath='.$cur_dir_path.'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;list=without">'.
  75. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'),'',ICON_SIZE_MEDIUM)."</a>";
  76. } else {
  77. if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'send_mail')) {
  78. $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$workId.'&amp;curdirpath='.$cur_dir_path.'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;list=without&amp;action=send_mail&amp;sec_token='.$token.'">'.
  79. Display::return_icon('mail_send.png', get_lang('ReminderMessage'),'',ICON_SIZE_MEDIUM)."</a>";
  80. } else {
  81. $display_output .= Display::return_icon('mail_send_na.png', get_lang('ReminderMessage'),'',ICON_SIZE_MEDIUM);
  82. }
  83. }
  84. }
  85. echo $display_output;
  86. echo '</div>';
  87. $error_message = Session::read('error_message');
  88. if (!empty($error_message)) {
  89. echo $error_message;
  90. Session::erase('error_message');
  91. }
  92. display_list_users_without_publication($workId);