Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(ci): codingStyle and psr2
Browse files Browse the repository at this point in the history
  • Loading branch information
sc979 committed Apr 10, 2019
1 parent 37b7a36 commit 40d943a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions www/class/centreonCustomView.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -658,29 +658,38 @@ public function addPublicViewWidgetParams($viewId, $userId)
{
//get all widget parameters from the view that is being added
if (isset($userId) && $userId) {
$query = 'SELECT * FROM widget_views wv LEFT JOIN widget_preferences wp ON wp.widget_view_id=wv.widget_view_id ' .
$stmt = $this->db->prepare(
'SELECT * FROM widget_views wv ' .
'LEFT JOIN widget_preferences wp ON wp.widget_view_id = wv.widget_view_id ' .
'LEFT JOIN custom_view_user_relation cvur ON cvur.custom_view_id=wv.custom_view_id ' .
'WHERE cvur.custom_view_id = :viewId and cvur.locked = 0';
$stmt = $this->db->prepare($query);
'WHERE cvur.custom_view_id = :viewId and cvur.locked = 0'
);
$stmt->bindParam(':viewId', $viewId, PDO::PARAM_INT);
$dbResult = $stmt->execute();
if (!$dbResult) {
throw new \Exception("An error occured");
throw new \Exception(
"An error occurred when retrieving user's Id : " . userId .
" parameters of the widgets from the view: Id = " . $viewId
);
}

//add every widget parameters for the current user
while ($row = $stmt->fetch()) {
$query2 = 'INSERT INTO widget_preferences VALUES (:widget_view_id, :parameter_id, :preference_value, :user_id)';

$stmt2 = $this->db->prepare($query2);
$stmt2 = $this->db->prepare(
'INSERT INTO widget_preferences ' .
'VALUES (:widget_view_id, :parameter_id, :preference_value, :user_id)'
);
$stmt2->bindParam(':widget_view_id', $row['widget_view_id'], PDO::PARAM_INT);
$stmt2->bindParam(':parameter_id', $row['parameter_id'], PDO::PARAM_INT);
$stmt2->bindParam(':preference_value', $row['preference_value'], PDO::PARAM_STR);
$stmt2->bindParam(':user_id', $userId, PDO::PARAM_INT);

$dbResult2 = $stmt2->execute();
if (!$dbResult2) {
throw new \Exception("An error occured");
throw new \Exception(
"An error occurred when adding user's Id : " . $userId .
" parameters to the widgets from the view: Id = " . $viewId
);
}
}
}
Expand Down

0 comments on commit 40d943a

Please sign in to comment.