Skip to content

Commit

Permalink
GroupController: Behave nicely when it's not possible to fetch any gr…
Browse files Browse the repository at this point in the history
…oups

refs #8826
  • Loading branch information
Johannes Meyer committed May 13, 2015
1 parent 8927121 commit 5db6fc9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 10 additions & 3 deletions application/controllers/GroupController.php
@@ -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\UserGroup\UserGroupBackend;
use Icinga\Authentication\UserGroup\UserGroupBackendInterface;
use Icinga\Web\Controller;
use Icinga\Web\Form;
use Icinga\Web\Notification;
use Icinga\Web\Widget;

class GroupController extends Controller
Expand Down Expand Up @@ -74,12 +76,17 @@ function ($b) { return $b->getName(); },
$query->applyFilter($filterEditor->getFilter());
$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->groups = $query->paginate();
$this->getTabs()->activate('group/list');

$this->setupLimitControl();
$this->setupPaginationControl($this->view->groups);
$this->setupSortControl(
array(
'group_name' => $this->translate('Group'),
Expand Down
5 changes: 5 additions & 0 deletions application/views/scripts/group/list.phtml
Expand Up @@ -18,6 +18,11 @@ if ($backend === null) {
return;
}

if (! isset($groups)) {
echo $this->translate('Failed to fetch any groups') . '</div>';
return;
}

if (count($groups) === 0) {
echo $this->translate('No groups found matching the filter') . '</div>';
return;
Expand Down

0 comments on commit 5db6fc9

Please sign in to comment.