4 * SystemStatus notification
6 * This notification can be used to indicate to the user that the system is
11 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
12 * @author Evert Pot (http://www.rooftopsolutions.nl/)
13 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
15 class Sabre_CalDAV_Notifications_Notification_SystemStatus extends Sabre_DAV_Property implements Sabre_CalDAV_Notifications_INotificationType {
18 const TYPE_MEDIUM = 2;
29 * The type of alert. This should be one of the TYPE_ constants.
36 * A human-readable description of the problem.
40 protected $description;
43 * A url to a website with more information for the user.
50 * Creates the notification.
52 * Some kind of unique id should be provided. This is used to generate a
57 * @param string $description
60 public function __construct($id, $type = self::TYPE_HIGH, $description = null, $href = null) {
64 $this->description = $description;
70 * Serializes the notification as a single property.
72 * You should usually just encode the single top-level element of the
75 * @param Sabre_DAV_Server $server
76 * @param DOMElement $node
79 public function serialize(Sabre_DAV_Server $server, \DOMElement $node) {
85 case self::TYPE_MEDIUM :
89 case self::TYPE_HIGH :
94 $prop = $node->ownerDocument->createElement('cs:systemstatus');
95 $prop->setAttribute('type', $type);
97 $node->appendChild($prop);
102 * This method serializes the entire notification, as it is used in the
105 * @param Sabre_DAV_Server $server
106 * @param DOMElement $node
109 public function serializeBody(Sabre_DAV_Server $server, \DOMElement $node) {
111 switch($this->type) {
112 case self::TYPE_LOW :
115 case self::TYPE_MEDIUM :
119 case self::TYPE_HIGH :
124 $prop = $node->ownerDocument->createElement('cs:systemstatus');
125 $prop->setAttribute('type', $type);
127 if ($this->description) {
128 $text = $node->ownerDocument->createTextNode($this->description);
129 $desc = $node->ownerDocument->createElement('cs:description');
130 $desc->appendChild($text);
131 $prop->appendChild($desc);
134 $text = $node->ownerDocument->createTextNode($this->href);
135 $href = $node->ownerDocument->createElement('d:href');
136 $href->appendChild($text);
137 $prop->appendChild($href);
140 $node->appendChild($prop);
145 * Returns a unique id for this notification
147 * This is just the base url. This should generally be some kind of unique
152 public function getId() {