Fix kolab_format_* classes to read v2 format; perpare kolab_storage to write out v2 format
This commit is contained in:
parent
dd2bf15adf
commit
d98e8787c6
11 changed files with 32 additions and 19 deletions
|
@ -2,6 +2,7 @@
|
||||||
/* Configuration for libkolab */
|
/* Configuration for libkolab */
|
||||||
|
|
||||||
$rcmail_config['kolab_cache'] = true;
|
$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_freebusy_server'] = 'https://' . $_SESSION['imap_host'] . '/freebusy';
|
||||||
$rcmail_config['kolab_ssl_verify_peer'] = true;
|
$rcmail_config['kolab_ssl_verify_peer'] = true;
|
||||||
|
|
|
@ -30,6 +30,7 @@ abstract class kolab_format
|
||||||
public static $timezone;
|
public static $timezone;
|
||||||
|
|
||||||
public /*abstract*/ $CTYPE;
|
public /*abstract*/ $CTYPE;
|
||||||
|
public /*abstract*/ $CTYPEv2;
|
||||||
|
|
||||||
protected /*abstract*/ $objclass;
|
protected /*abstract*/ $objclass;
|
||||||
protected /*abstract*/ $read_func;
|
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
|
* Factory method to instantiate a kolab_format object of the given type and version
|
||||||
*
|
*
|
||||||
* @param string Object type to instantiate
|
* @param string Object type to instantiate
|
||||||
* @param string Cached xml data to initialize with
|
|
||||||
* @param float Format version
|
* @param float Format version
|
||||||
|
* @param string Cached xml data to initialize with
|
||||||
* @return object kolab_format
|
* @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))
|
if (!isset(self::$timezone))
|
||||||
self::$timezone = new DateTimeZone('UTC');
|
self::$timezone = new DateTimeZone('UTC');
|
||||||
|
@ -249,7 +250,7 @@ abstract class kolab_format
|
||||||
'type' => 'php',
|
'type' => 'php',
|
||||||
'file' => __FILE__,
|
'file' => __FILE__,
|
||||||
'line' => __LINE__,
|
'line' => __LINE__,
|
||||||
'message' => "kolabformat write $log: " . kolabformat::errorMessage(),
|
'message' => "kolabformat $log: " . kolabformat::errorMessage(),
|
||||||
), true);
|
), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +334,7 @@ abstract class kolab_format
|
||||||
public function load($xml)
|
public function load($xml)
|
||||||
{
|
{
|
||||||
$read_func = $this->libfunc($this->read_func);
|
$read_func = $this->libfunc($this->read_func);
|
||||||
|
|
||||||
if (is_array($read_func))
|
if (is_array($read_func))
|
||||||
$r = call_user_func($read_func, $xml, $this->libversion());
|
$r = call_user_func($read_func, $xml, $this->libversion());
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,10 +25,11 @@
|
||||||
class kolab_format_configuration extends kolab_format
|
class kolab_format_configuration extends kolab_format
|
||||||
{
|
{
|
||||||
public $CTYPE = 'application/x-vnd.kolab.configuration';
|
public $CTYPE = 'application/x-vnd.kolab.configuration';
|
||||||
|
public $CTYPEv2 = 'application/x-vnd.kolab.configuration';
|
||||||
|
|
||||||
protected $objclass = 'Configuration';
|
protected $objclass = 'Configuration';
|
||||||
protected $read_func = 'kolabformat::readConfiguration';
|
protected $read_func = 'readConfiguration';
|
||||||
protected $write_func = 'kolabformat::writeConfiguration';
|
protected $write_func = 'writeConfiguration';
|
||||||
|
|
||||||
private $type_map = array(
|
private $type_map = array(
|
||||||
'dictionary' => Configuration::TypeDictionary,
|
'dictionary' => Configuration::TypeDictionary,
|
||||||
|
@ -69,7 +70,7 @@ class kolab_format_configuration extends kolab_format
|
||||||
$this->obj->setCreated(self::get_datetime($object['created']));
|
$this->obj->setCreated(self::get_datetime($object['created']));
|
||||||
|
|
||||||
// adjust content-type string
|
// 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
|
// cache this data
|
||||||
$this->data = $object;
|
$this->data = $object;
|
||||||
|
@ -121,7 +122,7 @@ class kolab_format_configuration extends kolab_format
|
||||||
|
|
||||||
// adjust content-type string
|
// adjust content-type string
|
||||||
if ($object['type'])
|
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;
|
$this->data = $object;
|
||||||
return $this->data;
|
return $this->data;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
class kolab_format_contact extends kolab_format
|
class kolab_format_contact extends kolab_format
|
||||||
{
|
{
|
||||||
public $CTYPE = 'application/vcard+xml';
|
public $CTYPE = 'application/vcard+xml';
|
||||||
|
public $CTYPEv2 = 'application/x-vnd.kolab.contact';
|
||||||
|
|
||||||
protected $objclass = 'Contact';
|
protected $objclass = 'Contact';
|
||||||
protected $read_func = 'readContact';
|
protected $read_func = 'readContact';
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
class kolab_format_distributionlist extends kolab_format
|
class kolab_format_distributionlist extends kolab_format
|
||||||
{
|
{
|
||||||
public $CTYPE = 'application/vcard+xml';
|
public $CTYPE = 'application/vcard+xml';
|
||||||
|
public $CTYPEv2 = 'application/x-vnd.kolab.distribution-list';
|
||||||
|
|
||||||
protected $objclass = 'DistList';
|
protected $objclass = 'DistList';
|
||||||
protected $read_func = 'readDistlist';
|
protected $read_func = 'readDistlist';
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
class kolab_format_event extends kolab_format_xcal
|
class kolab_format_event extends kolab_format_xcal
|
||||||
{
|
{
|
||||||
|
public $CTYPEv2 = 'application/x-vnd.kolab.event';
|
||||||
|
|
||||||
protected $objclass = 'Event';
|
protected $objclass = 'Event';
|
||||||
protected $read_func = 'readEvent';
|
protected $read_func = 'readEvent';
|
||||||
protected $write_func = 'writeEvent';
|
protected $write_func = 'writeEvent';
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
class kolab_format_journal extends kolab_format
|
class kolab_format_journal extends kolab_format
|
||||||
{
|
{
|
||||||
public $CTYPE = 'application/calendar+xml';
|
public $CTYPE = 'application/calendar+xml';
|
||||||
|
public $CTYPEv2 = 'application/x-vnd.kolab.journal';
|
||||||
|
|
||||||
protected $objclass = 'Journal';
|
protected $objclass = 'Journal';
|
||||||
protected $read_func = 'readJournal';
|
protected $read_func = 'readJournal';
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
class kolab_format_note extends kolab_format
|
class kolab_format_note extends kolab_format
|
||||||
{
|
{
|
||||||
public $CTYPE = 'application/x-vnd.kolab.note';
|
public $CTYPE = 'application/x-vnd.kolab.note';
|
||||||
|
public $CTYPEv2 = 'application/x-vnd.kolab.note';
|
||||||
|
|
||||||
protected $objclass = 'Note';
|
protected $objclass = 'Note';
|
||||||
protected $read_func = 'readNote';
|
protected $read_func = 'readNote';
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
class kolab_format_task extends kolab_format_xcal
|
class kolab_format_task extends kolab_format_xcal
|
||||||
{
|
{
|
||||||
|
public $CTYPEv2 = 'application/x-vnd.kolab.task';
|
||||||
|
|
||||||
protected $objclass = 'Todo';
|
protected $objclass = 'Todo';
|
||||||
protected $read_func = 'readTodo';
|
protected $read_func = 'readTodo';
|
||||||
protected $write_func = 'writeTodo';
|
protected $write_func = 'writeTodo';
|
||||||
|
|
|
@ -582,7 +582,7 @@ class kolab_storage_cache
|
||||||
$object['_type'] = $sql_arr['type'];
|
$object['_type'] = $sql_arr['type'];
|
||||||
$object['_msguid'] = $sql_arr['msguid'];
|
$object['_msguid'] = $sql_arr['msguid'];
|
||||||
$object['_mailbox'] = $this->folder->name;
|
$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;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -719,8 +719,9 @@ class kolab_storage_folder
|
||||||
. 'To view this object you will need an email client that understands the Kolab Groupware format. '
|
. '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");
|
. "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
|
$mime->addAttachment($xml, // file
|
||||||
$format->CTYPE, // content-type
|
$ctype, // content-type
|
||||||
'kolab.xml', // filename
|
'kolab.xml', // filename
|
||||||
false, // is_file
|
false, // is_file
|
||||||
'8bit', // encoding
|
'8bit', // encoding
|
||||||
|
|
Loading…
Add table
Reference in a new issue