mirror of https://github.com/MISP/MISP
new: [dashboard templates] show which modules will be visible to the given user
parent
a60202d9d1
commit
712321eb81
|
@ -316,6 +316,8 @@ class DashboardsController extends AppController
|
|||
public function listTemplates()
|
||||
{
|
||||
$conditions = array();
|
||||
// load all widgets for internal use, won't be displayed to the user. Thus we circumvent the ACL on it.
|
||||
$accessible_widgets = array_keys($this->Dashboard->loadAllWidgets($this->Auth->user()));
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
$permission_flags = array();
|
||||
foreach ($this->Auth->user('Role') as $perm => $value) {
|
||||
|
@ -394,6 +396,15 @@ class DashboardsController extends AppController
|
|||
}
|
||||
$element['Dashboard']['widgets'] = array_keys($widgets);
|
||||
sort($element['Dashboard']['widgets']);
|
||||
$temp = [];
|
||||
foreach ($element['Dashboard']['widgets'] as $widget) {
|
||||
if (in_array($widget, $accessible_widgets)) {
|
||||
$temp['allow'][] = $widget;
|
||||
} else {
|
||||
$temp['deny'][] = $widget;
|
||||
}
|
||||
}
|
||||
$element['Dashboard']['widgets'] = $temp;
|
||||
if ($element['Dashboard']['user_id'] != $this->Auth->user('id')) {
|
||||
$element['User']['email'] = '';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
$data = Hash::extract($row, $field['data_path']);
|
||||
$setup = [
|
||||
'allow' => [
|
||||
'name' => __('Allowed'),
|
||||
'color' => 'green'
|
||||
],
|
||||
'deny' => [
|
||||
'name' => __('Denied'),
|
||||
'color' => 'red'
|
||||
]
|
||||
];
|
||||
foreach ($setup as $state => $settings) {
|
||||
if (!empty($data[$state])) {
|
||||
echo sprintf(
|
||||
'<div class="bold %s">%s</div>',
|
||||
$settings['color'],
|
||||
$settings['name']
|
||||
);
|
||||
foreach ($data[$state] as $k => $element) {
|
||||
$data[$state][$k] = sprintf(
|
||||
'<span class="%s">%s</span>',
|
||||
$settings['color'],
|
||||
h($element)
|
||||
);
|
||||
}
|
||||
echo implode('<br />', $data[$state]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue