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


PHP CMap::update方法代码示例

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


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

示例1: DBstart

    require_once 'include/export.inc.php';
    DBstart();
    $result = zbxXML::import($_FILES['import_file']['tmp_name']);
    if ($result) {
        $result = zbxXML::parseMap($rules);
    }
    $result = DBend($result);
    show_messages($result, S_IMPORTED . SPACE . S_SUCCESSEFULLY_SMALL, S_IMPORT . SPACE . S_FAILED_SMALL);
}
$_REQUEST['go'] = get_request('go', 'none');
if (isset($_REQUEST['save'])) {
    if (isset($_REQUEST['sysmapid'])) {
        // TODO check permission by new value.
        $map = array('sysmapid' => $_REQUEST['sysmapid'], 'name' => $_REQUEST['name'], 'width' => $_REQUEST['width'], 'height' => $_REQUEST['height'], 'backgroundid' => $_REQUEST['backgroundid'], 'highlight' => get_request('highlight', 0), 'markelements' => get_request('markelements', 0), 'expandproblem' => get_request('expandproblem', 0), 'label_type' => $_REQUEST['label_type'], 'label_location' => $_REQUEST['label_location'], 'show_unack' => get_request('show_unack', 0));
        DBstart();
        $result = CMap::update($map);
        $result = DBend($result);
        add_audit_if($result, AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_MAP, 'Name [' . $_REQUEST['name'] . ']');
        show_messages($result, S_MAP_UPDATED, S_CANNOT_UPDATE_MAP);
    } else {
        if (!count(get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY))) {
            access_deny();
        }
        $map = array('name' => $_REQUEST['name'], 'width' => $_REQUEST['width'], 'height' => $_REQUEST['height'], 'backgroundid' => $_REQUEST['backgroundid'], 'highlight' => get_request('highlight', 0), 'markelements' => get_request('markelements', 0), 'expandproblem' => get_request('expandproblem', 0), 'label_type' => $_REQUEST['label_type'], 'label_location' => $_REQUEST['label_location'], 'show_unack' => get_request('show_unack', 0));
        DBstart();
        $result = CMap::create($map);
        $result = DBend($result);
        add_audit_if($result, AUDIT_ACTION_ADD, AUDIT_RESOURCE_MAP, 'Name [' . $_REQUEST['name'] . ']');
        show_messages($result, S_MAP_ADDED, S_CANNOT_ADD_MAP);
    }
    if ($result) {
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:sysmaps.php

示例2: parseMap

 public static function parseMap($rules)
 {
     global $USER_DETAILS;
     $importMaps = self::XMLtoArray(self::$xml);
     if (!isset($importMaps['zabbix_export'])) {
         $importMaps['zabbix_export'] = $importMaps;
     }
     try {
         if ($USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN) {
             $images = $importMaps['zabbix_export']['images'];
             $images_to_add = array();
             $images_to_update = array();
             foreach ($images as $inum => $image) {
                 if (CImage::exists($image)) {
                     if ($image['imagetype'] == IMAGE_TYPE_ICON && isset($rules['icons']['exist']) || $image['imagetype'] == IMAGE_TYPE_BACKGROUND && isset($rules['background']['exist'])) {
                         $options = array('filter' => array('name' => $image['name']), 'output' => API_OUTPUT_SHORTEN);
                         $imgs = CImage::get($options);
                         $img = reset($imgs);
                         $image['imageid'] = $img['imageid'];
                         // image will be decoded in class.image.php
                         $image['image'] = $image['encodedImage'];
                         unset($image['encodedImage']);
                         $images_to_update[] = $image;
                     }
                 } else {
                     if ($image['imagetype'] == IMAGE_TYPE_ICON && isset($rules['icons']['missed']) || $image['imagetype'] == IMAGE_TYPE_BACKGROUND && isset($rules['background']['missed'])) {
                         // No need to decode_base64
                         $image['image'] = $image['encodedImage'];
                         unset($image['encodedImage']);
                         $images_to_add[] = $image;
                     }
                 }
             }
             //sdi($images_to_add);
             if (!empty($images_to_add)) {
                 $result = CImage::create($images_to_add);
                 if (!$result) {
                     throw new Exception(S_CANNOT_ADD_IMAGE);
                 }
             }
             //sdi($images_to_update);
             if (!empty($images_to_update)) {
                 $result = CImage::update($images_to_update);
                 if (!$result) {
                     throw new Exception(S_CANNOT_UPDATE_IMAGE);
                 }
             }
         }
         $importMaps = $importMaps['zabbix_export']['sysmaps'];
         $sysmaps = array();
         foreach ($importMaps as $mnum => &$sysmap) {
             unset($sysmap['sysmapid']);
             $exists = CMap::exists(array('name' => $sysmap['name']));
             if ($exists && isset($rules['maps']['exist'])) {
                 $db_maps = CMap::getObjects(array('name' => $sysmap['name']));
                 if (empty($db_maps)) {
                     throw new Exception(S_NO_PERMISSIONS_FOR_MAP . ' [' . $sysmap['name'] . '] import');
                 }
                 $db_map = reset($db_maps);
                 $sysmap['sysmapid'] = $db_map['sysmapid'];
             } else {
                 if ($exists || !isset($rules['maps']['missed'])) {
                     info('Map [' . $sysmap['name'] . '] skipped - user rule');
                     unset($importMaps[$mnum]);
                     continue;
                     // break if not update exist
                 }
             }
             if (isset($sysmap['backgroundid'])) {
                 $image = getImageByIdent($sysmap['backgroundid']);
                 if (!$image) {
                     error(S_CANNOT_FIND_BACKGROUND_IMAGE . ' "' . $sysmap['backgroundid']['name'] . '" ' . S_USED_IN_EXPORTED_MAP_SMALL . ' "' . $sysmap['name'] . '"');
                     $sysmap['backgroundid'] = 0;
                 } else {
                     $sysmap['backgroundid'] = $image['imageid'];
                 }
             } else {
                 $sysmap['backgroundid'] = 0;
             }
             if (!isset($sysmap['selements'])) {
                 $sysmap['selements'] = array();
             }
             if (!isset($sysmap['links'])) {
                 $sysmap['links'] = array();
             }
             foreach ($sysmap['selements'] as $snum => &$selement) {
                 $nodeCaption = isset($selement['elementid']['node']) ? $selement['elementid']['node'] . ':' : '';
                 if (!isset($selement['elementid'])) {
                     $selement['elementid'] = 0;
                 }
                 switch ($selement['elementtype']) {
                     case SYSMAP_ELEMENT_TYPE_MAP:
                         $db_sysmaps = CMap::getObjects($selement['elementid']);
                         if (empty($db_sysmaps)) {
                             $error = S_CANNOT_FIND_MAP . ' "' . $nodeCaption . $selement['elementid']['name'] . '" ' . S_USED_IN_EXPORTED_MAP_SMALL . ' "' . $sysmap['name'] . '"';
                             throw new Exception($error);
                         }
                         $tmp = reset($db_sysmaps);
                         $selement['elementid'] = $tmp['sysmapid'];
                         break;
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:export.inc.php


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