Esempio n. 1
0
 /**
  * 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();
 }
Esempio n. 2
0
    } 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'])) {
Esempio n. 3
0
 * 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);