Calendar_Frontend_Json - add getFreeBusyInfo
authorPaul Mehrer <p.mehrer@metaways.de>
Wed, 7 Jun 2017 07:56:08 +0000 (09:56 +0200)
committerPaul Mehrer <p.mehrer@metaways.de>
Wed, 7 Jun 2017 11:30:08 +0000 (13:30 +0200)
and test

Change-Id: I1eca5f1e07858023cdab9027d755000f078b140b
Reviewed-on: http://gerrit.tine20.com/customers/4838
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
Tested-by: Paul Mehrer <p.mehrer@metaways.de>
tests/tine20/Calendar/JsonTests.php
tine20/Calendar/Frontend/Json.php

index 53b13b0..2b4dcce 100644 (file)
@@ -1987,4 +1987,26 @@ class Calendar_JsonTests extends Calendar_TestCase
         $this->assertEquals(1, $relations['totalcount']);
         $this->assertEquals($contact->n_fn, $relations['results'][0]['related_record']['n_family'], print_r($relations['results'], true));
     }
+
+    public function testGetFreeBusyInfo()
+    {
+        $event = $this->_getEvent();
+        $event->attendee = new Tinebase_Record_RecordSet('Calendar_Model_Attender', array(
+            array('user_id' => $this->_getPersonasContacts('sclever')->getId()),
+            array('user_id' => $this->_getPersonasContacts('pwulf')->getId())
+        ));
+        $persistentEvent = $this->_eventController->create($event);
+
+        $period = array(array(
+            'field'     => 'period',
+            'operator'  => 'within',
+            'value'     => array(
+                'from'      => $persistentEvent->dtstart,
+                'until'     => $persistentEvent->dtend
+            ),
+        ));
+
+        $fbinfo = $this->_uit->getFreeBusyInfo($persistentEvent->attendee->toArray(), $period);
+        $this->assertGreaterThanOrEqual(2, count($fbinfo));
+    }
 }
index e122669..1f2948f 100644 (file)
@@ -460,4 +460,20 @@ class Calendar_Frontend_Json extends Tinebase_Frontend_Json_Abstract
         
         return $this->iMIPPrepare($iMIPMessage);
     }
+
+    /**
+     * @param array $_attendee
+     * @param array $_periods
+     * @param array $_ignoreUIDs
+     * @return array
+     */
+    public function getFreeBusyInfo($_attendee, $_periods, $_ignoreUIDs = array())
+    {
+        $attendee = new Tinebase_Record_RecordSet('Calendar_Model_Attender', $_attendee);
+        $periods = new Calendar_Model_EventFilter($_periods);
+
+        $fbInfo = Calendar_Controller_Event::getInstance()->getFreeBusyInfo($periods, $attendee, $_ignoreUIDs);
+
+        return $fbInfo->toArray();
+    }
 }