Beispiel #1
0
 /**
  * PUBLIC getObjectInformation()
  *
  * Gets all necessary information of the object as array
  *
  * @return	Array		Object configuration
  * @author 	Lars Michelsen <*****@*****.**>
  */
 public function getObjectInformation($bFetchChilds = true)
 {
     global $CORE;
     $arr = array();
     // When the childs don't need to be fetched this object is a child
     // itselfs. So much less information are needed. Progress them here
     // If someone wants more information in hover menu children, this is
     // the place to change.
     if (!$bFetchChilds) {
         return $this->fetchObjectAsChild();
     }
     // Need to remove some options which are not relevant
     // FIXME: Would be much better to name the needed vars explicit
     if (self::$arrDenyKeys == null) {
         self::$arrDenyKeys = array('MAPCFG' => '', 'MAP' => '', 'conf' => '', 'services' => '', 'fetchedChildObjects' => '', 'childObjects' => '', 'parentObjects' => '', 'members' => '', 'objects' => '', 'linkedMaps' => '', 'isSummaryObject' => '', 'isView' => '', 'dateFormat' => '', 'arrDenyKeys' => '', 'aStateCounts' => '', 'iconDetails' => '', 'problem_msg' => '', 'isLoopingBacklink' => '');
     }
     foreach ($this as $key => $val) {
         if (!isset(self::$arrDenyKeys[$key]) && $val !== null) {
             $arr[$key] = $val;
         }
     }
     if ($this instanceof NagVisStatefulObject) {
         $num_members = $this->getNumMembers();
         if ($num_members !== null) {
             $arr['num_members'] = $num_members;
         }
     }
     // I want only "name" in js
     if (!isset($CORE->statelessObjectTypes[$this->type])) {
         $arr['name'] = $this->getName();
         if ($this->type == 'service') {
             unset($arr['host_name']);
         } else {
             unset($arr[$this->type . '_name']);
         }
         if ($this->type == 'host' || $this->type == 'service') {
             $obj_attrs = array('alias' => ALIAS, 'display_name' => DISPLAY_NAME, 'address' => ADDRESS, 'notes' => NOTES, 'check_command' => CHECK_COMMAND);
             foreach ($obj_attrs as $attr => $state_key) {
                 if (isset($this->state[$state_key]) && $this->state[$state_key] != '') {
                     $arr[$attr] = $this->state[$state_key];
                 } else {
                     $arr[$attr] = '';
                 }
             }
         } elseif ($this->type == 'map' || $this->type == 'servicegroup' || $this->type == 'hostgroup' || $this->type == 'aggregation') {
             if (isset($this->state[ALIAS])) {
                 $arr['alias'] = $this->state[ALIAS];
             } else {
                 $arr['alias'] = '';
             }
         }
         // Add the custom htmlcgi path for the object
         $i = 0;
         foreach ($this->backend_id as $backend_id) {
             if ($i == 0) {
                 $arr['htmlcgi'] = cfg('backend_' . $backend_id, 'htmlcgi');
                 $arr['custom_1'] = cfg('backend_' . $backend_id, 'custom_1');
                 $arr['custom_2'] = cfg('backend_' . $backend_id, 'custom_2');
                 $arr['custom_3'] = cfg('backend_' . $backend_id, 'custom_3');
             } else {
                 $arr['htmlcgi_' . $i] = cfg('backend_' . $backend_id, 'htmlcgi');
                 $arr['custom_1_' . $i] = cfg('backend_' . $backend_id, 'custom_1');
                 $arr['custom_2_' . $i] = cfg('backend_' . $backend_id, 'custom_2');
                 $arr['custom_3_' . $i] = cfg('backend_' . $backend_id, 'custom_3');
             }
             $i++;
         }
         // Little hack: Overwrite the options with correct state information
         $arr = array_merge($arr, $this->getObjectStateInformations(false));
     }
     // If there are some members fetch the information for them
     if (isset($arr['num_members']) && $arr['num_members'] > 0) {
         $members = array();
         foreach ($this->getSortedObjectMembers() as $OBJ) {
             $members[] = $OBJ->fetchObjectAsChild();
         }
         $arr['members'] = $members;
     }
     return $arr;
 }