/** * Export configuration data. * * $params structure: * array( * 'options' => array( * 'hosts' => array with host ids, * 'templates' => array with templateids, * ... * ), * 'format' => 'json'|'xml' * ) * * @param array $params * * @return string */ public function export(array $params) { $export = new CConfigurationExport($params['options']); $export->setBuilder(new CConfigurationExportBuilder()); $writer = CExportWriterFactory::getWriter($params['format']); $writer->formatOutput(false); $export->setWriter($writer); return $export->export(); }
} else { $screens = API::Screen()->get($options); } if (empty($screens)) { access_deny(); } } /* * Export */ if ($isExportData) { $screens = get_request('screens', array()); $export = new CConfigurationExport(array('screens' => $screens)); $export->setBuilder(new CConfigurationExportBuilder()); $export->setWriter(CExportWriterFactory::getWriter(CExportWriterFactory::XML)); $exportData = $export->export(); if (!no_errors()) { show_messages(); } else { print $exportData; } exit; } /* * Actions */ if (isset($_REQUEST['clone']) && isset($_REQUEST['screenid'])) { unset($_REQUEST['screenid']); $_REQUEST['form'] = 'clone'; } elseif (isset($_REQUEST['save'])) { if (isset($_REQUEST['screenid'])) {
* Permissions */ if (hasRequest('valuemapid')) { $valuemaps = API::ValueMap()->get(['output' => ['valuemapid'], 'valuemapids' => [getRequest('valuemapid')]]); if (!$valuemaps) { access_deny(); } } /* * Export */ if ($export) { $export = new CConfigurationExport(['valueMaps' => getRequest('valuemapids')]); $export->setBuilder(new CConfigurationExportBuilder()); $export->setWriter(CExportWriterFactory::getWriter(CExportWriterFactory::XML)); $export_data = $export->export(); if (hasErrorMesssages()) { show_messages(); } else { print $export_data; } exit; } /* * Actions */ if (hasRequest('add') || hasRequest('update')) { $valuemap = ['name' => getRequest('name'), 'mappings' => getRequest('mappings')]; if (hasRequest('update')) { $valuemap['valuemapid'] = getRequest('valuemapid'); $result = (bool) API::ValueMap()->update($valuemap);