3 commits - plugins/kolab_config plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed Jun 6 10:25:04 CEST 2012
plugins/kolab_config/kolab_config.php | 6 -
plugins/libkolab/lib/kolab_format.php | 4
plugins/libkolab/lib/kolab_format_configuration.php | 82 +++++++++++++++-----
3 files changed, 67 insertions(+), 25 deletions(-)
New commits:
commit 435b94f8f61f153eabcf0385a42ad932f12b0bfc
Merge: 0bd829a 3f3cf6b
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jun 6 10:24:42 2012 +0200
Merge branch 'master' of ssh://git.kolabsys.com/git/roundcube
commit 0bd829aa6f9ba4948045a1f7ef69c1146c4d5bac
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jun 6 10:24:28 2012 +0200
Finish reading/writing of Dictionary configuration objects
diff --git a/plugins/kolab_config/kolab_config.php b/plugins/kolab_config/kolab_config.php
index 3433056..9135467 100644
--- a/plugins/kolab_config/kolab_config.php
+++ b/plugins/kolab_config/kolab_config.php
@@ -102,7 +102,7 @@ class kolab_config extends rcube_plugin
$lang = $args['language'];
$dict = $this->read_dictionary($lang, true);
-
+console($lang, $dict);
$dict['type'] = 'dictionary';
$dict['language'] = $args['language'];
$dict['e'] = $args['dictionary'];
@@ -113,7 +113,7 @@ class kolab_config extends rcube_plugin
}
else {
// Update the object
- // $this->default->save($dict);
+ $this->default->save($dict, 'configuration.dictionary', $dict['uid']);
}
$args['abort'] = true;
@@ -160,7 +160,7 @@ class kolab_config extends rcube_plugin
if (isset($this->dicts[$lang]))
return $this->dicts[$lang];
- $query = array(array('type','=','configuration.dictionary'), array('tags','=',' '.$lang.' '));
+ $query = array(array('type','=','configuration.dictionary'), array('tags','=',$lang));
foreach ($this->folders as $folder) {
// we only want to read from default folder
diff --git a/plugins/libkolab/lib/kolab_format_configuration.php b/plugins/libkolab/lib/kolab_format_configuration.php
index 5ef0fa7..974fc45 100644
--- a/plugins/libkolab/lib/kolab_format_configuration.php
+++ b/plugins/libkolab/lib/kolab_format_configuration.php
@@ -29,6 +29,11 @@ class kolab_format_configuration extends kolab_format
protected $read_func = 'kolabformat::readConfiguration';
protected $write_func = 'kolabformat::writeConfiguration';
+ private $type_map = array(
+ 'dictionary' => Configuration::TypeDictionary,
+ 'category' => Configuration::TypeCategoryColor,
+ );
+
function __construct($xmldata = null)
{
@@ -45,11 +50,31 @@ class kolab_format_configuration extends kolab_format
{
$this->init();
+ // read type-specific properties
+ switch ($object['type']) {
+ case 'dictionary':
+ $dict = new Dictionary($object['language']);
+ $dict->setEntries(self::array2vector($object['e']));
+ $this->obj = new Configuration($dict);
+ break;
+
+ case 'category':
+ // TODO: implement this
+ $categories = new vectorcategorycolor;
+ $this->obj = new Configuration($categories);
+ break;
+ default:
+ return false;
+ }
+
// set some automatic values if missing
-# if (!empty($object['uid']))
-# $this->obj->setUid($object['uid']);
+ if (!empty($object['uid']))
+ $this->obj->setUid($object['uid']);
+ if (!empty($object['created']))
+ $this->obj->setCreated(self::get_datetime($object['created']));
- // TODO: set object propeties
+ // adjust content-type string
+ $this->CTYPE = 'application/x-vnd.kolab.configuration.' . $object['type'];
// cache this data
$this->data = $object;
@@ -61,20 +86,7 @@ class kolab_format_configuration extends kolab_format
*/
public function is_valid()
{
- return $this->data || (is_object($this->obj)/* && $this->obj->isValid()*/);
- }
-
- /**
- * Load data from old Kolab2 format
- */
- public function fromkolab2($record)
- {
- $object = array(
- 'uid' => $record['uid'],
- 'changed' => $record['last-modification-date'],
- );
-
- $this->data = $object + $record;
+ return $this->data || (is_object($this->obj) && $this->obj->isValid());
}
/**
@@ -89,21 +101,51 @@ class kolab_format_configuration extends kolab_format
return $this->data;
$this->init();
+ $type_map = array_flip($this->type_map);
// read object properties
$object = array(
-# 'uid' => $this->obj->uid(),
-# 'changed' => $this->obj->lastModified(),
+ 'uid' => $this->obj->uid(),
+ 'created' => self::php_datetime($this->obj->created()),
+ 'changed' => self::php_datetime($this->obj->lastModified()),
+ 'type' => $type_map[$this->obj->type()],
);
+ // read type-specific properties
+ switch ($object['type']) {
+ case 'dictionary':
+ $dict = $this->obj->dictionary();
+ $object['language'] = $dict->language();
+ $object['e'] = self::vector2array($dict->entries());
+ break;
- // TODO: read object properties
+ case 'category':
+ // TODO: implement this
+ break;
+ }
+
+ // adjust content-type string
+ if ($object['type'])
+ $this->CTYPE = 'application/x-vnd.kolab.configuration.' . $object['type'];
$this->data = $object;
return $this->data;
}
/**
+ * Load data from old Kolab2 format
+ */
+ public function fromkolab2($record)
+ {
+ $object = array(
+ 'uid' => $record['uid'],
+ 'changed' => $record['last-modification-date'],
+ );
+
+ $this->data = $object + $record;
+ }
+
+ /**
* Callback for kolab_storage_cache to get object specific tags to cache
*
* @return array List of tags to save in cache
commit ad59203f274940e9263a6bdd86c0cb5abe914b2a
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Jun 6 10:22:51 2012 +0200
Fix libkolabxml error handling
diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index b6215e0..d7f60b5 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -173,10 +173,10 @@ abstract class kolab_format
{
$ret = $log = false;
switch (kolabformat::error()) {
- case kolabformat.NoError:
+ case kolabformat::NoError:
$ret = false;
break;
- case kolabformat.Warning:
+ case kolabformat::Warning:
$ret = false;
$log = "Warning";
break;
More information about the commits
mailing list