VJournal.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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) 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. * * ? - May appear, but not more than once.
  48. *
  49. * @var array
  50. */
  51. public function getValidationRules() {
  52. return array(
  53. 'UID' => 1,
  54. 'DTSTAMP' => 1,
  55. 'CLASS' => '?',
  56. 'CREATED' => '?',
  57. 'DTSTART' => '?',
  58. 'LAST-MODIFIED' => '?',
  59. 'ORGANIZER' => '?',
  60. 'RECURRENCE-ID' => '?',
  61. 'SEQUENCE' => '?',
  62. 'STATUS' => '?',
  63. 'SUMMARY' => '?',
  64. 'URL' => '?',
  65. 'RRULE' => '?',
  66. 'ATTACH' => '*',
  67. 'ATTENDEE' => '*',
  68. 'CATEGORIES' => '*',
  69. 'COMMENT' => '*',
  70. 'CONTACT' => '*',
  71. 'DESCRIPTION' => '*',
  72. 'EXDATE' => '*',
  73. 'RELATED-TO' => '*',
  74. 'RDATE' => '*',
  75. );
  76. }
  77. }