@@ -38,281 +38,281 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { |
| 40 | 40 | |
| 41 | - public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n) { |
|
| 42 | - parent::__construct($caldavBackend, $calendarInfo); |
|
| 43 | - |
|
| 44 | - if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
| 45 | - $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Contact birthdays'); |
|
| 46 | - } |
|
| 47 | - if ($this->getName() === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
| 48 | - $this->calendarInfo['{DAV:}displayname'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
| 49 | - $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Personal'); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Updates the list of shares. |
|
| 55 | - * |
|
| 56 | - * The first array is a list of people that are to be added to the |
|
| 57 | - * resource. |
|
| 58 | - * |
|
| 59 | - * Every element in the add array has the following properties: |
|
| 60 | - * * href - A url. Usually a mailto: address |
|
| 61 | - * * commonName - Usually a first and last name, or false |
|
| 62 | - * * summary - A description of the share, can also be false |
|
| 63 | - * * readOnly - A boolean value |
|
| 64 | - * |
|
| 65 | - * Every element in the remove array is just the address string. |
|
| 66 | - * |
|
| 67 | - * @param array $add |
|
| 68 | - * @param array $remove |
|
| 69 | - * @return void |
|
| 70 | - * @throws Forbidden |
|
| 71 | - */ |
|
| 72 | - public function updateShares(array $add, array $remove) { |
|
| 73 | - if ($this->isShared()) { |
|
| 74 | - throw new Forbidden(); |
|
| 75 | - } |
|
| 76 | - $this->caldavBackend->updateShares($this, $add, $remove); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Returns the list of people whom this resource is shared with. |
|
| 81 | - * |
|
| 82 | - * Every element in this array should have the following properties: |
|
| 83 | - * * href - Often a mailto: address |
|
| 84 | - * * commonName - Optional, for example a first + last name |
|
| 85 | - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
| 86 | - * * readOnly - boolean |
|
| 87 | - * * summary - Optional, a description for the share |
|
| 88 | - * |
|
| 89 | - * @return array |
|
| 90 | - */ |
|
| 91 | - public function getShares() { |
|
| 92 | - if ($this->isShared()) { |
|
| 93 | - return []; |
|
| 94 | - } |
|
| 95 | - return $this->caldavBackend->getShares($this->getResourceId()); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @return int |
|
| 100 | - */ |
|
| 101 | - public function getResourceId() { |
|
| 102 | - return $this->calendarInfo['id']; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return string |
|
| 107 | - */ |
|
| 108 | - public function getPrincipalURI() { |
|
| 109 | - return $this->calendarInfo['principaluri']; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - public function getACL() { |
|
| 113 | - $acl = [ |
|
| 114 | - [ |
|
| 115 | - 'privilege' => '{DAV:}read', |
|
| 116 | - 'principal' => $this->getOwner(), |
|
| 117 | - 'protected' => true, |
|
| 118 | - ]]; |
|
| 119 | - if ($this->getName() !== BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
| 120 | - $acl[] = [ |
|
| 121 | - 'privilege' => '{DAV:}write', |
|
| 122 | - 'principal' => $this->getOwner(), |
|
| 123 | - 'protected' => true, |
|
| 124 | - ]; |
|
| 125 | - } else { |
|
| 126 | - $acl[] = [ |
|
| 127 | - 'privilege' => '{DAV:}write-properties', |
|
| 128 | - 'principal' => $this->getOwner(), |
|
| 129 | - 'protected' => true, |
|
| 130 | - ]; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if ($this->getOwner() !== parent::getOwner()) { |
|
| 134 | - $acl[] = [ |
|
| 135 | - 'privilege' => '{DAV:}read', |
|
| 136 | - 'principal' => parent::getOwner(), |
|
| 137 | - 'protected' => true, |
|
| 138 | - ]; |
|
| 139 | - if ($this->canWrite()) { |
|
| 140 | - $acl[] = [ |
|
| 141 | - 'privilege' => '{DAV:}write', |
|
| 142 | - 'principal' => parent::getOwner(), |
|
| 143 | - 'protected' => true, |
|
| 144 | - ]; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - if ($this->isPublic()) { |
|
| 148 | - $acl[] = [ |
|
| 149 | - 'privilege' => '{DAV:}read', |
|
| 150 | - 'principal' => 'principals/system/public', |
|
| 151 | - 'protected' => true, |
|
| 152 | - ]; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl); |
|
| 156 | - |
|
| 157 | - if (!$this->isShared()) { |
|
| 158 | - return $acl; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public']; |
|
| 162 | - return array_filter($acl, function($rule) use ($allowedPrincipals) { |
|
| 163 | - return in_array($rule['principal'], $allowedPrincipals); |
|
| 164 | - }); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - public function getChildACL() { |
|
| 168 | - return $this->getACL(); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - public function getOwner() { |
|
| 172 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 173 | - return $this->calendarInfo['{http://owncloud.org/ns}owner-principal']; |
|
| 174 | - } |
|
| 175 | - return parent::getOwner(); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - public function delete() { |
|
| 179 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && |
|
| 180 | - $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']) { |
|
| 181 | - $principal = 'principal:' . parent::getOwner(); |
|
| 182 | - $shares = $this->caldavBackend->getShares($this->getResourceId()); |
|
| 183 | - $shares = array_filter($shares, function($share) use ($principal){ |
|
| 184 | - return $share['href'] === $principal; |
|
| 185 | - }); |
|
| 186 | - if (empty($shares)) { |
|
| 187 | - throw new Forbidden(); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $this->caldavBackend->updateShares($this, [], [ |
|
| 191 | - 'href' => $principal |
|
| 192 | - ]); |
|
| 193 | - return; |
|
| 194 | - } |
|
| 195 | - parent::delete(); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - public function propPatch(PropPatch $propPatch) { |
|
| 199 | - // parent::propPatch will only update calendars table |
|
| 200 | - // if calendar is shared, changes have to be made to the properties table |
|
| 201 | - if (!$this->isShared()) { |
|
| 202 | - parent::propPatch($propPatch); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - public function getChild($name) { |
|
| 207 | - |
|
| 208 | - $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
| 209 | - |
|
| 210 | - if (!$obj) { |
|
| 211 | - throw new NotFound('Calendar object not found'); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 215 | - throw new NotFound('Calendar object not found'); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - $obj['acl'] = $this->getChildACL(); |
|
| 219 | - |
|
| 220 | - return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
| 221 | - |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - public function getChildren() { |
|
| 225 | - |
|
| 226 | - $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); |
|
| 227 | - $children = []; |
|
| 228 | - foreach ($objs as $obj) { |
|
| 229 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 230 | - continue; |
|
| 231 | - } |
|
| 232 | - $obj['acl'] = $this->getChildACL(); |
|
| 233 | - $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
| 234 | - } |
|
| 235 | - return $children; |
|
| 236 | - |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - public function getMultipleChildren(array $paths) { |
|
| 240 | - |
|
| 241 | - $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); |
|
| 242 | - $children = []; |
|
| 243 | - foreach ($objs as $obj) { |
|
| 244 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 245 | - continue; |
|
| 246 | - } |
|
| 247 | - $obj['acl'] = $this->getChildACL(); |
|
| 248 | - $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
| 249 | - } |
|
| 250 | - return $children; |
|
| 251 | - |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - public function childExists($name) { |
|
| 255 | - $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
| 256 | - if (!$obj) { |
|
| 257 | - return false; |
|
| 258 | - } |
|
| 259 | - if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 260 | - return false; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - return true; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - public function calendarQuery(array $filters) { |
|
| 267 | - |
|
| 268 | - $uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); |
|
| 269 | - if ($this->isShared()) { |
|
| 270 | - return array_filter($uris, function ($uri) { |
|
| 271 | - return $this->childExists($uri); |
|
| 272 | - }); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - return $uris; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * @param boolean $value |
|
| 280 | - * @return string|null |
|
| 281 | - */ |
|
| 282 | - public function setPublishStatus($value) { |
|
| 283 | - $publicUri = $this->caldavBackend->setPublishStatus($value, $this); |
|
| 284 | - $this->calendarInfo['publicuri'] = $publicUri; |
|
| 285 | - return $publicUri; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * @return mixed $value |
|
| 290 | - */ |
|
| 291 | - public function getPublishStatus() { |
|
| 292 | - return $this->caldavBackend->getPublishStatus($this); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - private function canWrite() { |
|
| 296 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
| 297 | - return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
| 298 | - } |
|
| 299 | - return true; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - private function isPublic() { |
|
| 303 | - return isset($this->calendarInfo['{http://owncloud.org/ns}public']); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - protected function isShared() { |
|
| 307 | - if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 308 | - return false; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - public function isSubscription() { |
|
| 315 | - return isset($this->calendarInfo['{http://calendarserver.org/ns/}source']); |
|
| 316 | - } |
|
| 41 | + public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n) { |
|
| 42 | + parent::__construct($caldavBackend, $calendarInfo); |
|
| 43 | + |
|
| 44 | + if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
| 45 | + $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Contact birthdays'); |
|
| 46 | + } |
|
| 47 | + if ($this->getName() === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
| 48 | + $this->calendarInfo['{DAV:}displayname'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
| 49 | + $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Personal'); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Updates the list of shares. |
|
| 55 | + * |
|
| 56 | + * The first array is a list of people that are to be added to the |
|
| 57 | + * resource. |
|
| 58 | + * |
|
| 59 | + * Every element in the add array has the following properties: |
|
| 60 | + * * href - A url. Usually a mailto: address |
|
| 61 | + * * commonName - Usually a first and last name, or false |
|
| 62 | + * * summary - A description of the share, can also be false |
|
| 63 | + * * readOnly - A boolean value |
|
| 64 | + * |
|
| 65 | + * Every element in the remove array is just the address string. |
|
| 66 | + * |
|
| 67 | + * @param array $add |
|
| 68 | + * @param array $remove |
|
| 69 | + * @return void |
|
| 70 | + * @throws Forbidden |
|
| 71 | + */ |
|
| 72 | + public function updateShares(array $add, array $remove) { |
|
| 73 | + if ($this->isShared()) { |
|
| 74 | + throw new Forbidden(); |
|
| 75 | + } |
|
| 76 | + $this->caldavBackend->updateShares($this, $add, $remove); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Returns the list of people whom this resource is shared with. |
|
| 81 | + * |
|
| 82 | + * Every element in this array should have the following properties: |
|
| 83 | + * * href - Often a mailto: address |
|
| 84 | + * * commonName - Optional, for example a first + last name |
|
| 85 | + * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
| 86 | + * * readOnly - boolean |
|
| 87 | + * * summary - Optional, a description for the share |
|
| 88 | + * |
|
| 89 | + * @return array |
|
| 90 | + */ |
|
| 91 | + public function getShares() { |
|
| 92 | + if ($this->isShared()) { |
|
| 93 | + return []; |
|
| 94 | + } |
|
| 95 | + return $this->caldavBackend->getShares($this->getResourceId()); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @return int |
|
| 100 | + */ |
|
| 101 | + public function getResourceId() { |
|
| 102 | + return $this->calendarInfo['id']; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 108 | + public function getPrincipalURI() { |
|
| 109 | + return $this->calendarInfo['principaluri']; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + public function getACL() { |
|
| 113 | + $acl = [ |
|
| 114 | + [ |
|
| 115 | + 'privilege' => '{DAV:}read', |
|
| 116 | + 'principal' => $this->getOwner(), |
|
| 117 | + 'protected' => true, |
|
| 118 | + ]]; |
|
| 119 | + if ($this->getName() !== BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
| 120 | + $acl[] = [ |
|
| 121 | + 'privilege' => '{DAV:}write', |
|
| 122 | + 'principal' => $this->getOwner(), |
|
| 123 | + 'protected' => true, |
|
| 124 | + ]; |
|
| 125 | + } else { |
|
| 126 | + $acl[] = [ |
|
| 127 | + 'privilege' => '{DAV:}write-properties', |
|
| 128 | + 'principal' => $this->getOwner(), |
|
| 129 | + 'protected' => true, |
|
| 130 | + ]; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if ($this->getOwner() !== parent::getOwner()) { |
|
| 134 | + $acl[] = [ |
|
| 135 | + 'privilege' => '{DAV:}read', |
|
| 136 | + 'principal' => parent::getOwner(), |
|
| 137 | + 'protected' => true, |
|
| 138 | + ]; |
|
| 139 | + if ($this->canWrite()) { |
|
| 140 | + $acl[] = [ |
|
| 141 | + 'privilege' => '{DAV:}write', |
|
| 142 | + 'principal' => parent::getOwner(), |
|
| 143 | + 'protected' => true, |
|
| 144 | + ]; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + if ($this->isPublic()) { |
|
| 148 | + $acl[] = [ |
|
| 149 | + 'privilege' => '{DAV:}read', |
|
| 150 | + 'principal' => 'principals/system/public', |
|
| 151 | + 'protected' => true, |
|
| 152 | + ]; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + $acl = $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl); |
|
| 156 | + |
|
| 157 | + if (!$this->isShared()) { |
|
| 158 | + return $acl; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + $allowedPrincipals = [$this->getOwner(), parent::getOwner(), 'principals/system/public']; |
|
| 162 | + return array_filter($acl, function($rule) use ($allowedPrincipals) { |
|
| 163 | + return in_array($rule['principal'], $allowedPrincipals); |
|
| 164 | + }); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + public function getChildACL() { |
|
| 168 | + return $this->getACL(); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + public function getOwner() { |
|
| 172 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 173 | + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal']; |
|
| 174 | + } |
|
| 175 | + return parent::getOwner(); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + public function delete() { |
|
| 179 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && |
|
| 180 | + $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']) { |
|
| 181 | + $principal = 'principal:' . parent::getOwner(); |
|
| 182 | + $shares = $this->caldavBackend->getShares($this->getResourceId()); |
|
| 183 | + $shares = array_filter($shares, function($share) use ($principal){ |
|
| 184 | + return $share['href'] === $principal; |
|
| 185 | + }); |
|
| 186 | + if (empty($shares)) { |
|
| 187 | + throw new Forbidden(); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $this->caldavBackend->updateShares($this, [], [ |
|
| 191 | + 'href' => $principal |
|
| 192 | + ]); |
|
| 193 | + return; |
|
| 194 | + } |
|
| 195 | + parent::delete(); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + public function propPatch(PropPatch $propPatch) { |
|
| 199 | + // parent::propPatch will only update calendars table |
|
| 200 | + // if calendar is shared, changes have to be made to the properties table |
|
| 201 | + if (!$this->isShared()) { |
|
| 202 | + parent::propPatch($propPatch); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + public function getChild($name) { |
|
| 207 | + |
|
| 208 | + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
| 209 | + |
|
| 210 | + if (!$obj) { |
|
| 211 | + throw new NotFound('Calendar object not found'); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 215 | + throw new NotFound('Calendar object not found'); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + $obj['acl'] = $this->getChildACL(); |
|
| 219 | + |
|
| 220 | + return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
| 221 | + |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + public function getChildren() { |
|
| 225 | + |
|
| 226 | + $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); |
|
| 227 | + $children = []; |
|
| 228 | + foreach ($objs as $obj) { |
|
| 229 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 230 | + continue; |
|
| 231 | + } |
|
| 232 | + $obj['acl'] = $this->getChildACL(); |
|
| 233 | + $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
| 234 | + } |
|
| 235 | + return $children; |
|
| 236 | + |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + public function getMultipleChildren(array $paths) { |
|
| 240 | + |
|
| 241 | + $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); |
|
| 242 | + $children = []; |
|
| 243 | + foreach ($objs as $obj) { |
|
| 244 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 245 | + continue; |
|
| 246 | + } |
|
| 247 | + $obj['acl'] = $this->getChildACL(); |
|
| 248 | + $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj); |
|
| 249 | + } |
|
| 250 | + return $children; |
|
| 251 | + |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + public function childExists($name) { |
|
| 255 | + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); |
|
| 256 | + if (!$obj) { |
|
| 257 | + return false; |
|
| 258 | + } |
|
| 259 | + if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) { |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + return true; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + public function calendarQuery(array $filters) { |
|
| 267 | + |
|
| 268 | + $uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); |
|
| 269 | + if ($this->isShared()) { |
|
| 270 | + return array_filter($uris, function ($uri) { |
|
| 271 | + return $this->childExists($uri); |
|
| 272 | + }); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + return $uris; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * @param boolean $value |
|
| 280 | + * @return string|null |
|
| 281 | + */ |
|
| 282 | + public function setPublishStatus($value) { |
|
| 283 | + $publicUri = $this->caldavBackend->setPublishStatus($value, $this); |
|
| 284 | + $this->calendarInfo['publicuri'] = $publicUri; |
|
| 285 | + return $publicUri; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * @return mixed $value |
|
| 290 | + */ |
|
| 291 | + public function getPublishStatus() { |
|
| 292 | + return $this->caldavBackend->getPublishStatus($this); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + private function canWrite() { |
|
| 296 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
| 297 | + return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
| 298 | + } |
|
| 299 | + return true; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + private function isPublic() { |
|
| 303 | + return isset($this->calendarInfo['{http://owncloud.org/ns}public']); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + protected function isShared() { |
|
| 307 | + if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 308 | + return false; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + public function isSubscription() { |
|
| 315 | + return isset($this->calendarInfo['{http://calendarserver.org/ns/}source']); |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | 318 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | public function getACL() { |
| 113 | - $acl = [ |
|
| 113 | + $acl = [ |
|
| 114 | 114 | [ |
| 115 | 115 | 'privilege' => '{DAV:}read', |
| 116 | 116 | 'principal' => $this->getOwner(), |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | if ($this->getOwner() !== parent::getOwner()) { |
| 134 | - $acl[] = [ |
|
| 134 | + $acl[] = [ |
|
| 135 | 135 | 'privilege' => '{DAV:}read', |
| 136 | 136 | 'principal' => parent::getOwner(), |
| 137 | 137 | 'protected' => true, |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function delete() { |
| 179 | 179 | if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && |
| 180 | 180 | $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']) { |
| 181 | - $principal = 'principal:' . parent::getOwner(); |
|
| 181 | + $principal = 'principal:'.parent::getOwner(); |
|
| 182 | 182 | $shares = $this->caldavBackend->getShares($this->getResourceId()); |
| 183 | 183 | $shares = array_filter($shares, function($share) use ($principal){ |
| 184 | 184 | return $share['href'] === $principal; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | $uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); |
| 269 | 269 | if ($this->isShared()) { |
| 270 | - return array_filter($uris, function ($uri) { |
|
| 270 | + return array_filter($uris, function($uri) { |
|
| 271 | 271 | return $this->childExists($uri); |
| 272 | 272 | }); |
| 273 | 273 | } |