From b18bc644404e02b57635bfcc8258e85abb141146 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:44:46 +0200 Subject: Adding upstream version 1.1.1. Signed-off-by: Daniel Baumann --- application/controllers/UsergroupsController.php | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 application/controllers/UsergroupsController.php (limited to 'application/controllers/UsergroupsController.php') diff --git a/application/controllers/UsergroupsController.php b/application/controllers/UsergroupsController.php new file mode 100644 index 0000000..99a73a9 --- /dev/null +++ b/application/controllers/UsergroupsController.php @@ -0,0 +1,95 @@ +assertRouteAccess(); + } + + public function indexAction() + { + $this->addTitleTab(t('User Groups')); + + $db = $this->getDb(); + + $usergroups = Usergroup::on($db); + + $limitControl = $this->createLimitControl(); + $paginationControl = $this->createPaginationControl($usergroups); + $sortControl = $this->createSortControl( + $usergroups, + [ + 'usergroup.display_name' => t('Name') + ] + ); + $searchBar = $this->createSearchBar($usergroups, [ + $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($usergroups, $filter); + + yield $this->export($usergroups); + + $this->addControl($paginationControl); + $this->addControl($sortControl); + $this->addControl($limitControl); + $this->addControl($searchBar); + + $this->addContent(new UsergroupTable($usergroups)); + + if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) { + $this->sendMultipartUpdate(); + } + + $this->setAutorefreshInterval(10); + } + + public function completeAction() + { + $suggestions = new ObjectSuggestions(); + $suggestions->setModel(Usergroup::class); + $suggestions->forRequest(ServerRequest::fromGlobals()); + $this->getDocument()->add($suggestions); + } + + public function searchEditorAction() + { + $editor = $this->createSearchEditor(Usergroup::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