| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- if(Core::$user->level == User::LEVEL_SUPERADMIN) {
- $page_title = "Users";
- }
- else {
- $page_title = "Testers";
- }
- Core::addBreadcrumb("/account", "Account");
- Core::addBreadcrumb("/account/users", $page_title);
- $sorts = [
- "newest" => "Newest",
- "score" => "Score",
- ];
- $id = http::value("id", "int");
- $first_name = http::value("first_name", "trim");
- $last_name = http::value("last_name", "trim");
- $archived = Http::value("archived", "int") ?? 0;
- $email = http::value("email", "trim");
- $level = http::value("level", "int");
- $customer_id = http::value("customer_id", "int");
- $location_id = http::value("location_id", "int");
- $nvp = [];
- if($id !== null) $nvp["id"] = $id;
- if(strlen($first_name) > 0) $nvp["first_name"] = ((new Constraint("CONTAINS"))->setValues($first_name));
- if(strlen($last_name) > 0) $nvp["last_name"] = ((new Constraint("CONTAINS"))->setValues($last_name));
- if(strlen($email) > 0) $nvp["email"] = $email;
- if($level !== null) $nvp["level"] = $level;
- if(!$archived) $nvp["archived"] = 0;
- $filter_count = null;
- if($nvp) {
- $filter_count = count(array_keys($nvp));
- }
- if(!$archived) {
- $filter_count--;
- }
- else {
- $filter_count++;
- }
- if($filter_count === 0) {
- $filter_count = null;
- }
- if(empty($nvp)) {
- $nvp["level"] = (new Constraint("NOT_EQUALS"))->setValues(User::LEVEL_REGISTERED);
- }
- $sort = http::value("sort");
- switch($sort) {
- case "score":
- $query_options = ["sort" => "score", "order" => "desc"];
- break;
- default:
- $sort = "newest";
- $query_options = ["sort" => "id", "order" => "desc"];
- break;
- }
- $users = User::query($nvp, $query_options);
- $pagination_object = Util::getPaginationObject($users);
- Core::$page = $pagination_object->page;
- Core::$page_count = $pagination_object->pageCount;
- $users = array_slice($users, $pagination_object->offset, $pagination_object->pageSize);
- View::includeOnce("header", compact("page_title"));
- View::include("users", compact("users", "pagination_object", "filter_count", "id", "first_name", "last_name", "archived", "email", "level", "customer_id", "location_id", "sort", "sorts"));
- View::includeOnce("modal_page_jump");
- View::includeOnce("modals/user_export");
- View::includeOnce("footer");
|