xref: /plugin/davcal/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\CalDAV\Xml\Property;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\Xml\XmlSerializable;
6*a1a3b679SAndreas Boehleruse Sabre\Xml\Writer;
7*a1a3b679SAndreas Boehleruse Sabre\CalDAV\Plugin;
8*a1a3b679SAndreas Boehler
9*a1a3b679SAndreas Boehler/**
10*a1a3b679SAndreas Boehler * AllowedSharingModes
11*a1a3b679SAndreas Boehler *
12*a1a3b679SAndreas Boehler * This property encodes the 'allowed-sharing-modes' property, as defined by
13*a1a3b679SAndreas Boehler * the 'caldav-sharing-02' spec, in the http://calendarserver.org/ns/
14*a1a3b679SAndreas Boehler * namespace.
15*a1a3b679SAndreas Boehler *
16*a1a3b679SAndreas Boehler * This property is a representation of the supported-calendar_component-set
17*a1a3b679SAndreas Boehler * property in the CalDAV namespace. It simply requires an array of components,
18*a1a3b679SAndreas Boehler * such as VEVENT, VTODO
19*a1a3b679SAndreas Boehler *
20*a1a3b679SAndreas Boehler * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt
21*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
22*a1a3b679SAndreas Boehler * @author Evert Pot (http://www.rooftopsolutions.nl/)
23*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License
24*a1a3b679SAndreas Boehler */
25*a1a3b679SAndreas Boehlerclass AllowedSharingModes implements XmlSerializable {
26*a1a3b679SAndreas Boehler
27*a1a3b679SAndreas Boehler    /**
28*a1a3b679SAndreas Boehler     * Whether or not a calendar can be shared with another user
29*a1a3b679SAndreas Boehler     *
30*a1a3b679SAndreas Boehler     * @var bool
31*a1a3b679SAndreas Boehler     */
32*a1a3b679SAndreas Boehler    protected $canBeShared;
33*a1a3b679SAndreas Boehler
34*a1a3b679SAndreas Boehler    /**
35*a1a3b679SAndreas Boehler     * Whether or not the calendar can be placed on a public url.
36*a1a3b679SAndreas Boehler     *
37*a1a3b679SAndreas Boehler     * @var bool
38*a1a3b679SAndreas Boehler     */
39*a1a3b679SAndreas Boehler    protected $canBePublished;
40*a1a3b679SAndreas Boehler
41*a1a3b679SAndreas Boehler    /**
42*a1a3b679SAndreas Boehler     * Constructor
43*a1a3b679SAndreas Boehler     *
44*a1a3b679SAndreas Boehler     * @param bool $canBeShared
45*a1a3b679SAndreas Boehler     * @param bool $canBePublished
46*a1a3b679SAndreas Boehler     * @return void
47*a1a3b679SAndreas Boehler     */
48*a1a3b679SAndreas Boehler    function __construct($canBeShared, $canBePublished) {
49*a1a3b679SAndreas Boehler
50*a1a3b679SAndreas Boehler        $this->canBeShared = $canBeShared;
51*a1a3b679SAndreas Boehler        $this->canBePublished = $canBePublished;
52*a1a3b679SAndreas Boehler
53*a1a3b679SAndreas Boehler    }
54*a1a3b679SAndreas Boehler
55*a1a3b679SAndreas Boehler    /**
56*a1a3b679SAndreas Boehler     * The xmlSerialize metod is called during xml writing.
57*a1a3b679SAndreas Boehler     *
58*a1a3b679SAndreas Boehler     * Use the $writer argument to write its own xml serialization.
59*a1a3b679SAndreas Boehler     *
60*a1a3b679SAndreas Boehler     * An important note: do _not_ create a parent element. Any element
61*a1a3b679SAndreas Boehler     * implementing XmlSerializble should only ever write what's considered
62*a1a3b679SAndreas Boehler     * its 'inner xml'.
63*a1a3b679SAndreas Boehler     *
64*a1a3b679SAndreas Boehler     * The parent of the current element is responsible for writing a
65*a1a3b679SAndreas Boehler     * containing element.
66*a1a3b679SAndreas Boehler     *
67*a1a3b679SAndreas Boehler     * This allows serializers to be re-used for different element names.
68*a1a3b679SAndreas Boehler     *
69*a1a3b679SAndreas Boehler     * If you are opening new elements, you must also close them again.
70*a1a3b679SAndreas Boehler     *
71*a1a3b679SAndreas Boehler     * @param Writer $writer
72*a1a3b679SAndreas Boehler     * @return void
73*a1a3b679SAndreas Boehler     */
74*a1a3b679SAndreas Boehler    function xmlSerialize(Writer $writer) {
75*a1a3b679SAndreas Boehler
76*a1a3b679SAndreas Boehler        if ($this->canBeShared) {
77*a1a3b679SAndreas Boehler            $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-shared');
78*a1a3b679SAndreas Boehler        }
79*a1a3b679SAndreas Boehler        if ($this->canBePublished) {
80*a1a3b679SAndreas Boehler            $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-published');
81*a1a3b679SAndreas Boehler        }
82*a1a3b679SAndreas Boehler
83*a1a3b679SAndreas Boehler    }
84*a1a3b679SAndreas Boehler
85*a1a3b679SAndreas Boehler
86*a1a3b679SAndreas Boehler
87*a1a3b679SAndreas Boehler}
88