index.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. if (cfr('USERSEARCH')) {
  3. //catch ajax backend callback
  4. if (ubRouting::checkGet('glosearch')) {
  5. $globalSearch = new GlobalSearch();
  6. $globalSearch->ajaxCallback();
  7. }
  8. if (ubRouting::checkGet('sphinxsearch')) {
  9. $fallback = json_encode(array());
  10. if (ubRouting::checkPost('search')) {
  11. $sphinxSearch = new SphinxSearch(ubRouting::post('search'));
  12. return $fallback;
  13. }
  14. return $fallback;
  15. }
  16. // rendering some search forms
  17. show_window(__('User search'), web_UserSearchGrid());
  18. // default fields search
  19. if (ubRouting::checkPost('searchquery')) {
  20. $query = ubRouting::post('searchquery');
  21. $searchtype = ubRouting::post('searchtype');
  22. if (!empty($query)) {
  23. show_window(__('Search results') . ' - ' . zb_UserSearchTypeLocalize($searchtype, $query), ($searchtype == 'full') ? zb_UserSearchAllFields($query) : zb_UserSearchFields($query, $searchtype));
  24. }
  25. }
  26. //full address search
  27. if (ubRouting::checkPost('aptsearch')) {
  28. $aptquery = ubRouting::post('aptsearch');
  29. show_window(__('Search results'), zb_UserSearchFields($aptquery, 'apt'));
  30. }
  31. //partial address search
  32. if (ubRouting::checkPost('partialaddr')) {
  33. $search_query = ubRouting::post('partialaddr', 'callback', 'trim');
  34. if (!empty($search_query)) {
  35. $found_users = zb_UserSearchAddressPartial($search_query);
  36. show_window(__('Search results') . ' - ' . zb_UserSearchTypeLocalize('partialaddr', $search_query), web_UserArrayShower($found_users));
  37. }
  38. }
  39. //CF search
  40. if (ubRouting::checkPost('cfquery', false)) {
  41. $search_query = ubRouting::post('cfquery');
  42. if (strlen($search_query) > 0) {
  43. $found_users = zb_UserSearchCF(ubRouting::post('cftypeid'), $search_query);
  44. show_window(__('Search results') . ' - ' . __('Additional profile fields'), web_UserArrayShower($found_users));
  45. }
  46. }
  47. //do the global search
  48. if (ubRouting::checkPost('globalsearchquery')) {
  49. $globalSearchQuery = ubRouting::post('globalsearchquery');
  50. if (ubRouting::checkPost('globalsearch_type')) {
  51. $globalSearchType = ubRouting::post('globalsearch_type');
  52. } else {
  53. $globalSearch = new GlobalSearch();
  54. $globalSearchType = $globalSearch->detectSearchType($globalSearchQuery);
  55. }
  56. if ($globalSearchType) {
  57. //partial address search
  58. if ($globalSearchType == 'address') {
  59. $globalSearchQuery = trim($globalSearchQuery);
  60. $found_users = zb_UserSearchAddressPartial($globalSearchQuery);
  61. show_window(__('Search results') . ' - ' . zb_UserSearchTypeLocalize('partialaddr', $globalSearchQuery), web_UserArrayShower($found_users));
  62. } elseif ($globalSearchType == 'address_extend') {
  63. $globalSearchQuery = trim($globalSearchQuery);
  64. $found_users = zb_UserSearchAddressPartial($globalSearchQuery, true);
  65. show_window(__('Search results') . ' - ' . zb_UserSearchTypeLocalize('extenaddr', $globalSearchQuery), web_UserArrayShower($found_users));
  66. } else {
  67. if ($globalSearchType != 'full') {
  68. //other fields search
  69. if (!empty($globalSearchQuery)) {
  70. show_window(__('Search results') . ' - ' . zb_UserSearchTypeLocalize($globalSearchType, $globalSearchQuery), zb_UserSearchFields($globalSearchQuery, $globalSearchType));
  71. }
  72. } else {
  73. //all fields search for sphinx
  74. show_window(__('Search results') . ' - ' . zb_UserSearchTypeLocalize($globalSearchType, $globalSearchQuery), zb_UserSearchAllFields($globalSearchQuery));
  75. }
  76. }
  77. } else {
  78. show_warning(__('Nothing found'));
  79. }
  80. }
  81. zb_BillingStats(true);
  82. } else {
  83. show_error(__('Access denied'));
  84. }