patch for kronolith vCal generation code for recurring events

Arvid Requate <[email protected]>
Newsgroups gmane.comp.horde.sync
Organization Univention GmbH
Message-ID <[email protected]>
Hello,

the attached patch addresses two bugs in the kronolith vCal generation code 
for recurring events (in Horde_Date_Recurrence::toRRule10):
1. end dates are not written as UTC DateTime as expected by the vCal (1.0) 
standard but as a Date instead.
2. the number of recurrences is written as number of incidences, but the vCal 
standard specifies that it should represent the number of weeks.

The patch was tested against horde-webmailer 1.2.0 with kolab-webclient 
patches. Theses issues also have been filed into the Kolab Issue tracker as 
https://issues.kolab.org/issue3894

Regards,
Arvid Requate

-- 
Arvid Requate
Open Source Software Engineer

Univention GmbH
Linux for your business
Mary-Somerville-Str.1
28359 Bremen
Tel. : +49 421 22232-0
Fax : +49 421 22232-99

[email protected]
http://www.univention.de

Geschäftsführer: Peter H. Ganten
HRB 20755 Amtsgericht Bremen
Steuer-Nr.: 71-597-02876

-- 
sync mailing list - Join the hunt: http://horde.org/bounties/#sync
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
t_SyncML_UV_recurring_events_week_count.diff (text/x-diff, 1.3 KB)
--- a/horde-webmailer/kronolith/lib/Recurrence.php	2009-04-08 10:04:57.000000000 +0200
+++ b/horde-webmailer/kronolith/lib/Recurrence.php	2009-04-23 11:38:33.000000000 +0200
@@ -855,6 +855,7 @@
      */
     function toRRule10($calendar)
     {
+        $rec_days_per_week = 0;
         switch ($this->recurType) {
         case HORDE_DATE_RECUR_NONE:
             return '';
@@ -870,6 +871,7 @@
             for ($i = 0; $i <= 7 ; ++$i) {
                 if ($this->recurOnDay(pow(2, $i))) {
                     $rrule .= ' ' . $vcaldays[$i];
+                    $rec_days_per_week++;
                 }
             }
             break;
@@ -908,9 +910,18 @@
             return '';
         }
 
-        return $this->hasRecurEnd() ?
-            $rrule . ' ' . $calendar->_exportDate($this->recurEnd) :
-            $rrule . ' #' . (int)$this->getRecurCount();
+        if ( $this->hasRecurEnd() ) {
+            $rrule .= ' ' . $calendar->_exportDateTime($this->recurEnd);
+        } else {
+            if ($rec_days_per_week > 1) {
+                $rec_weeks= (int)floor((int)$this->getRecurCount() / $rec_days_per_week);
+                $rrule .= ' #' . $rec_weeks;
+	    } else {
+                $rrule .= ' #' . (int)$this->getRecurCount();
+            }
+        }
+
+        return $rrule;
     }
 
     /**
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.