admin.ajax.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Responses to AJAX calls
  5. */
  6. require_once '../global.inc.php';
  7. api_protect_admin_script();
  8. $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
  9. switch ($action) {
  10. case 'user_exists':
  11. $user_info = api_get_user_info($_REQUEST['id']);
  12. if (empty($user_info)) {
  13. echo 0;
  14. } else {
  15. echo 1;
  16. }
  17. break;
  18. case 'find_coaches':
  19. $coaches = SessionManager::get_coaches_by_keyword($_REQUEST['tag']);
  20. $json_coaches = array();
  21. if (!empty($coaches)) {
  22. foreach ($coaches as $coach) {
  23. $json_coaches[] = array(
  24. 'key' => $coach['user_id'],
  25. 'value' => api_get_person_name($coach['firstname'], $coach['lastname'])
  26. );
  27. }
  28. }
  29. echo json_encode($json_coaches);
  30. break;
  31. case 'update_changeable_setting':
  32. $url_id = api_get_current_access_url_id();
  33. if (api_is_global_platform_admin() && $url_id == 1) {
  34. if (isset($_GET['id']) && !empty($_GET['id'])) {
  35. $params = array('variable = ? ' => array($_GET['id']));
  36. $data = api_get_settings_params($params);
  37. if (!empty($data)) {
  38. foreach ($data as $item) {
  39. $params = array('id' =>$item['id'], 'access_url_changeable' => $_GET['changeable']);
  40. api_set_setting_simple($params);
  41. }
  42. }
  43. echo '1';
  44. }
  45. }
  46. break;
  47. }
  48. exit;