user_manager.ajax.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Responses to AJAX calls
  5. */
  6. $language_file = array('admin', 'registration', 'userInfo');
  7. require_once '../global.inc.php';
  8. $action = $_GET['a'];
  9. switch ($action) {
  10. case 'get_user_popup':
  11. $user_info = api_get_user_info($_REQUEST['user_id']);
  12. //var_dump($user_info);
  13. echo '<div class="well">';
  14. echo '<div class="row">';
  15. echo '<div class="span2">';
  16. echo '<div class="thumbnail">';
  17. echo '<img src="'.$user_info['avatar'].'" /> ';
  18. echo '</div>';
  19. echo '</div>';
  20. echo '<div class="span3">';
  21. if (api_get_setting('show_email_addresses') == 'false') {
  22. $user_info['mail'] = ' ';
  23. } else {
  24. $user_info['mail'] = ' '.$user_info['mail'].' ';
  25. }
  26. echo '<h3>'.$user_info['complete_name'].'</h3>'.$user_info['mail'].$user_info['official_code'];
  27. echo '<br/><br/><a class="btn" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user_info['user_id'].'">'.get_lang('ViewSharedProfile').'</a>';
  28. echo '</div>';
  29. echo '</div>';
  30. echo '</div>';
  31. break;
  32. case 'user_id_exists':
  33. if (api_is_anonymous()) {
  34. echo '';
  35. } else {
  36. if (UserManager::is_user_id_valid($_GET['user_id'])) {
  37. echo 1;
  38. } else {
  39. echo 0;
  40. }
  41. }
  42. break;
  43. case 'search_tags':
  44. if (api_is_anonymous()) {
  45. echo '';
  46. } else {
  47. if (isset($_GET['tag']) && isset($_GET['field_id'])) {
  48. echo UserManager::get_tags($_GET['tag'], $_GET['field_id'],'json','10');
  49. }
  50. }
  51. break;
  52. case 'generate_api_key':
  53. if (api_is_anonymous()) {
  54. echo '';
  55. } else {
  56. $array_list_key = array();
  57. $user_id = api_get_user_id();
  58. $api_service = 'dokeos';
  59. $num = UserManager::update_api_key($user_id, $api_service);
  60. $array_list_key = UserManager::get_api_keys($user_id, $api_service);
  61. ?>
  62. <div class="row">
  63. <div class="label"><?php echo get_lang('MyApiKey'); ?></div>
  64. <div class="formw">
  65. <input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php echo $array_list_key[$num]; ?>"/>
  66. </div>
  67. </div>
  68. <?php
  69. }
  70. break;
  71. case 'active_user':
  72. if (api_is_platform_admin() && api_global_admin_can_edit_admin($_GET['user_id'])) {
  73. $user_id = intval($_GET['user_id']);
  74. $status = intval($_GET['status']);
  75. if (!empty($user_id)) {
  76. UserManager::change_active_state($user_id, $status, true);
  77. echo $status;
  78. }
  79. } else {
  80. echo '-1';
  81. }
  82. break;
  83. default:
  84. echo '';
  85. }
  86. exit;