GroupController: Behave nicely when it's not possible to fetch any groups
refs #8826
This commit is contained in:
parent
8927121266
commit
5db6fc9ba9
|
@ -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\UserGroup\UserGroupBackend;
|
use Icinga\Authentication\UserGroup\UserGroupBackend;
|
||||||
use Icinga\Authentication\UserGroup\UserGroupBackendInterface;
|
use Icinga\Authentication\UserGroup\UserGroupBackendInterface;
|
||||||
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 GroupController extends Controller
|
class GroupController extends Controller
|
||||||
|
@ -74,12 +76,17 @@ class GroupController extends Controller
|
||||||
$query->applyFilter($filterEditor->getFilter());
|
$query->applyFilter($filterEditor->getFilter());
|
||||||
$this->setupFilterControl($filterEditor);
|
$this->setupFilterControl($filterEditor);
|
||||||
|
|
||||||
$this->getTabs()->activate('group/list');
|
try {
|
||||||
|
$this->view->groups = $query->paginate();
|
||||||
|
$this->setupPaginationControl($this->view->groups);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Notification::error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$this->view->backend = $backend;
|
$this->view->backend = $backend;
|
||||||
$this->view->groups = $query->paginate();
|
$this->getTabs()->activate('group/list');
|
||||||
|
|
||||||
$this->setupLimitControl();
|
$this->setupLimitControl();
|
||||||
$this->setupPaginationControl($this->view->groups);
|
|
||||||
$this->setupSortControl(
|
$this->setupSortControl(
|
||||||
array(
|
array(
|
||||||
'group_name' => $this->translate('Group'),
|
'group_name' => $this->translate('Group'),
|
||||||
|
|
|
@ -18,6 +18,11 @@ if ($backend === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! isset($groups)) {
|
||||||
|
echo $this->translate('Failed to fetch any groups') . '</div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (count($groups) === 0) {
|
if (count($groups) === 0) {
|
||||||
echo $this->translate('No groups found matching the filter') . '</div>';
|
echo $this->translate('No groups found matching the filter') . '</div>';
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue