new: [dashboard templates] show which modules will be visible to the given user

new_widgets
iglocska 2023-05-16 14:04:32 +02:00
parent a60202d9d1
commit 712321eb81
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 42 additions and 0 deletions

View File

@ -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'] = '';
}

View File

@ -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]);
}
}
?>