announcement.ajax.php 972 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Responses to AJAX calls
  5. */
  6. require_once __DIR__.'/../global.inc.php';
  7. $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
  8. $isAllowedToEdit = api_is_allowed_to_edit();
  9. $courseInfo = api_get_course_info();
  10. switch ($action) {
  11. case 'delete_item':
  12. if ($isAllowedToEdit) {
  13. if (empty($_REQUEST['id'])) {
  14. return false;
  15. }
  16. if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) {
  17. return false;
  18. }
  19. $list = explode(',', $_REQUEST['id']);
  20. foreach ($list as $itemId) {
  21. if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $itemId)) {
  22. AnnouncementManager::delete_announcement($courseInfo, $itemId);
  23. }
  24. }
  25. }
  26. break;
  27. default:
  28. echo '';
  29. break;
  30. }
  31. exit;