MFB:
authorGunnar Wrobel <p@rdus.de>
Wed, 7 Jul 2010 07:31:20 +0000 (09:31 +0200)
committerGunnar Wrobel <wrobel@temple.(none)>
Wed, 7 Jul 2010 09:43:33 +0000 (11:43 +0200)
Actually use the newer Freebusy handler.
Merge several minor fixes from Git HEAD. Reactivated some tests.
kolab/issue4257 (Always accept policy doesnt set atendee status to accepted)

framework/Kolab_Filter/lib/Horde/Kolab/Resource.php
framework/Kolab_Filter/lib/Horde/Kolab/Resource/Epoch.php
framework/Kolab_Filter/lib/Horde/Kolab/Resource/Freebusy.php
framework/Kolab_Filter/lib/Horde/Kolab/Resource/Freebusy/Kolab.php
framework/Kolab_Filter/lib/Horde/Kolab/Resource/Freebusy/Mock.php

index 78e1880..8513745 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Resource management for the Kolab server.
  *
- * PHP version 4
+ * PHP version 5
  *
  * @category Kolab
  * @package  Kolab_Filter
@@ -44,7 +44,7 @@ define('RM_ITIP_TENTATIVE',                 3);
 /**
  * Provides Kolab resource handling
  *
- * Copyright 2004-2009 Klarälvdalens Datakonsult AB
+ * Copyright 2004-2010 Klarälvdalens Datakonsult AB
  *
  * See the enclosed file COPYING for license information (LGPL). If you
  * did not receive this file, see http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
@@ -231,115 +231,6 @@ class Kolab_Resource
         return $default;
     }
 
-    function _objectFromItip(&$itip)
-    {
-        $object = array();
-        $object['uid'] = $itip->getAttributeDefault('UID', '');
-
-        $org_params = $itip->getAttribute('ORGANIZER', true);
-        if (!is_a( $org_params, 'PEAR_Error')) {
-            if (!empty($org_params[0]['CN'])) {
-                $object['organizer']['display-name'] = $org_params[0]['CN'];
-            }
-            $orgemail = $itip->getAttributeDefault('ORGANIZER', '');
-            if (preg_match('/mailto:(.*)/i', $orgemail, $regs )) {
-                $orgemail = $regs[1];
-            }
-            $object['organizer']['smtp-address'] = $orgemail;
-        }
-        $object['summary'] = $itip->getAttributeDefault('SUMMARY', '');
-        $object['location'] = $itip->getAttributeDefault('LOCATION', '');
-        $object['body'] = $itip->getAttributeDefault('DESCRIPTION', '');
-
-        $dtend = $itip->getAttributeDefault('DTEND', '');
-        if (is_array($dtend)) {
-            $object['_is_all_day'] = true;
-        }
-        $object['start-date'] = $this->convert2epoch($itip->getAttributeDefault('DTSTART', ''));
-        $object['end-date'] = $this->convert2epoch($dtend);
-
-        $attendees = $itip->getAttribute('ATTENDEE');
-        if (!is_a( $attendees, 'PEAR_Error')) {
-            $attendees_params = $itip->getAttribute('ATTENDEE', true);
-            if (!is_array($attendees)) {
-                $attendees = array($attendees);
-            }
-            if (!is_array($attendees_params)) {
-                $attendees_params = array($attendees_params);
-            }
-
-            $object['attendee'] = array();
-            for ($i = 0; $i < count($attendees); $i++) {
-                $attendee = array();
-                if (isset($attendees_params[$i]['CN'])) {
-                    $attendee['display-name'] = $attendees_params[$i]['CN'];
-                }
-
-                $attendeeemail = $attendees[$i];
-                if (preg_match('/mailto:(.*)/i', $attendeeemail, $regs)) {
-                    $attendeeemail = $regs[1];
-                }
-                $attendee['smtp-address'] = $attendeeemail;
-
-                if( $attendees_params[$i]['RSVP'] == 'FALSE' ) {
-                    $attendee['request-response'] = false;
-                } else {
-                    $attendee['request-response'] = true;
-                }
-
-                if (isset($attendees_params[$i]['ROLE'])) {
-                    $attendee['role'] = $attendees_params[$i]['ROLE'];
-                }
-
-                if (isset($attendees_params[$i]['PARTSTAT'])) {
-                    $status = strtolower($attendees_params[$i]['PARTSTAT']);
-                    switch ($status) {
-                    case 'needs-action':
-                    case 'delegated':
-                        $attendee['status'] = 'none';
-                        break;
-                    default:
-                        $attendee['status'] = $status;
-                        break;
-                    }
-                }
-
-                $object['attendee'][] = $attendee;
-            }
-        }
-
-        // Alarm
-        $valarm = $itip->findComponent('VALARM');
-        if ($valarm) {
-            $trigger = $valarm->getAttribute('TRIGGER');
-            if (!is_a($trigger, 'PEAR_Error')) {
-                $p = $valarm->getAttribute('TRIGGER', true);
-                if ($trigger < 0) {
-                    // All OK, enter the alarm into the XML
-                    // NOTE: The Kolab XML format seems underspecified
-                    // wrt. alarms currently...
-                    $object['alarm'] = -$trigger / 60;
-                }
-            } else {
-                Horde::logMessage('No TRIGGER in VALARM. ' . $trigger->getMessage(), 'ERR');
-            }
-        }
-
-        // Recurrence
-        $rrule_str = $itip->getAttribute('RRULE');
-        if (!is_a($rrule_str, 'PEAR_Error')) {
-            require_once 'Horde/Date/Recurrence.php';
-            $recurrence = new Horde_Date_Recurrence(time());
-            $recurrence->fromRRule20($rrule_str);
-            $object['recurrence'] = $recurrence->toHash();
-        }
-
-        Horde::logMessage(sprintf('Assembled event object: %s',
-                                  print_r($object, true)), 'DEBUG');
-
-        return $object;
-    }
-
     function handleMessage($fqhostname, $sender, $resource, $tmpfname)
     {
         global $conf;
@@ -509,7 +400,7 @@ class Kolab_Resource
                                               print_r($extraparams, true)), 'DEBUG');
                     $conflict = false;
                     if (!empty($object['recurrence'])) {
-                        $recurrence = new Horde_Date_Recurrence(time());
+                        $recurrence = new Horde_Date_Recurrence($dtstart);
                         $recurrence->fromHash($object['recurrence']);
                         $duration = $dtend - $dtstart;
                         $events = array();
@@ -530,6 +421,10 @@ class Kolab_Resource
                     }
 
                     foreach ($events as $dtstart => $dtend) {
+                        Horde::logMessage(sprintf('Requested event from %s to %s',
+                                                  strftime('%a, %d %b %Y %H:%M:%S %z', $dtstart),
+                                                  strftime('%a, %d %b %Y %H:%M:%S %z', $dtend)
+                                          ), 'DEBUG');
                         foreach ($busyperiods as $busyfrom => $busyto) {
                             if (empty($busyfrom) && empty($busyto)) {
                                 continue;
@@ -692,7 +587,7 @@ class Kolab_Resource
 
             Horde::logMessage('Successfully sent cancellation reply', 'INFO');
 
-            return false;;
+            return false;
 
         default:
             // We either don't currently handle these iTip methods, or they do not
index 6178dba..a9c2c78 100644 (file)
@@ -55,7 +55,7 @@ class Horde_Kolab_Resource_Epoch
      *
      * @return array The cleaned array.
      */
-    function cleanArray($ical_date)
+    private function cleanArray($ical_date)
     {
         if (!array_key_exists('hour', $ical_date)) {
             $temp['DATE'] = '1';
index 4a2bb41..ac78302 100644 (file)
  */
 
 /**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
  * Retrieves free/busy data for an email address.
  *
  * Copyright 2004-2009 Klarälvdalens Datakonsult AB
@@ -44,6 +39,13 @@ class Horde_Kolab_Resource_Freebusy
     static protected $_instances = array();
 
     /**
+     * Class parameters.
+     *
+     * @var array
+     */
+    protected $_params;
+
+    /**
      * Constructor.
      *
      * @param array $params A hash containing any additional configuration or
@@ -70,10 +72,12 @@ class Horde_Kolab_Resource_Freebusy
      */
     static public function factory($driver, $params = array())
     {
-        $driver = basename($driver);
-        $class  = ($driver == 'none')
+        $driver = ucfirst(basename($driver));
+        $class  = ($driver == 'None')
             ? 'Horde_Kolab_Resource_Freebusy'
-            : 'Horde_Kolab_Resource_Freebusy_' . ucfirst($driver);
+            : 'Horde_Kolab_Resource_Freebusy_' . $driver;
+
+        require_once dirname(__FILE__) . '/Freebusy/' . $driver . '.php';
 
         if (!class_exists($class)) {
             $class = 'Horde_Kolab_Resource_Freebusy';
@@ -105,6 +109,11 @@ class Horde_Kolab_Resource_Freebusy
     {
         global $conf;
 
+        if (isset($GLOBALS['KOLAB_FILTER_TESTING'])) {
+            $driver = 'mock';
+            $params['data'] = $GLOBALS['KOLAB_FILTER_TESTING'];
+        }
+
         if (empty($driver)) {
             $driver = $conf['freebusy']['driver'];
         }
index 89bbb5d..ed860c4 100644 (file)
@@ -37,7 +37,7 @@ class Horde_Kolab_Resource_Freebusy_Kolab extends Horde_Kolab_Resource_Freebusy
      *
      * @return string The Free/Busy URL for that resource.
      */
-    static protected function getUrl($resource)
+    protected function getUrl($resource)
     {
         $server = Horde_Kolab_Server::singleton();
         $uid    = $server->uidForIdOrMailOrAlias($resource);
index 5137353..9169b05 100644 (file)
@@ -50,6 +50,6 @@ class Horde_Kolab_Resource_Freebusy_Mock extends Horde_Kolab_Resource_Freebusy
      */
     public function get($resource)
     {
-        return parent::get($resource);
+        return $this->_params['data'];
     }
 }
\ No newline at end of file