work_missing.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. Security::clear_token();
  37. }
  38. break;
  39. }
  40. $token = Security::get_token();
  41. if (!empty($group_id)) {
  42. $group_properties = GroupManager::get_group_properties($group_id);
  43. $show_work = false;
  44. if (api_is_allowed_to_edit(false, true)) {
  45. $show_work = true;
  46. } else {
  47. // you are not a teacher
  48. $show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
  49. }
  50. if (!$show_work) {
  51. api_not_allowed();
  52. }
  53. $interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
  54. $interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  55. }
  56. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  57. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
  58. if (isset($_GET['list']) && $_GET['list'] == 'with') {
  59. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UsersWithTask'));
  60. } else {
  61. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UsersWithoutTask'));
  62. }
  63. Display :: display_header(null);
  64. echo '<div class="actions">';
  65. 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>';
  66. if (!empty($workId)) {
  67. if (empty($_GET['list']) or Security::remove_XSS($_GET['list']) == 'with') {
  68. $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">'.
  69. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'),'',ICON_SIZE_MEDIUM)."</a>";
  70. } else {
  71. if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'send_mail')) {
  72. $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.'">'.
  73. Display::return_icon('mail_send.png', get_lang('ReminderMessage'),'',ICON_SIZE_MEDIUM)."</a>";
  74. } else {
  75. $display_output .= Display::return_icon('mail_send_na.png', get_lang('ReminderMessage'),'',ICON_SIZE_MEDIUM);
  76. }
  77. }
  78. }
  79. echo $display_output;
  80. echo '</div>';
  81. if (empty($error_message)) {
  82. $error_message = isset($_GET['error_message']) ? Security::remove_XSS($_GET['error_message']) : null;
  83. }
  84. if (!empty($error_message)) {
  85. echo $error_message;
  86. }
  87. display_list_users_without_publication($workId);