Пример #1
0
 /**
  * 
  * @param array $resultSet
  */
 protected function formatDatas(&$resultSet)
 {
     $previousType = '';
     foreach ($resultSet as &$myBaSet) {
         $sideMenuCustom = new SlideMenu($myBaSet['ba_id']);
         $events = Di::getDefault()->get('events');
         $events->emit('centreon-bam.slide.menu.business.activity', array($sideMenuCustom));
         $myBaSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu();
         $myBaSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu();
         // Set business activity type
         $baType = \CentreonBam\Models\BusinessActivityType::getParameters($myBaSet['ba_type_id'], array('name'));
         $myBaSet['ba_type_id'] = $baType['name'];
         if ($myBaSet['ba_type_id'] === $previousType) {
             $myBaSet['ba_type_id'] = '';
         } else {
             $previousType = $myBaSet['ba_type_id'];
         }
         // set business activity name
         $myBaSet['name'] = BusinessActivityRepository::getIconImage($myBaSet['name']) . $myBaSet['name'];
         /* Tags */
         $myBaSet['tagname'] = "";
         $aTags = TagsRepository::getList('ba', $myBaSet['ba_id'], 2);
         foreach ($aTags as $oTags) {
             $myBaSet['tagname'] .= TagsRepository::getTag('ba', $myBaSet['ba_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']);
         }
         $myBaSet['tagname'] .= TagsRepository::getAddTag('ba', $myBaSet['ba_id']);
     }
 }
Пример #2
0
 /**
  * 
  * @param array $resultSet
  */
 protected function formatDatas(&$resultSet)
 {
     foreach ($resultSet as $key => &$myHostSet) {
         $sideMenuCustom = new SlideMenu($myHostSet['host_id']);
         $events = Di::getDefault()->get('events');
         $events->emit('centreon-realtime.slide.menu.host', array($sideMenuCustom));
         $myHostSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu();
         $myHostSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu();
         $aTagUsed = array();
         // @todo remove virtual hosts and virtual services
         if ($myHostSet['name'] === '_Module_BAM') {
             unset($resultSet[$key]);
             continue;
         }
         // Set host_name
         $myHostSet['name'] = '<span class="icoListing">' . HostConfigurationRepository::getIconImage($myHostSet['name']) . '</span>' . $myHostSet['name'];
         if ($myHostSet['state'] != '0' && $myHostSet['state'] != '4') {
             $acknowledgement = HostRealtimeRepository::getAcknowledgementInfos($myHostSet['host_id']);
             if (count($acknowledgement) > 0) {
                 $myHostSet['name'] .= ' <i class="fa fa-thumb-tack"></i>';
             }
         }
         $myHostSet['duration'] = Datetime::humanReadable(time() - $myHostSet['duration'], Datetime::PRECISION_FORMAT, 2);
         $myHostSet['last_check'] = Datetime::humanReadable(time() - $myHostSet['last_check'], Datetime::PRECISION_FORMAT, 2);
         /* Tags */
         $myHostSet['tagname'] = "";
         /*
                     $aTags = TagsRepository::getList('host', $myHostSet['host_id'], 2, 0);
                     foreach ($aTags as $oTags) {
            $myHostSet['tagname'] .= TagsRepository::getTag('host', $myHostSet['host_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']);
                     }
         * 
         */
         $aTags = TagsRepository::getList('host', $myHostSet['host_id'], 2, 0);
         foreach ($aTags as $oTags) {
             if (!in_array($oTags['id'], $aTagUsed)) {
                 $aTagUsed[] = $oTags['id'];
                 $myHostSet['tagname'] .= TagsRepository::getTag('host', $myHostSet['host_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']);
             }
         }
         //Get tags affected by the template
         $templates = HostConfigurationRepository::getTemplateChain($myHostSet['host_id'], array(), -1);
         foreach ($templates as $template) {
             $aTags = TagsRepository::getList('host', $template['id'], 2, 0);
             foreach ($aTags as $oTags) {
                 if (!in_array($oTags['id'], $aTagUsed)) {
                     $aTagUsed[] = $oTags['id'];
                     $myHostSet['tagname'] .= TagsRepository::getTag('host', $template['id'], $oTags['id'], $oTags['text'], $oTags['user_id'], 1);
                 }
             }
         }
         $myHostSet['tagname'] .= TagsRepository::getAddTag('host', $myHostSet['host_id']);
     }
     $resultSet = array_values($resultSet);
 }
Пример #3
0
 /**
  * 
  * @param array $resultSet
  */
 protected function formatDatas(&$resultSet)
 {
     $previousHost = '';
     HostRepository::setObjectClass('\\CentreonConfiguration\\Models\\Host');
     $router = Di::getDefault()->get('router');
     foreach ($resultSet as &$myServiceSet) {
         // Keep up
         $save = $myServiceSet['service_activate'];
         unset($myServiceSet['service_activate']);
         // Set host_name
         if ($myServiceSet['host_name'] === $previousHost) {
             $myServiceSet['host_name'] = '';
         } else {
             $previousHost = $myServiceSet['host_name'];
             $myServiceSet['host_name'] = '<span class="icoListing">' . HostRepository::getIconImage($myServiceSet['host_name']) . '</span>' . $myServiceSet['host_name'];
         }
         // Set Scheduling
         $myServiceSet['service_normal_check_interval'] = ServiceRepository::formatNotificationOptions(ServiceRepository::getMyServiceField($myServiceSet['service_id'], 'service_normal_check_interval'));
         $myServiceSet['service_retry_check_interval'] = ServiceRepository::formatNotificationOptions(ServiceRepository::getMyServiceField($myServiceSet['service_id'], 'service_normal_check_interval'));
         $myServiceSet['service_max_check_attempts'] = ServiceRepository::getMyServiceField($myServiceSet['service_id'], 'service_max_check_attempts');
         // Get Real Service Description
         if (!$myServiceSet["service_description"]) {
             $myServiceSet["service_description"] = ServiceRepository::getMyServiceAlias($myServiceSet['service_template_model_stm_id']);
         }
         $sideMenuCustom = new SlideMenu($myServiceSet['service_id']);
         $events = Di::getDefault()->get('events');
         $events->emit('centreon-configuration.slide.menu.service', array($sideMenuCustom));
         $myServiceSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu();
         $myServiceSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu();
         // Set Tpl Chain
         $tplStr = null;
         $tplArr = ServiceRepository::getMyServiceTemplateModels($myServiceSet["service_template_model_stm_id"]);
         $idServiceTpl = $myServiceSet["service_template_model_stm_id"];
         if (!is_null($tplArr)) {
             $tplRoute = str_replace("//", "/", $router->getPathFor('/centreon-configuration/servicetemplate/[i:id]', array('id' => $tplArr['id'])));
             $tplStr .= '<span><a href="' . $tplRoute . '">' . $tplArr['description'] . '</a></span>';
             $myServiceSet['service_template_model_stm_id'] = $tplStr;
         }
         $myServiceSet['service_description'] = '<span class="icoListing">' . ServiceRepository::getIconImage($myServiceSet['service_id']) . '</span>' . $myServiceSet['service_description'];
         $myServiceSet['service_description'] .= '</a><a href="#">';
         $myServiceSet['service_description'] .= ServiceRealTimeRepository::getStatusBadge(ServiceRealTimeRepository::getStatus($myServiceSet["host_id"], $myServiceSet["service_id"]));
         $myServiceSet['service_activate'] = $save;
         /* Get personal tags */
         $myServiceSet['tagname'] = '';
         $aTagUsed = array();
         $aTags = TagsRepository::getList('service', $myServiceSet['service_id'], 0, 0);
         foreach ($aTags as $oTags) {
             if (!in_array($oTags['id'], $aTagUsed)) {
                 $aTagUsed[] = $oTags['id'];
                 $myServiceSet['tagname'] .= TagsRepository::getTag('service', $myServiceSet['service_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], 1);
             }
         }
         $myServiceSet['tagname'] .= TagsRepository::getAddTag('service', $myServiceSet['service_id']);
     }
 }
Пример #4
0
 /**
  * 
  * @param array $resultSet
  * @todo fix getIconImage() (perf issue)
  */
 protected function formatDatas(&$resultSet)
 {
     $router = Di::getDefault()->get('router');
     $previousHost = '';
     HostConfigurationRepository::setObjectClass('\\CentreonConfiguration\\Models\\Host');
     foreach ($resultSet as $key => &$myServiceSet) {
         $aTagUsed = array();
         // Set host_name
         $myHostName = Host::get($myServiceSet['host_id'], array('name'));
         $myServiceSet['name'] = $myHostName['name'];
         $sideMenuCustom = new SlideMenu($myServiceSet['service_id']);
         $events = Di::getDefault()->get('events');
         $events->emit('centreon-realtime.slide.menu.service', array($sideMenuCustom));
         $myServiceSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu();
         $myServiceSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu();
         // @todo remove virtual hosts and virtual services
         if ($myServiceSet['name'] === '_Module_BAM') {
             unset($resultSet[$key]);
             continue;
         }
         if ($myServiceSet['name'] === $previousHost) {
             $myServiceSet['name'] = '';
         } else {
             $previousHost = $myServiceSet['name'];
             $icon = '<span class="icoListing">' . HostConfigurationRepository::getIconImage($myServiceSet['name']) . '</span>';
             $myServiceSet['name'] = $icon . $myServiceSet['name'];
         }
         $icon = '<span class="icoListing">' . ServiceConfigurationRepository::getIconImage($myServiceSet['service_id']) . '</span>';
         /*$myServiceSet['DT_RowData']['right_side_details'] = $router->getPathFor('/centreon-realtime/service/')
               . $myServiceSet['host_id']
               . '/'.$myServiceSet['service_id']
               . '/tooltip';
           */
         $myServiceSet['description'] = '<span>' . $icon . '' . $myServiceSet['description'] . '</span>';
         if ($myServiceSet['state'] != '0' && $myServiceSet['state'] != '4') {
             $acknowledgement = ServiceRealtimeRepository::getAcknowledgementInfos($myServiceSet['service_id']);
             if (count($acknowledgement) > 0) {
                 $myServiceSet['description'] .= ' <i class="fa fa-thumb-tack"></i>';
             }
         }
         if ($myServiceSet['perfdata'] != '') {
             $myServiceSet['ico'] = '<span data-overlay-url="/centreon-realtime/service/' . $myServiceSet['host_id'] . '/' . $myServiceSet['service_id'] . '/graph"><span class="overlay"><i class="fa fa-bar-chart-o"></i></span></span>';
         } else {
             $myServiceSet['ico'] = '';
         }
         $myServiceSet['duration'] = Datetime::humanReadable(time() - $myServiceSet['duration'], Datetime::PRECISION_FORMAT, 2);
         $myServiceSet['last_check'] = Datetime::humanReadable(time() - $myServiceSet['last_check'], Datetime::PRECISION_FORMAT, 2);
         /* Tags */
         $myServiceSet['tagname'] = "";
         $aTags = TagsRepository::getList('service', $myServiceSet['service_id'], 2, 0);
         foreach ($aTags as $oTags) {
             if (!in_array($oTags['id'], $aTagUsed)) {
                 $aTagUsed[] = $oTags['id'];
                 $myServiceSet['tagname'] .= TagsRepository::getTag('service', $myServiceSet['service_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']);
             }
         }
         /*
         $templates = ServiceConfigurationRepository::getListTemplates($myServiceSet['service_id'], array(), -1);
         foreach ($templates as $template) {
             $aTags = TagsRepository::getList('service', $template, 2, 0);
             foreach ($aTags as $oTags) {
                 if (!in_array($oTags['id'], $aTagUsed)) {
                     $aTagUsed[] = $oTags['id'];
                     $myServiceSet['tagname'] .= TagsRepository::getTag('service', $template, $oTags['id'], $oTags['text'], $oTags['user_id'], 1);
                 }
             }
         }
         */
         $myServiceSet['tagname'] .= TagsRepository::getAddTag('service', $myServiceSet['service_id']);
     }
     $resultSet = array_values($resultSet);
 }
Пример #5
0
 /**
  * 
  * @param array $resultSet
  */
 protected function formatDatas(&$resultSet)
 {
     $router = Di::getDefault()->get('router');
     foreach ($resultSet as &$myHostSet) {
         $myHostSet['host_name'] = '<span class="icoListing">' . HostRepository::getIconImage($myHostSet['host_name']) . '</span>' . $myHostSet['host_name'];
         /* Templates */
         $myHostSet['host_template'] = "";
         $templates = HostRepository::getTemplateChain($myHostSet['host_id'], array(), 1);
         foreach ($templates as $template) {
             $myHostSet['host_template'] .= '<a href="' . $router->getPathFor("/centreon-configuration/hosttemplate/[i:id]", array('id' => $template['id'])) . '"><i class="icon-template ico-20"></i></a>';
         }
         /* Display human readable the check/retry interval */
         $myHostSet['host_check_interval'] = HumanReadable::convert($myHostSet['host_check_interval'], 's', $units, null, true);
         $myHostSet['host_retry_check_interval'] = HumanReadable::convert($myHostSet['host_retry_check_interval'], 's', $units, null, true);
         $sideMenuCustom = new SlideMenu($myHostSet['host_id']);
         $events = Di::getDefault()->get('events');
         $events->emit('centreon-configuration.slide.menu.host.template', array($sideMenuCustom));
         //$myHostSet['DT_RowData']['right_side_details'] = $router->getPathFor('/centreon-configuration/host/snapshot/').$myHostSet['host_id'];
         $myHostSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu();
         $myHostSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu();
         /* Get personal tags */
         $myHostSet['tagname'] = '';
         $aTagUsed = array();
         $aTags = TagsRepository::getList('host', $myHostSet['host_id'], 0, 0);
         foreach ($aTags as $oTags) {
             if (!in_array($oTags['id'], $aTagUsed)) {
                 $aTagUsed[] = $oTags['id'];
                 $myHostSet['tagname'] .= TagsRepository::getTag('host', $myHostSet['host_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], 1);
             }
         }
         $myHostSet['tagname'] .= TagsRepository::getAddTag('host', $myHostSet['host_id']);
     }
 }
 /**
  * 
  * @param array $resultSet
  */
 protected function formatDatas(&$resultSet)
 {
     $router = Di::getDefault()->get('router');
     foreach ($resultSet as &$myServiceSet) {
         $myServiceSet['service_description'] = '<span class="icoListing">' . ServiceRepository::getIconImage($myServiceSet['service_id']) . '</span>' . $myServiceSet['service_description'];
         // Set Tpl Chain
         $tplStr = null;
         if (isset($myServiceSet["service_template_model_stm_id"])) {
             $tplArr = ServicetemplateRepository::getMyServiceTemplateModels($myServiceSet["service_template_model_stm_id"]);
             $tplRoute = str_replace("//", "/", Di::getDefault()->get('router')->getPathFor('/centreon-configuration/servicetemplate/[i:id]', array('id' => $tplArr['id'])));
             if (isset($tplArr['description'])) {
                 $tplStr .= '<span><a href="' . $tplRoute . '">' . $tplArr['description'] . '</a></span>';
             }
         }
         $sideMenuCustom = new SlideMenu($myServiceSet['service_id']);
         $events = Di::getDefault()->get('events');
         $events->emit('centreon-configuration.slide.menu.service.template', array($sideMenuCustom));
         //$myHostSet['DT_RowData']['right_side_details'] = $router->getPathFor('/centreon-configuration/host/snapshot/').$myHostSet['host_id'];
         $myServiceSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu();
         $myServiceSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu();
         $myServiceSet['service_template_model_stm_id'] = $tplStr;
         /* Display human readable the check/retry interval */
         $myServiceSet['service_normal_check_interval'] = HumanReadable::convert($myServiceSet['service_normal_check_interval'], 's', $units, null, true);
         $myServiceSet['service_retry_check_interval'] = HumanReadable::convert($myServiceSet['service_retry_check_interval'], 's', $units, null, true);
         /* Get personal tags */
         $myServiceSet['tagname'] = '';
         $aTagUsed = array();
         $aTags = TagsRepository::getList('service', $myServiceSet['service_id'], 0, 0);
         foreach ($aTags as $oTags) {
             if (!in_array($oTags['id'], $aTagUsed)) {
                 $aTagUsed[] = $oTags['id'];
                 $myServiceSet['tagname'] .= TagsRepository::getTag('service', $myServiceSet['service_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], 1);
             }
         }
         $myServiceSet['tagname'] .= TagsRepository::getAddTag('service', $myServiceSet['service_id']);
     }
 }