marcus: server/kolab-resource-handlers/kolab-resource-handlers/freebusy freebusyimapcache.class.php, 1.3, 1.4
cvs at kolab.org
cvs at kolab.org
Sun Apr 29 20:44:47 CEST 2007
Author: marcus
Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy
In directory doto:/tmp/cvs-serv5066/freebusy
Modified Files:
freebusyimapcache.class.php
Log Message:
Fixed indention. Now it fits better to the other freebusy classes. (sorry for this commit but IMHO it's easier to read the freebusy-code if we have one coding style)
Index: freebusyimapcache.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusyimapcache.class.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- freebusyimapcache.class.php 22 Nov 2006 15:22:40 -0000 1.3
+++ freebusyimapcache.class.php 29 Apr 2007 18:44:45 -0000 1.4
@@ -86,130 +86,130 @@
if (!$changed)
myLog("check_changed: folder didn't change", RM_LOG_DEBUG);
- return $changed;
- }
+ return $changed;
+ }
- function check_uid_exists($uid) {
- return array_key_exists($uid, $this->cache["imap2fb"]);
- }
+ function check_uid_exists($uid) {
+ return array_key_exists($uid, $this->cache["imap2fb"]);
+ }
- function add_empty_imap2fb(&$imap_uid) {
- $this->cache["imap2fb"][$imap_uid] = array();
- $this->cache_modified = true;
- }
+ function add_empty_imap2fb(&$imap_uid) {
+ $this->cache["imap2fb"][$imap_uid] = array();
+ $this->cache_modified = true;
+ }
- function add_imap2fb(&$imap_uid, $fb_start, $fb_end, $fb_duration, $fb_extra) {
- /*
- Internal imap2fb array structure:
- 0..n IMAP uid
- |----------- 0..n free/busy periods
- |----------- start
- |----------- end
- |----------- duration
- |----------- extra
- */
- myLog("added event to store: uid: $imap_uid, start: $fb_start, end: $fb_end, duration: $fb_duration", RM_LOG_DEBUG);
+ function add_imap2fb(&$imap_uid, $fb_start, $fb_end, $fb_duration, $fb_extra) {
+ /*
+ Internal imap2fb array structure:
+ 0..n IMAP uid
+ |----------- 0..n free/busy periods
+ |----------- start
+ |----------- end
+ |----------- duration
+ |----------- extra
+ */
+ myLog("added event to store: uid: $imap_uid, start: $fb_start, end: $fb_end, duration: $fb_duration", RM_LOG_DEBUG);
- $store = array();
- $store["start"] = $fb_start;
- $store["end"] = $fb_end;
- $store["duration"] = $fb_duration;
- $store["extra"] = $fb_extra;
+ $store = array();
+ $store["start"] = $fb_start;
+ $store["end"] = $fb_end;
+ $store["duration"] = $fb_duration;
+ $store["extra"] = $fb_extra;
- $this->cache["imap2fb"][$imap_uid][] = $store;
- $this->cache_modified = true;
- }
+ $this->cache["imap2fb"][$imap_uid][] = $store;
+ $this->cache_modified = true;
+ }
- function output_fb(&$vFb) {
- reset($this->cache["imap2fb"]);
- while(list($uid, $periods) = each($this->cache["imap2fb"]))
- while(list($key, $period) = each($periods))
- $vFb->addBusyPeriod('BUSY', $period["start"], $period["end"], $period["duration"], $period["extra"]);
- }
+ function output_fb(&$vFb) {
+ reset($this->cache["imap2fb"]);
+ while(list($uid, $periods) = each($this->cache["imap2fb"]))
+ while(list($key, $period) = each($periods))
+ $vFb->addBusyPeriod('BUSY', $period["start"], $period["end"], $period["duration"], $period["extra"]);
+ }
- function compute_filename() {
- $folder_parts = explode('/', $this->foldername);
- unset($folder_parts[0]);
- $folder_storename = join('/', $folder_parts);
-
- $folder_storename = str_replace(".", "^", $folder_storename);
- $folder_storename = str_replace("\0", "", $folder_storename);
+ function compute_filename() {
+ $folder_parts = explode('/', $this->foldername);
+ unset($folder_parts[0]);
+ $folder_storename = join('/', $folder_parts);
- if( ereg( '(.*)@(.*)', $this->owner, $regs ) ) {
- $domain = $regs[2].'/';
- $domain = str_replace(".", "^", $domain);
- $domain = str_replace("\0", "", $domain);
- } else $domain = '';
+ $folder_storename = str_replace(".", "^", $folder_storename);
+ $folder_storename = str_replace("\0", "", $folder_storename);
+
+ if( ereg( '(.*)@(.*)', $this->owner, $regs ) ) {
+ $domain = $regs[2].'/';
+ $domain = str_replace(".", "^", $domain);
+ $domain = str_replace("\0", "", $domain);
+ } else $domain = '';
- $full_path = $this->store_prefix.$domain.$folder_storename.".imapcache";
- return $full_path;
- }
+ $full_path = $this->store_prefix.$domain.$folder_storename.".imapcache";
+ return $full_path;
+ }
- function cache_load() {
- $filename = $this->compute_filename();
+ function cache_load() {
+ $filename = $this->compute_filename();
- myLog("Trying to load file: $filename", RM_LOG_DEBUG);
+ myLog("Trying to load file: $filename", RM_LOG_DEBUG);
- if (!is_readable($filename))
- return false;
+ if (!is_readable($filename))
+ return false;
- $this->cache = unserialize(file_get_contents($filename));
+ $this->cache = unserialize(file_get_contents($filename));
- // Delete disc cache if it's from an old version
- if ($this->cache["version"] != $this->version) {
- myLog("Version mismatch (got: ".$this->cache["version"].", current: ".$this->version.", dropping cache", RM_LOG_WARN);
- $this->reset_cache();
- }
- else $this->cache_modified = false;
- return true;
- }
+ // Delete disc cache if it's from an old version
+ if ($this->cache["version"] != $this->version) {
+ myLog("Version mismatch (got: ".$this->cache["version"].", current: ".$this->version.", dropping cache", RM_LOG_WARN);
+ $this->reset_cache();
+ }
+ else $this->cache_modified = false;
+ return true;
+ }
- function cache_store($force=false) {
- if ($this->cache_modified || $force) {
- $filename = $this->compute_filename();
- myLog("Trying to save cache to file: $filename", RM_LOG_DEBUG);
+ function cache_store($force=false) {
+ if ($this->cache_modified || $force) {
+ $filename = $this->compute_filename();
+ myLog("Trying to save cache to file: $filename", RM_LOG_DEBUG);
- if (!$this->mkdirhier(dirname($filename))) {
- myLog("can't create director hierachy: ".dirname($filename), RM_LOG_ERROR);
+ if (!$this->mkdirhier(dirname($filename))) {
+ myLog("can't create director hierachy: ".dirname($filename), RM_LOG_ERROR);
+ return;
+ }
+
+ $tmpname = tempnam(dirname($this->store_prefix), 'imapcache');
+ $fp = fopen($tmpname, 'w');
+ if(!$fp) return false;
+ if (fwrite($fp, serialize($this->cache)) === false) {
+ fclose ($fp);
+ myLog("can't write to file: $tmpname. Out of discspace?", RM_LOG_ERROR);
return;
}
- $tmpname = tempnam(dirname($this->store_prefix), 'imapcache');
- $fp = fopen($tmpname, 'w');
- if(!$fp) return false;
- if (fwrite($fp, serialize($this->cache)) === false) {
- fclose ($fp);
- myLog("can't write to file: $tmpname. Out of discspace?", RM_LOG_ERROR);
- return;
- }
-
- if(!rename($tmpname, $filename)) {
- myLog("can't rename $tmpname to $filename", RM_LOG_ERROR);
- return false;
- }
- fclose($fp);
- $this->cache_modified = false;
- }
- else {
- myLog("IMAPcache unmodified, not saving", RM_LOG_DEBUG);
- }
- }
+ if(!rename($tmpname, $filename)) {
+ myLog("can't rename $tmpname to $filename", RM_LOG_ERROR);
+ return false;
+ }
+ fclose($fp);
+ $this->cache_modified = false;
+ }
+ else {
+ myLog("IMAPcache unmodified, not saving", RM_LOG_DEBUG);
+ }
+ }
- function cache_delete() {
- unlink($this->compute_filename());
- $this->reset_cache();
- }
+ function cache_delete() {
+ unlink($this->compute_filename());
+ $this->reset_cache();
+ }
- function mkdirhier( $dirname ) {
- $base = substr($dirname,0,strrpos($dirname,'/'));
- $base = str_replace(".", "^", $base);
- if( !empty( $base ) && !is_dir( $base ) ) {
- if( !$this->mkdirhier( $base ) ) return false;
- }
- if( !file_exists( $dirname ) ) return mkdir( $dirname, 0755 );
- return true;
+ function mkdirhier( $dirname ) {
+ $base = substr($dirname,0,strrpos($dirname,'/'));
+ $base = str_replace(".", "^", $base);
+ if( !empty( $base ) && !is_dir( $base ) ) {
+ if( !$this->mkdirhier( $base ) ) return false;
}
+ if( !file_exists( $dirname ) ) return mkdir( $dirname, 0755 );
+ return true;
+ }
};
-?>
\ No newline at end of file
+?>
More information about the commits
mailing list