mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 17:24:16 +02:00
parent
6a61d4aa25
commit
6b31898566
@ -63,18 +63,63 @@ class NavigationController extends Controller
|
|||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all shared navigation item configurations
|
||||||
|
*
|
||||||
|
* @param string $owner A username if only items shared by a specific user are desired
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function fetchSharedNavigationItemConfigs($owner = null)
|
||||||
|
{
|
||||||
|
$configs = array();
|
||||||
|
foreach ($this->itemTypeConfig as $type => $_) {
|
||||||
|
$config = Config::navigation($type);
|
||||||
|
$config->getConfigObject()->setKeyColumn('name');
|
||||||
|
$query = $config->select();
|
||||||
|
if ($owner !== null) {
|
||||||
|
$query->where('owner', $owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($query as $itemConfig) {
|
||||||
|
$configs[] = $itemConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $configs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all user navigation item configurations
|
||||||
|
*
|
||||||
|
* @param string $username
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function fetchUserNavigationItemConfigs($username)
|
||||||
|
{
|
||||||
|
$configs = array();
|
||||||
|
foreach ($this->itemTypeConfig as $type => $_) {
|
||||||
|
$config = Config::navigation($type, $username);
|
||||||
|
$config->getConfigObject()->setKeyColumn('name');
|
||||||
|
foreach ($config->select() as $itemConfig) {
|
||||||
|
$configs[] = $itemConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $configs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the current user a list of his/her navigation items
|
* Show the current user a list of his/her navigation items
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$user = $this->Auth()->getUser();
|
$user = $this->Auth()->getUser();
|
||||||
|
|
||||||
$ds = new ArrayDatasource(array_merge(
|
$ds = new ArrayDatasource(array_merge(
|
||||||
Config::app('navigation')->select()->where('owner', $user->getUsername())->fetchAll(),
|
$this->fetchSharedNavigationItemConfigs($user->getUsername()),
|
||||||
iterator_to_array($user->loadNavigationConfig())
|
$this->fetchUserNavigationItemConfigs($user->getUsername())
|
||||||
));
|
));
|
||||||
$ds->setKeyColumn('name');
|
|
||||||
$query = $ds->select();
|
$query = $ds->select();
|
||||||
|
|
||||||
$this->view->types = $this->listItemTypes();
|
$this->view->types = $this->listItemTypes();
|
||||||
@ -104,9 +149,8 @@ class NavigationController extends Controller
|
|||||||
public function sharedAction()
|
public function sharedAction()
|
||||||
{
|
{
|
||||||
$this->assertPermission('config/application/navigation');
|
$this->assertPermission('config/application/navigation');
|
||||||
$config = Config::app('navigation');
|
$ds = new ArrayDatasource($this->fetchSharedNavigationItemConfigs());
|
||||||
$config->getConfigObject()->setKeyColumn('name');
|
$query = $ds->select();
|
||||||
$query = $config->select();
|
|
||||||
|
|
||||||
$removeForm = new Form();
|
$removeForm = new Form();
|
||||||
$removeForm->setUidDisabled();
|
$removeForm->setUidDisabled();
|
||||||
@ -302,6 +346,7 @@ class NavigationController extends Controller
|
|||||||
$this->assertPermission('config/application/navigation');
|
$this->assertPermission('config/application/navigation');
|
||||||
$this->assertHttpMethod('POST');
|
$this->assertHttpMethod('POST');
|
||||||
|
|
||||||
|
// TODO: I'd like these being form fields
|
||||||
$itemType = $this->params->getRequired('type');
|
$itemType = $this->params->getRequired('type');
|
||||||
$itemOwner = $this->params->getRequired('owner');
|
$itemOwner = $this->params->getRequired('owner');
|
||||||
|
|
||||||
|
@ -22,17 +22,17 @@
|
|||||||
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
|
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($items as $name => $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= $this->qlink(
|
<td><?= $this->qlink(
|
||||||
$name,
|
$item->name,
|
||||||
'navigation/edit',
|
'navigation/edit',
|
||||||
array(
|
array(
|
||||||
'name' => $name,
|
'name' => $item->name,
|
||||||
'type' => $item->type
|
'type' => $item->type
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => sprintf($this->translate('Edit navigation item %s'), $name)
|
'title' => sprintf($this->translate('Edit navigation item %s'), $item->name)
|
||||||
)
|
)
|
||||||
); ?></td>
|
); ?></td>
|
||||||
<td><?= $item->type && isset($types[$item->type])
|
<td><?= $item->type && isset($types[$item->type])
|
||||||
@ -43,12 +43,12 @@
|
|||||||
'',
|
'',
|
||||||
'navigation/remove',
|
'navigation/remove',
|
||||||
array(
|
array(
|
||||||
'name' => $name,
|
'name' => $item->name,
|
||||||
'type' => $item->type
|
'type' => $item->type
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'icon' => 'trash',
|
'icon' => 'trash',
|
||||||
'title' => sprintf($this->translate('Remove navigation item %s'), $name)
|
'title' => sprintf($this->translate('Remove navigation item %s'), $item->name)
|
||||||
)
|
)
|
||||||
); ?></td>
|
); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -23,19 +23,19 @@ if (! $this->compact): ?>
|
|||||||
<th style="width: 5em"><?= $this->translate('Unshare'); ?></th>
|
<th style="width: 5em"><?= $this->translate('Unshare'); ?></th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($items as $name => $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= $this->qlink(
|
<td><?= $this->qlink(
|
||||||
$name,
|
$item->name,
|
||||||
'navigation/edit',
|
'navigation/edit',
|
||||||
array(
|
array(
|
||||||
'name' => $name,
|
'name' => $item->name,
|
||||||
'type' => $item->type,
|
'type' => $item->type,
|
||||||
'owner' => $item->owner,
|
'owner' => $item->owner,
|
||||||
'referrer' => 'shared'
|
'referrer' => 'shared'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => sprintf($this->translate('Edit shared navigation item %s'), $name)
|
'title' => sprintf($this->translate('Edit shared navigation item %s'), $item->name)
|
||||||
)
|
)
|
||||||
); ?></td>
|
); ?></td>
|
||||||
<td><?= $item->type && isset($types[$item->type])
|
<td><?= $item->type && isset($types[$item->type])
|
||||||
@ -55,7 +55,7 @@ if (! $this->compact): ?>
|
|||||||
); ?></td>
|
); ?></td>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<td data-base-target="_self"><?= $removeForm
|
<td data-base-target="_self"><?= $removeForm
|
||||||
->setDefault('name', $name)
|
->setDefault('name', $item->name)
|
||||||
->setAction(Url::fromPath(
|
->setAction(Url::fromPath(
|
||||||
'navigation/unshare',
|
'navigation/unshare',
|
||||||
array('type' => $item->type, 'owner' => $item->owner)
|
array('type' => $item->type, 'owner' => $item->owner)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user