Merge branch 'dev/kolab3'

This commit is contained in:
Jeroen van Meeuwen (Kolab Systems) 2012-05-23 10:25:24 +01:00
commit de40ba8950
6 changed files with 51 additions and 93 deletions

View file

@ -1149,6 +1149,7 @@ class calendar extends rcube_plugin
return array(
'start' => gmdate('c', $this->fromGMT($event['start'])), // client treats date strings as they were in users's timezone
'end' => gmdate('c', $this->fromGMT($event['end'])), // so shift timestamps to users's timezone and render a date string
'title' => strval($event['title']),
'description' => strval($event['description']),
'location' => strval($event['location']),
'className' => ($addcss ? 'fc-event-cal-'.asciiwords($event['calendar'], true).' ' : '') . 'fc-event-cat-' . asciiwords(strtolower($event['categories']), true),

View file

@ -29,6 +29,11 @@ abstract class kolab_format
{
public static $timezone;
public /*abstract*/ $CTYPE;
protected /*abstract*/ $read_func;
protected /*abstract*/ $write_func;
protected $obj;
protected $data;
protected $xmldata;
@ -232,7 +237,29 @@ abstract class kolab_format
*
* @param string XML data
*/
abstract public function load($xml);
public function load($xml)
{
$this->obj = call_user_func($this->read_func, $xml, false);
$this->loaded = !$this->format_errors();
}
/**
* Write object data to XML format
*
* @return string XML data
*/
public function write()
{
$this->init();
$this->xmldata = call_user_func($this->write_func, $this->obj);
if (!$this->format_errors())
$this->update_uid();
else
$this->xmldata = null;
return $this->xmldata;
}
/**
* Set properties to the kolabformat object
@ -246,13 +273,6 @@ abstract class kolab_format
*/
abstract public function is_valid();
/**
* Write object data to XML format
*
* @return string XML data
*/
abstract public function write();
/**
* Convert the Kolab object into a hash array data structure
*

View file

@ -26,6 +26,9 @@ class kolab_format_contact extends kolab_format
{
public $CTYPE = 'application/vcard+xml';
protected $read_func = 'kolabformat::readContact';
protected $write_func = 'kolabformat::writeContact';
public static $fulltext_cols = array('name', 'firstname', 'surname', 'middlename', 'email');
public $phonetypes = array(
@ -113,35 +116,6 @@ class kolab_format_contact extends kolab_format
$this->phonetypes['workfax'] |= Telephone::Work;
}
/**
* Load Contact object data from the given XML block
*
* @param string XML data
*/
public function load($xml)
{
$this->obj = kolabformat::readContact($xml, false);
$this->loaded = true;
}
/**
* Write Contact object data to XML format
*
* @return string XML data
*/
public function write()
{
$this->init();
$this->xmldata = kolabformat::writeContact($this->obj);
if (!parent::format_errors())
parent::update_uid();
else
$this->xmldata = null;
return $this->xmldata;
}
/**
* Set contact properties to the kolabformat object
*

View file

@ -26,6 +26,10 @@ class kolab_format_distributionlist extends kolab_format
{
public $CTYPE = 'application/vcard+xml';
protected $read_func = 'kolabformat::readDistlist';
protected $write_func = 'kolabformat::writeDistlist';
function __construct($xmldata = null)
{
$this->obj = new DistList;
@ -33,34 +37,10 @@ class kolab_format_distributionlist extends kolab_format
}
/**
* Load Kolab object data from the given XML block
* Set properties to the kolabformat object
*
* @param string XML data
* @param array Object data as hash array
*/
public function load($xml)
{
$this->obj = kolabformat::readDistlist($xml, false);
$this->loaded = true;
}
/**
* Write object data to XML format
*
* @return string XML data
*/
public function write()
{
$this->init();
$this->xmldata = kolabformat::writeDistlist($this->obj);
if (!parent::format_errors())
parent::update_uid();
else
$this->xmldata = null;
return $this->xmldata;
}
public function set(&$object)
{
$this->init();
@ -137,7 +117,7 @@ class kolab_format_distributionlist extends kolab_format
// read object properties
$object = array(
'uid' => $this->obj->uid(),
# 'changed' => $this->obj->lastModified(),
'changed' => $this->obj->lastModified(),
'name' => $this->obj->name(),
'member' => array(),
);

View file

@ -26,6 +26,9 @@ class kolab_format_event extends kolab_format
{
public $CTYPE = 'application/calendar+xml';
protected $read_func = 'kolabformat::readEvent';
protected $write_func = 'kolabformat::writeEvent';
public static $fulltext_cols = array('title', 'description', 'location', 'attendees:name', 'attendees:email');
private $sensitivity_map = array(
@ -99,35 +102,6 @@ class kolab_format_event extends kolab_format
$this->xmldata = $xmldata;
}
/**
* Load Contact object data from the given XML block
*
* @param string XML data
*/
public function load($xml)
{
$this->obj = kolabformat::readEvent($xml, false);
$this->loaded = true;
}
/**
* Write Contact object data to XML format
*
* @return string XML data
*/
public function write()
{
$this->init();
$this->xmldata = kolabformat::writeEvent($this->obj);
if (!parent::format_errors())
parent::update_uid();
else
$this->xmldata = null;
return $this->xmldata;
}
/**
* Set contact properties to the kolabformat object
*

View file

@ -506,6 +506,12 @@ class kolab_storage_cache
'lock'
));
// abort if database is not set-up
if ($this->db->is_error()) {
$this->ready = false;
return;
}
// create lock record if not exists
if (!$sql_arr) {
$this->db->query(
@ -538,6 +544,9 @@ class kolab_storage_cache
*/
private function _sync_unlock()
{
if (!$this->ready)
return;
$this->db->query(
"UPDATE kolab_cache SET msguid=0, created='' ".
"WHERE resource=? AND type=?",