Blame view

sources/3rdparty/sabre/dav/lib/Sabre/CalDAV/Property/ScheduleCalendarTransp.php 2.6 KB
03e52840d   Kload   Init
1
  <?php
6d9380f96   Cédric Dupont   Update sources OC...
2
3
4
5
  namespace Sabre\CalDAV\Property;
  
  use Sabre\DAV;
  use Sabre\CalDAV;
03e52840d   Kload   Init
6
7
8
9
10
11
12
13
14
15
  /**
   * schedule-calendar-transp property.
   *
   * This property is a representation of the schedule-calendar-transp property.
   * This property is defined in RFC6638 (caldav scheduling).
   *
   * Its values are either 'transparent' or 'opaque'. If it's transparent, it
   * means that this calendar will not be taken into consideration when a
   * different user queries for free-busy information. If it's 'opaque', it will.
   *
6d9380f96   Cédric Dupont   Update sources OC...
16
17
18
   * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
   * @author Evert Pot (http://evertpot.com/)
   * @license http://sabre.io/license/ Modified BSD License
03e52840d   Kload   Init
19
   */
6d9380f96   Cédric Dupont   Update sources OC...
20
  class ScheduleCalendarTransp extends DAV\Property {
03e52840d   Kload   Init
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  
      const TRANSPARENT = 'transparent';
      const OPAQUE = 'opaque';
  
      protected $value;
  
      /**
       * Creates the property
       *
       * @param string $value
       */
      public function __construct($value) {
  
          if ($value !== self::TRANSPARENT && $value !== self::OPAQUE) {
              throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"');
          }
          $this->value = $value;
  
      }
  
      /**
       * Returns the current value
       *
       * @return string
       */
      public function getValue() {
  
          return $this->value;
  
      }
  
      /**
       * Serializes the property in a DOMDocument
       *
6d9380f96   Cédric Dupont   Update sources OC...
55
56
       * @param DAV\Server $server
       * @param \DOMElement $node
03e52840d   Kload   Init
57
58
       * @return void
       */
6d9380f96   Cédric Dupont   Update sources OC...
59
      public function serialize(DAV\Server $server,\DOMElement $node) {
03e52840d   Kload   Init
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  
          $doc = $node->ownerDocument;
          switch($this->value) {
              case self::TRANSPARENT :
                  $xval = $doc->createElement('cal:transparent');
                  break;
              case self::OPAQUE :
                  $xval = $doc->createElement('cal:opaque');
                  break;
          }
  
          $node->appendChild($xval);
  
      }
  
      /**
       * Unserializes the DOMElement back into a Property class.
       *
6d9380f96   Cédric Dupont   Update sources OC...
78
79
       * @param \DOMElement $node
       * @return ScheduleCalendarTransp
03e52840d   Kload   Init
80
       */
6d9380f96   Cédric Dupont   Update sources OC...
81
      static function unserialize(\DOMElement $node) {
03e52840d   Kload   Init
82
83
84
  
          $value = null;
          foreach($node->childNodes as $childNode) {
6d9380f96   Cédric Dupont   Update sources OC...
85
86
              switch(DAV\XMLUtil::toClarkNotation($childNode)) {
                  case '{' . CalDAV\Plugin::NS_CALDAV . '}opaque' :
03e52840d   Kload   Init
87
88
                      $value = self::OPAQUE;
                      break;
6d9380f96   Cédric Dupont   Update sources OC...
89
                  case '{' . CalDAV\Plugin::NS_CALDAV . '}transparent' :
03e52840d   Kload   Init
90
91
92
93
94
95
96
97
98
99
100
                      $value = self::TRANSPARENT;
                      break;
              }
          }
          if (is_null($value))
             return null;
  
          return new self($value);
  
      }
  }