[Pkg-owncloud-commits] [php-sabre-vobject] 322/341: Refactored the freebusy generator a bit.

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 13:36:01 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit ec248d64bbd2a1d91c7c39a1b8323aa7086d3c39
Author: Evert Pot <me at evertpot.com>
Date:   Thu Jul 16 17:48:12 2015 -0400

    Refactored the freebusy generator a bit.
---
 lib/FreeBusyGenerator.php | 55 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 50 insertions(+), 5 deletions(-)

diff --git a/lib/FreeBusyGenerator.php b/lib/FreeBusyGenerator.php
index fe2de15..6eba3f8 100644
--- a/lib/FreeBusyGenerator.php
+++ b/lib/FreeBusyGenerator.php
@@ -208,12 +208,46 @@ class FreeBusyGenerator {
      */
     function getResult() {
 
-        $busyTimes = new FreeBusyData(
+        $fbData = new FreeBusyData(
             $this->start->getTimeStamp(),
             $this->end->getTimeStamp()
         );
+        if ($this->vavailability) {
 
-        foreach ($this->objects as $key => $object) {
+            $this->calculateAvailability($fbData, $this->vavailability);
+
+        }
+
+        $this->calculateBusy($fbData, $this->objects);
+
+        return $this->generateFreeBusyCalendar($fbData);
+
+
+    }
+
+    /**
+     * This method takes a VAVAILABILITY component and figures out all the
+     * available times.
+     *
+     * @param FreeBusyData $fbData
+     * @param VCalendar $vavailability
+     * @return void
+     */
+    protected function calculateAvailability(FreeBusyData $fbData, VCalendar $vavailability) {
+
+
+    }
+
+    /**
+     * This method takes an array of iCalendar objects and applies its busy
+     * times on fbData.
+     *
+     * @param FreeBusyData $fbData
+     * @param VCalendar[] $objects
+     */
+    protected function calculateBusy(FreeBusyData $fbData, array $objects) {
+
+        foreach ($objects as $key => $object) {
 
             foreach ($object->getBaseComponents() as $component) {
 
@@ -299,7 +333,7 @@ class FreeBusyGenerator {
                             if ($this->end && $time[0] > $this->end) break;
                             if ($this->start && $time[1] < $this->start) break;
 
-                            $busyTimes->add(
+                            $fbData->add(
                                 $time[0]->getTimeStamp(),
                                 $time[1]->getTimeStamp(),
                                 $FBTYPE
@@ -331,7 +365,7 @@ class FreeBusyGenerator {
 
                                 if ($this->start && $this->start > $endTime) continue;
                                 if ($this->end && $this->end < $startTime) continue;
-                                $busyTimes->add(
+                                $fbData->add(
                                     $startTime->getTimeStamp(),
                                     $endTime->getTimeStamp(),
                                     $fbType
@@ -350,6 +384,16 @@ class FreeBusyGenerator {
 
         }
 
+    }
+
+    /**
+     * This method takes a FreeBusyData object and generates the VCALENDAR
+     * object associated with it.
+     *
+     * @return VCalendar
+     */
+    function generateFreeBusyCalendar(FreeBusyData $fbData) {
+
         if ($this->baseObject) {
             $calendar = $this->baseObject;
         } else {
@@ -375,7 +419,7 @@ class FreeBusyGenerator {
         $dtstamp->setDateTime(new DateTimeImmutable('now', $tz));
         $vfreebusy->add($dtstamp);
 
-        foreach ($busyTimes->getData() as $busyTime) {
+        foreach ($fbData->getData() as $busyTime) {
 
             // Ignoring all the FREE parts, because those are already assumed.
             if ($busyTime['type'] === 'FREE') {
@@ -396,6 +440,7 @@ class FreeBusyGenerator {
 
         return $calendar;
 
+
     }
 
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list