当前位置: 首页>>代码示例>>PHP>>正文


PHP API::Map方法代码示例

本文整理汇总了PHP中API::Map方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Map方法的具体用法?PHP API::Map怎么用?PHP API::Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::Map方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: import

 /**
  * Import maps.
  *
  * @param array $maps
  *
  * @return void
  */
 public function import(array $maps)
 {
     $maps = zbx_toHash($maps, 'name');
     $this->checkCircularMapReferences($maps);
     do {
         $im = $this->getIndependentMaps($maps);
         $mapsToCreate = array();
         $mapsToUpdate = array();
         foreach ($im as $name) {
             $map = $maps[$name];
             unset($maps[$name]);
             $map = $this->resolveMapReferences($map);
             if ($mapId = $this->referencer->resolveMap($map['name'])) {
                 $map['sysmapid'] = $mapId;
                 $mapsToUpdate[] = $map;
             } else {
                 $mapsToCreate[] = $map;
             }
         }
         if ($this->options['maps']['createMissing'] && $mapsToCreate) {
             $newMapIds = API::Map()->create($mapsToCreate);
             foreach ($mapsToCreate as $num => $map) {
                 $mapId = $newMapIds['sysmapids'][$num];
                 $this->referencer->addMapRef($map['name'], $mapId);
             }
         }
         if ($this->options['maps']['updateExisting'] && $mapsToUpdate) {
             API::Map()->update($mapsToUpdate);
         }
     } while (!empty($im));
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:38,代码来源:CMapImporter.php

示例2: doAction

 protected function doAction()
 {
     CProfile::update('web.maps.sysmapid', $this->sysmapid, PROFILE_TYPE_ID);
     $data = ['fullscreen' => $this->getInput('fullscreen', 0)];
     $maps = API::Map()->get(['output' => ['name', 'severity_min'], 'sysmapids' => [$this->sysmapid]]);
     $data['map'] = reset($maps);
     $data['map']['editable'] = API::Map()->isWritable([$this->sysmapid]);
     $data['pageFilter'] = new CPageFilter(['severitiesMin' => ['default' => $data['map']['severity_min'], 'mapId' => $this->sysmapid], 'severityMin' => $this->hasInput('severity_min') ? $this->getInput('severity_min') : null]);
     $data['severity_min'] = $data['pageFilter']->severityMin;
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Network maps'));
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:13,代码来源:CControllerMapView.php

示例3: import

 /**
  * Import maps.
  *
  * @param array $maps
  *
  * @return void
  */
 public function import(array $maps)
 {
     $maps = zbx_toHash($maps, 'name');
     $this->checkCircularMapReferences($maps);
     $maps = $this->resolveMapElementReferences($maps);
     /*
      * Get all importable maps with removed elements and links. First import maps and then update maps with
      * elements and links from import file. This way we make sure we are able to resolve any references
      * between maps and links that are imported.
      */
     $mapsWithoutElements = $this->getMapsWithoutElements($maps);
     $mapsToProcess = array('createMissing' => array(), 'updateExisting' => array());
     foreach ($mapsWithoutElements as $mapName => $mapWithoutElements) {
         $mapId = $this->referencer->resolveMap($mapWithoutElements['name']);
         if ($mapId) {
             // Update sysmapid in source map too.
             $mapWithoutElements['sysmapid'] = $mapId;
             $maps[$mapName]['sysmapid'] = $mapId;
             $mapsToProcess['updateExisting'][] = $mapWithoutElements;
         } else {
             $mapsToProcess['createMissing'][] = $mapWithoutElements;
         }
     }
     if ($this->options['maps']['createMissing'] && $mapsToProcess['createMissing']) {
         $newMapIds = API::Map()->create($mapsToProcess['createMissing']);
         foreach ($mapsToProcess['createMissing'] as $num => $map) {
             $mapId = $newMapIds['sysmapids'][$num];
             $this->referencer->addMapRef($map['name'], $mapId);
             $maps[$map['name']]['sysmapid'] = $mapId;
         }
     }
     if ($this->options['maps']['updateExisting'] && $mapsToProcess['updateExisting']) {
         API::Map()->update($mapsToProcess['updateExisting']);
     }
     // Form an array of maps that need to be updated with elements and links, respecting the create/update options.
     $mapsToUpdate = array();
     foreach ($mapsToProcess as $mapActionKey => $mapArray) {
         if ($this->options['maps'][$mapActionKey] && $mapsToProcess[$mapActionKey]) {
             foreach ($mapArray as $mapItem) {
                 $map = array('sysmapid' => $maps[$mapItem['name']]['sysmapid'], 'name' => $mapItem['name'], 'selements' => $maps[$mapItem['name']]['selements'], 'links' => $maps[$mapItem['name']]['links']);
                 $map = $this->resolveMapReferences($map);
                 // Remove the map name so API does not make an update query to the database.
                 unset($map['name']);
                 $mapsToUpdate[] = $map;
             }
         }
     }
     if ($mapsToUpdate) {
         API::Map()->update($mapsToUpdate);
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:58,代码来源:CMapImporter.php

示例4: getFavouriteMaps

 /**
  * Prepare data for favourite maps menu popup.
  *
  * @return array
  */
 public static function getFavouriteMaps()
 {
     $maps = [];
     $favourites = CFavorite::get('web.favorite.sysmapids');
     if ($favourites) {
         $mapids = [];
         foreach ($favourites as $favourite) {
             $mapids[$favourite['value']] = true;
         }
         $db_maps = API::Map()->get(['output' => ['sysmapid', 'name'], 'sysmapids' => array_keys($mapids)]);
         foreach ($db_maps as $db_map) {
             $maps[] = ['id' => $db_map['sysmapid'], 'label' => $db_map['name']];
         }
     }
     return ['type' => 'favouriteMaps', 'maps' => $maps];
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:21,代码来源:CMenuPopupHelper.php

示例5: getFavouriteMaps

 /**
  * Prepare data for favourite maps menu popup.
  *
  * @return array
  */
 public static function getFavouriteMaps()
 {
     $maps = array();
     $favourites = CFavorite::get('web.favorite.sysmapids');
     if ($favourites) {
         $mapIds = array();
         foreach ($favourites as $favourite) {
             $mapIds[$favourite['value']] = $favourite['value'];
         }
         $dbMaps = API::Map()->get(array('output' => array('sysmapid', 'name'), 'sysmapids' => $mapIds));
         foreach ($dbMaps as $dbMap) {
             $maps[] = array('id' => $dbMap['sysmapid'], 'label' => $dbMap['name']);
         }
     }
     return array('type' => 'favouriteMaps', 'maps' => $maps);
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:21,代码来源:CMenuPopupHelper.php

示例6: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $image = new CImg('map.php?noedit=1&sysmapid=' . $this->screenitem['resourceid'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] . '&curtime=' . time());
     $image->setAttribute('id', 'map_' . $this->screenitem['screenitemid']);
     if ($this->mode == SCREEN_MODE_PREVIEW) {
         $sysmap = API::Map()->get(array('sysmapids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'selectSelements' => API_OUTPUT_EXTEND, 'selectLinks' => API_OUTPUT_EXTEND, 'expandUrls' => true, 'nopermissions' => true, 'preservekeys' => true));
         $sysmap = reset($sysmap);
         $actionMap = getActionMapBySysmap($sysmap);
         $image->setMap($actionMap->getName());
         $output = array($actionMap, $image);
     } elseif ($this->mode == SCREEN_MODE_EDIT) {
         $output = array($image, BR(), new CLink(_('Change'), $this->action));
     } else {
         $output = array($image);
     }
     $this->insertFlickerfreeJs();
     $div = new CDiv($output, 'map-container flickerfreescreen', $this->getScreenId());
     $div->setAttribute('data-timestamp', $this->timestamp);
     $div->addStyle('position: relative;');
     return $div;
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:26,代码来源:CScreenMap.php

示例7: elseif

} elseif ($srctbl == 'sysmaps') {
    $form = new CForm();
    $form->setName('sysmapform');
    $form->setAttribute('id', 'sysmaps');
    $table = new CTableInfo(_('No maps found.'));
    if ($multiselect) {
        $header = array(array(new CCheckBox('all_sysmaps', null, "javascript: checkAll('" . $form->getName() . "', 'all_sysmaps', 'sysmaps');"), _('Name')));
    } else {
        $header = array(_('Name'));
    }
    $table->setHeader($header);
    $options = array('nodeids' => $nodeId, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true);
    if (!is_null($writeonly)) {
        $options['editable'] = true;
    }
    $sysmaps = API::Map()->get($options);
    order_result($sysmaps, 'name');
    foreach ($sysmaps as $sysmap) {
        $sysmap['node_name'] = isset($sysmap['node_name']) ? '(' . $sysmap['node_name'] . ') ' : '';
        $name = $sysmap['node_name'] . $sysmap['name'];
        $description = new CSpan($sysmap['name'], 'link');
        if ($multiselect) {
            $js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($sysmap['sysmapid']) . ');';
        } else {
            $values = array($dstfld1 => $sysmap[$srcfld1], $dstfld2 => $sysmap[$srcfld2]);
            $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); close_window(); return false;';
        }
        if (isset($excludeids[$sysmap['sysmapid']])) {
            $description->removeAttr('class');
        } else {
            $description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");');
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:popup.php

示例8: getFavouriteMapsData

/**
 * Get favourite maps data.
 *
 * @return array
 */
function getFavouriteMapsData()
{
    $maps = [];
    $favourites = CFavorite::get('web.favorite.sysmapids');
    if ($favourites) {
        $mapIds = [];
        foreach ($favourites as $favourite) {
            $mapIds[$favourite['value']] = $favourite['value'];
        }
        $dbMaps = API::Map()->get(['output' => ['sysmapid', 'name'], 'sysmapids' => $mapIds]);
        foreach ($dbMaps as $dbMap) {
            $maps[] = ['id' => $dbMap['sysmapid'], 'label' => $dbMap['name']];
        }
    }
    return $maps;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:21,代码来源:blocks.inc.php

示例9: getMapsReferences

 /**
  * Get maps references by map ids.
  *
  * @param array $mapIds
  *
  * @return array
  */
 protected function getMapsReferences(array $mapIds)
 {
     $idents = array();
     $maps = API::Map()->get(array('sysmapids' => $mapIds, 'output' => array('name'), 'nodeids' => get_current_nodeid(true), 'preservekeys' => true));
     foreach ($maps as $id => $map) {
         $idents[$id] = array('name' => $map['name']);
     }
     return $idents;
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:16,代码来源:CConfigurationExport.php

示例10: ob_clean

            ob_clean();
            echo 'alert(' . zbx_jsvalue(implode("\r\n", $msg)) . ');';
        }
        @ob_flush();
        exit;
    }
}
if (PAGE_TYPE_HTML != $page['type']) {
    require_once dirname(__FILE__) . '/include/page_footer.php';
    exit;
}
/*
 * Permissions
 */
if (isset($_REQUEST['sysmapid'])) {
    $sysmap = API::Map()->get(['output' => ['sysmapid', 'expand_macros', 'grid_show', 'grid_align', 'grid_size', 'width', 'height', 'iconmapid'], 'selectSelements' => API_OUTPUT_EXTEND, 'selectLinks' => API_OUTPUT_EXTEND, 'sysmapids' => getRequest('sysmapid'), 'editable' => true, 'preservekeys' => true]);
    if (empty($sysmap)) {
        access_deny();
    } else {
        $sysmap = reset($sysmap);
    }
}
/*
 * Display
 */
$data = ['sysmap' => $sysmap, 'iconList' => [], 'defaultAutoIconId' => null, 'defaultIconId' => null, 'defaultIconName' => null];
// get selements
add_elementNames($data['sysmap']['selements']);
$data['sysmap']['selements'] = zbx_toHash($data['sysmap']['selements'], 'selementid');
$data['sysmap']['links'] = zbx_toHash($data['sysmap']['links'], 'linkid');
// get links
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:sysmap.php

示例11: unset

    unset($_REQUEST['sysmapid']);
    foreach ($maps as $map) {
        if ($map['name'] === $mapName) {
            $_REQUEST['sysmapid'] = $map['sysmapid'];
        }
    }
} elseif (empty($_REQUEST['sysmapid'])) {
    $_REQUEST['sysmapid'] = CProfile::get('web.maps.sysmapid');
    if (!$_REQUEST['sysmapid'] && !isset($maps[$_REQUEST['sysmapid']])) {
        if ($firstMap = reset($maps)) {
            $_REQUEST['sysmapid'] = $firstMap['sysmapid'];
        }
    }
}
if (isset($_REQUEST['sysmapid']) && !isset($maps[$_REQUEST['sysmapid']])) {
    access_deny();
}
CProfile::update('web.maps.sysmapid', $_REQUEST['sysmapid'], PROFILE_TYPE_ID);
/*
 * Display
 */
$data = array('fullscreen' => $_REQUEST['fullscreen'], 'sysmapid' => $_REQUEST['sysmapid'], 'maps' => $maps);
$data['map'] = API::Map()->get(array('output' => API_OUTPUT_EXTEND, 'sysmapids' => $data['sysmapid'], 'expandUrls' => true, 'selectSelements' => API_OUTPUT_EXTEND, 'selectLinks' => API_OUTPUT_EXTEND, 'preservekeys' => true));
$data['map'] = reset($data['map']);
$data['pageFilter'] = new CPageFilter(array('severitiesMin' => array('default' => $data['map']['severity_min'], 'mapId' => $data['sysmapid']), 'severityMin' => get_request('severity_min')));
$data['severity_min'] = $data['pageFilter']->severityMin;
// render view
$mapsView = new CView('monitoring.maps', $data);
$mapsView->render();
$mapsView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:maps.php

示例12: selectMaps

 /**
  * Select map ids for previously added maps names.
  */
 protected function selectMaps()
 {
     if (!empty($this->maps)) {
         $this->mapsRefs = [];
         $dbMaps = API::Map()->get(['filter' => ['name' => $this->maps], 'output' => ['sysmapid', 'name'], 'preservekeys' => true]);
         foreach ($dbMaps as $dbMap) {
             $this->mapsRefs[$dbMap['name']] = $dbMap['sysmapid'];
         }
         $this->maps = [];
     }
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:14,代码来源:CImportReferencer.php

示例13: checkInput


//.........这里部分代码省略.........
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect value "%1$s" for "%2$s" field: must be between %3$s and %4$s.', $screenItem['elements'], 'elements', 1, 100));
                     }
                     break;
             }
         }
         // check 'max_columns' parameter for LLD screen resources:
         // is set and valid for create method, and is valid for update method, if set
         $dbScreenItem = isset($screenItem['screenitemid']) ? $dbScreenItems[$screenItem['screenitemid']] : null;
         $lldResources = array(SCREEN_RESOURCE_LLD_GRAPH, SCREEN_RESOURCE_LLD_SIMPLE_GRAPH);
         if (in_array($screenItem['resourcetype'], $lldResources)) {
             $set = isset($screenItem['max_columns']);
             $valid = $set && $this->isValidMaxColumns($screenItem['max_columns']);
             $error = $dbScreenItem ? $set && !$valid : !$set || !$valid;
             if ($error) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect max columns provided for screen element.'));
             }
         }
         if (isset($validStyles[$screenItem['resourcetype']]) && !in_array($screenItem['style'], $validStyles[$screenItem['resourcetype']])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect style provided for screen element.'));
         }
     }
     // check host groups
     if ($hostGroupsIds) {
         $dbHostGroups = API::HostGroup()->get(array('output' => array('groupid'), 'groupids' => $hostGroupsIds, 'editable' => true, 'preservekeys' => true));
         foreach ($hostGroupsIds as $hostGroupsId) {
             if (!isset($dbHostGroups[$hostGroupsId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect host group ID "%1$s" provided for screen element.', $hostGroupsId));
             }
         }
     }
     // check hosts
     if ($hostIds) {
         $dbHosts = API::Host()->get(array('output' => array('hostid'), 'hostids' => $hostIds, 'editable' => true, 'preservekeys' => true));
         foreach ($hostIds as $hostId) {
             if (!isset($dbHosts[$hostId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect host ID "%1$s" provided for screen element.', $hostId));
             }
         }
     }
     // check graphs
     if ($graphIds) {
         $dbGraphs = API::Graph()->get(array('output' => array('graphid'), 'graphids' => $graphIds, 'editable' => true, 'preservekeys' => true));
         foreach ($graphIds as $graphId) {
             if (!isset($dbGraphs[$graphId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect graph ID "%1$s" provided for screen element.', $graphId));
             }
         }
     }
     // check graph prototypes
     if ($graphPrototypeIds) {
         $dbGraphPrototypes = API::GraphPrototype()->get(array('output' => array('graphid'), 'graphids' => $graphPrototypeIds, 'editable' => true, 'preservekeys' => true));
         foreach ($graphPrototypeIds as $graphPrototypeId) {
             if (!isset($dbGraphPrototypes[$graphPrototypeId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect graph prototype ID "%1$s" provided for screen element.', $graphPrototypeId));
             }
         }
     }
     // check items
     if ($itemIds) {
         $dbItems = API::Item()->get(array('output' => array('itemid'), 'itemids' => $itemIds, 'editable' => true, 'preservekeys' => true, 'webitems' => true));
         foreach ($itemIds as $itemId) {
             if (!isset($dbItems[$itemId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect item ID "%1$s" provided for screen element.', $itemId));
             }
         }
     }
     // check item prototypes
     if ($itemPrototypeIds) {
         $dbItemPrototypes = API::ItemPrototype()->get(array('output' => array('itemid'), 'itemids' => $itemPrototypeIds, 'editable' => true, 'preservekeys' => true));
         foreach ($itemPrototypeIds as $itemPrototypeId) {
             if (!isset($dbItemPrototypes[$itemPrototypeId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect item prototype ID "%1$s" provided for screen element.', $itemPrototypeId));
             }
         }
     }
     // check maps
     if ($mapIds) {
         $dbMaps = API::Map()->get(array('output' => array('sysmapid'), 'sysmapids' => $mapIds, 'editable' => true, 'preservekeys' => true));
         foreach ($mapIds as $mapId) {
             if (!isset($dbMaps[$mapId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect map ID "%1$s" provided for screen element.', $mapId));
             }
         }
     }
     // check screens
     if ($screenIds) {
         $dbScreens = API::Screen()->get(array('output' => array('screenid'), 'screenids' => $screenIds, 'editable' => true, 'preservekeys' => true));
         if (count($dbScreens) < count($screenIds)) {
             $dbTemplateScreens = API::TemplateScreen()->get(array('output' => array('screenid'), 'screenids' => $screenIds, 'editable' => true, 'preservekeys' => true));
             if ($dbTemplateScreens) {
                 $dbScreens = zbx_array_merge($dbScreens, $dbTemplateScreens);
             }
         }
         foreach ($screenIds as $screenId) {
             if (!isset($dbScreens[$screenId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect screen ID "%1$s" provided for screen element.', $screenId));
             }
         }
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:CScreenItem.php

示例14: checkInput


//.........这里部分代码省略.........
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('No item ID provided for screen element.'));
                     }
                     $itemIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 }
                 break;
             case SCREEN_RESOURCE_MAP:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No map ID provided for screen element.'));
                 }
                 $mapIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
             case SCREEN_RESOURCE_SCREEN:
                 if (!$screenItem['resourceid']) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('No screen ID provided for screen element.'));
                 }
                 $screenIds[$screenItem['resourceid']] = $screenItem['resourceid'];
                 break;
         }
         // check url
         if ($screenItem['resourcetype'] == SCREEN_RESOURCE_URL) {
             if (!isset($screenItem['url']) || zbx_empty($screenItem['url'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No URL provided for screen element.'));
             }
         }
         // check "Show lines"
         if (isset($screenItem['elements'])) {
             switch ($screenItem['resourcetype']) {
                 case SCREEN_RESOURCE_ACTIONS:
                 case SCREEN_RESOURCE_EVENTS:
                 case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
                 case SCREEN_RESOURCE_HOST_TRIGGERS:
                 case SCREEN_RESOURCE_PLAIN_TEXT:
                     if ($screenItem['elements'] < 1 || $screenItem['elements'] > 100) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect value "%1$s" for "%2$s" field: must be between %3$s and %4$s.', $screenItem['elements'], 'elements', 1, 100));
                     }
                     break;
             }
         }
     }
     // check host groups
     if ($hostGroupsIds) {
         $dbHostGroups = API::HostGroup()->get(array('groupids' => $hostGroupsIds, 'output' => array('groupid'), 'editable' => true, 'preservekeys' => true));
         foreach ($hostGroupsIds as $hostGroupsId) {
             if (!isset($dbHostGroups[$hostGroupsId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect host group ID "%1$s" provided for screen element.', $hostGroupsId));
             }
         }
     }
     // check hosts
     if ($hostIds) {
         $dbHosts = API::Host()->get(array('hostids' => $hostIds, 'output' => array('hostid'), 'editable' => true, 'preservekeys' => true));
         foreach ($hostIds as $hostId) {
             if (!isset($dbHosts[$hostId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect host ID "%1$s" provided for screen element.', $hostId));
             }
         }
     }
     // check graphs
     if ($graphIds) {
         $dbGraphs = API::Graph()->get(array('graphids' => $graphIds, 'output' => array('graphid'), 'editable' => true, 'preservekeys' => true));
         foreach ($graphIds as $graphId) {
             if (!isset($dbGraphs[$graphId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect graph ID "%1$s" provided for screen element.', $graphId));
             }
         }
     }
     // check items
     if ($itemIds) {
         $dbItems = API::Item()->get(array('itemids' => $itemIds, 'output' => array('itemid'), 'editable' => true, 'preservekeys' => true, 'webitems' => true));
         foreach ($itemIds as $itemId) {
             if (!isset($dbItems[$itemId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect item ID "%1$s" provided for screen element.', $itemId));
             }
         }
     }
     // check maps
     if ($mapIds) {
         $dbMaps = API::Map()->get(array('sysmapids' => $mapIds, 'output' => array('sysmapid'), 'editable' => true, 'preservekeys' => true));
         foreach ($mapIds as $mapId) {
             if (!isset($dbMaps[$mapId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect map ID "%1$s" provided for screen element.', $mapId));
             }
         }
     }
     // check screens
     if ($screenIds) {
         $dbScreens = API::Screen()->get(array('screenids' => $screenIds, 'output' => array('screenid'), 'editable' => true, 'preservekeys' => true));
         if (count($dbScreens) < count($screenIds)) {
             $dbTemplateScreens = API::TemplateScreen()->get(array('screenids' => $screenIds, 'output' => array('screenid'), 'editable' => true, 'preservekeys' => true));
             if ($dbTemplateScreens) {
                 $dbScreens = zbx_array_merge($dbScreens, $dbTemplateScreens);
             }
         }
         foreach ($screenIds as $screenId) {
             if (!isset($dbScreens[$screenId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect screen ID "%1$s" provided for screen element.', $screenId));
             }
         }
     }
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:101,代码来源:CScreenItem.php

示例15: getSelementsInfo

/**
 * Prepare map elements data.
 * Calculate problem triggers and priorities. Populate map elements with automatic icon mapping, acknowledging and
 * recent change markers.
 *
 * @param array $sysmap
 * @param int   $options
 * @param int   $options['severity_min'] Minimum trigger severity, default value is maximal (Disaster)
 *
 * @return array
 */
function getSelementsInfo($sysmap, array $options = array())
{
    if (!isset($options['severity_min'])) {
        $options['severity_min'] = TRIGGER_SEVERITY_NOT_CLASSIFIED;
    }
    $config = select_config();
    $showUnacknowledged = $config['event_ack_enable'] ? $sysmap['show_unack'] : EXTACK_OPTION_ALL;
    $triggerIdToSelementIds = array();
    $subSysmapTriggerIdToSelementIds = array();
    $hostGroupIdToSelementIds = array();
    $hostIdToSelementIds = array();
    if ($sysmap['sysmapid']) {
        $iconMap = API::IconMap()->get(array('sysmapids' => $sysmap['sysmapid'], 'selectMappings' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND));
        $iconMap = reset($iconMap);
    }
    $hostsToGetInventories = array();
    $selements = $sysmap['selements'];
    $selementIdToSubSysmaps = array();
    foreach ($selements as $selementId => &$selement) {
        $selement['hosts'] = array();
        $selement['triggers'] = array();
        switch ($selement['elementtype']) {
            case SYSMAP_ELEMENT_TYPE_MAP:
                $sysmapIds = array($selement['elementid']);
                while (!empty($sysmapIds)) {
                    $subSysmaps = API::Map()->get(array('sysmapids' => $sysmapIds, 'output' => array('sysmapid'), 'selectSelements' => API_OUTPUT_EXTEND, 'nopermissions' => true, 'preservekeys' => true));
                    if (!isset($selementIdToSubSysmaps[$selementId])) {
                        $selementIdToSubSysmaps[$selementId] = array();
                    }
                    $selementIdToSubSysmaps[$selementId] += $subSysmaps;
                    $sysmapIds = array();
                    foreach ($subSysmaps as $subSysmap) {
                        foreach ($subSysmap['selements'] as $subSysmapSelement) {
                            switch ($subSysmapSelement['elementtype']) {
                                case SYSMAP_ELEMENT_TYPE_MAP:
                                    $sysmapIds[] = $subSysmapSelement['elementid'];
                                    break;
                                case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
                                    $hostGroupIdToSelementIds[$subSysmapSelement['elementid']][$selementId] = $selementId;
                                    break;
                                case SYSMAP_ELEMENT_TYPE_HOST:
                                    $hostIdToSelementIds[$subSysmapSelement['elementid']][$selementId] = $selementId;
                                    break;
                                case SYSMAP_ELEMENT_TYPE_TRIGGER:
                                    $subSysmapTriggerIdToSelementIds[$subSysmapSelement['elementid']][$selementId] = $selementId;
                                    break;
                            }
                        }
                    }
                }
                break;
            case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
                $hostGroupId = $selement['elementid'];
                $hostGroupIdToSelementIds[$hostGroupId][$selementId] = $selementId;
                break;
            case SYSMAP_ELEMENT_TYPE_HOST:
                $hostId = $selement['elementid'];
                $hostIdToSelementIds[$hostId][$selementId] = $selementId;
                // if we have icon map applied, we need to get inventories for all hosts,
                // where automatic icon selection is enabled.
                if ($sysmap['iconmapid'] && $selement['use_iconmap']) {
                    $hostsToGetInventories[] = $hostId;
                }
                break;
            case SYSMAP_ELEMENT_TYPE_TRIGGER:
                $triggerId = $selement['elementid'];
                $triggerIdToSelementIds[$triggerId][$selementId] = $selementId;
                break;
        }
    }
    unset($selement);
    // get host inventories
    if ($sysmap['iconmapid']) {
        $hostInventories = API::Host()->get(array('hostids' => $hostsToGetInventories, 'output' => array('hostid'), 'nopermissions' => true, 'preservekeys' => true, 'selectInventory' => API_OUTPUT_EXTEND));
    }
    $allHosts = array();
    if (!empty($hostIdToSelementIds)) {
        $hosts = API::Host()->get(array('hostids' => array_keys($hostIdToSelementIds), 'output' => array('name', 'status', 'maintenance_status', 'maintenanceid'), 'nopermissions' => true, 'preservekeys' => true));
        $allHosts = array_merge($allHosts, $hosts);
        foreach ($hosts as $hostId => $host) {
            foreach ($hostIdToSelementIds[$hostId] as $selementId) {
                $selements[$selementId]['hosts'][$hostId] = $hostId;
            }
        }
    }
    $hostsFromHostGroups = array();
    if (!empty($hostGroupIdToSelementIds)) {
        $hostsFromHostGroups = API::Host()->get(array('groupids' => array_keys($hostGroupIdToSelementIds), 'output' => array('name', 'status', 'maintenance_status', 'maintenanceid'), 'selectGroups' => array('groupid'), 'nopermissions' => true, 'preservekeys' => true));
        foreach ($hostsFromHostGroups as $hostId => $host) {
//.........这里部分代码省略.........
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:101,代码来源:maps.inc.php


注:本文中的API::Map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。