VJournal.php 2.3 KB

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