steffen: server/kolab-resource-handlers/kolab-resource-handlers/freebusy freebusy.class.php, 1.3, 1.4 pfb.php, 1.3, 1.4

cvs at intevation.de cvs at intevation.de
Thu Oct 14 04:12:53 CEST 2004


Author: steffen

Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy
In directory doto:/tmp/cvs-serv29772/kolab-resource-handlers/freebusy

Modified Files:
	freebusy.class.php pfb.php 
Log Message:
generate both pfb and xpfb no matter what the user asks for -- it is simply faster to create both at the same time instead of running thru the mailbox twice

Index: freebusy.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy.class.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- freebusy.class.php	13 Oct 2004 14:17:06 -0000	1.3
+++ freebusy.class.php	14 Oct 2004 02:12:51 -0000	1.4
@@ -33,7 +33,7 @@
     return $this->imap->getACL();
   }
 
-  function &generateFreeBusy($extended = false, $startstamp = NULL, $endstamp = NULL ) {
+  function &generateFreeBusy($startstamp = NULL, $endstamp = NULL ) {
   
     require_once 'PEAR.php';
     require_once 'Horde/iCalendar.php';
@@ -122,24 +122,20 @@
 	continue;
       }
     
-      if ($extended ) {
-	$extra = array(
-		       'X-UID'     => base64_encode($uid),
-		       );
-	if (!empty($summary)) {
-	  $extra['X-SUMMARY'] = base64_encode($summary);
-	}
-      
-	$vFb->addBusyPeriod('BUSY', $initial_start, $initial_end, null, $extra);
-      } else {
-	$vFb->addBusyPeriod('BUSY', $initial_start, $initial_end);
+      $extra = array( 'X-UID'     => base64_encode($uid) );
+      if (!empty($summary)) {
+	$extra['X-SUMMARY'] = base64_encode($summary);
       }
+      
+      $vFb->addBusyPeriod('BUSY', $initial_start, $initial_end, null, $extra);
     }
   
-    $vCal->addComponent($vFb);
+    $xvCal = $vCal;
+    $xvCal->addComponent($vFb);
+    $vCal->addComponent($this->clearExtra($vFb));
   
     // Generate the vCal file.
-    return $vCal->exportvCalendar();
+    return array( $vCal->exportvCalendar(), $xvCal->exportvCalendar() );
   }
 
   /********************** Private API below this line ********************/
@@ -262,6 +258,10 @@
     return $event_hash;
   }
 
+  function clearExtra( $vFb ) {
+    $vFb->_extraParams = array();
+    return $vFb;
+  }
  
   var $username;
   var $password;

Index: pfb.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/pfb.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pfb.php	5 Oct 2004 09:13:41 -0000	1.3
+++ pfb.php	14 Oct 2004 02:12:51 -0000	1.4
@@ -42,11 +42,17 @@
 }
 
 $cache =& new FreeBusyCache( $params['kolab_prefix'].'/var/kolab/www/freebusy/cache',
-			     $req_extended );
+			     false );
+$xcache =& new FreeBusyCache( $params['kolab_prefix'].'/var/kolab/www/freebusy/cache',
+			     true );
 
 if( $req_cache ) {
   $acl = false;
-  $vfb = $cache->load( $req_folder, $ts, $acl );
+  if( $req_extended ) {
+    $vfb = $xcache->load( $req_folder, $ts, $acl );
+  } else {
+    $vfb = $cache->load( $req_folder, $ts, $acl );
+  }
   if( $acl && $req_extended ) {
     // Check access
     $distlists = $ldap->distlists( $ldap->dn($imapuser));
@@ -54,7 +60,7 @@
     for( $i = 0; $i < count($distlists); $i++ ) {
       $distlists[$i] = $distlists[$i].'@'.$params['email_domain'];
     }
-    $rights = $cache->getRights( $acl, $imapuser, $distlists );
+    $rights = $xcache->getRights( $acl, $imapuser, $distlists );
     if( $rights['r'] ) {
       // All OK
     } else {
@@ -93,7 +99,7 @@
     notfound( "Folder: ".$fb->foldername.', '.$rc->toString());
     return false;
   }  
-  $vfb = $fb->generateFreeBusy($req_extended);
+  list($vfb,$xvfb) = $fb->generateFreeBusy();
   $ts = mktime();
   if( PEAR::isError( $vfb ) ) {
     unauthorized($rc->toString());
@@ -102,8 +108,12 @@
 
   $acl = $fb->getACL();
   if( !$cache->store( $owner.'/'.$folder, $vfb, $acl ) ) {
-    trigger_error('Could not store vfb in cache file '.$owner.'/'.$folder
-		  .($req_extended?'.xpfb':'.pfb').$cache->error, E_USER_WARNING);
+    trigger_error('Could not store pfb in cache file '.$owner.'/'.$folder
+		  .'.pfb: '.$cache->error, E_USER_WARNING);
+  }
+  if( !$xcache->store( $owner.'/'.$folder, $xvfb, $acl ) ) {
+    trigger_error('Could not store xpfb in cache file '.$owner.'/'.$folder
+		  .'.xpfb: '.$cache->error, E_USER_WARNING);
   }
 }
 
@@ -119,14 +129,14 @@
     header('Content-Type: text/calendar');
 }
 if ($params['send_content_length']) {
-    header('Content-Length: ' . strlen($vfb));
+    header('Content-Length: ' . strlen($req_extended?$xvfb:$vfb));
 }
 if ($params['send_content_disposition']) {
     header('Content-Disposition: attachment; filename="' . $user . '.vfb"');
 }
 
 #print "folder=$req_folder, cache=$req_cache, extended=$req_extended";
-echo $vfb;
+echo ($req_extended?$xvfb:$vfb);
 #print_r($acl);
 
 // Finish up





More information about the commits mailing list