Completed
Pull Request — master (#7152)
by Georg
12:36
created
apps/dav/lib/CalDAV/CalendarObject.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -32,114 +32,114 @@
 block discarded – undo
32 32
 
33 33
 class CalendarObject extends \Sabre\CalDAV\CalendarObject {
34 34
 
35
-	/**
36
-	 * CalendarObject constructor.
37
-	 *
38
-	 * @param CalDavBackend $caldavBackend
39
-	 * @param array $calendarInfo
40
-	 * @param array $objectData
41
-	 */
42
-	public function __construct(CalDavBackend $caldavBackend, array $calendarInfo,
43
-								array $objectData) {
44
-		parent::__construct($caldavBackend, $calendarInfo, $objectData);
45
-
46
-		if ($this->isShared()) {
47
-			unset($this->objectData['size']);
48
-		}
49
-	}
50
-
51
-	/**
52
-	 * @inheritdoc
53
-	 */
54
-	function get() {
55
-		$data = parent::get();
56
-
57
-		if (!$this->isShared()) {
58
-			return $data;
59
-		}
60
-
61
-		$vObject = Reader::read($data);
62
-
63
-		// remove VAlarms if calendar is shared read-only
64
-		if (!$this->canWrite()) {
65
-			$this->removeVAlarms($vObject);
66
-		}
67
-
68
-		// shows as busy if event is declared confidential
69
-		if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL) {
70
-			$this->createConfidentialObject($vObject);
71
-		}
72
-
73
-		return $vObject->serialize();
74
-	}
75
-
76
-	protected function isShared() {
77
-		if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
78
-			return false;
79
-		}
80
-
81
-		return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri'];
82
-	}
83
-
84
-	/**
85
-	 * @param Component\VCalendar $vObject
86
-	 * @return void
87
-	 */
88
-	private static function createConfidentialObject(Component\VCalendar $vObject) {
89
-		/** @var Component $vElement */
90
-		$vElement = null;
91
-		if(isset($vObject->VEVENT)) {
92
-			$vElement = $vObject->VEVENT;
93
-		}
94
-		if(isset($vObject->VJOURNAL)) {
95
-			$vElement = $vObject->VJOURNAL;
96
-		}
97
-		if(isset($vObject->VTODO)) {
98
-			$vElement = $vObject->VTODO;
99
-		}
100
-		if(!is_null($vElement)) {
101
-			foreach ($vElement->children() as &$property) {
102
-				/** @var Property $property */
103
-				switch($property->name) {
104
-					case 'CREATED':
105
-					case 'DTSTART':
106
-					case 'RRULE':
107
-					case 'DURATION':
108
-					case 'DTEND':
109
-					case 'CLASS':
110
-					case 'UID':
111
-						break;
112
-					case 'SUMMARY':
113
-						$property->setValue('Busy');
114
-						break;
115
-					default:
116
-						$vElement->__unset($property->name);
117
-						unset($property);
118
-						break;
119
-				}
120
-			}
121
-		}
122
-	}
123
-
124
-	/**
125
-	 * @param Component\VCalendar $vObject
126
-	 * @return void
127
-	 */
128
-	private function removeVAlarms(Component\VCalendar $vObject) {
129
-		$subcomponents = $vObject->getComponents();
130
-
131
-		foreach($subcomponents as $subcomponent) {
132
-			unset($subcomponent->VALARM);
133
-		}
134
-	}
135
-
136
-	/**
137
-	 * @return bool
138
-	 */
139
-	private function canWrite() {
140
-		if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) {
141
-			return !$this->calendarInfo['{http://owncloud.org/ns}read-only'];
142
-		}
143
-		return true;
144
-	}
35
+    /**
36
+     * CalendarObject constructor.
37
+     *
38
+     * @param CalDavBackend $caldavBackend
39
+     * @param array $calendarInfo
40
+     * @param array $objectData
41
+     */
42
+    public function __construct(CalDavBackend $caldavBackend, array $calendarInfo,
43
+                                array $objectData) {
44
+        parent::__construct($caldavBackend, $calendarInfo, $objectData);
45
+
46
+        if ($this->isShared()) {
47
+            unset($this->objectData['size']);
48
+        }
49
+    }
50
+
51
+    /**
52
+     * @inheritdoc
53
+     */
54
+    function get() {
55
+        $data = parent::get();
56
+
57
+        if (!$this->isShared()) {
58
+            return $data;
59
+        }
60
+
61
+        $vObject = Reader::read($data);
62
+
63
+        // remove VAlarms if calendar is shared read-only
64
+        if (!$this->canWrite()) {
65
+            $this->removeVAlarms($vObject);
66
+        }
67
+
68
+        // shows as busy if event is declared confidential
69
+        if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL) {
70
+            $this->createConfidentialObject($vObject);
71
+        }
72
+
73
+        return $vObject->serialize();
74
+    }
75
+
76
+    protected function isShared() {
77
+        if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
78
+            return false;
79
+        }
80
+
81
+        return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri'];
82
+    }
83
+
84
+    /**
85
+     * @param Component\VCalendar $vObject
86
+     * @return void
87
+     */
88
+    private static function createConfidentialObject(Component\VCalendar $vObject) {
89
+        /** @var Component $vElement */
90
+        $vElement = null;
91
+        if(isset($vObject->VEVENT)) {
92
+            $vElement = $vObject->VEVENT;
93
+        }
94
+        if(isset($vObject->VJOURNAL)) {
95
+            $vElement = $vObject->VJOURNAL;
96
+        }
97
+        if(isset($vObject->VTODO)) {
98
+            $vElement = $vObject->VTODO;
99
+        }
100
+        if(!is_null($vElement)) {
101
+            foreach ($vElement->children() as &$property) {
102
+                /** @var Property $property */
103
+                switch($property->name) {
104
+                    case 'CREATED':
105
+                    case 'DTSTART':
106
+                    case 'RRULE':
107
+                    case 'DURATION':
108
+                    case 'DTEND':
109
+                    case 'CLASS':
110
+                    case 'UID':
111
+                        break;
112
+                    case 'SUMMARY':
113
+                        $property->setValue('Busy');
114
+                        break;
115
+                    default:
116
+                        $vElement->__unset($property->name);
117
+                        unset($property);
118
+                        break;
119
+                }
120
+            }
121
+        }
122
+    }
123
+
124
+    /**
125
+     * @param Component\VCalendar $vObject
126
+     * @return void
127
+     */
128
+    private function removeVAlarms(Component\VCalendar $vObject) {
129
+        $subcomponents = $vObject->getComponents();
130
+
131
+        foreach($subcomponents as $subcomponent) {
132
+            unset($subcomponent->VALARM);
133
+        }
134
+    }
135
+
136
+    /**
137
+     * @return bool
138
+     */
139
+    private function canWrite() {
140
+        if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) {
141
+            return !$this->calendarInfo['{http://owncloud.org/ns}read-only'];
142
+        }
143
+        return true;
144
+    }
145 145
 }
Please login to merge, or discard this patch.