diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index acb29469..f48592b5 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -150,7 +150,10 @@ final class Users extends VKAPIRequestHandler break; case "interests": $response[$i]->interests = $usr->getInterests(); - break; + break; + case "rating": + $response[$i]->rating = $usr->getRating(); + break; } } @@ -188,19 +191,94 @@ final class Users extends VKAPIRequestHandler ]; } - function search(string $q, string $fields = "", int $offset = 0, int $count = 100) + function search(string $q, + string $fields = "", + int $offset = 0, + int $count = 100, + string $city = "", + string $hometown = "", + int $sex = 2, + int $status = 0, # это про marital status + bool $online = false, + # дальше идут параметры которых нету в vkapi но есть на сайте + string $profileStatus = "", # а это уже нормальный статус + int $sort = 0, + int $before = 0, + int $politViews = 0, + int $after = 0, + string $interests = "", + string $fav_music = "", + string $fav_films = "", + string $fav_shows = "", + string $fav_books = "", + string $fav_quotes = "" + ) { $users = new UsersRepo; + $sortg = "id ASC"; + + $nfilds = $fields; + + switch($sort) { + case 0: + $sortg = "id DESC"; + break; + case 1: + $sortg = "id ASC"; + break; + case 2: + $sortg = "first_name DESC"; + break; + case 3: + $sortg = "first_name ASC"; + break; + case 4: + $sortg = "rating DESC"; + + if(!str_contains($nfilds, "rating")) { + $nfilds .= "rating"; + } + + break; + case 5: + $sortg = "rating DESC"; + + if(!str_contains($nfilds, "rating")) { + $nfilds .= "rating"; + } + + break; + } + $array = []; - $find = $users->find($q); + + $parameters = [ + "city" => !empty($city) ? $city : NULL, + "hometown" => !empty($hometown) ? $hometown : NULL, + "gender" => $sex < 2 ? $sex : NULL, + "maritalstatus" => (bool)$status ? $status : NULL, + "politViews" => (bool)$politViews ? $politViews : NULL, + "is_online" => $online ? 1 : NULL, + "status" => !empty($profileStatus) ? $profileStatus : NULL, + "before" => $before != 0 ? $before : NULL, + "after" => $after != 0 ? $after : NULL, + "interests" => !empty($interests) ? $interests : NULL, + "fav_music" => !empty($fav_music) ? $fav_music : NULL, + "fav_films" => !empty($fav_films) ? $fav_films : NULL, + "fav_shows" => !empty($fav_shows) ? $fav_shows : NULL, + "fav_books" => !empty($fav_books) ? $fav_books : NULL, + "fav_quotes" => !empty($fav_quotes) ? $fav_quotes : NULL, + ]; + + $find = $users->find($q, $parameters, $sortg); foreach ($find as $user) $array[] = $user->getId(); return (object) [ "count" => $find->size(), - "items" => $this->get(implode(',', $array), $fields, $offset, $count) + "items" => $this->get(implode(',', $array), $nfilds, $offset, $count) ]; } } diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index fcbf4f63..7bb7e194 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -89,7 +89,7 @@ {_header_log_out} {var $atSearch = str_contains($_SERVER['REQUEST_URI'], "/search")} -