#13344 dashboard remove dashboardId on public link

This commit is contained in:
Jonathan 2024-04-11 11:57:42 +02:00
parent aaa3761a86
commit 31f4124083
2 changed files with 40 additions and 10 deletions

View File

@ -994,6 +994,27 @@ class Manager implements PublicLogin
ui_require_css_file('modal');
ui_require_css_file('form');
$hash_aux = get_parameter('hash');
if (empty($dashboardId)) {
$dashboards = $this->getDashboards();
$dashboards = array_reduce(
$dashboards,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
foreach ($dashboards as $key => $layout) {
$hash_compare = self::generatePublicHash($key);
if (hash_equals($hash_aux, $hash_compare)) {
$this->dashboardId = $key;
break;
}
}
}
if ($this->dashboardId === 0
|| $this->deleteDashboard === true
|| $this->copyDashboard === true
@ -1164,11 +1185,10 @@ class Manager implements PublicLogin
[
'dashboards' => $dashboards,
'ajaxController' => $this->ajaxController,
'dashboardId' => $this->dashboardId,
'refr' => $this->refr,
'url' => $this->url,
'dashboardName' => $this->dashboardFields['name'],
'hash' => self::generatePublicHash(),
'hash' => self::generatePublicHash($this->dashboardId),
'publicLink' => $this->publicLink,
'dashboardGroup' => $this->dashboardFields['id_group'],
'dashboardUser' => $this->dashboardFields['id_user'],
@ -1210,7 +1230,7 @@ class Manager implements PublicLogin
'updateDashboard' => $this->updateDashboard,
'cellIdCreate' => \get_parameter('cellIdCreate', 0),
'class' => (($config['public_dashboard'] === true) ? quotemeta(__CLASS__) : ''),
'hash' => (($config['public_dashboard'] === true) ? self::generatePublicHash() : ''),
'hash' => (($config['public_dashboard'] === true) ? self::generatePublicHash($this->dashboardId) : ''),
]
);
} else {

View File

@ -27,12 +27,23 @@
*/
// Button for display full screen mode.
use PandoraFMS\Dashboard\Manager;
global $config;
if (empty($dashboardId)) {
foreach ($dashboards as $key => $layout) {
$hash_compare = Manager::generatePublicHash($key);
if (hash_equals($hash, $hash_compare)) {
$dashboardId = $key;
break;
}
}
}
$queryFull = [
'dashboardId' => $dashboardId,
'refr' => $refr,
'pure' => 1,
'refr' => $refr,
'pure' => 1,
'hash' => $hash,
];
$urlFull = $url.'&'.http_build_query($queryFull);
$fullscreen['text'] = '<a id="full_screen_link" href="'.$urlFull.'">';
@ -124,10 +135,9 @@ $slides['text'] .= '</a>';
// Public Url.
$queryPublic = [
'dashboardId' => $dashboardId,
'hash' => $hash,
'id_user' => $config['id_user'],
'pure' => 1,
'hash' => $hash,
'id_user' => $config['id_user'],
'pure' => 1,
];
$publicUrl = ui_get_full_url(
'operation/dashboard/public_dashboard.php?'.http_build_query($queryPublic)