From f0a4dbe051d29b5051fd578bd2d3f4a3c01053a2 Mon Sep 17 00:00:00 2001 From: Valentin Hristov Date: Fri, 6 Jul 2018 12:51:47 +0300 Subject: [PATCH] fix(cv): issue with moving of widgets (#6448) * fix(cv): issue with moving of widgets Resolve CP7M-137 --- www/class/centreonWidget.class.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/www/class/centreonWidget.class.php b/www/class/centreonWidget.class.php index 6fd3876a598..e6f7f0cc427 100644 --- a/www/class/centreonWidget.class.php +++ b/www/class/centreonWidget.class.php @@ -712,21 +712,18 @@ public function updateWidgetPositions($params) if (count($tmp) != 3) { throw new CentreonWidgetException('incorrect position data'); } - $column = $tmp[0]; - $row = $tmp[1]; + $widgetOrder = "{$tmp[0]}_{$tmp[1]}"; $widgetId = $tmp[2]; - $queryValues = array(); + $query = 'UPDATE widget_views SET widget_order = :widgetOrder ' . 'WHERE custom_view_id = :viewId ' . 'AND widget_id = :widgetId'; - $queryValues[] = (string)$column . "_" . $row; - $queryValues[] = (int)$viewId; - $queryValues[] = (int)$widgetId; $stmt = $this->db->prepare($query); - $stmt->bindParam(':widgetOrder', $column . "_" . $row, PDO::PARAM_STR); + $stmt->bindParam(':widgetOrder', $widgetOrder, PDO::PARAM_STR); $stmt->bindParam(':viewId', $viewId, PDO::PARAM_INT); $stmt->bindParam(':widgetId', $widgetId, PDO::PARAM_INT); $dbResult = $stmt->execute(); + if (!$dbResult) { throw new \Exception("An error occured"); }