work_missing.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. $language_file = array('exercice', 'work', 'document', 'admin', 'gradebook');
  5. require_once '../inc/global.inc.php';
  6. $current_course_tool = TOOL_STUDENTPUBLICATION;
  7. /* Configuration settings */
  8. api_protect_course_script(true);
  9. // Including necessary files
  10. require_once 'work.lib.php';
  11. $this_section = SECTION_COURSES;
  12. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  13. $group_id = api_get_group_id();
  14. if (empty($workId)) {
  15. api_not_allowed(true);
  16. }
  17. $my_folder_data = get_work_data_by_id($workId);
  18. if (empty($my_folder_data)) {
  19. api_not_allowed(true);
  20. }
  21. if (!api_is_allowed_to_edit(null, true)) {
  22. api_not_allowed(true);
  23. }
  24. // User with no works
  25. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
  26. switch ($action) {
  27. case 'send_mail':
  28. $check = Security::check_token('get');
  29. if ($check) {
  30. $mails_sent_to = send_reminder_users_without_publication($my_folder_data);
  31. if (empty($mails_sent_to)) {
  32. $error_message = Display::return_message(get_lang('NoResults'), 'warning');
  33. } else {
  34. $error_message = Display::return_message(get_lang('MessageHasBeenSent').' '.implode(', ', $mails_sent_to), 'success');
  35. }
  36. if (!empty($error_message)) {
  37. Session::write('error_message', $error_message);
  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_id,
  54. GroupManager::GROUP_TOOL_WORK
  55. );
  56. }
  57. if (!$show_work) {
  58. api_not_allowed();
  59. }
  60. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group.php', 'name' => get_lang('Groups'));
  61. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  62. }
  63. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  64. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
  65. if (isset($_GET['list']) && $_GET['list'] == 'with') {
  66. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UsersWithTask'));
  67. } else {
  68. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UsersWithoutTask'));
  69. }
  70. Display :: display_header(null);
  71. echo '<div class="actions">';
  72. 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>';
  73. if (!empty($workId)) {
  74. if (empty($_GET['list']) or Security::remove_XSS($_GET['list']) == 'with') {
  75. $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">'.
  76. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'),'',ICON_SIZE_MEDIUM)."</a>";
  77. } else {
  78. if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'send_mail')) {
  79. $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.'">'.
  80. Display::return_icon('mail_send.png', get_lang('ReminderMessage'),'',ICON_SIZE_MEDIUM)."</a>";
  81. } else {
  82. $display_output .= Display::return_icon('mail_send_na.png', get_lang('ReminderMessage'),'',ICON_SIZE_MEDIUM);
  83. }
  84. }
  85. }
  86. echo $display_output;
  87. echo '</div>';
  88. $error_message = Session::read('error_message');
  89. if (!empty($error_message)) {
  90. echo $error_message;
  91. Session::erase('error_message');
  92. }
  93. display_list_users_without_publication($workId);