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