From 081ba68af4db416cd3cf5b4db14a90c6bb6c23e1 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 11 Dec 2019 19:41:26 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02634=20-=20Fix=20non=20editable=20dashle?= =?UTF-8?q?ts=20in=20dashboards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/dashboard.class.inc.php | 40 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index f28419a64..5141c0921 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -1,20 +1,21 @@ +/** + * Copyright (C) 2013-2019 Combodo SARL + * + * This file is part of iTop. + * + * iTop is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * iTop is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + */ require_once(APPROOT.'application/dashboardlayout.class.inc.php'); require_once(APPROOT.'application/dashlet.class.inc.php'); @@ -164,6 +165,13 @@ abstract class Dashboard protected function InitDashletFromDOMNode($oDomNode) { $sId = $oDomNode->getAttribute('id'); + // To avoid collision with other dashlets with the same ID we suffix it. Collisions typically happen with extensions. + // Note: The check is done so we don't append it at each save of the dashboard. + if(strpos($sId, 'uniqid_') === false) + { + $sId .= '_uniqid_' . uniqid(); + } + $sDashletType = $oDomNode->getAttribute('xsi:type'); // Test if dashlet can be instanciated, otherwise (uninstalled, broken, ...) we display a placeholder