steffen: server/kolab-resource-handlers/kolab-resource-handlers/resmgr resmgr.php, 1.43, 1.44

cvs at intevation.de cvs at intevation.de
Sun Oct 31 14:05:26 CET 2004


Author: steffen

Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/resmgr
In directory doto:/tmp/cvs-serv25820/kolab-resource-handlers/resmgr

Modified Files:
	resmgr.php 
Log Message:
fix for issue489 (scheduling ID on server)

Index: resmgr.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/resmgr/resmgr.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- resmgr.php	29 Oct 2004 00:20:20 -0000	1.43
+++ resmgr.php	31 Oct 2004 13:05:24 -0000	1.44
@@ -377,9 +377,9 @@
         return false;
     }
 
-    $uid = $entries[0]['uid'][0];
+    $ldap_uid = $entries[0]['uid'][0];
     ldap_close($ldap);
-    if( $uid ) return $uid;
+    if( $ldap_uid ) return $ldap_uid;
     else return $resource;
 }
 
@@ -470,7 +470,7 @@
     }
     
     sendSMTP($sender, $resource, $requestText);
-    shutdown(0);
+    shutdown(0,"",false);
 }
 
 /** Helper function */
@@ -515,7 +515,7 @@
 {
     global $resource, $params, $calmbox;
 
-    if( ereg( '/user/[^/].*/(.*)', $calmbox, $regs ) ) {
+    if( ereg( 'user/[^/].*/(.*)', $calmbox, $regs ) ) {
       // Folder in INBOX
       $folder = $regs[1];
     } else {
@@ -532,7 +532,10 @@
 
     $text = @file_get_contents($url);
     if ($text == false || empty($text)) {
-        myLog("Unable to retrieve free/busy information for $resource", RM_LOG_ERROR);
+        $parsed = parse_url($url);
+	$parsed['pass'] = 'XXX';
+	$url = assembleUri($parsed);        
+        myLog("Unable to retrieve free/busy information for $resource from $url", RM_LOG_ERROR);
         //shutdown(1, "Unable to retrieve free/busy information for $resource");
         return false;
     }
@@ -558,7 +561,7 @@
 
 function sendITipReply($type = RM_ITIP_ACCEPT)
 {
-    global $organiser, $itip, $resource, $uid, $is_update, $summary;
+    global $organiser, $itip, $resource, $uid, $sid, $is_update, $summary;
 
     // Build the reply.
     $vCal = &new Horde_iCalendar();
@@ -566,7 +569,7 @@
     $vCal->setAttribute('METHOD', 'REPLY');
 
     $itip_reply = &Horde_iCalendar::newComponent('VEVENT', $vCal);
-    $itip_reply->setAttribute('UID', $uid);
+    $itip_reply->setAttribute('UID', $sid);
     if (!is_a($itip->getAttribute('SUMMARY'), 'PEAR_error')) {
         $itip_reply->setAttribute('SUMMARY', $itip->getAttribute('SUMMARY'));
     }
@@ -769,9 +772,9 @@
 
 function imapAppend($text)
 {
-    global $imap;
+    global $imap, $calmbox;
 
-    myLog("Appending to $fullmbox", RM_LOG_DEBUG);
+    myLog("Appending to $calmbox", RM_LOG_DEBUG);
 
     $rc = $imap->appendMessage($text);
     if( PEAR::isError( $rc ) ) {
@@ -788,7 +791,7 @@
 
 function &buildKolabEvent()
 {
-    global $organiser, $itip, $resource, $uid;
+    global $organiser, $itip, $resource, $uid, $sid;
 
     $kolab_xml = domxml_new_doc('1.0');
     $kolab_event = $kolab_xml->append_child($kolab_xml->create_element('event'));
@@ -797,9 +800,14 @@
     // We're not interested in too much information about the event; the only
     // critical things are the UID and the time spans. We include the
     // summary, body and organizer for display purposes (e.g. in the free/busy viewer).
+    //
+    // Actually, we need everything! /steffen
     $kolab_node = $kolab_event->append_child($kolab_xml->create_element('uid'));
     $kolab_node->append_child($kolab_xml->create_text_node($uid));
 
+    $kolab_node = $kolab_event->append_child($kolab_xml->create_element('scheduling-id'));
+    $kolab_node->append_child($kolab_xml->create_text_node($sid));
+
     $kolab_node = $kolab_event->append_child($kolab_xml->create_element('organizer'));
     $org_params = $itip->getAttribute('ORGANIZER', true);
     if( !is_a( $org_params, 'PEAR_Error' ) ) {
@@ -1011,8 +1019,11 @@
 myLog("Processing $method method for $resource", RM_LOG_DEBUG);
 
 // This is assumed to be constant across event creation/modification/deletipn
-$uid = $itip->getAttributeDefault('UID', '');
-myLog("Event has UID $uid", RM_LOG_DEBUG);
+$sid = $itip->getAttributeDefault('UID', '');
+myLog("Event has UID $sid", RM_LOG_DEBUG);
+
+// Generate a new UID in case we need it
+$uid = 'kolab-'.md5( ''.mt_rand().time().$resource.$params['email_domain'] );
 
 // Who is the organiser?
 $organiser = preg_replace('/^mailto:\s*/i', '', $itip->getAttributeDefault('ORGANIZER', ''));
@@ -1054,14 +1065,14 @@
         }
 
         // Check if the request is actually an update of an existing event
-        $updated_messages = $imap->search('SUBJECT "' . $uid . '"');
+        $updated_messages = $imap->search('SUBJECT "' . $sid . '"');
 	if( PEAR::isError( $updated_messages ) ) {
 	  myLog("Error searching mailbox: ".$updated_messages->getMessage(), RM_LOG_ERROR);
 	  $updated_messages = array();
 	}
         if (!empty($updated_messages)) {
-            myLog("Updating message $uid");
-            $ignore[] = $uid;
+            myLog("Updating message $sid");
+            $ignore[] = $sid;
             $is_update = true;
 
             if (!is_array($updated_messages)) {
@@ -1092,7 +1103,8 @@
 	    $extraparams = $vfb->getExtraParams();
             foreach ($busyperiods as $busyfrom => $busyto) {
                 myLog('Busy period from ' . strftime('%a, %d %b %Y %H:%M:%S %z', $busyfrom) . ' to ' . strftime('%a, %d %b %Y %H:%M:%S %z', $busyto), RM_LOG_DEBUG);
-		if ( in_array(base64_decode($extraparams[$busyfrom]['X-UID']), $ignore) ) {
+		if ( in_array(base64_decode($extraparams[$busyfrom]['X-UID']), $ignore) ||
+		     in_array(base64_decode($extraparams[$busyfrom]['X-SID']), $ignore) ) {
 		  myLog("Ignoring $uid in fb check", RM_LOG_DEBUG);
 		  continue;
 		}
@@ -1121,7 +1133,7 @@
         // was specified; either way we add the new event & send an 'ACCEPT'
         // iTip reply
 
-        myLog("Adding event $uid");
+        myLog("Adding event $sid");
 
         $kolab_xml = &buildKolabEvent();
 
@@ -1141,7 +1153,7 @@
         $headers = &new MIME_Headers();
         $headers->addHeader("From", $resource);
         $headers->addHeader("To", $resource);
-        $headers->addHeader("Subject", $uid);
+        $headers->addHeader("Subject", $sid);
         $headers->addHeader("User-Agent", "proko2/resmgr");
         $headers->addHeader("Reply-To", "");
         $headers->addHeader("Date", date("r"));
@@ -1191,22 +1203,23 @@
 
         // Delete any old events that we updated
         foreach ($updated_messages as $mid) {
+	  myLog("Deleting $mid because of update", RM_LOG_DEBUG);
 	  $imap->deleteMessages($mid);
         }
 	$imap->expunge();
         shutdown(0);
 
  case 'CANCEL':
-        myLog("Removing event $uid");
+        myLog("Removing event $sid");
 	
         // Try to delete the event
-        $deleted_messages = $imap->search('SUBJECT "' . $uid . '"');
+        $deleted_messages = $imap->search('SUBJECT "' . $sid . '"');
         if( PEAR::isError($deleted_messages) ) {
 	  myLog("Error searching mailbox: ".$deleted_messages->getMessage(), RM_LOG_ERROR);
 	  $deleted_messages = array();
 	}
         if (empty($deleted_messages)) {
-            myLog("Canceled event $uid is not present in $resource's calendar", RM_LOG_WARN);
+            myLog("Canceled event $sid is not present in $resource's calendar", RM_LOG_WARN);
             $body = sprintf(_("The following event that was canceled is not present in %s's calendar:\r\n\r\n%s"), $resource, $summary);
             $subject = sprintf(_("Error processing '%s'"), $summary);
         } else {
@@ -1266,6 +1279,7 @@
 
         // Delete the messages from IMAP
         foreach ($deleted_messages as $mid) {
+	    myLog("Deleting $mid because of cancel", RM_LOG_DEBUG);
             $imap->deleteMessages($mid);
         }
 	$imap->expunge();





More information about the commits mailing list