Esempio n. 1
0
 /**
  * Display the configuration snapshot of a service
  * with template inheritance
  *
  * @method get
  * @route /service/snapshotslide/[i:id]
  */
 public function snapshotslideAction()
 {
     $params = $this->getParams();
     $data = ServiceRepository::getConfigurationData($params['id']);
     $serviceId = Service::getPrimaryKey();
     $serviceDescription = Service::getUniqueLabelField();
     $hostId = Host::getPrimaryKey();
     $hostName = Host::getUniqueLabelField();
     $filters = array($serviceId => $params['id']);
     //If service inherits a template
     if (isset($data['service_template_model_stm_id'])) {
         $data = ServiceRepository::getConfigurationData($data['service_template_model_stm_id']);
     } else {
         $data = ServiceRepository::getConfigurationData($params['id']);
     }
     $list = HostService::getMergedParameters(array($hostId, $hostName), array($serviceId, $serviceDescription), -1, 0, null, "ASC", $filters, "OR");
     foreach ($list as $obj) {
         $data[$serviceDescription] = $obj[$hostName] . '|' . $obj[$serviceDescription];
     }
     $serviceConfiguration = ServiceRepository::formatDataForSlider($data);
     $edit_url = $this->router->getPathFor("/centreon-configuration/service/" . $params['id']);
     $this->router->response()->json(array('serviceConfig' => $serviceConfiguration, 'edit_url' => $edit_url, 'success' => true));
 }
 /**
  * Display the configuration snapshot of a service
  * with template inheritance
  *
  * @method get
  * @route /servicetemplate/snapshotslide/[i:id]
  */
 public function snapshotslideAction()
 {
     $params = $this->getParams();
     $data = ServiceTemplateRepository::getConfigurationData($params['id']);
     //If service inherits a template
     /*if (isset($data['service_template_model_stm_id'])) {
           $data = ServiceTemplateRepository::getConfigurationData($data['service_template_model_stm_id']);   
       } else {
           $data = ServiceTemplateRepository::getConfigurationData($params['id']);
       }*/
     $serviceConfiguration = ServiceRepository::formatDataForSlider($data);
     $edit_url = $this->router->getPathFor("/centreon-configuration/servicetemplate/" . $params['id']);
     $this->router->response()->json(array('serviceConfig' => $serviceConfiguration, 'edit_url' => $edit_url, 'success' => true));
 }
Esempio n. 3
0
 /**
  * Get list of services for a specific host
  * 
  * @method get
  * @route /host/[i:id]/service
  */
 public function hostForServiceAction()
 {
     $requestParam = $this->getParams('named');
     $relationClass = static::$relationMap['host_services'];
     $services = $relationClass::getMergedParameters(array(), array('service_id', 'service_description'), -1, 0, null, "ASC", array('host_id' => $requestParam['id']), "AND");
     $finalServices = array();
     foreach ($services as $service) {
         $finalService = ServicetemplateRepository::getInheritanceValues($service['service_id'], true);
         $finalService['service_id'] = $service['service_id'];
         $finalService['service_description'] = $service['service_description'];
         $finalService = ServiceRepository::formatDataForSlider($finalService);
         $finalServices[] = $finalService;
     }
     $this->router->response()->json(array('service' => $finalServices, 'success' => true));
 }
Esempio n. 4
0
 /**
  * Get relations 
  *
  * @param string $relClass
  * @param int $id
  * @return array 
  */
 public static function getRelationsCustom($relClass, $id)
 {
     $router = Di::getDefault()->get('router');
     $curObj = static::$objectClass;
     if ($relClass::$firstObject == $curObj) {
         $tmp = $relClass::$secondObject;
         $fArr = array("*");
         $sArr = array($tmp::getPrimaryKey(), $tmp::getUniqueLabelField());
     } else {
         $tmp = $relClass::$firstObject;
         $fArr = array("*");
         $sArr = array();
     }
     $cmp = $curObj::getTableName() . '.' . $curObj::getPrimaryKey();
     $list = $relClass::getMergedParameters($fArr, $sArr, -1, 0, null, "ASC", array($cmp => $id), "AND");
     $finalList = array();
     foreach ($list as $obj) {
         $tmpList = ServiceRepository::formatDataForSlider($obj);
         $tmpList['url_edit'] = $router->getPathFor('/centreon-configuration/servicetemplate/' . $obj['service_id']);
         $finalList[] = $tmpList;
     }
     return $finalList;
 }