Merge branch 'master' of ssh://git.kolabsys.com/git/roundcube

This commit is contained in:
Thomas Bruederli 2012-06-13 10:36:53 +02:00
commit f678e8f16a
4 changed files with 19 additions and 5 deletions

View file

@ -39,6 +39,8 @@ abstract class kolab_format
protected $xmldata; protected $xmldata;
protected $loaded = false; protected $loaded = false;
const VERSION = '3.0';
/** /**
* Factory method to instantiate a kolab_format object of the given type * Factory method to instantiate a kolab_format object of the given type
* *

View file

@ -177,7 +177,7 @@ class kolab_format_contact extends kolab_format
$vurls = new vectorurl; $vurls = new vectorurl;
foreach ((array)$object['website'] as $url) { foreach ((array)$object['website'] as $url) {
$type = $url['type'] == 'blog' ? Url::Blog : Url::None; $type = $url['type'] == 'blog' ? Url::Blog : Url::NoType;
$vurls->push(new Url($url['url'], $type)); $vurls->push(new Url($url['url'], $type));
} }
$this->obj->setUrls($vurls); $this->obj->setUrls($vurls);

View file

@ -438,9 +438,20 @@ class kolab_storage_folder
return false; return false;
// check kolab format version // check kolab format version
list($xmltype, $subtype) = explode('.', $object_type); $mime_version = $headers->others['x-kolab-mime-version'];
if (strpos($xml, '<' . $xmltype) !== false && strpos($xml, 'xmlns=') === false) { if (empty($mime_version)) {
// old Kolab 2.0 format detected list($xmltype, $subtype) = explode('.', $object_type);
$xmlhead = substr($xml, 0, 512);
// detect old Kolab 2.0 format
if (strpos($xmlhead, '<' . $xmltype) !== false && strpos($xmlhead, 'xmlns=') === false)
$mime_version = 2.0;
else
$mime_version = 3.0; // assume 3.0
}
if ($mime_version <= 2.0) {
// read Kolab 2.0 format
$handler = class_exists('Horde_Kolab_Format') ? Horde_Kolab_Format::factory('XML', $xmltype, array('subtype' => $subtype)) : null; $handler = class_exists('Horde_Kolab_Format') ? Horde_Kolab_Format::factory('XML', $xmltype, array('subtype' => $subtype)) : null;
if (!is_object($handler) || is_a($handler, 'PEAR_Error')) { if (!is_object($handler) || is_a($handler, 'PEAR_Error')) {
return false; return false;
@ -652,6 +663,7 @@ class kolab_storage_folder
} }
$headers['Date'] = date('r'); $headers['Date'] = date('r');
$headers['X-Kolab-Type'] = self::KTYPE_PREFIX . $type; $headers['X-Kolab-Type'] = self::KTYPE_PREFIX . $type;
$headers['X-Kolab-Mime-Version'] = kolab_format::VERSION;
$headers['Subject'] = $object['uid']; $headers['Subject'] = $object['uid'];
// $headers['Message-ID'] = $rcmail->gen_message_id(); // $headers['Message-ID'] = $rcmail->gen_message_id();
$headers['User-Agent'] = $rcmail->config->get('useragent'); $headers['User-Agent'] = $rcmail->config->get('useragent');

View file

@ -67,7 +67,7 @@ class libkolab extends rcube_plugin
*/ */
function storage_init($p) function storage_init($p)
{ {
$p['fetch_headers'] = trim($p['fetch_headers'] .' X-KOLAB-TYPE'); $p['fetch_headers'] = trim($p['fetch_headers'] .' X-KOLAB-TYPE X-KOLAB-MIME-VERSION');
return $p; return $p;
} }