123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace Sabre\VObject\Component;
- use Sabre\VObject;
- class VFreeBusy extends VObject\Component {
-
- public function isFree(\DateTime $start, \Datetime $end) {
- foreach($this->select('FREEBUSY') as $freebusy) {
-
-
- if (isset($freebusy['FBTYPE']) && strtoupper(substr((string)$freebusy['FBTYPE'],0,4))!=='BUSY') {
- continue;
- }
-
-
- $periods = explode(',', (string)$freebusy);
- foreach($periods as $period) {
-
-
-
- list($busyStart, $busyEnd) = explode('/', $period);
- $busyStart = VObject\DateTimeParser::parse($busyStart);
- $busyEnd = VObject\DateTimeParser::parse($busyEnd);
- if ($busyEnd instanceof \DateInterval) {
- $tmp = clone $busyStart;
- $tmp->add($busyEnd);
- $busyEnd = $tmp;
- }
- if($start < $busyEnd && $end > $busyStart) {
- return false;
- }
- }
- }
- return true;
- }
-
- public function getValidationRules() {
- return array(
- 'UID' => 1,
- 'DTSTAMP' => 1,
- 'CONTACT' => '?',
- 'DTSTART' => '?',
- 'DTEND' => '?',
- 'ORGANIZER' => '?',
- 'URL' => '?',
- 'ATTENDEE' => '*',
- 'COMMENT' => '*',
- 'FREEBUSY' => '*',
- 'REQUEST-STATUS' => '*',
- );
- }
- }
|