summaryrefslogtreecommitdiff
path: root/lib/Kolab/FreeBusy/Directory.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-05-06 15:57:22 (GMT)
committerThomas Bruederli <thomas@roundcube.net>2014-05-06 15:57:22 (GMT)
commit886215e40e6fd4e5c8994d069bc390840ab0e0bf (patch)
tree3405c626db8274fbdb0067501cef86a56c2148db /lib/Kolab/FreeBusy/Directory.php
parent8599e8f0925aa994fca1cc0530950ff8b97b1efb (diff)
downloadkolab-freebusy-886215e40e6fd4e5c8994d069bc390840ab0e0bf.tar.gz
- Implement source type 'imap' that fetches free-busy data right from IMAP folders.
This requires the Roundcube framework, config and plugins to be symlinked. Described in README - Add caching option for all sources + expire option for file source.
Diffstat (limited to 'lib/Kolab/FreeBusy/Directory.php')
-rw-r--r--lib/Kolab/FreeBusy/Directory.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Kolab/FreeBusy/Directory.php b/lib/Kolab/FreeBusy/Directory.php
index 8ac2c24..95ce87a 100644
--- a/lib/Kolab/FreeBusy/Directory.php
+++ b/lib/Kolab/FreeBusy/Directory.php
@@ -74,12 +74,25 @@ abstract class Directory
// resolve user record first
if ($user = $this->resolve($user)) {
$fbsource = $this->config['fbsource'];
- if ($source = Source::Factory($fbsource)) {
+ if ($source = Source::Factory($fbsource, $this->config)) {
// forward request to Source instance
if ($data = $source->getFreeBusyData($this->postprocessAttrib($user), $extended)) {
// send data through the according format converter
$converter = Format::factory($this->config['format']);
$data = $converter->toVCalendar($data);
+
+ // cache the generated data
+ if ($data && $this->config['cacheto'] && !$source->isCached()) {
+ $path = preg_replace_callback(
+ '/%\{?([a-z0-9]+)\}?/',
+ function($m) use ($user) { return $user[$m[1]]; },
+ $this->config['cacheto']
+ );
+
+ if (!@file_put_contents($path, $data, LOCK_EX)) {
+ Logger::get('directory')->addError("Failed to write to cache file '" . $path . "'!");
+ }
+ }
}
return $data;