steffen: server/kolab-resource-handlers/kolab-resource-handlers/resmgr kolabfilter.php, 1.22, 1.23 olhacks.php, 1.6, 1.7

cvs at intevation.de cvs at intevation.de
Wed May 4 16:32:47 CEST 2005


Author: steffen

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

Modified Files:
	kolabfilter.php olhacks.php 
Log Message:
Hacked missing ORGANIZER into the iCal for Outlook (Issue665)

Index: kolabfilter.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/resmgr/kolabfilter.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- kolabfilter.php	3 May 2005 02:11:25 -0000	1.22
+++ kolabfilter.php	4 May 2005 14:32:44 -0000	1.23
@@ -28,6 +28,34 @@
 require_once 'kolabfilter/misc.php';
 require_once 'kolabfilter/kolabmailtransport.php';
 
+// Profiling code
+/*
+function mymtime(){
+  $tmp=explode(' ',microtime());
+  $rt=$tmp[0]+$tmp[1];
+  return $rt;
+}
+
+class MyTimer {
+  function MyTimer( $name ) {
+    $this->name = $name;
+  }
+  function start() {
+    $this->time = mymtime();
+  }
+  function stop() {
+    $time = 100*(mymtime()-$this->time);
+    myLog("Section ".$this->name." took $time msecs", RM_LOG_DEBUG);
+  }
+
+  var $name;
+  var $time;
+};
+
+$totaltime =& new MyTimer("Total");
+$totaltime->start();
+*/
+
 // Load our configuration file
 $params = array();
 require_once '@l_prefix@/etc/resmgr/resmgr.conf';
@@ -37,6 +65,9 @@
 define( 'EX_TEMPFAIL', 75 );
 define( 'EX_UNAVAILABLE', 69 );
 
+//$inputtime =& new MyTimer("Input");
+//$inputtime->start();
+
 // Temp file for storing the message
 $tmpfname = tempnam( TMPDIR, 'IN.' );
 $tmpf = fopen($tmpfname, "w");
@@ -153,6 +184,8 @@
 }
 fclose($tmpf);
 
+//$inputtime->stop();
+
 if( !$senderok ) {
   if( $ical && $params['allow_outlook_ical_forward'] ) {
     require_once('kolabfilter/olhacks.php');
@@ -170,6 +203,9 @@
   }
 }
 
+//$outputtime =& new MyTimer("Output");
+//$outputtime->start();
+
 $tmpf = fopen($tmpfname,"r");
 $smtp = new KolabSMTP( 'localhost', 10026 );
 if( PEAR::isError( $smtp ) ) {
@@ -204,6 +240,8 @@
 
 //myLog("Calling smtp->end()", RM_LOG_DEBUG);
 $smtp->end();
+//$outputtime->stop();
 myLog("Kolabfilter successfully completed", RM_LOG_DEBUG);
+//$totaltime->stop();
 exit(0);
 ?>

Index: olhacks.php
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/resmgr/olhacks.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- olhacks.php	28 Apr 2005 09:08:41 -0000	1.6
+++ olhacks.php	4 May 2005 14:32:44 -0000	1.7
@@ -20,6 +20,7 @@
 
 require_once 'kolabfilter/misc.php';
 require_once HORDE_BASE . '/lib/core.php';
+require_once 'Horde/iCalendar.php';
 require_once 'Horde/NLS.php';
 require_once 'Horde/MIME.php';
 require_once 'Horde/MIME/Message.php';
@@ -68,6 +69,35 @@
   }
 }
 
+/*
+ * Yet another problem: Outlook seems to remove the organizer
+ * from the iCal when forwarding -- we put the original sender
+ * back in as organizer.
+ */
+/* static */ function add_organizer( &$icaltxt, $from ) {
+  global $params;
+  $iCal = &new Horde_iCalendar();
+  $iCal->parsevCalendar($icaltxt);
+  $vevent =& $iCal->findComponent('VEVENT');
+  if( $vevent ) {
+    #myLog("Successfully parsed vevent", RM_LOG_DEBUG);
+    if( !$vevent->organizerName() ) {
+      #myLog("event has no organizer, adding $from", RM_LOG_DEBUG);
+      $adrs = imap_rfc822_parse_adrlist($from, $params['email_domain']);
+      if( count($adrs) > 0 ) {
+	$org_email = $adrs[0]->mailbox.'@'.$adrs[0]->host;
+	$org_name  = $adrs[0]->personal;
+	if( $org_name ) $vevent->setAttribute( 'ORGANIZER', $org_email, 
+					       array( 'CN' => $org_name), false );
+	else $vevent->setAttribute( 'ORGANIZER', $org_email, 
+				    array(), false );
+	myLog("Adding missing organizer '$org_name <$org_email>' to iCal", RM_LOG_DEBUG);
+	$icaltxt = $iCal->exportvCalendar();
+      }
+    }
+  }
+}
+
 /* Yet another Outlook problem: Some versions of Outlook seems to be incapable
  * of handling non-ascii characters properly in text/calendar parts of
  * a multi-part/mixed mail which we use for forwarding.
@@ -75,7 +105,7 @@
  * two-letter ascii.
  */
 /* static */ function olhacks_recode_to_ascii( $text ) {
-  myLog("recoding \"$text\"", RM_LOG_DEBUG);
+  #myLog("recoding \"$text\"", RM_LOG_DEBUG);
   $text = str_replace( ('æ'), 'ae', $text );
   $text = str_replace( ('ø'), 'oe', $text );
   $text = str_replace( ('Ã¥'), 'aa', $text );
@@ -90,7 +120,7 @@
   $text = str_replace( ('Ä'), 'Ae', $text );
   $text = str_replace( ('Ö'), 'Oe', $text );
   $text = str_replace( ('Ü'), 'Ue', $text );
-  myLog("recoded to \"$text\"", RM_LOG_DEBUG);
+  #myLog("recoded to \"$text\"", RM_LOG_DEBUG);
 
   return $text;
 }
@@ -125,7 +155,9 @@
   $toppart = &new MIME_Message();
   $dorigfrom = Mail_mimeDecode::_decodeHeader($origfrom);
   $textpart = &new MIME_Part('text/plain', sprintf($forwardtext,$dorigfrom,$dorigfrom), 'UTF-8' );
-  $msgpart = &new MIME_Part($basepart->getType(), olhacks_recode_to_ascii($basepart->transferDecode()), 
+  $ical_txt = $basepart->transferDecode();
+  add_organizer($ical_txt, $dorigfrom);
+  $msgpart = &new MIME_Part($basepart->getType(), olhacks_recode_to_ascii($ical_txt), 
 			    $basepart->getCharset() );
   
   $toppart->addPart($textpart);





More information about the commits mailing list