users = array(); $this->pageCount = 0; $this->page = 1; } public function loadView() { parent::loadView(); $this->title = L("User Control"); $this->requestUsers(); } private function requestUsers() { if(isset($_GET["page"]) && is_numeric($_GET["page"])) { $this->page = intval($_GET["page"]); } else { $this->page = 1; } $req = new \Api\User\Fetch($this->getDocument()->getUser()); if (!$req->execute(array("page" => $this->page))) { $this->errorMessages[] = $req->getLastError(); } else { $result = $req->getResult(); $this->users = $result["users"]; $this->pageCount = $result["pages"]; } } private function getGroups($groups) { $badges = []; foreach($groups as $groupId => $group) { $badgeClass = "secondary"; if ($groupId === USER_GROUP_ADMIN) { $badgeClass = "danger"; } $badges[] = $this->createBadge($badgeClass, $group); } return implode(" ", $badges); } private function getPagination() { $userPageNavigation = L("User page navigation"); $previousDisabled = ($this->page == 1 ? " disabled" : ""); $nextDisabled = ($this->page >= $this->pageCount ? " disabled" : ""); $html = ""; return $html; } private function getUserRows() { $userRows = array(); foreach($this->users as $uid => $user) { $name = $user["name"]; $email = $user["email"] ?? ""; $registeredAt = formatDate($user["registered_at"]); $groups = $this->getGroups($user["groups"]); $userRows[] = "
$name | $groups | $registeredAt |
---|