UserController: Behave nicely when it's not possible to fetch any users

refs #8826
This commit is contained in:
Johannes Meyer 2015-05-13 13:50:19 +02:00
parent e9fee2dad6
commit 8927121266
2 changed files with 15 additions and 3 deletions

View File

@ -1,12 +1,14 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use \Exception;
use \Zend_Controller_Action_Exception;
use Icinga\Application\Config;
use Icinga\Authentication\User\UserBackend;
use Icinga\Authentication\User\UserBackendInterface;
use Icinga\Web\Controller;
use Icinga\Web\Form;
use Icinga\Web\Notification;
use Icinga\Web\Widget;
class UserController extends Controller
@ -74,12 +76,17 @@ class UserController extends Controller
$query->applyFilter($filterEditor->getFilter());
$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->users = $query->paginate();
$this->getTabs()->activate('user/list');
$this->setupLimitControl();
$this->setupPaginationControl($this->view->users);
$this->setupSortControl(
array(
'user_name' => $this->translate('Username'),

View File

@ -18,6 +18,11 @@ if ($backend === null) {
return;
}
if (! isset($users)) {
echo $this->translate('Failed to fetch any users') . '</div>';
return;
}
if (count($users) === 0) {
echo $this->translate('No users found matching the filter') . '</div>';
return;