@@ -33,17 +33,17 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class Capabilities implements ICapability { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Return this classes capabilities |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - public function getCapabilities() { |
|
| 42 | - return [ |
|
| 43 | - 'files' => [ |
|
| 44 | - 'undelete' => true |
|
| 45 | - ] |
|
| 46 | - ]; |
|
| 47 | - } |
|
| 36 | + /** |
|
| 37 | + * Return this classes capabilities |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + public function getCapabilities() { |
|
| 42 | + return [ |
|
| 43 | + 'files' => [ |
|
| 44 | + 'undelete' => true |
|
| 45 | + ] |
|
| 46 | + ]; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
@@ -109,8 +109,8 @@ |
||
| 109 | 109 | throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"'; |
|
| 113 | - $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches); |
|
| 112 | + $regexValue = '\"'.self::REGEX_TIME.' '.self::REGEX_TIMEZONE.'\"'; |
|
| 113 | + $result = preg_match('/^\['.$regexValue.','.$regexValue.'\]$/', $value, $matches); |
|
| 114 | 114 | if (!$result) { |
| 115 | 115 | throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2); |
| 116 | 116 | } |
@@ -26,109 +26,109 @@ |
||
| 26 | 26 | use OCP\WorkflowEngine\ICheck; |
| 27 | 27 | |
| 28 | 28 | class RequestTime implements ICheck { |
| 29 | - public const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])'; |
|
| 30 | - public const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)'; |
|
| 31 | - |
|
| 32 | - /** @var bool[] */ |
|
| 33 | - protected $cachedResults; |
|
| 34 | - |
|
| 35 | - /** @var IL10N */ |
|
| 36 | - protected $l; |
|
| 37 | - |
|
| 38 | - /** @var ITimeFactory */ |
|
| 39 | - protected $timeFactory; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param ITimeFactory $timeFactory |
|
| 43 | - */ |
|
| 44 | - public function __construct(IL10N $l, ITimeFactory $timeFactory) { |
|
| 45 | - $this->l = $l; |
|
| 46 | - $this->timeFactory = $timeFactory; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param string $operator |
|
| 51 | - * @param string $value |
|
| 52 | - * @return bool |
|
| 53 | - */ |
|
| 54 | - public function executeCheck($operator, $value) { |
|
| 55 | - $valueHash = md5($value); |
|
| 56 | - |
|
| 57 | - if (isset($this->cachedResults[$valueHash])) { |
|
| 58 | - return $this->cachedResults[$valueHash]; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - $timestamp = $this->timeFactory->getTime(); |
|
| 62 | - |
|
| 63 | - $values = json_decode($value, true); |
|
| 64 | - $timestamp1 = $this->getTimestamp($timestamp, $values[0]); |
|
| 65 | - $timestamp2 = $this->getTimestamp($timestamp, $values[1]); |
|
| 66 | - |
|
| 67 | - if ($timestamp1 < $timestamp2) { |
|
| 68 | - $in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2; |
|
| 69 | - } else { |
|
| 70 | - $in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - return ($operator === 'in') ? $in : !$in; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param int $currentTimestamp |
|
| 78 | - * @param string $value Format: "H:i e" |
|
| 79 | - * @return int |
|
| 80 | - */ |
|
| 81 | - protected function getTimestamp($currentTimestamp, $value) { |
|
| 82 | - list($time1, $timezone1) = explode(' ', $value); |
|
| 83 | - list($hour1, $minute1) = explode(':', $time1); |
|
| 84 | - $date1 = new \DateTime('now', new \DateTimeZone($timezone1)); |
|
| 85 | - $date1->setTimestamp($currentTimestamp); |
|
| 86 | - $date1->setTime($hour1, $minute1); |
|
| 87 | - |
|
| 88 | - return $date1->getTimestamp(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @param string $operator |
|
| 93 | - * @param string $value |
|
| 94 | - * @throws \UnexpectedValueException |
|
| 95 | - */ |
|
| 96 | - public function validateCheck($operator, $value) { |
|
| 97 | - if (!in_array($operator, ['in', '!in'])) { |
|
| 98 | - throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"'; |
|
| 102 | - $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches); |
|
| 103 | - if (!$result) { |
|
| 104 | - throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $values = json_decode($value, true); |
|
| 108 | - $time1 = \DateTime::createFromFormat('H:i e', $values[0]); |
|
| 109 | - if ($time1 === false) { |
|
| 110 | - throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $time2 = \DateTime::createFromFormat('H:i e', $values[1]); |
|
| 114 | - if ($time2 === false) { |
|
| 115 | - throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function isAvailableForScope(int $scope): bool { |
|
| 120 | - return true; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * returns a list of Entities the checker supports. The values must match |
|
| 125 | - * the class name of the entity. |
|
| 126 | - * |
|
| 127 | - * An empty result means the check is universally available. |
|
| 128 | - * |
|
| 129 | - * @since 18.0.0 |
|
| 130 | - */ |
|
| 131 | - public function supportedEntities(): array { |
|
| 132 | - return []; |
|
| 133 | - } |
|
| 29 | + public const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])'; |
|
| 30 | + public const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)'; |
|
| 31 | + |
|
| 32 | + /** @var bool[] */ |
|
| 33 | + protected $cachedResults; |
|
| 34 | + |
|
| 35 | + /** @var IL10N */ |
|
| 36 | + protected $l; |
|
| 37 | + |
|
| 38 | + /** @var ITimeFactory */ |
|
| 39 | + protected $timeFactory; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param ITimeFactory $timeFactory |
|
| 43 | + */ |
|
| 44 | + public function __construct(IL10N $l, ITimeFactory $timeFactory) { |
|
| 45 | + $this->l = $l; |
|
| 46 | + $this->timeFactory = $timeFactory; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param string $operator |
|
| 51 | + * @param string $value |
|
| 52 | + * @return bool |
|
| 53 | + */ |
|
| 54 | + public function executeCheck($operator, $value) { |
|
| 55 | + $valueHash = md5($value); |
|
| 56 | + |
|
| 57 | + if (isset($this->cachedResults[$valueHash])) { |
|
| 58 | + return $this->cachedResults[$valueHash]; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + $timestamp = $this->timeFactory->getTime(); |
|
| 62 | + |
|
| 63 | + $values = json_decode($value, true); |
|
| 64 | + $timestamp1 = $this->getTimestamp($timestamp, $values[0]); |
|
| 65 | + $timestamp2 = $this->getTimestamp($timestamp, $values[1]); |
|
| 66 | + |
|
| 67 | + if ($timestamp1 < $timestamp2) { |
|
| 68 | + $in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2; |
|
| 69 | + } else { |
|
| 70 | + $in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + return ($operator === 'in') ? $in : !$in; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param int $currentTimestamp |
|
| 78 | + * @param string $value Format: "H:i e" |
|
| 79 | + * @return int |
|
| 80 | + */ |
|
| 81 | + protected function getTimestamp($currentTimestamp, $value) { |
|
| 82 | + list($time1, $timezone1) = explode(' ', $value); |
|
| 83 | + list($hour1, $minute1) = explode(':', $time1); |
|
| 84 | + $date1 = new \DateTime('now', new \DateTimeZone($timezone1)); |
|
| 85 | + $date1->setTimestamp($currentTimestamp); |
|
| 86 | + $date1->setTime($hour1, $minute1); |
|
| 87 | + |
|
| 88 | + return $date1->getTimestamp(); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @param string $operator |
|
| 93 | + * @param string $value |
|
| 94 | + * @throws \UnexpectedValueException |
|
| 95 | + */ |
|
| 96 | + public function validateCheck($operator, $value) { |
|
| 97 | + if (!in_array($operator, ['in', '!in'])) { |
|
| 98 | + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"'; |
|
| 102 | + $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches); |
|
| 103 | + if (!$result) { |
|
| 104 | + throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + $values = json_decode($value, true); |
|
| 108 | + $time1 = \DateTime::createFromFormat('H:i e', $values[0]); |
|
| 109 | + if ($time1 === false) { |
|
| 110 | + throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $time2 = \DateTime::createFromFormat('H:i e', $values[1]); |
|
| 114 | + if ($time2 === false) { |
|
| 115 | + throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function isAvailableForScope(int $scope): bool { |
|
| 120 | + return true; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * returns a list of Entities the checker supports. The values must match |
|
| 125 | + * the class name of the entity. |
|
| 126 | + * |
|
| 127 | + * An empty result means the check is universally available. |
|
| 128 | + * |
|
| 129 | + * @since 18.0.0 |
|
| 130 | + */ |
|
| 131 | + public function supportedEntities(): array { |
|
| 132 | + return []; |
|
| 133 | + } |
|
| 134 | 134 | } |
@@ -34,23 +34,23 @@ |
||
| 34 | 34 | * ] |
| 35 | 35 | */ |
| 36 | 36 | class AlternativeHomeUserBackend extends \OC\User\Database { |
| 37 | - public function __construct() { |
|
| 38 | - parent::__construct(); |
|
| 39 | - } |
|
| 40 | - /** |
|
| 41 | - * get the user's home directory |
|
| 42 | - * @param string $uid the username |
|
| 43 | - * @return string|false |
|
| 44 | - */ |
|
| 45 | - public function getHome($uid) { |
|
| 46 | - if ($this->userExists($uid)) { |
|
| 47 | - // workaround to avoid killing the admin |
|
| 48 | - if ($uid !== 'admin') { |
|
| 49 | - $uid = md5($uid); |
|
| 50 | - } |
|
| 51 | - return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
| 52 | - } |
|
| 37 | + public function __construct() { |
|
| 38 | + parent::__construct(); |
|
| 39 | + } |
|
| 40 | + /** |
|
| 41 | + * get the user's home directory |
|
| 42 | + * @param string $uid the username |
|
| 43 | + * @return string|false |
|
| 44 | + */ |
|
| 45 | + public function getHome($uid) { |
|
| 46 | + if ($this->userExists($uid)) { |
|
| 47 | + // workaround to avoid killing the admin |
|
| 48 | + if ($uid !== 'admin') { |
|
| 49 | + $uid = md5($uid); |
|
| 50 | + } |
|
| 51 | + return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return false; |
|
| 55 | - } |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | if ($uid !== 'admin') { |
| 49 | 49 | $uid = md5($uid); |
| 50 | 50 | } |
| 51 | - return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
| 51 | + return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/'.$uid; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return false; |
@@ -184,12 +184,12 @@ |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | try { |
| 187 | - $this->getDisplayNameFromContact($user . '@http://' . $server); |
|
| 187 | + $this->getDisplayNameFromContact($user.'@http://'.$server); |
|
| 188 | 188 | } catch (\OutOfBoundsException $e) { |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | try { |
| 192 | - $this->getDisplayNameFromContact($user . '@https://' . $server); |
|
| 192 | + $this->getDisplayNameFromContact($user.'@https://'.$server); |
|
| 193 | 193 | } catch (\OutOfBoundsException $e) { |
| 194 | 194 | } |
| 195 | 195 | |
@@ -35,229 +35,229 @@ |
||
| 35 | 35 | use OCP\Notification\INotifier; |
| 36 | 36 | |
| 37 | 37 | class Notifier implements INotifier { |
| 38 | - /** @var IFactory */ |
|
| 39 | - protected $factory; |
|
| 40 | - /** @var IManager */ |
|
| 41 | - protected $contactsManager; |
|
| 42 | - /** @var IURLGenerator */ |
|
| 43 | - protected $url; |
|
| 44 | - /** @var array */ |
|
| 45 | - protected $federatedContacts; |
|
| 46 | - /** @var ICloudIdManager */ |
|
| 47 | - protected $cloudIdManager; |
|
| 38 | + /** @var IFactory */ |
|
| 39 | + protected $factory; |
|
| 40 | + /** @var IManager */ |
|
| 41 | + protected $contactsManager; |
|
| 42 | + /** @var IURLGenerator */ |
|
| 43 | + protected $url; |
|
| 44 | + /** @var array */ |
|
| 45 | + protected $federatedContacts; |
|
| 46 | + /** @var ICloudIdManager */ |
|
| 47 | + protected $cloudIdManager; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @param IFactory $factory |
|
| 51 | - * @param IManager $contactsManager |
|
| 52 | - * @param IURLGenerator $url |
|
| 53 | - * @param ICloudIdManager $cloudIdManager |
|
| 54 | - */ |
|
| 55 | - public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) { |
|
| 56 | - $this->factory = $factory; |
|
| 57 | - $this->contactsManager = $contactsManager; |
|
| 58 | - $this->url = $url; |
|
| 59 | - $this->cloudIdManager = $cloudIdManager; |
|
| 60 | - } |
|
| 49 | + /** |
|
| 50 | + * @param IFactory $factory |
|
| 51 | + * @param IManager $contactsManager |
|
| 52 | + * @param IURLGenerator $url |
|
| 53 | + * @param ICloudIdManager $cloudIdManager |
|
| 54 | + */ |
|
| 55 | + public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) { |
|
| 56 | + $this->factory = $factory; |
|
| 57 | + $this->contactsManager = $contactsManager; |
|
| 58 | + $this->url = $url; |
|
| 59 | + $this->cloudIdManager = $cloudIdManager; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Identifier of the notifier, only use [a-z0-9_] |
|
| 64 | - * |
|
| 65 | - * @return string |
|
| 66 | - * @since 17.0.0 |
|
| 67 | - */ |
|
| 68 | - public function getID(): string { |
|
| 69 | - return 'federatedfilesharing'; |
|
| 70 | - } |
|
| 62 | + /** |
|
| 63 | + * Identifier of the notifier, only use [a-z0-9_] |
|
| 64 | + * |
|
| 65 | + * @return string |
|
| 66 | + * @since 17.0.0 |
|
| 67 | + */ |
|
| 68 | + public function getID(): string { |
|
| 69 | + return 'federatedfilesharing'; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Human readable name describing the notifier |
|
| 74 | - * |
|
| 75 | - * @return string |
|
| 76 | - * @since 17.0.0 |
|
| 77 | - */ |
|
| 78 | - public function getName(): string { |
|
| 79 | - return $this->factory->get('federatedfilesharing')->t('Federated sharing'); |
|
| 80 | - } |
|
| 72 | + /** |
|
| 73 | + * Human readable name describing the notifier |
|
| 74 | + * |
|
| 75 | + * @return string |
|
| 76 | + * @since 17.0.0 |
|
| 77 | + */ |
|
| 78 | + public function getName(): string { |
|
| 79 | + return $this->factory->get('federatedfilesharing')->t('Federated sharing'); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @param INotification $notification |
|
| 84 | - * @param string $languageCode The code of the language that should be used to prepare the notification |
|
| 85 | - * @return INotification |
|
| 86 | - * @throws \InvalidArgumentException |
|
| 87 | - */ |
|
| 88 | - public function prepare(INotification $notification, string $languageCode): INotification { |
|
| 89 | - if ($notification->getApp() !== 'files_sharing' || $notification->getObjectType() !== 'remote_share') { |
|
| 90 | - // Not my app => throw |
|
| 91 | - throw new \InvalidArgumentException(); |
|
| 92 | - } |
|
| 82 | + /** |
|
| 83 | + * @param INotification $notification |
|
| 84 | + * @param string $languageCode The code of the language that should be used to prepare the notification |
|
| 85 | + * @return INotification |
|
| 86 | + * @throws \InvalidArgumentException |
|
| 87 | + */ |
|
| 88 | + public function prepare(INotification $notification, string $languageCode): INotification { |
|
| 89 | + if ($notification->getApp() !== 'files_sharing' || $notification->getObjectType() !== 'remote_share') { |
|
| 90 | + // Not my app => throw |
|
| 91 | + throw new \InvalidArgumentException(); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // Read the language from the notification |
|
| 95 | - $l = $this->factory->get('files_sharing', $languageCode); |
|
| 94 | + // Read the language from the notification |
|
| 95 | + $l = $this->factory->get('files_sharing', $languageCode); |
|
| 96 | 96 | |
| 97 | - switch ($notification->getSubject()) { |
|
| 98 | - // Deal with known subjects |
|
| 99 | - case 'remote_share': |
|
| 100 | - $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
| 97 | + switch ($notification->getSubject()) { |
|
| 98 | + // Deal with known subjects |
|
| 99 | + case 'remote_share': |
|
| 100 | + $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
| 101 | 101 | |
| 102 | - $params = $notification->getSubjectParameters(); |
|
| 103 | - if ($params[0] !== $params[1] && $params[1] !== null) { |
|
| 104 | - $notification->setParsedSubject( |
|
| 105 | - $l->t('You received "%3$s" as a remote share from %4$s (%1$s) (on behalf of %5$s (%2$s))', $params) |
|
| 106 | - ); |
|
| 102 | + $params = $notification->getSubjectParameters(); |
|
| 103 | + if ($params[0] !== $params[1] && $params[1] !== null) { |
|
| 104 | + $notification->setParsedSubject( |
|
| 105 | + $l->t('You received "%3$s" as a remote share from %4$s (%1$s) (on behalf of %5$s (%2$s))', $params) |
|
| 106 | + ); |
|
| 107 | 107 | |
| 108 | - $initiator = $params[0]; |
|
| 109 | - $initiatorDisplay = isset($params[3]) ? $params[3] : null; |
|
| 110 | - $owner = $params[1]; |
|
| 111 | - $ownerDisplay = isset($params[4]) ? $params[4] : null; |
|
| 108 | + $initiator = $params[0]; |
|
| 109 | + $initiatorDisplay = isset($params[3]) ? $params[3] : null; |
|
| 110 | + $owner = $params[1]; |
|
| 111 | + $ownerDisplay = isset($params[4]) ? $params[4] : null; |
|
| 112 | 112 | |
| 113 | - $notification->setRichSubject( |
|
| 114 | - $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'), |
|
| 115 | - [ |
|
| 116 | - 'share' => [ |
|
| 117 | - 'type' => 'pending-federated-share', |
|
| 118 | - 'id' => $notification->getObjectId(), |
|
| 119 | - 'name' => $params[2], |
|
| 120 | - ], |
|
| 121 | - 'user' => $this->createRemoteUser($initiator, $initiatorDisplay), |
|
| 122 | - 'behalf' => $this->createRemoteUser($owner, $ownerDisplay), |
|
| 123 | - ] |
|
| 124 | - ); |
|
| 125 | - } else { |
|
| 126 | - $notification->setParsedSubject( |
|
| 127 | - $l->t('You received "%3$s" as a remote share from %4$s (%1$s)', $params) |
|
| 128 | - ); |
|
| 113 | + $notification->setRichSubject( |
|
| 114 | + $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'), |
|
| 115 | + [ |
|
| 116 | + 'share' => [ |
|
| 117 | + 'type' => 'pending-federated-share', |
|
| 118 | + 'id' => $notification->getObjectId(), |
|
| 119 | + 'name' => $params[2], |
|
| 120 | + ], |
|
| 121 | + 'user' => $this->createRemoteUser($initiator, $initiatorDisplay), |
|
| 122 | + 'behalf' => $this->createRemoteUser($owner, $ownerDisplay), |
|
| 123 | + ] |
|
| 124 | + ); |
|
| 125 | + } else { |
|
| 126 | + $notification->setParsedSubject( |
|
| 127 | + $l->t('You received "%3$s" as a remote share from %4$s (%1$s)', $params) |
|
| 128 | + ); |
|
| 129 | 129 | |
| 130 | - $owner = $params[0]; |
|
| 131 | - $ownerDisplay = isset($params[3]) ? $params[3] : null; |
|
| 130 | + $owner = $params[0]; |
|
| 131 | + $ownerDisplay = isset($params[3]) ? $params[3] : null; |
|
| 132 | 132 | |
| 133 | - $notification->setRichSubject( |
|
| 134 | - $l->t('You received {share} as a remote share from {user}'), |
|
| 135 | - [ |
|
| 136 | - 'share' => [ |
|
| 137 | - 'type' => 'pending-federated-share', |
|
| 138 | - 'id' => $notification->getObjectId(), |
|
| 139 | - 'name' => $params[2], |
|
| 140 | - ], |
|
| 141 | - 'user' => $this->createRemoteUser($owner, $ownerDisplay), |
|
| 142 | - ] |
|
| 143 | - ); |
|
| 144 | - } |
|
| 133 | + $notification->setRichSubject( |
|
| 134 | + $l->t('You received {share} as a remote share from {user}'), |
|
| 135 | + [ |
|
| 136 | + 'share' => [ |
|
| 137 | + 'type' => 'pending-federated-share', |
|
| 138 | + 'id' => $notification->getObjectId(), |
|
| 139 | + 'name' => $params[2], |
|
| 140 | + ], |
|
| 141 | + 'user' => $this->createRemoteUser($owner, $ownerDisplay), |
|
| 142 | + ] |
|
| 143 | + ); |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - // Deal with the actions for a known subject |
|
| 147 | - foreach ($notification->getActions() as $action) { |
|
| 148 | - switch ($action->getLabel()) { |
|
| 149 | - case 'accept': |
|
| 150 | - $action->setParsedLabel( |
|
| 151 | - (string) $l->t('Accept') |
|
| 152 | - ) |
|
| 153 | - ->setPrimary(true); |
|
| 154 | - break; |
|
| 146 | + // Deal with the actions for a known subject |
|
| 147 | + foreach ($notification->getActions() as $action) { |
|
| 148 | + switch ($action->getLabel()) { |
|
| 149 | + case 'accept': |
|
| 150 | + $action->setParsedLabel( |
|
| 151 | + (string) $l->t('Accept') |
|
| 152 | + ) |
|
| 153 | + ->setPrimary(true); |
|
| 154 | + break; |
|
| 155 | 155 | |
| 156 | - case 'decline': |
|
| 157 | - $action->setParsedLabel( |
|
| 158 | - (string) $l->t('Decline') |
|
| 159 | - ); |
|
| 160 | - break; |
|
| 161 | - } |
|
| 156 | + case 'decline': |
|
| 157 | + $action->setParsedLabel( |
|
| 158 | + (string) $l->t('Decline') |
|
| 159 | + ); |
|
| 160 | + break; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $notification->addParsedAction($action); |
|
| 164 | - } |
|
| 165 | - return $notification; |
|
| 163 | + $notification->addParsedAction($action); |
|
| 164 | + } |
|
| 165 | + return $notification; |
|
| 166 | 166 | |
| 167 | - default: |
|
| 168 | - // Unknown subject => Unknown notification => throw |
|
| 169 | - throw new \InvalidArgumentException(); |
|
| 170 | - } |
|
| 171 | - } |
|
| 167 | + default: |
|
| 168 | + // Unknown subject => Unknown notification => throw |
|
| 169 | + throw new \InvalidArgumentException(); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * @param string $cloudId |
|
| 175 | - * @return array |
|
| 176 | - */ |
|
| 177 | - protected function createRemoteUser($cloudId, $displayName = null) { |
|
| 178 | - try { |
|
| 179 | - $resolvedId = $this->cloudIdManager->resolveCloudId($cloudId); |
|
| 180 | - if ($displayName === null) { |
|
| 181 | - $displayName = $this->getDisplayName($resolvedId); |
|
| 182 | - } |
|
| 183 | - $user = $resolvedId->getUser(); |
|
| 184 | - $server = $resolvedId->getRemote(); |
|
| 185 | - } catch (HintException $e) { |
|
| 186 | - $user = $cloudId; |
|
| 187 | - $displayName = $cloudId; |
|
| 188 | - $server = ''; |
|
| 189 | - } |
|
| 173 | + /** |
|
| 174 | + * @param string $cloudId |
|
| 175 | + * @return array |
|
| 176 | + */ |
|
| 177 | + protected function createRemoteUser($cloudId, $displayName = null) { |
|
| 178 | + try { |
|
| 179 | + $resolvedId = $this->cloudIdManager->resolveCloudId($cloudId); |
|
| 180 | + if ($displayName === null) { |
|
| 181 | + $displayName = $this->getDisplayName($resolvedId); |
|
| 182 | + } |
|
| 183 | + $user = $resolvedId->getUser(); |
|
| 184 | + $server = $resolvedId->getRemote(); |
|
| 185 | + } catch (HintException $e) { |
|
| 186 | + $user = $cloudId; |
|
| 187 | + $displayName = $cloudId; |
|
| 188 | + $server = ''; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - return [ |
|
| 192 | - 'type' => 'user', |
|
| 193 | - 'id' => $user, |
|
| 194 | - 'name' => $displayName, |
|
| 195 | - 'server' => $server, |
|
| 196 | - ]; |
|
| 197 | - } |
|
| 191 | + return [ |
|
| 192 | + 'type' => 'user', |
|
| 193 | + 'id' => $user, |
|
| 194 | + 'name' => $displayName, |
|
| 195 | + 'server' => $server, |
|
| 196 | + ]; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Try to find the user in the contacts |
|
| 201 | - * |
|
| 202 | - * @param ICloudId $cloudId |
|
| 203 | - * @return string |
|
| 204 | - */ |
|
| 205 | - protected function getDisplayName(ICloudId $cloudId) { |
|
| 206 | - $server = $cloudId->getRemote(); |
|
| 207 | - $user = $cloudId->getUser(); |
|
| 208 | - if (strpos($server, 'http://') === 0) { |
|
| 209 | - $server = substr($server, strlen('http://')); |
|
| 210 | - } elseif (strpos($server, 'https://') === 0) { |
|
| 211 | - $server = substr($server, strlen('https://')); |
|
| 212 | - } |
|
| 199 | + /** |
|
| 200 | + * Try to find the user in the contacts |
|
| 201 | + * |
|
| 202 | + * @param ICloudId $cloudId |
|
| 203 | + * @return string |
|
| 204 | + */ |
|
| 205 | + protected function getDisplayName(ICloudId $cloudId) { |
|
| 206 | + $server = $cloudId->getRemote(); |
|
| 207 | + $user = $cloudId->getUser(); |
|
| 208 | + if (strpos($server, 'http://') === 0) { |
|
| 209 | + $server = substr($server, strlen('http://')); |
|
| 210 | + } elseif (strpos($server, 'https://') === 0) { |
|
| 211 | + $server = substr($server, strlen('https://')); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - try { |
|
| 215 | - return $this->getDisplayNameFromContact($cloudId->getId()); |
|
| 216 | - } catch (\OutOfBoundsException $e) { |
|
| 217 | - } |
|
| 214 | + try { |
|
| 215 | + return $this->getDisplayNameFromContact($cloudId->getId()); |
|
| 216 | + } catch (\OutOfBoundsException $e) { |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - try { |
|
| 220 | - $this->getDisplayNameFromContact($user . '@http://' . $server); |
|
| 221 | - } catch (\OutOfBoundsException $e) { |
|
| 222 | - } |
|
| 219 | + try { |
|
| 220 | + $this->getDisplayNameFromContact($user . '@http://' . $server); |
|
| 221 | + } catch (\OutOfBoundsException $e) { |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - try { |
|
| 225 | - $this->getDisplayNameFromContact($user . '@https://' . $server); |
|
| 226 | - } catch (\OutOfBoundsException $e) { |
|
| 227 | - } |
|
| 224 | + try { |
|
| 225 | + $this->getDisplayNameFromContact($user . '@https://' . $server); |
|
| 226 | + } catch (\OutOfBoundsException $e) { |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - return $cloudId->getId(); |
|
| 230 | - } |
|
| 229 | + return $cloudId->getId(); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - /** |
|
| 233 | - * Try to find the user in the contacts |
|
| 234 | - * |
|
| 235 | - * @param string $federatedCloudId |
|
| 236 | - * @return string |
|
| 237 | - * @throws \OutOfBoundsException when there is no contact for the id |
|
| 238 | - */ |
|
| 239 | - protected function getDisplayNameFromContact($federatedCloudId) { |
|
| 240 | - if (isset($this->federatedContacts[$federatedCloudId])) { |
|
| 241 | - if ($this->federatedContacts[$federatedCloudId] !== '') { |
|
| 242 | - return $this->federatedContacts[$federatedCloudId]; |
|
| 243 | - } else { |
|
| 244 | - throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
| 245 | - } |
|
| 246 | - } |
|
| 232 | + /** |
|
| 233 | + * Try to find the user in the contacts |
|
| 234 | + * |
|
| 235 | + * @param string $federatedCloudId |
|
| 236 | + * @return string |
|
| 237 | + * @throws \OutOfBoundsException when there is no contact for the id |
|
| 238 | + */ |
|
| 239 | + protected function getDisplayNameFromContact($federatedCloudId) { |
|
| 240 | + if (isset($this->federatedContacts[$federatedCloudId])) { |
|
| 241 | + if ($this->federatedContacts[$federatedCloudId] !== '') { |
|
| 242 | + return $this->federatedContacts[$federatedCloudId]; |
|
| 243 | + } else { |
|
| 244 | + throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']); |
|
| 249 | - foreach ($addressBookEntries as $entry) { |
|
| 250 | - if (isset($entry['CLOUD'])) { |
|
| 251 | - foreach ($entry['CLOUD'] as $cloudID) { |
|
| 252 | - if ($cloudID === $federatedCloudId) { |
|
| 253 | - $this->federatedContacts[$federatedCloudId] = $entry['FN']; |
|
| 254 | - return $entry['FN']; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 248 | + $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']); |
|
| 249 | + foreach ($addressBookEntries as $entry) { |
|
| 250 | + if (isset($entry['CLOUD'])) { |
|
| 251 | + foreach ($entry['CLOUD'] as $cloudID) { |
|
| 252 | + if ($cloudID === $federatedCloudId) { |
|
| 253 | + $this->federatedContacts[$federatedCloudId] = $entry['FN']; |
|
| 254 | + return $entry['FN']; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - $this->federatedContacts[$federatedCloudId] = ''; |
|
| 261 | - throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
| 262 | - } |
|
| 260 | + $this->federatedContacts[$federatedCloudId] = ''; |
|
| 261 | + throw new \OutOfBoundsException('No contact found for federated cloud id'); |
|
| 262 | + } |
|
| 263 | 263 | } |
@@ -29,41 +29,41 @@ |
||
| 29 | 29 | |
| 30 | 30 | class Admin implements ISettings { |
| 31 | 31 | |
| 32 | - /** @var TrustedServers */ |
|
| 33 | - private $trustedServers; |
|
| 32 | + /** @var TrustedServers */ |
|
| 33 | + private $trustedServers; |
|
| 34 | 34 | |
| 35 | - public function __construct(TrustedServers $trustedServers) { |
|
| 36 | - $this->trustedServers = $trustedServers; |
|
| 37 | - } |
|
| 35 | + public function __construct(TrustedServers $trustedServers) { |
|
| 36 | + $this->trustedServers = $trustedServers; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return TemplateResponse |
|
| 41 | - */ |
|
| 42 | - public function getForm() { |
|
| 43 | - $parameters = [ |
|
| 44 | - 'trustedServers' => $this->trustedServers->getServers(), |
|
| 45 | - 'autoAddServers' => $this->trustedServers->getAutoAddServers(), |
|
| 46 | - ]; |
|
| 39 | + /** |
|
| 40 | + * @return TemplateResponse |
|
| 41 | + */ |
|
| 42 | + public function getForm() { |
|
| 43 | + $parameters = [ |
|
| 44 | + 'trustedServers' => $this->trustedServers->getServers(), |
|
| 45 | + 'autoAddServers' => $this->trustedServers->getAutoAddServers(), |
|
| 46 | + ]; |
|
| 47 | 47 | |
| 48 | - return new TemplateResponse('federation', 'settings-admin', $parameters, ''); |
|
| 49 | - } |
|
| 48 | + return new TemplateResponse('federation', 'settings-admin', $parameters, ''); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return string the section ID, e.g. 'sharing' |
|
| 53 | - */ |
|
| 54 | - public function getSection() { |
|
| 55 | - return 'sharing'; |
|
| 56 | - } |
|
| 51 | + /** |
|
| 52 | + * @return string the section ID, e.g. 'sharing' |
|
| 53 | + */ |
|
| 54 | + public function getSection() { |
|
| 55 | + return 'sharing'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @return int whether the form should be rather on the top or bottom of |
|
| 60 | - * the admin section. The forms are arranged in ascending order of the |
|
| 61 | - * priority values. It is required to return a value between 0 and 100. |
|
| 62 | - * |
|
| 63 | - * E.g.: 70 |
|
| 64 | - */ |
|
| 65 | - public function getPriority() { |
|
| 66 | - return 30; |
|
| 67 | - } |
|
| 58 | + /** |
|
| 59 | + * @return int whether the form should be rather on the top or bottom of |
|
| 60 | + * the admin section. The forms are arranged in ascending order of the |
|
| 61 | + * priority values. It is required to return a value between 0 and 100. |
|
| 62 | + * |
|
| 63 | + * E.g.: 70 |
|
| 64 | + */ |
|
| 65 | + public function getPriority() { |
|
| 66 | + return 30; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | */ |
| 85 | 85 | private function isRequestPublic(RequestInterface $request) { |
| 86 | 86 | $url = $request->getPath(); |
| 87 | - $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
| 87 | + $matchingUrls = array_filter($this->publicURLs, function($publicUrl) use ($url) { |
|
| 88 | 88 | return strpos($url, $publicUrl, 0) === 0; |
| 89 | 89 | }); |
| 90 | 90 | return !empty($matchingUrls); |
@@ -26,66 +26,66 @@ |
||
| 26 | 26 | |
| 27 | 27 | class PublicAuth implements BackendInterface { |
| 28 | 28 | |
| 29 | - /** @var string[] */ |
|
| 30 | - private $publicURLs; |
|
| 29 | + /** @var string[] */ |
|
| 30 | + private $publicURLs; |
|
| 31 | 31 | |
| 32 | - public function __construct() { |
|
| 33 | - $this->publicURLs = [ |
|
| 34 | - 'public-calendars', |
|
| 35 | - 'principals/system/public' |
|
| 36 | - ]; |
|
| 37 | - } |
|
| 32 | + public function __construct() { |
|
| 33 | + $this->publicURLs = [ |
|
| 34 | + 'public-calendars', |
|
| 35 | + 'principals/system/public' |
|
| 36 | + ]; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * When this method is called, the backend must check if authentication was |
|
| 41 | - * successful. |
|
| 42 | - * |
|
| 43 | - * The returned value must be one of the following |
|
| 44 | - * |
|
| 45 | - * [true, "principals/username"] |
|
| 46 | - * [false, "reason for failure"] |
|
| 47 | - * |
|
| 48 | - * If authentication was successful, it's expected that the authentication |
|
| 49 | - * backend returns a so-called principal url. |
|
| 50 | - * |
|
| 51 | - * Examples of a principal url: |
|
| 52 | - * |
|
| 53 | - * principals/admin |
|
| 54 | - * principals/user1 |
|
| 55 | - * principals/users/joe |
|
| 56 | - * principals/uid/123457 |
|
| 57 | - * |
|
| 58 | - * If you don't use WebDAV ACL (RFC3744) we recommend that you simply |
|
| 59 | - * return a string such as: |
|
| 60 | - * |
|
| 61 | - * principals/users/[username] |
|
| 62 | - * |
|
| 63 | - * @param RequestInterface $request |
|
| 64 | - * @param ResponseInterface $response |
|
| 65 | - * @return array |
|
| 66 | - */ |
|
| 67 | - public function check(RequestInterface $request, ResponseInterface $response) { |
|
| 68 | - if ($this->isRequestPublic($request)) { |
|
| 69 | - return [true, "principals/system/public"]; |
|
| 70 | - } |
|
| 71 | - return [false, "No public access to this resource."]; |
|
| 72 | - } |
|
| 39 | + /** |
|
| 40 | + * When this method is called, the backend must check if authentication was |
|
| 41 | + * successful. |
|
| 42 | + * |
|
| 43 | + * The returned value must be one of the following |
|
| 44 | + * |
|
| 45 | + * [true, "principals/username"] |
|
| 46 | + * [false, "reason for failure"] |
|
| 47 | + * |
|
| 48 | + * If authentication was successful, it's expected that the authentication |
|
| 49 | + * backend returns a so-called principal url. |
|
| 50 | + * |
|
| 51 | + * Examples of a principal url: |
|
| 52 | + * |
|
| 53 | + * principals/admin |
|
| 54 | + * principals/user1 |
|
| 55 | + * principals/users/joe |
|
| 56 | + * principals/uid/123457 |
|
| 57 | + * |
|
| 58 | + * If you don't use WebDAV ACL (RFC3744) we recommend that you simply |
|
| 59 | + * return a string such as: |
|
| 60 | + * |
|
| 61 | + * principals/users/[username] |
|
| 62 | + * |
|
| 63 | + * @param RequestInterface $request |
|
| 64 | + * @param ResponseInterface $response |
|
| 65 | + * @return array |
|
| 66 | + */ |
|
| 67 | + public function check(RequestInterface $request, ResponseInterface $response) { |
|
| 68 | + if ($this->isRequestPublic($request)) { |
|
| 69 | + return [true, "principals/system/public"]; |
|
| 70 | + } |
|
| 71 | + return [false, "No public access to this resource."]; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @inheritdoc |
|
| 76 | - */ |
|
| 77 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
| 78 | - } |
|
| 74 | + /** |
|
| 75 | + * @inheritdoc |
|
| 76 | + */ |
|
| 77 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @param RequestInterface $request |
|
| 82 | - * @return bool |
|
| 83 | - */ |
|
| 84 | - private function isRequestPublic(RequestInterface $request) { |
|
| 85 | - $url = $request->getPath(); |
|
| 86 | - $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
| 87 | - return strpos($url, $publicUrl, 0) === 0; |
|
| 88 | - }); |
|
| 89 | - return !empty($matchingUrls); |
|
| 90 | - } |
|
| 80 | + /** |
|
| 81 | + * @param RequestInterface $request |
|
| 82 | + * @return bool |
|
| 83 | + */ |
|
| 84 | + private function isRequestPublic(RequestInterface $request) { |
|
| 85 | + $url = $request->getPath(); |
|
| 86 | + $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
| 87 | + return strpos($url, $publicUrl, 0) === 0; |
|
| 88 | + }); |
|
| 89 | + return !empty($matchingUrls); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -49,17 +49,17 @@ |
||
| 49 | 49 | * @param \DOMElement $errorNode |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { |
|
| 52 | + public function serialize(\Sabre\DAV\Server $server, \DOMElement $errorNode) { |
|
| 53 | 53 | |
| 54 | 54 | // set ownCloud namespace |
| 55 | 55 | $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
| 56 | 56 | |
| 57 | 57 | // adding the retry node |
| 58 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); |
|
| 58 | + $error = $errorNode->ownerDocument->createElementNS('o:', 'o:retry', var_export($this->retry, true)); |
|
| 59 | 59 | $errorNode->appendChild($error); |
| 60 | 60 | |
| 61 | 61 | // adding the message node |
| 62 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); |
|
| 62 | + $error = $errorNode->ownerDocument->createElementNS('o:', 'o:reason', $this->getMessage()); |
|
| 63 | 63 | $errorNode->appendChild($error); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -23,42 +23,42 @@ |
||
| 23 | 23 | namespace OCA\DAV\Connector\Sabre\Exception; |
| 24 | 24 | |
| 25 | 25 | class Forbidden extends \Sabre\DAV\Exception\Forbidden { |
| 26 | - public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
| 26 | + public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var bool |
|
| 30 | - */ |
|
| 31 | - private $retry; |
|
| 28 | + /** |
|
| 29 | + * @var bool |
|
| 30 | + */ |
|
| 31 | + private $retry; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param string $message |
|
| 35 | - * @param bool $retry |
|
| 36 | - * @param \Exception $previous |
|
| 37 | - */ |
|
| 38 | - public function __construct($message, $retry = false, \Exception $previous = null) { |
|
| 39 | - parent::__construct($message, 0, $previous); |
|
| 40 | - $this->retry = $retry; |
|
| 41 | - } |
|
| 33 | + /** |
|
| 34 | + * @param string $message |
|
| 35 | + * @param bool $retry |
|
| 36 | + * @param \Exception $previous |
|
| 37 | + */ |
|
| 38 | + public function __construct($message, $retry = false, \Exception $previous = null) { |
|
| 39 | + parent::__construct($message, 0, $previous); |
|
| 40 | + $this->retry = $retry; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * This method allows the exception to include additional information |
|
| 45 | - * into the WebDAV error response |
|
| 46 | - * |
|
| 47 | - * @param \Sabre\DAV\Server $server |
|
| 48 | - * @param \DOMElement $errorNode |
|
| 49 | - * @return void |
|
| 50 | - */ |
|
| 51 | - public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { |
|
| 43 | + /** |
|
| 44 | + * This method allows the exception to include additional information |
|
| 45 | + * into the WebDAV error response |
|
| 46 | + * |
|
| 47 | + * @param \Sabre\DAV\Server $server |
|
| 48 | + * @param \DOMElement $errorNode |
|
| 49 | + * @return void |
|
| 50 | + */ |
|
| 51 | + public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { |
|
| 52 | 52 | |
| 53 | - // set ownCloud namespace |
|
| 54 | - $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
| 53 | + // set ownCloud namespace |
|
| 54 | + $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
| 55 | 55 | |
| 56 | - // adding the retry node |
|
| 57 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); |
|
| 58 | - $errorNode->appendChild($error); |
|
| 56 | + // adding the retry node |
|
| 57 | + $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true)); |
|
| 58 | + $errorNode->appendChild($error); |
|
| 59 | 59 | |
| 60 | - // adding the message node |
|
| 61 | - $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); |
|
| 62 | - $errorNode->appendChild($error); |
|
| 63 | - } |
|
| 60 | + // adding the message node |
|
| 61 | + $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage()); |
|
| 62 | + $errorNode->appendChild($error); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -60,9 +60,9 @@ |
||
| 60 | 60 | |
| 61 | 61 | public function propFind(PropFind $propFind, INode $node) { |
| 62 | 62 | /* Overload current-user-principal */ |
| 63 | - $propFind->handle('{DAV:}current-user-principal', function () { |
|
| 63 | + $propFind->handle('{DAV:}current-user-principal', function() { |
|
| 64 | 64 | if ($url = parent::getCurrentUserPrincipal()) { |
| 65 | - return new Principal(Principal::HREF, $url . '/'); |
|
| 65 | + return new Principal(Principal::HREF, $url.'/'); |
|
| 66 | 66 | } else { |
| 67 | 67 | return new Principal(Principal::UNAUTHENTICATED); |
| 68 | 68 | } |
@@ -32,44 +32,44 @@ |
||
| 32 | 32 | |
| 33 | 33 | class LegacyDAVACL extends DavAclPlugin { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @inheritdoc |
|
| 37 | - */ |
|
| 38 | - public function getCurrentUserPrincipals() { |
|
| 39 | - $principalV2 = $this->getCurrentUserPrincipal(); |
|
| 35 | + /** |
|
| 36 | + * @inheritdoc |
|
| 37 | + */ |
|
| 38 | + public function getCurrentUserPrincipals() { |
|
| 39 | + $principalV2 = $this->getCurrentUserPrincipal(); |
|
| 40 | 40 | |
| 41 | - if (is_null($principalV2)) { |
|
| 42 | - return []; |
|
| 43 | - } |
|
| 41 | + if (is_null($principalV2)) { |
|
| 42 | + return []; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $principalV1 = $this->convertPrincipal($principalV2, false); |
|
| 46 | - return array_merge( |
|
| 47 | - [ |
|
| 48 | - $principalV2, |
|
| 49 | - $principalV1 |
|
| 50 | - ], |
|
| 51 | - $this->getPrincipalMembership($principalV1) |
|
| 52 | - ); |
|
| 53 | - } |
|
| 45 | + $principalV1 = $this->convertPrincipal($principalV2, false); |
|
| 46 | + return array_merge( |
|
| 47 | + [ |
|
| 48 | + $principalV2, |
|
| 49 | + $principalV1 |
|
| 50 | + ], |
|
| 51 | + $this->getPrincipalMembership($principalV1) |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - private function convertPrincipal($principal, $toV2) { |
|
| 56 | - list(, $name) = \Sabre\Uri\split($principal); |
|
| 57 | - if ($toV2) { |
|
| 58 | - return "principals/users/$name"; |
|
| 59 | - } |
|
| 60 | - return "principals/$name"; |
|
| 61 | - } |
|
| 55 | + private function convertPrincipal($principal, $toV2) { |
|
| 56 | + list(, $name) = \Sabre\Uri\split($principal); |
|
| 57 | + if ($toV2) { |
|
| 58 | + return "principals/users/$name"; |
|
| 59 | + } |
|
| 60 | + return "principals/$name"; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function propFind(PropFind $propFind, INode $node) { |
|
| 64 | - /* Overload current-user-principal */ |
|
| 65 | - $propFind->handle('{DAV:}current-user-principal', function () { |
|
| 66 | - if ($url = parent::getCurrentUserPrincipal()) { |
|
| 67 | - return new Principal(Principal::HREF, $url . '/'); |
|
| 68 | - } else { |
|
| 69 | - return new Principal(Principal::UNAUTHENTICATED); |
|
| 70 | - } |
|
| 71 | - }); |
|
| 63 | + public function propFind(PropFind $propFind, INode $node) { |
|
| 64 | + /* Overload current-user-principal */ |
|
| 65 | + $propFind->handle('{DAV:}current-user-principal', function () { |
|
| 66 | + if ($url = parent::getCurrentUserPrincipal()) { |
|
| 67 | + return new Principal(Principal::HREF, $url . '/'); |
|
| 68 | + } else { |
|
| 69 | + return new Principal(Principal::UNAUTHENTICATED); |
|
| 70 | + } |
|
| 71 | + }); |
|
| 72 | 72 | |
| 73 | - return parent::propFind($propFind, $node); |
|
| 74 | - } |
|
| 73 | + return parent::propFind($propFind, $node); |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -28,35 +28,35 @@ |
||
| 28 | 28 | |
| 29 | 29 | class FixBirthdayCalendarComponent implements IRepairStep { |
| 30 | 30 | |
| 31 | - /** @var IDBConnection */ |
|
| 32 | - private $connection; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * FixBirthdayCalendarComponent constructor. |
|
| 36 | - * |
|
| 37 | - * @param IDBConnection $connection |
|
| 38 | - */ |
|
| 39 | - public function __construct(IDBConnection $connection) { |
|
| 40 | - $this->connection = $connection; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @inheritdoc |
|
| 45 | - */ |
|
| 46 | - public function getName() { |
|
| 47 | - return 'Fix component of birthday calendars'; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @inheritdoc |
|
| 52 | - */ |
|
| 53 | - public function run(IOutput $output) { |
|
| 54 | - $query = $this->connection->getQueryBuilder(); |
|
| 55 | - $updated = $query->update('calendars') |
|
| 56 | - ->set('components', $query->createNamedParameter('VEVENT')) |
|
| 57 | - ->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))) |
|
| 58 | - ->execute(); |
|
| 59 | - |
|
| 60 | - $output->info("$updated birthday calendars updated."); |
|
| 61 | - } |
|
| 31 | + /** @var IDBConnection */ |
|
| 32 | + private $connection; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * FixBirthdayCalendarComponent constructor. |
|
| 36 | + * |
|
| 37 | + * @param IDBConnection $connection |
|
| 38 | + */ |
|
| 39 | + public function __construct(IDBConnection $connection) { |
|
| 40 | + $this->connection = $connection; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @inheritdoc |
|
| 45 | + */ |
|
| 46 | + public function getName() { |
|
| 47 | + return 'Fix component of birthday calendars'; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @inheritdoc |
|
| 52 | + */ |
|
| 53 | + public function run(IOutput $output) { |
|
| 54 | + $query = $this->connection->getQueryBuilder(); |
|
| 55 | + $updated = $query->update('calendars') |
|
| 56 | + ->set('components', $query->createNamedParameter('VEVENT')) |
|
| 57 | + ->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))) |
|
| 58 | + ->execute(); |
|
| 59 | + |
|
| 60 | + $output->info("$updated birthday calendars updated."); |
|
| 61 | + } |
|
| 62 | 62 | } |