3 commits - plugins/calendar plugins/libkolab
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Wed May 23 11:25:32 CEST 2012
plugins/calendar/calendar.php | 1
plugins/libkolab/lib/kolab_format.php | 36 +++++++++++++----
plugins/libkolab/lib/kolab_format_contact.php | 32 +--------------
plugins/libkolab/lib/kolab_format_distributionlist.php | 34 +++-------------
plugins/libkolab/lib/kolab_format_event.php | 32 +--------------
plugins/libkolab/lib/kolab_storage_cache.php | 9 ++++
6 files changed, 51 insertions(+), 93 deletions(-)
New commits:
commit de40ba89502755606619c1cfef015f4c105c77a6
Merge: 2cf2cbc b4dc760
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed May 23 10:25:24 2012 +0100
Merge branch 'dev/kolab3'
commit b4dc760d787e34d1ec0e5ebb5f84111134a81808
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed May 23 10:46:25 2012 +0200
Ensure title property is present as a string
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 83993ac..3ee3d7b 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -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),
commit 9da61e6d4bbbbced3ec946cd4987a6c1843b2e47
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Tue May 22 10:14:56 2012 +0200
Reduce code redundancy: implement load() and write() method in parent class kolab_format; do more error checking
diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index a7b1e48..b7ce057 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -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,26 +237,41 @@ 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();
+ }
/**
- * Set properties to the kolabformat object
+ * Write object data to XML format
*
- * @param array Object data as hash array
+ * @return string XML data
*/
- abstract public function set(&$object);
+ 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
*
+ * @param array Object data as hash array
*/
- abstract public function is_valid();
+ abstract public function set(&$object);
/**
- * Write object data to XML format
*
- * @return string XML data
*/
- abstract public function write();
+ abstract public function is_valid();
/**
* Convert the Kolab object into a hash array data structure
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index d6da235..d39b32e 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -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(
@@ -114,35 +117,6 @@ class kolab_format_contact extends kolab_format
}
/**
- * 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
*
* @param array Contact data as hash array
diff --git a/plugins/libkolab/lib/kolab_format_distributionlist.php b/plugins/libkolab/lib/kolab_format_distributionlist.php
index 592387e..3931c61 100644
--- a/plugins/libkolab/lib/kolab_format_distributionlist.php
+++ b/plugins/libkolab/lib/kolab_format_distributionlist.php
@@ -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
- *
- * @param string XML data
- */
- public function load($xml)
- {
- $this->obj = kolabformat::readDistlist($xml, false);
- $this->loaded = true;
- }
-
- /**
- * Write object data to XML format
+ * Set properties to the kolabformat object
*
- * @return string XML data
+ * @param array Object data as hash array
*/
- 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(),
);
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index 699cfb8..aec4e8d 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -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(
@@ -100,35 +103,6 @@ class kolab_format_event extends kolab_format
}
/**
- * 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
*
* @param array Contact data as hash array
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index be94bb8..370eac1 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -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=?",
More information about the commits
mailing list