1<?php 2 3namespace Sabre\VObject\Component; 4 5use Sabre\VObject; 6 7/** 8 * VJournal component 9 * 10 * This component contains some additional functionality specific for VJOURNALs. 11 * 12 * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/). 13 * @author Evert Pot (http://evertpot.com/) 14 * @license http://sabre.io/license/ Modified BSD License 15 */ 16class VJournal extends VObject\Component { 17 18 /** 19 * Returns true or false depending on if the event falls in the specified 20 * time-range. This is used for filtering purposes. 21 * 22 * The rules used to determine if an event falls within the specified 23 * time-range is based on the CalDAV specification. 24 * 25 * @param DateTime $start 26 * @param DateTime $end 27 * @return bool 28 */ 29 public function isInTimeRange(\DateTime $start, \DateTime $end) { 30 31 $dtstart = isset($this->DTSTART)?$this->DTSTART->getDateTime():null; 32 if ($dtstart) { 33 $effectiveEnd = clone $dtstart; 34 if (!$this->DTSTART->hasTime()) { 35 $effectiveEnd->modify('+1 day'); 36 } 37 38 return ($start <= $effectiveEnd && $end > $dtstart); 39 40 } 41 return false; 42 43 } 44 45 /** 46 * A simple list of validation rules. 47 * 48 * This is simply a list of properties, and how many times they either 49 * must or must not appear. 50 * 51 * Possible values per property: 52 * * 0 - Must not appear. 53 * * 1 - Must appear exactly once. 54 * * + - Must appear at least once. 55 * * * - Can appear any number of times. 56 * * ? - May appear, but not more than once. 57 * 58 * @var array 59 */ 60 public function getValidationRules() { 61 62 return array( 63 'UID' => 1, 64 'DTSTAMP' => 1, 65 66 'CLASS' => '?', 67 'CREATED' => '?', 68 'DTSTART' => '?', 69 'LAST-MODIFIED' => '?', 70 'ORGANIZER' => '?', 71 'RECURRENCE-ID' => '?', 72 'SEQUENCE' => '?', 73 'STATUS' => '?', 74 'SUMMARY' => '?', 75 'URL' => '?', 76 77 'RRULE' => '?', 78 79 'ATTACH' => '*', 80 'ATTENDEE' => '*', 81 'CATEGORIES' => '*', 82 'COMMENT' => '*', 83 'CONTACT' => '*', 84 'DESCRIPTION' => '*', 85 'EXDATE' => '*', 86 'RELATED-TO' => '*', 87 'RDATE' => '*', 88 ); 89 90 } 91} 92