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