server profiles import
This commit is contained in:
parent
ea72ab63a9
commit
8d50dd59b0
|
@ -1 +1 @@
|
|||
7.2.RC1
|
||||
7.2.DEV
|
||||
|
|
|
@ -667,6 +667,17 @@ class LAMConfig {
|
|||
$data['moduleSettings'] = $this->moduleSettings;
|
||||
$data['toolSettings'] = $this->toolSettings;
|
||||
$data['jobSettings'] = $this->jobSettings;
|
||||
if ($this->jobsDatabase === 'SQLite') {
|
||||
$dbFileName = __DIR__ . '/../config/' . $this->getName() . '.sqlite';
|
||||
if (is_file($dbFileName) && is_readable($dbFileName)) {
|
||||
$file = @fopen($dbFileName, "r");
|
||||
if ($file) {
|
||||
$dbData = fread($file, 100000000);
|
||||
fclose($file);
|
||||
$data['jobSQLite'] = base64_encode($dbData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -699,6 +710,14 @@ class LAMConfig {
|
|||
$this->toolSettings = $toolSettingsData;
|
||||
$jobSettingsData = !empty($data['jobSettings']) && is_array($data['jobSettings']) ? $data['jobSettings'] : array();
|
||||
$this->jobSettings = $jobSettingsData;
|
||||
if (!empty($data['jobSQLite'])) {
|
||||
$dbFileName = __DIR__ . '/../config/' . $this->getName() . '.sqlite';
|
||||
$file = @fopen($dbFileName, "wb");
|
||||
if ($file) {
|
||||
fputs($file, base64_decode($data['jobSQLite']));
|
||||
fclose($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -811,6 +830,10 @@ class LAMConfig {
|
|||
/** Saves preferences to config file */
|
||||
public function save() {
|
||||
$conffile = $this->getPath();
|
||||
if (!file_exists($conffile)) {
|
||||
$newFile = fopen($conffile, 'wb');
|
||||
fclose($newFile);
|
||||
}
|
||||
if (is_file($conffile) && is_readable($conffile)) {
|
||||
$file = fopen($conffile, "r");
|
||||
$file_array = array();
|
||||
|
|
|
@ -169,6 +169,9 @@ class ConfigDataImporter {
|
|||
case 'certificates':
|
||||
$this->importCertificates($step->getValue());
|
||||
break;
|
||||
case 'serverProfiles':
|
||||
$this->importServerProfiles($step);
|
||||
break;
|
||||
default:
|
||||
logNewMessage(LOG_WARNING, 'Unknown import type: ' . $key);
|
||||
}
|
||||
|
@ -198,6 +201,25 @@ class ConfigDataImporter {
|
|||
$cfgMain->importCertificates($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports the server profiles.
|
||||
*
|
||||
* @param ImporterStep $step step
|
||||
* @throws LAMException error during import
|
||||
*/
|
||||
private function importServerProfiles($step) {
|
||||
foreach ($step->getSubSteps() as $profileStep) {
|
||||
if (!$profileStep->isActive()) {
|
||||
continue;
|
||||
}
|
||||
$data = $profileStep->getValue();
|
||||
$profileName = str_replace('serverProfile_', '', $profileStep->getKey());
|
||||
$serverProfile = new LAMConfig($profileName);
|
||||
$serverProfile->importData($data);
|
||||
$serverProfile->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,10 +240,10 @@ class ImporterStep {
|
|||
* @param string $key key
|
||||
* @param array $value value
|
||||
*/
|
||||
public function __construct($label, $key, &$value) {
|
||||
public function __construct($label, $key, $value) {
|
||||
$this->label = $label;
|
||||
$this->key = $key;
|
||||
$this->value = &$value;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -251,6 +251,9 @@ printHeaderContents(_("Import and export configuration"), '../..');
|
|||
$importSteps = $importer->getPossibleImportSteps($data);
|
||||
foreach ($importSteps as $importStep) {
|
||||
$importStep->setActive(isset($_POST['step_' . $importStep->getKey()]));
|
||||
foreach ($importStep->getSubSteps() as $subStep) {
|
||||
$subStep->setActive(isset($_POST['step_' . $subStep->getKey()]));
|
||||
}
|
||||
}
|
||||
$importer->runImport($importSteps);
|
||||
unlink($_SESSION['configImportFile']);
|
||||
|
|
Loading…
Reference in New Issue