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 */
|
||||
|
||||
$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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue