コード例 #1
0
 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $graphids = array_keys($result);
     // adding Items
     if ($options['selectItems'] !== null && $options['selectItems'] !== API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'graphid', 'itemid', 'graphs_items');
         $items = API::Item()->get(array('output' => $options['selectItems'], 'itemids' => $relationMap->getRelatedIds(), 'webitems' => true, 'nopermissions' => true, 'preservekeys' => true, 'filter' => array('flags' => null)));
         $result = $relationMap->mapMany($result, $items, 'items');
     }
     // adding discoveryRule
     if (!is_null($options['selectDiscoveryRule'])) {
         $dbRules = DBselect('SELECT id.parent_itemid,gi.graphid' . ' FROM item_discovery id,graphs_items gi' . ' WHERE ' . dbConditionInt('gi.graphid', $graphids) . ' AND gi.itemid=id.itemid');
         $relationMap = new CRelationMap();
         while ($relation = DBfetch($dbRules)) {
             $relationMap->addRelation($relation['graphid'], $relation['parent_itemid']);
         }
         $discoveryRules = API::DiscoveryRule()->get(array('output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
         $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule');
     }
     return $result;
 }
コード例 #2
0
ファイル: CGraph.php プロジェクト: jbfavre/debian-zabbix
 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $graphids = array_keys($result);
     // adding Items
     if ($options['selectItems'] !== null && $options['selectItems'] !== API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'graphid', 'itemid', 'graphs_items');
         $items = API::Item()->get(['output' => $options['selectItems'], 'itemids' => $relationMap->getRelatedIds(), 'webitems' => true, 'nopermissions' => true, 'preservekeys' => true]);
         $result = $relationMap->mapMany($result, $items, 'items');
     }
     // adding discoveryRule
     if ($options['selectDiscoveryRule'] !== null) {
         $dbRules = DBselect('SELECT id.parent_itemid,gd.graphid' . ' FROM graph_discovery gd,item_discovery id,graphs_items gi' . ' WHERE ' . dbConditionInt('gd.graphid', $graphids) . ' AND gd.parent_graphid=gi.graphid' . ' AND gi.itemid=id.itemid');
         $relationMap = new CRelationMap();
         while ($relation = DBfetch($dbRules)) {
             $relationMap->addRelation($relation['graphid'], $relation['parent_itemid']);
         }
         $discoveryRules = API::DiscoveryRule()->get(['output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true]);
         $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule');
     }
     // adding graph discovery
     if ($options['selectGraphDiscovery'] !== null) {
         $graphDiscoveries = API::getApiService()->select('graph_discovery', ['output' => $this->outputExtend($options['selectGraphDiscovery'], ['graphid']), 'filter' => ['graphid' => array_keys($result)], 'preservekeys' => true]);
         $relationMap = $this->createRelationMap($graphDiscoveries, 'graphid', 'graphid');
         $graphDiscoveries = $this->unsetExtraFields($graphDiscoveries, ['graphid'], $options['selectGraphDiscovery']);
         $result = $relationMap->mapOne($result, $graphDiscoveries, 'graphDiscovery');
     }
     return $result;
 }