Add support for configuration./file_driver objects (#3775)
This commit is contained in:
parent
232b458be4
commit
6c8d7d4000
2 changed files with 35 additions and 5 deletions
|
@ -174,7 +174,7 @@ abstract class kolab_format
|
||||||
if (!self::supports($version))
|
if (!self::supports($version))
|
||||||
return PEAR::raiseError("No support for Kolab format version " . $version);
|
return PEAR::raiseError("No support for Kolab format version " . $version);
|
||||||
|
|
||||||
$type = preg_replace('/configuration\.[a-z.]+$/', 'configuration', $type);
|
$type = preg_replace('/configuration\.[a-z._]+$/', 'configuration', $type);
|
||||||
$suffix = preg_replace('/[^a-z]+/', '', $type);
|
$suffix = preg_replace('/[^a-z]+/', '', $type);
|
||||||
$classname = 'kolab_format_' . $suffix;
|
$classname = 'kolab_format_' . $suffix;
|
||||||
if (class_exists($classname))
|
if (class_exists($classname))
|
||||||
|
|
|
@ -32,12 +32,14 @@ class kolab_format_configuration extends kolab_format
|
||||||
protected $write_func = 'writeConfiguration';
|
protected $write_func = 'writeConfiguration';
|
||||||
|
|
||||||
private $type_map = array(
|
private $type_map = array(
|
||||||
'category' => Configuration::TypeCategoryColor,
|
'category' => Configuration::TypeCategoryColor,
|
||||||
'dictionary' => Configuration::TypeDictionary,
|
'dictionary' => Configuration::TypeDictionary,
|
||||||
'relation' => Configuration::TypeRelation,
|
'file_driver' => Configuration::TypeFileDriver,
|
||||||
'snippet' => Configuration::TypeSnippet,
|
'relation' => Configuration::TypeRelation,
|
||||||
|
'snippet' => Configuration::TypeSnippet,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private $driver_settings_fields = array('host', 'port', 'username', 'password');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set properties to the kolabformat object
|
* Set properties to the kolabformat object
|
||||||
|
@ -63,6 +65,21 @@ class kolab_format_configuration extends kolab_format
|
||||||
$this->obj = new Configuration($categories);
|
$this->obj = new Configuration($categories);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'file_driver':
|
||||||
|
$driver = new FileDriver($object['driver'], $object['title']);
|
||||||
|
|
||||||
|
$driver->setEnabled((bool) $object['enabled']);
|
||||||
|
|
||||||
|
foreach ($this->driver_settings_fields as $field) {
|
||||||
|
$value = $object[$field];
|
||||||
|
if ($value !== null) {
|
||||||
|
$driver->{'set' . ucfirst($field)}($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->obj = new Configuration($driver);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'relation':
|
case 'relation':
|
||||||
$relation = new Relation(strval($object['name']), strval($object['category']));
|
$relation = new Relation(strval($object['name']), strval($object['category']));
|
||||||
|
|
||||||
|
@ -157,6 +174,19 @@ class kolab_format_configuration extends kolab_format
|
||||||
// TODO: implement this
|
// TODO: implement this
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'file_driver':
|
||||||
|
$driver = $this->obj->file_driver();
|
||||||
|
|
||||||
|
$object['driver'] = $driver->driver();
|
||||||
|
$object['title'] = $driver->title();
|
||||||
|
$object['enabled'] = $driver->enabled();
|
||||||
|
|
||||||
|
foreach ($this->driver_settings_fields as $field) {
|
||||||
|
$object[$field] = $driver->{$field}();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 'relation':
|
case 'relation':
|
||||||
$relation = $this->obj->relation();
|
$relation = $this->obj->relation();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue