From: Paul Mehrer
Date: Wed, 7 Jun 2017 07:56:08 +0000 (+0200)
Subject: Calendar_Frontend_Json - add getFreeBusyInfo
X-Git-Tag: 2017.02.4~2^2~18
X-Git-Url: http://git.tine20.org/?p=tine20;a=commitdiff_plain;h=03abae599bfc99b9446962795610d3a158506cc4
Calendar_Frontend_Json - add getFreeBusyInfo
and test
Change-Id: I1eca5f1e07858023cdab9027d755000f078b140b
Reviewed-on: http://gerrit.tine20.com/customers/4838
Reviewed-by: Paul Mehrer
Tested-by: Paul Mehrer
---
diff --git a/tests/tine20/Calendar/JsonTests.php b/tests/tine20/Calendar/JsonTests.php
index 53b13b0..2b4dcce 100644
--- a/tests/tine20/Calendar/JsonTests.php
+++ b/tests/tine20/Calendar/JsonTests.php
@@ -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));
+ }
}
diff --git a/tine20/Calendar/Frontend/Json.php b/tine20/Calendar/Frontend/Json.php
index e122669..1f2948f 100644
--- a/tine20/Calendar/Frontend/Json.php
+++ b/tine20/Calendar/Frontend/Json.php
@@ -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();
+ }
}