예제 #1
0
 /**
  * Look for "computer name" inside all databases
  *
  * @param $fqdn                     name to search (for instance : forge.indepnet.net)
  * @param $wildcard_search boolean  true if we search with wildcard (false by default)
  *
  * @return (array) each value of the array (corresponding to one NetworkPort) is an array of the
  *                 items from the master item to the NetworkPort
  **/
 static function getItemsByFQDN($fqdn, $wildcard_search = false)
 {
     $FQNDs_with_Items = array();
     if (!$wildcard_search) {
         if (!FQDN::checkFQDN($fqdn)) {
             return array();
         }
     }
     $position = strpos($fqdn, ".");
     if ($position !== false) {
         $label = strtolower(substr($fqdn, 0, $position));
         $fqdns_id = FQDN::getFQDNIDByFQDN(substr($fqdn, $position + 1), $wildcard_search);
     } else {
         $label = $fqdn;
         $fqdns_id = -1;
     }
     foreach (self::getIDsByLabelAndFQDNID($label, $fqdns_id, $wildcard_search) as $class => $IDs) {
         if ($FQDNlabel = getItemForItemtype($class)) {
             foreach ($IDs as $ID) {
                 if ($FQDNlabel->getFromDB($ID)) {
                     $FQNDs_with_Items[] = array_merge(array_reverse($FQDNlabel->recursivelyGetItems()), array(clone $FQDNlabel));
                 }
             }
         }
     }
     return $FQNDs_with_Items;
 }