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

WuiMap::getObjectsOfType ( type,
mergeWithGlobals = 1 
)

Gets all objects of the defined type from a map and return an array with states

Parameters:
String $type Type of objects
Boolean $mergeWithGlobals Merge with globals
Returns:
Array Array of Objects of this type on the map
Author:
Lars Michelsen <lars@vertical-visions.de>

Definition at line 333 of file WuiMap.php.

                                                           {
            if (DEBUG&&DEBUGLEVEL&1) debug('Start method GlobalMap::getObjectsOfType('.$type.','.$mergeWithGlobals.')');
            // object array
            $objects = Array();
            
            // Default object state
            if($type == 'host' || $type == 'hostgroup') {
                  $objState = Array('state'=>'UP','stateOutput'=>'Default State');
            } else {
                  $objState = Array('state'=>'OK','stateOutput'=>'Default State');
            }
            
            if(is_array($objs = $this->MAPCFG->getDefinitions($type))){
                  foreach($objs AS $index => $obj) {
                        if (DEBUG&&DEBUGLEVEL&2) debug('Start object of type: '.$type);
                        // workaround
                        $obj['id'] = $index;
                        
                        if($mergeWithGlobals) {
                              // merge with "global" settings
                              foreach($this->MAPCFG->validConfig[$type] AS $key => $values) {
                                    if((!isset($obj[$key]) || $obj[$key] == '') && isset($values['default'])) {
                                          $obj[$key] = $values['default'];
                                    }
                              }
                        }
                        
                        // add default state to the object
                        $obj = array_merge($obj,$objState);
                        
                        if($obj['type'] != 'textbox' && $obj['type'] != 'shape') {
                              $obj['icon'] = $this->getIcon($obj);
                        }
                        
                        // add object to array of objects
                        $objects[] = $obj;
                        if (DEBUG&&DEBUGLEVEL&2) debug('End object of type: '.$type);
                  }
                  
                  if (DEBUG&&DEBUGLEVEL&1) debug('End method GlobalMap::getObjectsOfType(): Array(...)');
                  return $objects;
            }
      }


Generated by  Doxygen 1.6.0   Back to index