summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2012-11-06 18:03:12 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2012-11-06 18:03:12 (GMT)
commitd98e8787c6b74bf26e9eec8df807435d455af990 (patch)
treea69beb0e31424ea430fd858907af9666f4a89295
parentdd2bf15adf7e39612df9548095ac1ed8cafb33a1 (diff)
downloadroundcubemail-plugins-kolab-d98e8787c6b74bf26e9eec8df807435d455af990.tar.gz
Fix kolab_format_* classes to read v2 format; perpare kolab_storage to write out v2 format
-rw-r--r--plugins/libkolab/config.inc.php.dist1
-rw-r--r--plugins/libkolab/lib/kolab_format.php28
-rw-r--r--plugins/libkolab/lib/kolab_format_configuration.php9
-rw-r--r--plugins/libkolab/lib/kolab_format_contact.php1
-rw-r--r--plugins/libkolab/lib/kolab_format_distributionlist.php1
-rw-r--r--plugins/libkolab/lib/kolab_format_event.php2
-rw-r--r--plugins/libkolab/lib/kolab_format_journal.php1
-rw-r--r--plugins/libkolab/lib/kolab_format_note.php1
-rw-r--r--plugins/libkolab/lib/kolab_format_task.php2
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache.php2
-rw-r--r--plugins/libkolab/lib/kolab_storage_folder.php3
11 files changed, 32 insertions, 19 deletions
diff --git a/plugins/libkolab/config.inc.php.dist b/plugins/libkolab/config.inc.php.dist
index fedf793..cb44652 100644
--- a/plugins/libkolab/config.inc.php.dist
+++ b/plugins/libkolab/config.inc.php.dist
@@ -2,6 +2,7 @@
/* Configuration for libkolab */
$rcmail_config['kolab_cache'] = true;
+ $rcmail_config['kolab_format_version'] = 3.0;
$rcmail_config['kolab_freebusy_server'] = 'https://' . $_SESSION['imap_host'] . '/freebusy';
$rcmail_config['kolab_ssl_verify_peer'] = true;
diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index 08dc962..c54558e 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -30,6 +30,7 @@ abstract class kolab_format
public static $timezone;
public /*abstract*/ $CTYPE;
+ public /*abstract*/ $CTYPEv2;
protected /*abstract*/ $objclass;
protected /*abstract*/ $read_func;
@@ -49,11 +50,11 @@ abstract class kolab_format
* Factory method to instantiate a kolab_format object of the given type and version
*
* @param string Object type to instantiate
- * @param string Cached xml data to initialize with
* @param float Format version
+ * @param string Cached xml data to initialize with
* @return object kolab_format
*/
- public static function factory($type, $xmldata = null, $version = 3.0)
+ public static function factory($type, $version = 3.0, $xmldata = null)
{
if (!isset(self::$timezone))
self::$timezone = new DateTimeZone('UTC');
@@ -249,7 +250,7 @@ abstract class kolab_format
'type' => 'php',
'file' => __FILE__,
'line' => __LINE__,
- 'message' => "kolabformat write $log: " . kolabformat::errorMessage(),
+ 'message' => "kolabformat $log: " . kolabformat::errorMessage(),
), true);
}
@@ -332,11 +333,12 @@ abstract class kolab_format
*/
public function load($xml)
{
- $read_func = $this->libfunc($this->read_func);
- if (is_array($read_func))
- $r = call_user_func($read_func, $xml, $this->libversion());
- else
- $r = call_user_func($read_func, $xml, false);
+ $read_func = $this->libfunc($this->read_func);
+
+ if (is_array($read_func))
+ $r = call_user_func($read_func, $xml, $this->libversion());
+ else
+ $r = call_user_func($read_func, $xml, false);
if (is_resource($r))
$this->obj = new $this->objclass($r);
@@ -355,11 +357,11 @@ abstract class kolab_format
public function write($version = null)
{
$this->init();
- $write_func = $this->libfunc($this->write_func);
- if (is_array($write_func))
- $this->xmldata = call_user_func($write_func, $this->obj, $this->libversion($version), self::PRODUCT_ID);
- else
- $this->xmldata = call_user_func($write_func, $this->obj, self::PRODUCT_ID);
+ $write_func = $this->libfunc($this->write_func);
+ if (is_array($write_func))
+ $this->xmldata = call_user_func($write_func, $this->obj, $this->libversion($version), self::PRODUCT_ID);
+ else
+ $this->xmldata = call_user_func($write_func, $this->obj, self::PRODUCT_ID);
if (!$this->format_errors())
$this->update_uid();
diff --git a/plugins/libkolab/lib/kolab_format_configuration.php b/plugins/libkolab/lib/kolab_format_configuration.php
index 1bb919d..918928b 100644
--- a/plugins/libkolab/lib/kolab_format_configuration.php
+++ b/plugins/libkolab/lib/kolab_format_configuration.php
@@ -25,10 +25,11 @@
class kolab_format_configuration extends kolab_format
{
public $CTYPE = 'application/x-vnd.kolab.configuration';
+ public $CTYPEv2 = 'application/x-vnd.kolab.configuration';
protected $objclass = 'Configuration';
- protected $read_func = 'kolabformat::readConfiguration';
- protected $write_func = 'kolabformat::writeConfiguration';
+ protected $read_func = 'readConfiguration';
+ protected $write_func = 'writeConfiguration';
private $type_map = array(
'dictionary' => Configuration::TypeDictionary,
@@ -69,7 +70,7 @@ class kolab_format_configuration extends kolab_format
$this->obj->setCreated(self::get_datetime($object['created']));
// adjust content-type string
- $this->CTYPE = 'application/x-vnd.kolab.configuration.' . $object['type'];
+ $this->CTYPE = $this->CTYPEv2 = 'application/x-vnd.kolab.configuration.' . $object['type'];
// cache this data
$this->data = $object;
@@ -121,7 +122,7 @@ class kolab_format_configuration extends kolab_format
// adjust content-type string
if ($object['type'])
- $this->CTYPE = 'application/x-vnd.kolab.configuration.' . $object['type'];
+ $this->CTYPE = $this->CTYPEv2 = 'application/x-vnd.kolab.configuration.' . $object['type'];
$this->data = $object;
return $this->data;
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index bae5fa3..9dedcb1 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -25,6 +25,7 @@
class kolab_format_contact extends kolab_format
{
public $CTYPE = 'application/vcard+xml';
+ public $CTYPEv2 = 'application/x-vnd.kolab.contact';
protected $objclass = 'Contact';
protected $read_func = 'readContact';
diff --git a/plugins/libkolab/lib/kolab_format_distributionlist.php b/plugins/libkolab/lib/kolab_format_distributionlist.php
index 6def48f..ba54742 100644
--- a/plugins/libkolab/lib/kolab_format_distributionlist.php
+++ b/plugins/libkolab/lib/kolab_format_distributionlist.php
@@ -25,6 +25,7 @@
class kolab_format_distributionlist extends kolab_format
{
public $CTYPE = 'application/vcard+xml';
+ public $CTYPEv2 = 'application/x-vnd.kolab.distribution-list';
protected $objclass = 'DistList';
protected $read_func = 'readDistlist';
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index b2cb87b..838f37d 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -24,6 +24,8 @@
class kolab_format_event extends kolab_format_xcal
{
+ public $CTYPEv2 = 'application/x-vnd.kolab.event';
+
protected $objclass = 'Event';
protected $read_func = 'readEvent';
protected $write_func = 'writeEvent';
diff --git a/plugins/libkolab/lib/kolab_format_journal.php b/plugins/libkolab/lib/kolab_format_journal.php
index 0e1b474..9144ea2 100644
--- a/plugins/libkolab/lib/kolab_format_journal.php
+++ b/plugins/libkolab/lib/kolab_format_journal.php
@@ -25,6 +25,7 @@
class kolab_format_journal extends kolab_format
{
public $CTYPE = 'application/calendar+xml';
+ public $CTYPEv2 = 'application/x-vnd.kolab.journal';
protected $objclass = 'Journal';
protected $read_func = 'readJournal';
diff --git a/plugins/libkolab/lib/kolab_format_note.php b/plugins/libkolab/lib/kolab_format_note.php
index 482a3e8..48e963e 100644
--- a/plugins/libkolab/lib/kolab_format_note.php
+++ b/plugins/libkolab/lib/kolab_format_note.php
@@ -25,6 +25,7 @@
class kolab_format_note extends kolab_format
{
public $CTYPE = 'application/x-vnd.kolab.note';
+ public $CTYPEv2 = 'application/x-vnd.kolab.note';
protected $objclass = 'Note';
protected $read_func = 'readNote';
diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php
index 425f5e0..0bfac3d 100644
--- a/plugins/libkolab/lib/kolab_format_task.php
+++ b/plugins/libkolab/lib/kolab_format_task.php
@@ -24,6 +24,8 @@
class kolab_format_task extends kolab_format_xcal
{
+ public $CTYPEv2 = 'application/x-vnd.kolab.task';
+
protected $objclass = 'Todo';
protected $read_func = 'readTodo';
protected $write_func = 'writeTodo';
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index 866a795..a800e58 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -582,7 +582,7 @@ class kolab_storage_cache
$object['_type'] = $sql_arr['type'];
$object['_msguid'] = $sql_arr['msguid'];
$object['_mailbox'] = $this->folder->name;
- $object['_formatobj'] = kolab_format::factory($sql_arr['type'], $sql_arr['xml']);
+ $object['_formatobj'] = kolab_format::factory($sql_arr['type'], 3.0, $sql_arr['xml']);
return $object;
}
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index e92a6fa..54aed7a 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -719,8 +719,9 @@ class kolab_storage_folder
. 'To view this object you will need an email client that understands the Kolab Groupware format. '
. "For a list of such email clients please visit http://www.kolab.org/\n\n");
+ $ctype = kolab_storage::$version == 2.0 ? $format->CTYPEv2 : $format->CTYPE;
$mime->addAttachment($xml, // file
- $format->CTYPE, // content-type
+ $ctype, // content-type
'kolab.xml', // filename
false, // is_file
'8bit', // encoding