/** * Update a user * * * @method post * @route /user/update */ public function updateAction() { parent::updateAction(); /* Let's see if we need to refresh the user object that is stored in session */ if (isset($_SESSION['user'])) { $user = $_SESSION['user']; $userId = $user->getId(); $givenParameters = $this->getParams('post'); /* Modified account matches the current user */ if (isset($givenParameters['object_id']) && $givenParameters['object_id'] == $userId) { $_SESSION['user'] = new User($userId); } } }
/** * Update a host * * * @method post * @route /hosttemplate/update */ public function updateAction() { $givenParameters = $this->getParams('post'); $macroList = array(); $aTagList = array(); $aTags = array(); $aTagsTemplate = array(); $aTagsInTpl = array(); $aTagsIdTpl = array(); if (isset($givenParameters['macro_name']) && isset($givenParameters['macro_value'])) { $macroName = $givenParameters['macro_name']; $macroValue = $givenParameters['macro_value']; $macroHidden = $givenParameters['macro_hidden']; foreach ($macroName as $key => $name) { if (!empty($name)) { if (isset($macroHidden[$key])) { $isPassword = '******'; } else { $isPassword = '******'; } $macroList[$name] = array('value' => $macroValue[$key], 'ispassword' => $isPassword); } } } if ($givenParameters['host_create_services_from_template']) { \CentreonConfiguration\Models\Host::deployServices($givenParameters['object_id']); } if (count($macroList) > 0) { try { CustomMacroRepository::saveHostCustomMacro(self::$objectName, $givenParameters['object_id'], $macroList); } catch (\Exception $ex) { $errorMessage = $ex->getMessage(); $this->router->response()->json(array('success' => false, 'error' => $errorMessage)); } } //Delete tags directilly rattached to the object TagsRepository::deleteTagsForResource(self::$objectName, $givenParameters['object_id'], 0); //Insert tags affected to the HOST if (isset($givenParameters['host_tags'])) { $aTagList = explode(",", $givenParameters['host_tags']); foreach ($aTagList as $var) { $var = trim($var); if (!empty($var)) { array_push($aTags, $var); } } if (count($aTags) > 0) { TagsRepository::saveTagsForResource(self::$objectName, $givenParameters['object_id'], $aTags, '', false, 1); } } parent::updateAction(); }
/** * Update a period * * @method post * @route /scheduled-downtime/update */ public function updateAction() { $givenParameters = $this->getParams('post'); $periods = json_decode($givenParameters['periods'], true); /* Update the periods */ if (is_array($periods)) { ScheduledDowntimeRepository::updatePeriods($givenParameters['object_id'], $periods); } parent::updateAction(); }
/** * Update centreon options * * * @method post * @route /options/centreon/update */ public function updateAction() { parent::updateAction(); }
/** * Update a business activity * * * @method post * @route /businessactivity/update */ public function updateAction() { $givenParameters = $this->getParams('post'); $aTagList = array(); $aTags = array(); parent::updateAction(); if (isset($givenParameters['ba_tags'])) { $aTagList = explode(",", $givenParameters['ba_tags']); foreach ($aTagList as $var) { if (strlen($var) > 1) { array_push($aTags, $var); } } if (count($aTags) > 0) { TagsRepository::saveTagsForResource('ba', $givenParameters['object_id'], $aTags, '', false, 1); } } }
/** * Update the graph template * * @method post * @route /configuration/graphtemplate/update */ public function updateAction() { $givenParameters = clone $this->getParams('post'); $listMetrics = array(); if (isset($givenParameters['metric_name'])) { foreach ($givenParameters['metric_name'] as $key => $value) { if (!empty($value)) { $listMetrics[$key]['metric_name'] = $value; if (isset($givenParameters['metric_fill'][$key])) { $listMetrics[$key]['metric_fill'] = '1'; } else { $listMetrics[$key]['metric_fill'] = '0'; } if (isset($givenParameters['metric_negative'][$key])) { $listMetrics[$key]['metric_negative'] = '1'; } else { $listMetrics[$key]['metric_negative'] = '0'; } if (isset($givenParameters['metric_color'][$key])) { $listMetrics[$key]['metric_color'] = $givenParameters['metric_color'][$key]; } else { $listMetrics[$key]['metric_color'] = '#000000'; } } } } try { GraphTemplateRepository::saveMetrics($givenParameters['object_id'], 'update', $listMetrics); } catch (\Exception $ex) { $errorMessage = $ex->getMessage(); $this->router->response()->json(array('success' => false, 'error' => $errorMessage)); } parent::updateAction(); }
/** * Update a contact * * @method post * @route /contact/update */ public function updateContactAction() { $givenParameters = $this->getParams('post'); $listWays = array(); if (isset($givenParameters['way_name']) && isset($givenParameters['way_value'])) { $wayName = $givenParameters['way_name']; $wayValue = $givenParameters['way_value']; foreach ($wayName as $key => $name) { if (!empty($name) && !empty($wayValue[$key])) { $listWays[$name] = array('value' => $wayValue[$key]); } } } try { NotificationWayRepository::saveNotificationWays($givenParameters['object_id'], 'update', $listWays); } catch (\Exception $ex) { $errorMessage = $ex->getMessage(); $this->router->response()->json(array('success' => false, 'error' => $errorMessage)); } //Delete all tags TagsRepository::deleteTagsForResource(self::$objectName, $givenParameters['object_id'], 0); $aTags = array(); if (isset($givenParameters['contact_tags'])) { $aTagList = explode(",", $givenParameters['contact_tags']); foreach ($aTagList as $var) { $var = trim($var); if (!empty($var)) { array_push($aTags, $var); } } if (count($aTags) > 0) { TagsRepository::saveTagsForResource(self::$objectName, $givenParameters['object_id'], $aTags, '', false, 1); } } parent::updateAction(); }