Logo Search packages:      
Sourcecode: nagvis version File versions  Download package

NagVisMap::getState ( &$  obj  ) 

Gets the state of an object

Parameters:
Array $obj Array with object properties
Returns:
Array Array with state of the object
Author:
Lars Michelsen <lars@vertical-visions.de>

Definition at line 577 of file NagVisMap.php.

                               {
            if (DEBUG&&DEBUGLEVEL&1) debug('Start method NagVisMap::getState(&$obj)');
            $state = Array('State'=>'','Output'=>'');
            if($obj['type'] == 'service') {
                  $name = 'host_name';
            } else {
                  $name = $obj['type'] . '_name';
            }
            
            switch($obj['type']) {
                  case 'map':
                        // prevent direct loops (map including itselfes as map icon)
                        if($this->MAPCFG->getName() == $obj[$name]) {
                              $FRONTEND = new GlobalPage($this->MAINCFG,Array('languageRoot'=>'global:global'));
                              $FRONTEND->messageToUser('WARNING','loopInMapRecursion');
                              
                              $LANG = new GlobalLanguage($this->MAINCFG,'global:global');
                              $state = Array('State' => 'UNKNOWN','Output' => $LANG->getMessageText('loopInMapRecursion'));
                        } else {
                              // save mapName in linkedMaps array
                              $this->linkedMaps[] = $this->MAPCFG->getName();
                              
                              $SUBMAPCFG = new NagVisMapCfg($this->MAINCFG,$obj[$name]);
                              $SUBMAPCFG->readMapConfig();
                              // Start map wihtout getting the state
                              $SUBMAP = new NagVisMap($this->MAINCFG,$SUBMAPCFG,$this->LANG,$this->BACKEND,FALSE);
                              $SUBMAP->linkedMaps = $this->linkedMaps;
                              
                              if($this->checkPermissions($SUBMAPCFG->getValue('global',0, 'allowed_user'),FALSE)) {
                                    // prevent loops in recursion
                                    if(in_array($SUBMAPCFG->getName(),$this->linkedMaps)) {
                                          $FRONTEND = new GlobalPage($this->MAINCFG,Array('languageRoot'=>'global:global'));
                                          $FRONTEND->messageToUser('WARNING','loopInMapRecursion');
                                          
                                          $LANG = new GlobalLanguage($this->MAINCFG,'global:global');
                                          $state = Array('State' => 'UNKNOWN','Output' => $LANG->getMessageText('loopInMapRecursion'));
                                    } else {
                                          $state = $SUBMAP->getMapState($SUBMAP->getMapObjects(1,1));
                                          // FIXME: Language entry
                                          $state = Array('State' => $state,'Output'=>'State of child map is '.$state);
                                    }
                              } else {
                                    // FIXME: Language entry
                                    $state = Array('State' => 'UNKNOWN','Output'=>'Error: You are not permited to view the state of this map.');
                              }
                        }
                  break;
                  case 'textbox':
                  break;
                  default:
                        if(!isset($obj['service_description'])) {
                              $obj['service_description'] = '';
                        }
                        if(!isset($obj['recognize_services'])) {
                              $obj['recognize_services'] = '';    
                        }
                        
                        if($this->BACKEND->checkBackendInitialized($obj['backend_id'],TRUE)) {
                              $state = $this->BACKEND->BACKENDS[$obj['backend_id']]->checkStates($obj['type'],$obj[$name],$obj['recognize_services'],$obj['service_description'],$obj['only_hard_states']);
                        }
                  break;      
            }
            
            if (DEBUG&&DEBUGLEVEL&1) debug('End method NagVisMap::getState(): Array()');
            return Array('state' => $state['State'],'stateOutput' => $state['Output']);
      }


Generated by  Doxygen 1.6.0   Back to index