From a0901c4b7f2db488cb4fb3be2dd921a0308f4659 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:36:40 +0200 Subject: Adding upstream version 1.0.2. Signed-off-by: Daniel Baumann --- application/controllers/UsersController.php | 99 +++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 application/controllers/UsersController.php (limited to 'application/controllers/UsersController.php') diff --git a/application/controllers/UsersController.php b/application/controllers/UsersController.php new file mode 100644 index 0000000..ef75e89 --- /dev/null +++ b/application/controllers/UsersController.php @@ -0,0 +1,99 @@ +assertRouteAccess(); + } + + public function indexAction() + { + $this->addTitleTab(t('Users')); + + $db = $this->getDb(); + + $users = User::on($db); + + $this->handleSearchRequest($users); + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($users); + $sortControl = $this->createSortControl( + $users, + [ + 'user.display_name' => t('Name'), + 'user.email' => t('Email'), + 'user.pager' => t('Pager Address / Number') + ] + ); + $searchBar = $this->createSearchBar($users, [ + $limitControl->getLimitParam(), + $sortControl->getSortParam() + ]); + + if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) { + if ($searchBar->hasBeenSubmitted()) { + $filter = $this->getFilter(); + } else { + $this->addControl($searchBar); + $this->sendMultipartUpdate(); + return; + } + } else { + $filter = $searchBar->getFilter(); + } + + $this->filter($users, $filter); + + yield $this->export($users); + + $this->addControl($paginationControl); + $this->addControl($sortControl); + $this->addControl($limitControl); + $this->addControl($searchBar); + + $this->addContent(new UserList($users)); + + if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) { + $this->sendMultipartUpdate(); + } + + $this->setAutorefreshInterval(10); + } + + public function completeAction() + { + $suggestions = new ObjectSuggestions(); + $suggestions->setModel(User::class); + $suggestions->forRequest(ServerRequest::fromGlobals()); + $this->getDocument()->add($suggestions); + } + + public function searchEditorAction() + { + $editor = $this->createSearchEditor(User::on($this->getDb()), [ + LimitControl::DEFAULT_LIMIT_PARAM, + SortControl::DEFAULT_SORT_PARAM, + ViewModeSwitcher::DEFAULT_VIEW_MODE_PARAM + ]); + + $this->getDocument()->add($editor); + $this->setTitle(t('Adjust Filter')); + } +} -- cgit v1.2.3