mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 00:34:03 +02:00
UserController: Behave nicely when it's not possible to fetch any users
refs #8826
This commit is contained in:
parent
e9fee2dad6
commit
8927121266
@ -1,12 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
use \Exception;
|
||||||
use \Zend_Controller_Action_Exception;
|
use \Zend_Controller_Action_Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Authentication\User\UserBackend;
|
use Icinga\Authentication\User\UserBackend;
|
||||||
use Icinga\Authentication\User\UserBackendInterface;
|
use Icinga\Authentication\User\UserBackendInterface;
|
||||||
use Icinga\Web\Controller;
|
use Icinga\Web\Controller;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Widget;
|
use Icinga\Web\Widget;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
@ -74,12 +76,17 @@ class UserController extends Controller
|
|||||||
$query->applyFilter($filterEditor->getFilter());
|
$query->applyFilter($filterEditor->getFilter());
|
||||||
$this->setupFilterControl($filterEditor);
|
$this->setupFilterControl($filterEditor);
|
||||||
|
|
||||||
$this->getTabs()->activate('user/list');
|
try {
|
||||||
|
$this->view->users = $query->paginate();
|
||||||
|
$this->setupPaginationControl($this->view->users);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Notification::error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$this->view->backend = $backend;
|
$this->view->backend = $backend;
|
||||||
$this->view->users = $query->paginate();
|
$this->getTabs()->activate('user/list');
|
||||||
|
|
||||||
$this->setupLimitControl();
|
$this->setupLimitControl();
|
||||||
$this->setupPaginationControl($this->view->users);
|
|
||||||
$this->setupSortControl(
|
$this->setupSortControl(
|
||||||
array(
|
array(
|
||||||
'user_name' => $this->translate('Username'),
|
'user_name' => $this->translate('Username'),
|
||||||
|
@ -18,6 +18,11 @@ if ($backend === null) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! isset($users)) {
|
||||||
|
echo $this->translate('Failed to fetch any users') . '</div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (count($users) === 0) {
|
if (count($users) === 0) {
|
||||||
echo $this->translate('No users found matching the filter') . '</div>';
|
echo $this->translate('No users found matching the filter') . '</div>';
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user