@@ -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; |
@@ -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 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | protected function setSubjects(IEvent $event, $subject, array $parameters) { |
50 | 50 | $placeholders = $replacements = []; |
51 | 51 | foreach ($parameters as $placeholder => $parameter) { |
52 | - $placeholders[] = '{' . $placeholder . '}'; |
|
52 | + $placeholders[] = '{'.$placeholder.'}'; |
|
53 | 53 | $replacements[] = $parameter['name']; |
54 | 54 | } |
55 | 55 |
@@ -36,136 +36,136 @@ |
||
36 | 36 | |
37 | 37 | abstract class Base implements IProvider { |
38 | 38 | |
39 | - /** @var IUserManager */ |
|
40 | - protected $userManager; |
|
41 | - |
|
42 | - /** @var string[] */ |
|
43 | - protected $userDisplayNames = []; |
|
44 | - |
|
45 | - /** @var IGroupManager */ |
|
46 | - protected $groupManager; |
|
47 | - |
|
48 | - /** @var string[] */ |
|
49 | - protected $groupDisplayNames = []; |
|
50 | - |
|
51 | - /** @var IURLGenerator */ |
|
52 | - protected $url; |
|
53 | - |
|
54 | - /** |
|
55 | - * @param IUserManager $userManager |
|
56 | - * @param IGroupManager $groupManager |
|
57 | - * @param IURLGenerator $urlGenerator |
|
58 | - */ |
|
59 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager, IURLGenerator $urlGenerator) { |
|
60 | - $this->userManager = $userManager; |
|
61 | - $this->groupManager = $groupManager; |
|
62 | - $this->url = $urlGenerator; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @param IEvent $event |
|
67 | - * @param string $subject |
|
68 | - * @param array $parameters |
|
69 | - */ |
|
70 | - protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
71 | - $placeholders = $replacements = []; |
|
72 | - foreach ($parameters as $placeholder => $parameter) { |
|
73 | - $placeholders[] = '{' . $placeholder . '}'; |
|
74 | - $replacements[] = $parameter['name']; |
|
75 | - } |
|
76 | - |
|
77 | - $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
78 | - ->setRichSubject($subject, $parameters); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @param array $data |
|
83 | - * @param IL10N $l |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - protected function generateCalendarParameter($data, IL10N $l) { |
|
87 | - if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
88 | - $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
89 | - return [ |
|
90 | - 'type' => 'calendar', |
|
91 | - 'id' => $data['id'], |
|
92 | - 'name' => $l->t('Personal'), |
|
93 | - ]; |
|
94 | - } |
|
95 | - |
|
96 | - return [ |
|
97 | - 'type' => 'calendar', |
|
98 | - 'id' => $data['id'], |
|
99 | - 'name' => $data['name'], |
|
100 | - ]; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param int $id |
|
105 | - * @param string $name |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - protected function generateLegacyCalendarParameter($id, $name) { |
|
109 | - return [ |
|
110 | - 'type' => 'calendar', |
|
111 | - 'id' => $id, |
|
112 | - 'name' => $name, |
|
113 | - ]; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $uid |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - protected function generateUserParameter($uid) { |
|
121 | - if (!isset($this->userDisplayNames[$uid])) { |
|
122 | - $this->userDisplayNames[$uid] = $this->getUserDisplayName($uid); |
|
123 | - } |
|
124 | - |
|
125 | - return [ |
|
126 | - 'type' => 'user', |
|
127 | - 'id' => $uid, |
|
128 | - 'name' => $this->userDisplayNames[$uid], |
|
129 | - ]; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @param string $uid |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - protected function getUserDisplayName($uid) { |
|
137 | - $user = $this->userManager->get($uid); |
|
138 | - if ($user instanceof IUser) { |
|
139 | - return $user->getDisplayName(); |
|
140 | - } |
|
141 | - return $uid; |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * @param string $gid |
|
146 | - * @return array |
|
147 | - */ |
|
148 | - protected function generateGroupParameter($gid) { |
|
149 | - if (!isset($this->groupDisplayNames[$gid])) { |
|
150 | - $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid); |
|
151 | - } |
|
152 | - |
|
153 | - return [ |
|
154 | - 'type' => 'user-group', |
|
155 | - 'id' => $gid, |
|
156 | - 'name' => $this->groupDisplayNames[$gid], |
|
157 | - ]; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @param string $gid |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - protected function getGroupDisplayName($gid) { |
|
165 | - $group = $this->groupManager->get($gid); |
|
166 | - if ($group instanceof IGroup) { |
|
167 | - return $group->getDisplayName(); |
|
168 | - } |
|
169 | - return $gid; |
|
170 | - } |
|
39 | + /** @var IUserManager */ |
|
40 | + protected $userManager; |
|
41 | + |
|
42 | + /** @var string[] */ |
|
43 | + protected $userDisplayNames = []; |
|
44 | + |
|
45 | + /** @var IGroupManager */ |
|
46 | + protected $groupManager; |
|
47 | + |
|
48 | + /** @var string[] */ |
|
49 | + protected $groupDisplayNames = []; |
|
50 | + |
|
51 | + /** @var IURLGenerator */ |
|
52 | + protected $url; |
|
53 | + |
|
54 | + /** |
|
55 | + * @param IUserManager $userManager |
|
56 | + * @param IGroupManager $groupManager |
|
57 | + * @param IURLGenerator $urlGenerator |
|
58 | + */ |
|
59 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager, IURLGenerator $urlGenerator) { |
|
60 | + $this->userManager = $userManager; |
|
61 | + $this->groupManager = $groupManager; |
|
62 | + $this->url = $urlGenerator; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @param IEvent $event |
|
67 | + * @param string $subject |
|
68 | + * @param array $parameters |
|
69 | + */ |
|
70 | + protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
71 | + $placeholders = $replacements = []; |
|
72 | + foreach ($parameters as $placeholder => $parameter) { |
|
73 | + $placeholders[] = '{' . $placeholder . '}'; |
|
74 | + $replacements[] = $parameter['name']; |
|
75 | + } |
|
76 | + |
|
77 | + $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
78 | + ->setRichSubject($subject, $parameters); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @param array $data |
|
83 | + * @param IL10N $l |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + protected function generateCalendarParameter($data, IL10N $l) { |
|
87 | + if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
88 | + $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
89 | + return [ |
|
90 | + 'type' => 'calendar', |
|
91 | + 'id' => $data['id'], |
|
92 | + 'name' => $l->t('Personal'), |
|
93 | + ]; |
|
94 | + } |
|
95 | + |
|
96 | + return [ |
|
97 | + 'type' => 'calendar', |
|
98 | + 'id' => $data['id'], |
|
99 | + 'name' => $data['name'], |
|
100 | + ]; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param int $id |
|
105 | + * @param string $name |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + protected function generateLegacyCalendarParameter($id, $name) { |
|
109 | + return [ |
|
110 | + 'type' => 'calendar', |
|
111 | + 'id' => $id, |
|
112 | + 'name' => $name, |
|
113 | + ]; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $uid |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + protected function generateUserParameter($uid) { |
|
121 | + if (!isset($this->userDisplayNames[$uid])) { |
|
122 | + $this->userDisplayNames[$uid] = $this->getUserDisplayName($uid); |
|
123 | + } |
|
124 | + |
|
125 | + return [ |
|
126 | + 'type' => 'user', |
|
127 | + 'id' => $uid, |
|
128 | + 'name' => $this->userDisplayNames[$uid], |
|
129 | + ]; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @param string $uid |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + protected function getUserDisplayName($uid) { |
|
137 | + $user = $this->userManager->get($uid); |
|
138 | + if ($user instanceof IUser) { |
|
139 | + return $user->getDisplayName(); |
|
140 | + } |
|
141 | + return $uid; |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * @param string $gid |
|
146 | + * @return array |
|
147 | + */ |
|
148 | + protected function generateGroupParameter($gid) { |
|
149 | + if (!isset($this->groupDisplayNames[$gid])) { |
|
150 | + $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid); |
|
151 | + } |
|
152 | + |
|
153 | + return [ |
|
154 | + 'type' => 'user-group', |
|
155 | + 'id' => $gid, |
|
156 | + 'name' => $this->groupDisplayNames[$gid], |
|
157 | + ]; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @param string $gid |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + protected function getGroupDisplayName($gid) { |
|
165 | + $group = $this->groupManager->get($gid); |
|
166 | + if ($group instanceof IGroup) { |
|
167 | + return $group->getDisplayName(); |
|
168 | + } |
|
169 | + return $gid; |
|
170 | + } |
|
171 | 171 | } |
@@ -28,65 +28,65 @@ |
||
28 | 28 | |
29 | 29 | class Todo implements IFilter { |
30 | 30 | |
31 | - /** @var IL10N */ |
|
32 | - protected $l; |
|
31 | + /** @var IL10N */ |
|
32 | + protected $l; |
|
33 | 33 | |
34 | - /** @var IURLGenerator */ |
|
35 | - protected $url; |
|
34 | + /** @var IURLGenerator */ |
|
35 | + protected $url; |
|
36 | 36 | |
37 | - public function __construct(IL10N $l, IURLGenerator $url) { |
|
38 | - $this->l = $l; |
|
39 | - $this->url = $url; |
|
40 | - } |
|
37 | + public function __construct(IL10N $l, IURLGenerator $url) { |
|
38 | + $this->l = $l; |
|
39 | + $this->url = $url; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string Lowercase a-z and underscore only identifier |
|
44 | - * @since 11.0.0 |
|
45 | - */ |
|
46 | - public function getIdentifier() { |
|
47 | - return 'calendar_todo'; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @return string Lowercase a-z and underscore only identifier |
|
44 | + * @since 11.0.0 |
|
45 | + */ |
|
46 | + public function getIdentifier() { |
|
47 | + return 'calendar_todo'; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string A translated string |
|
52 | - * @since 11.0.0 |
|
53 | - */ |
|
54 | - public function getName() { |
|
55 | - return $this->l->t('Todos'); |
|
56 | - } |
|
50 | + /** |
|
51 | + * @return string A translated string |
|
52 | + * @since 11.0.0 |
|
53 | + */ |
|
54 | + public function getName() { |
|
55 | + return $this->l->t('Todos'); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return int whether the filter should be rather on the top or bottom of |
|
60 | - * the admin section. The filters are arranged in ascending order of the |
|
61 | - * priority values. It is required to return a value between 0 and 100. |
|
62 | - * @since 11.0.0 |
|
63 | - */ |
|
64 | - public function getPriority() { |
|
65 | - return 40; |
|
66 | - } |
|
58 | + /** |
|
59 | + * @return int whether the filter should be rather on the top or bottom of |
|
60 | + * the admin section. The filters are arranged in ascending order of the |
|
61 | + * priority values. It is required to return a value between 0 and 100. |
|
62 | + * @since 11.0.0 |
|
63 | + */ |
|
64 | + public function getPriority() { |
|
65 | + return 40; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string Full URL to an icon, empty string when none is given |
|
70 | - * @since 11.0.0 |
|
71 | - */ |
|
72 | - public function getIcon() { |
|
73 | - return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg')); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @return string Full URL to an icon, empty string when none is given |
|
70 | + * @since 11.0.0 |
|
71 | + */ |
|
72 | + public function getIcon() { |
|
73 | + return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg')); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string[] $types |
|
78 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function filterTypes(array $types) { |
|
82 | - return array_intersect(['calendar_todo'], $types); |
|
83 | - } |
|
76 | + /** |
|
77 | + * @param string[] $types |
|
78 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function filterTypes(array $types) { |
|
82 | + return array_intersect(['calendar_todo'], $types); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
87 | - * @since 11.0.0 |
|
88 | - */ |
|
89 | - public function allowedApps() { |
|
90 | - return []; |
|
91 | - } |
|
85 | + /** |
|
86 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
87 | + * @since 11.0.0 |
|
88 | + */ |
|
89 | + public function allowedApps() { |
|
90 | + return []; |
|
91 | + } |
|
92 | 92 | } |