summaryrefslogtreecommitdiff
path: root/plugins/libkolab/lib/kolab_storage_cache.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/libkolab/lib/kolab_storage_cache.php')
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index 4f12df7..134631e 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -48,6 +48,7 @@ class kolab_storage_cache
protected $extra_cols = array();
protected $order_by = null;
protected $limit = null;
+ protected $error = 0;
/**
@@ -150,6 +151,16 @@ class kolab_storage_cache
}
/**
+ * Returns code of last error
+ *
+ * @return int Error code
+ */
+ public function get_error()
+ {
+ return $this->error;
+ }
+
+ /**
* Synchronize local cache data with remote
*/
public function synchronize()
@@ -243,6 +254,7 @@ class kolab_storage_cache
}
}
+ $this->check_error();
$this->synched = time();
}
@@ -288,6 +300,7 @@ class kolab_storage_cache
}
}
+ $this->check_error();
return $this->objects[$msguid];
}
@@ -326,6 +339,8 @@ class kolab_storage_cache
// ...or set in-memory cache to false
$this->objects[$msguid] = $object;
}
+
+ $this->check_error();
}
@@ -384,6 +399,8 @@ class kolab_storage_cache
// keep a copy in memory for fast access
$this->objects = array($msguid => $object);
$this->uid2msg = array($object['uid'] => $msguid);
+
+ $this->check_error();
}
@@ -423,6 +440,7 @@ class kolab_storage_cache
}
unset($this->uid2msg[$uid]);
+ $this->check_error();
}
@@ -465,6 +483,8 @@ class kolab_storage_cache
$target->get_resource_uri(),
$this->resource_uri
);
+
+ $this->check_error();
}
/**
@@ -529,6 +549,7 @@ class kolab_storage_cache
}
if ($index->is_error()) {
+ $this->check_error();
if ($uids) {
return null;
}
@@ -551,6 +572,8 @@ class kolab_storage_cache
}
}
+ $this->check_error();
+
return $result;
}
@@ -593,6 +616,7 @@ class kolab_storage_cache
}
if ($index->is_error()) {
+ $this->check_error();
return null;
}
@@ -601,6 +625,7 @@ class kolab_storage_cache
$count = $index->count();
}
+ $this->check_error();
return $count;
}
@@ -937,6 +962,7 @@ class kolab_storage_cache
// abort if database is not set-up
if ($this->db->is_error()) {
+ $this->check_error();
$this->ready = false;
return;
}
@@ -976,6 +1002,22 @@ class kolab_storage_cache
}
/**
+ * Check IMAP connection error state
+ */
+ protected function check_error()
+ {
+ if (($err_code = $this->imap->get_error_code()) < 0) {
+ $this->error = kolab_storage::ERROR_IMAP_CONN;
+ if (($res_code = $this->imap->get_response_code()) !== 0 && in_array($res_code, array(rcube_storage::NOPERM, rcube_storage::READONLY))) {
+ $this->error = kolab_storage::ERROR_NO_PERMISSION;
+ }
+ }
+ else if ($this->db->is_error()) {
+ $this->error = kolab_storage::ERROR_CACHE_DB;
+ }
+ }
+
+ /**
* Resolve an object UID into an IMAP message UID
*
* @param string Kolab object UID