Changeset View
Changeset View
Standalone View
Standalone View
lib/Kolab/FreeBusy/SourceFBDaemon.php
Show All 36 Lines | public function getFreeBusyData($user, $extended) | ||||
$config = $this->getUserConfig($user); | $config = $this->getUserConfig($user); | ||||
parse_str(strval($config['query']), $param); | parse_str(strval($config['query']), $param); | ||||
$config += $param; | $config += $param; | ||||
// log this... | // log this... | ||||
$log->addInfo("Fetching data for ", $config); | $log->addInfo("Fetching data for ", $config); | ||||
// caching is enabled | |||||
if (!empty($config['cacheto'])) { | |||||
// check for cached data | |||||
if ($cached = $this->getCached($config)) { | |||||
$log->addInfo("Deliver cached data from " . $config['cacheto']); | |||||
return $cached; | |||||
} | |||||
// touch cache file to avoid multiple requests generating the same data | |||||
if (file_exists($config['cacheto'])) { | |||||
touch($config['cacheto']); | |||||
} | |||||
else { | |||||
file_put_contents($config['cacheto'], Utils::dummyVFreebusy($user['mail'])); | |||||
$tempfile = $config['cacheto']; | |||||
} | |||||
} | |||||
// compose command for freebusyd | // compose command for freebusyd | ||||
if (!empty($config['folder'])) { | if (!empty($config['folder'])) { | ||||
$cmd = 'FOLDER'; | $cmd = 'FOLDER'; | ||||
$target = $config['folder']; | $target = $config['folder']; | ||||
} | } | ||||
else if (!empty($config['user'])) { | else if (!empty($config['user'])) { | ||||
$cmd = 'USER'; | $cmd = 'USER'; | ||||
$target = $config['user']; | $target = $config['user']; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | public function getFreeBusyData($user, $extended) | ||||
if (!empty($fbdata)) { | if (!empty($fbdata)) { | ||||
// post-process fbdata (replace ORGANIZER: property) | // post-process fbdata (replace ORGANIZER: property) | ||||
if (!empty($user['mail'])) { | if (!empty($user['mail'])) { | ||||
$fbdata = preg_replace('/(ORGANIZER:mailto:)(.+)/i', '\1' . $user['mail'], $fbdata); | $fbdata = preg_replace('/(ORGANIZER:mailto:)(.+)/i', '\1' . $user['mail'], $fbdata); | ||||
} | } | ||||
return $fbdata; | return $fbdata; | ||||
} | } | ||||
// remove (temporary) cache file again | |||||
else if ($tempfile) { | |||||
unlink($tempfile); | |||||
} | |||||
// not found | // not found | ||||
return false; | return false; | ||||
} | } | ||||
} | } |