@@ -58,7 +58,7 @@ |
||
58 | 58 | public function getChild($name) { |
59 | 59 | $elements = pathinfo($name); |
60 | 60 | $ext = isset($elements['extension']) ? $elements['extension'] : ''; |
61 | - $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64'); |
|
61 | + $size = (int) (isset($elements['filename']) ? $elements['filename'] : '64'); |
|
62 | 62 | if (!in_array($ext, ['jpeg', 'png'], true)) { |
63 | 63 | throw new MethodNotAllowed('File format not allowed'); |
64 | 64 | } |
@@ -33,87 +33,87 @@ |
||
33 | 33 | |
34 | 34 | class AvatarHome implements ICollection { |
35 | 35 | |
36 | - /** @var array */ |
|
37 | - private $principalInfo; |
|
38 | - /** @var IAvatarManager */ |
|
39 | - private $avatarManager; |
|
36 | + /** @var array */ |
|
37 | + private $principalInfo; |
|
38 | + /** @var IAvatarManager */ |
|
39 | + private $avatarManager; |
|
40 | 40 | |
41 | - /** |
|
42 | - * AvatarHome constructor. |
|
43 | - * |
|
44 | - * @param array $principalInfo |
|
45 | - * @param IAvatarManager $avatarManager |
|
46 | - */ |
|
47 | - public function __construct($principalInfo, IAvatarManager $avatarManager) { |
|
48 | - $this->principalInfo = $principalInfo; |
|
49 | - $this->avatarManager = $avatarManager; |
|
50 | - } |
|
41 | + /** |
|
42 | + * AvatarHome constructor. |
|
43 | + * |
|
44 | + * @param array $principalInfo |
|
45 | + * @param IAvatarManager $avatarManager |
|
46 | + */ |
|
47 | + public function __construct($principalInfo, IAvatarManager $avatarManager) { |
|
48 | + $this->principalInfo = $principalInfo; |
|
49 | + $this->avatarManager = $avatarManager; |
|
50 | + } |
|
51 | 51 | |
52 | - public function createFile($name, $data = null) { |
|
53 | - throw new Forbidden('Permission denied to create a file'); |
|
54 | - } |
|
52 | + public function createFile($name, $data = null) { |
|
53 | + throw new Forbidden('Permission denied to create a file'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function createDirectory($name) { |
|
57 | - throw new Forbidden('Permission denied to create a folder'); |
|
58 | - } |
|
56 | + public function createDirectory($name) { |
|
57 | + throw new Forbidden('Permission denied to create a folder'); |
|
58 | + } |
|
59 | 59 | |
60 | - public function getChild($name) { |
|
61 | - $elements = pathinfo($name); |
|
62 | - $ext = isset($elements['extension']) ? $elements['extension'] : ''; |
|
63 | - $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64'); |
|
64 | - if (!in_array($ext, ['jpeg', 'png'], true)) { |
|
65 | - throw new MethodNotAllowed('File format not allowed'); |
|
66 | - } |
|
67 | - if ($size <= 0 || $size > 1024) { |
|
68 | - throw new MethodNotAllowed('Invalid image size'); |
|
69 | - } |
|
70 | - $avatar = $this->avatarManager->getAvatar($this->getName()); |
|
71 | - if (!$avatar->exists()) { |
|
72 | - throw new NotFound(); |
|
73 | - } |
|
74 | - return new AvatarNode($size, $ext, $avatar); |
|
75 | - } |
|
60 | + public function getChild($name) { |
|
61 | + $elements = pathinfo($name); |
|
62 | + $ext = isset($elements['extension']) ? $elements['extension'] : ''; |
|
63 | + $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64'); |
|
64 | + if (!in_array($ext, ['jpeg', 'png'], true)) { |
|
65 | + throw new MethodNotAllowed('File format not allowed'); |
|
66 | + } |
|
67 | + if ($size <= 0 || $size > 1024) { |
|
68 | + throw new MethodNotAllowed('Invalid image size'); |
|
69 | + } |
|
70 | + $avatar = $this->avatarManager->getAvatar($this->getName()); |
|
71 | + if (!$avatar->exists()) { |
|
72 | + throw new NotFound(); |
|
73 | + } |
|
74 | + return new AvatarNode($size, $ext, $avatar); |
|
75 | + } |
|
76 | 76 | |
77 | - public function getChildren() { |
|
78 | - try { |
|
79 | - return [ |
|
80 | - $this->getChild('96.jpeg') |
|
81 | - ]; |
|
82 | - } catch (NotFound $exception) { |
|
83 | - return []; |
|
84 | - } |
|
85 | - } |
|
77 | + public function getChildren() { |
|
78 | + try { |
|
79 | + return [ |
|
80 | + $this->getChild('96.jpeg') |
|
81 | + ]; |
|
82 | + } catch (NotFound $exception) { |
|
83 | + return []; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - public function childExists($name) { |
|
88 | - try { |
|
89 | - $ret = $this->getChild($name); |
|
90 | - return $ret !== null; |
|
91 | - } catch (NotFound $ex) { |
|
92 | - return false; |
|
93 | - } catch (MethodNotAllowed $ex) { |
|
94 | - return false; |
|
95 | - } |
|
96 | - } |
|
87 | + public function childExists($name) { |
|
88 | + try { |
|
89 | + $ret = $this->getChild($name); |
|
90 | + return $ret !== null; |
|
91 | + } catch (NotFound $ex) { |
|
92 | + return false; |
|
93 | + } catch (MethodNotAllowed $ex) { |
|
94 | + return false; |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | - public function delete() { |
|
99 | - throw new Forbidden('Permission denied to delete this folder'); |
|
100 | - } |
|
98 | + public function delete() { |
|
99 | + throw new Forbidden('Permission denied to delete this folder'); |
|
100 | + } |
|
101 | 101 | |
102 | - public function getName() { |
|
103 | - list(,$name) = Uri\split($this->principalInfo['uri']); |
|
104 | - return $name; |
|
105 | - } |
|
102 | + public function getName() { |
|
103 | + list(,$name) = Uri\split($this->principalInfo['uri']); |
|
104 | + return $name; |
|
105 | + } |
|
106 | 106 | |
107 | - public function setName($name) { |
|
108 | - throw new Forbidden('Permission denied to rename this folder'); |
|
109 | - } |
|
107 | + public function setName($name) { |
|
108 | + throw new Forbidden('Permission denied to rename this folder'); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Returns the last modification time, as a unix timestamp |
|
113 | - * |
|
114 | - * @return int|null |
|
115 | - */ |
|
116 | - public function getLastModified() { |
|
117 | - return null; |
|
118 | - } |
|
111 | + /** |
|
112 | + * Returns the last modification time, as a unix timestamp |
|
113 | + * |
|
114 | + * @return int|null |
|
115 | + */ |
|
116 | + public function getLastModified() { |
|
117 | + return null; |
|
118 | + } |
|
119 | 119 | } |
@@ -26,71 +26,71 @@ |
||
26 | 26 | use Sabre\DAV\File; |
27 | 27 | |
28 | 28 | class AvatarNode extends File { |
29 | - private $ext; |
|
30 | - private $size; |
|
31 | - private $avatar; |
|
29 | + private $ext; |
|
30 | + private $size; |
|
31 | + private $avatar; |
|
32 | 32 | |
33 | - /** |
|
34 | - * AvatarNode constructor. |
|
35 | - * |
|
36 | - * @param integer $size |
|
37 | - * @param string $ext |
|
38 | - * @param IAvatar $avatar |
|
39 | - */ |
|
40 | - public function __construct($size, $ext, $avatar) { |
|
41 | - $this->size = $size; |
|
42 | - $this->ext = $ext; |
|
43 | - $this->avatar = $avatar; |
|
44 | - } |
|
33 | + /** |
|
34 | + * AvatarNode constructor. |
|
35 | + * |
|
36 | + * @param integer $size |
|
37 | + * @param string $ext |
|
38 | + * @param IAvatar $avatar |
|
39 | + */ |
|
40 | + public function __construct($size, $ext, $avatar) { |
|
41 | + $this->size = $size; |
|
42 | + $this->ext = $ext; |
|
43 | + $this->avatar = $avatar; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Returns the name of the node. |
|
48 | - * |
|
49 | - * This is used to generate the url. |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function getName() { |
|
54 | - return "$this->size.$this->ext"; |
|
55 | - } |
|
46 | + /** |
|
47 | + * Returns the name of the node. |
|
48 | + * |
|
49 | + * This is used to generate the url. |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function getName() { |
|
54 | + return "$this->size.$this->ext"; |
|
55 | + } |
|
56 | 56 | |
57 | - public function get() { |
|
58 | - $image = $this->avatar->get($this->size); |
|
59 | - $res = $image->resource(); |
|
57 | + public function get() { |
|
58 | + $image = $this->avatar->get($this->size); |
|
59 | + $res = $image->resource(); |
|
60 | 60 | |
61 | - ob_start(); |
|
62 | - if ($this->ext === 'png') { |
|
63 | - imagepng($res); |
|
64 | - } else { |
|
65 | - imagejpeg($res); |
|
66 | - } |
|
61 | + ob_start(); |
|
62 | + if ($this->ext === 'png') { |
|
63 | + imagepng($res); |
|
64 | + } else { |
|
65 | + imagejpeg($res); |
|
66 | + } |
|
67 | 67 | |
68 | - return ob_get_clean(); |
|
69 | - } |
|
68 | + return ob_get_clean(); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Returns the mime-type for a file |
|
73 | - * |
|
74 | - * If null is returned, we'll assume application/octet-stream |
|
75 | - * |
|
76 | - * @return string|null |
|
77 | - */ |
|
78 | - public function getContentType() { |
|
79 | - if ($this->ext === 'png') { |
|
80 | - return 'image/png'; |
|
81 | - } |
|
82 | - return 'image/jpeg'; |
|
83 | - } |
|
71 | + /** |
|
72 | + * Returns the mime-type for a file |
|
73 | + * |
|
74 | + * If null is returned, we'll assume application/octet-stream |
|
75 | + * |
|
76 | + * @return string|null |
|
77 | + */ |
|
78 | + public function getContentType() { |
|
79 | + if ($this->ext === 'png') { |
|
80 | + return 'image/png'; |
|
81 | + } |
|
82 | + return 'image/jpeg'; |
|
83 | + } |
|
84 | 84 | |
85 | - public function getETag() { |
|
86 | - return $this->avatar->getFile($this->size)->getEtag(); |
|
87 | - } |
|
85 | + public function getETag() { |
|
86 | + return $this->avatar->getFile($this->size)->getEtag(); |
|
87 | + } |
|
88 | 88 | |
89 | - public function getLastModified() { |
|
90 | - $timestamp = $this->avatar->getFile($this->size)->getMTime(); |
|
91 | - if (!empty($timestamp)) { |
|
92 | - return (int)$timestamp; |
|
93 | - } |
|
94 | - return $timestamp; |
|
95 | - } |
|
89 | + public function getLastModified() { |
|
90 | + $timestamp = $this->avatar->getFile($this->size)->getMTime(); |
|
91 | + if (!empty($timestamp)) { |
|
92 | + return (int)$timestamp; |
|
93 | + } |
|
94 | + return $timestamp; |
|
95 | + } |
|
96 | 96 | } |
@@ -89,7 +89,7 @@ |
||
89 | 89 | public function getLastModified() { |
90 | 90 | $timestamp = $this->avatar->getFile($this->size)->getMTime(); |
91 | 91 | if (!empty($timestamp)) { |
92 | - return (int)$timestamp; |
|
92 | + return (int) $timestamp; |
|
93 | 93 | } |
94 | 94 | return $timestamp; |
95 | 95 | } |
@@ -32,84 +32,84 @@ |
||
32 | 32 | |
33 | 33 | class ImageExportPlugin extends ServerPlugin { |
34 | 34 | |
35 | - /** @var Server */ |
|
36 | - protected $server; |
|
37 | - /** @var PhotoCache */ |
|
38 | - private $cache; |
|
39 | - |
|
40 | - /** |
|
41 | - * ImageExportPlugin constructor. |
|
42 | - * |
|
43 | - * @param PhotoCache $cache |
|
44 | - */ |
|
45 | - public function __construct(PhotoCache $cache) { |
|
46 | - $this->cache = $cache; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Initializes the plugin and registers event handlers |
|
51 | - * |
|
52 | - * @param Server $server |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initialize(Server $server) { |
|
56 | - $this->server = $server; |
|
57 | - $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Intercepts GET requests on addressbook urls ending with ?photo. |
|
62 | - * |
|
63 | - * @param RequestInterface $request |
|
64 | - * @param ResponseInterface $response |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
68 | - $queryParams = $request->getQueryParameters(); |
|
69 | - // TODO: in addition to photo we should also add logo some point in time |
|
70 | - if (!array_key_exists('photo', $queryParams)) { |
|
71 | - return true; |
|
72 | - } |
|
73 | - |
|
74 | - $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1; |
|
75 | - |
|
76 | - $path = $request->getPath(); |
|
77 | - $node = $this->server->tree->getNodeForPath($path); |
|
78 | - |
|
79 | - if (!($node instanceof Card)) { |
|
80 | - return true; |
|
81 | - } |
|
82 | - |
|
83 | - $this->server->transactionType = 'carddav-image-export'; |
|
84 | - |
|
85 | - // Checking ACL, if available. |
|
86 | - if ($aclPlugin = $this->server->getPlugin('acl')) { |
|
87 | - /** @var \Sabre\DAVACL\Plugin $aclPlugin */ |
|
88 | - $aclPlugin->checkPrivileges($path, '{DAV:}read'); |
|
89 | - } |
|
90 | - |
|
91 | - // Fetch addressbook |
|
92 | - $addressbookpath = explode('/', $path); |
|
93 | - array_pop($addressbookpath); |
|
94 | - $addressbookpath = implode('/', $addressbookpath); |
|
95 | - /** @var AddressBook $addressbook */ |
|
96 | - $addressbook = $this->server->tree->getNodeForPath($addressbookpath); |
|
97 | - |
|
98 | - $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate'); |
|
99 | - $response->setHeader('Etag', $node->getETag()); |
|
100 | - $response->setHeader('Pragma', 'public'); |
|
101 | - |
|
102 | - try { |
|
103 | - $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node); |
|
104 | - $response->setHeader('Content-Type', $file->getMimeType()); |
|
105 | - $response->setHeader('Content-Disposition', 'attachment'); |
|
106 | - $response->setStatus(200); |
|
107 | - |
|
108 | - $response->setBody($file->getContent()); |
|
109 | - } catch (NotFoundException $e) { |
|
110 | - $response->setStatus(404); |
|
111 | - } |
|
112 | - |
|
113 | - return false; |
|
114 | - } |
|
35 | + /** @var Server */ |
|
36 | + protected $server; |
|
37 | + /** @var PhotoCache */ |
|
38 | + private $cache; |
|
39 | + |
|
40 | + /** |
|
41 | + * ImageExportPlugin constructor. |
|
42 | + * |
|
43 | + * @param PhotoCache $cache |
|
44 | + */ |
|
45 | + public function __construct(PhotoCache $cache) { |
|
46 | + $this->cache = $cache; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Initializes the plugin and registers event handlers |
|
51 | + * |
|
52 | + * @param Server $server |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initialize(Server $server) { |
|
56 | + $this->server = $server; |
|
57 | + $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Intercepts GET requests on addressbook urls ending with ?photo. |
|
62 | + * |
|
63 | + * @param RequestInterface $request |
|
64 | + * @param ResponseInterface $response |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
68 | + $queryParams = $request->getQueryParameters(); |
|
69 | + // TODO: in addition to photo we should also add logo some point in time |
|
70 | + if (!array_key_exists('photo', $queryParams)) { |
|
71 | + return true; |
|
72 | + } |
|
73 | + |
|
74 | + $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1; |
|
75 | + |
|
76 | + $path = $request->getPath(); |
|
77 | + $node = $this->server->tree->getNodeForPath($path); |
|
78 | + |
|
79 | + if (!($node instanceof Card)) { |
|
80 | + return true; |
|
81 | + } |
|
82 | + |
|
83 | + $this->server->transactionType = 'carddav-image-export'; |
|
84 | + |
|
85 | + // Checking ACL, if available. |
|
86 | + if ($aclPlugin = $this->server->getPlugin('acl')) { |
|
87 | + /** @var \Sabre\DAVACL\Plugin $aclPlugin */ |
|
88 | + $aclPlugin->checkPrivileges($path, '{DAV:}read'); |
|
89 | + } |
|
90 | + |
|
91 | + // Fetch addressbook |
|
92 | + $addressbookpath = explode('/', $path); |
|
93 | + array_pop($addressbookpath); |
|
94 | + $addressbookpath = implode('/', $addressbookpath); |
|
95 | + /** @var AddressBook $addressbook */ |
|
96 | + $addressbook = $this->server->tree->getNodeForPath($addressbookpath); |
|
97 | + |
|
98 | + $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate'); |
|
99 | + $response->setHeader('Etag', $node->getETag()); |
|
100 | + $response->setHeader('Pragma', 'public'); |
|
101 | + |
|
102 | + try { |
|
103 | + $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node); |
|
104 | + $response->setHeader('Content-Type', $file->getMimeType()); |
|
105 | + $response->setHeader('Content-Disposition', 'attachment'); |
|
106 | + $response->setStatus(200); |
|
107 | + |
|
108 | + $response->setBody($file->getContent()); |
|
109 | + } catch (NotFoundException $e) { |
|
110 | + $response->setStatus(404); |
|
111 | + } |
|
112 | + |
|
113 | + return false; |
|
114 | + } |
|
115 | 115 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | return true; |
72 | 72 | } |
73 | 73 | |
74 | - $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1; |
|
74 | + $size = isset($queryParams['size']) ? (int) $queryParams['size'] : -1; |
|
75 | 75 | |
76 | 76 | $path = $request->getPath(); |
77 | 77 | $node = $this->server->tree->getNodeForPath($path); |
@@ -39,7 +39,7 @@ |
||
39 | 39 | |
40 | 40 | public function xmlSerialize(Writer $writer) { |
41 | 41 | foreach ($this->groups as $group) { |
42 | - $writer->writeElement('{' . self::NS_OWNCLOUD . '}group', $group); |
|
42 | + $writer->writeElement('{'.self::NS_OWNCLOUD.'}group', $group); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -27,21 +27,21 @@ |
||
27 | 27 | use Sabre\Xml\XmlSerializable; |
28 | 28 | |
29 | 29 | class Groups implements XmlSerializable { |
30 | - public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
30 | + public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
31 | 31 | |
32 | - /** @var string[] of TYPE:CHECKSUM */ |
|
33 | - private $groups; |
|
32 | + /** @var string[] of TYPE:CHECKSUM */ |
|
33 | + private $groups; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param string $groups |
|
37 | - */ |
|
38 | - public function __construct($groups) { |
|
39 | - $this->groups = $groups; |
|
40 | - } |
|
35 | + /** |
|
36 | + * @param string $groups |
|
37 | + */ |
|
38 | + public function __construct($groups) { |
|
39 | + $this->groups = $groups; |
|
40 | + } |
|
41 | 41 | |
42 | - public function xmlSerialize(Writer $writer) { |
|
43 | - foreach ($this->groups as $group) { |
|
44 | - $writer->writeElement('{' . self::NS_OWNCLOUD . '}group', $group); |
|
45 | - } |
|
46 | - } |
|
42 | + public function xmlSerialize(Writer $writer) { |
|
43 | + foreach ($this->groups as $group) { |
|
44 | + $writer->writeElement('{' . self::NS_OWNCLOUD . '}group', $group); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $offset = $arguments['offset']; |
72 | 72 | $stopAt = $arguments['stopAt']; |
73 | 73 | |
74 | - $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
74 | + $this->logger->info('Building calendar index ('.$offset.'/'.$stopAt.')'); |
|
75 | 75 | |
76 | 76 | $offset = $this->buildIndex($offset, $stopAt); |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'offset' => $offset, |
83 | 83 | 'stopAt' => $stopAt |
84 | 84 | ]); |
85 | - $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
85 | + $this->logger->info('New building calendar index job scheduled with offset '.$offset); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 |
@@ -33,90 +33,90 @@ |
||
33 | 33 | |
34 | 34 | class BuildCalendarSearchIndexBackgroundJob extends QueuedJob { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $db; |
|
38 | - |
|
39 | - /** @var CalDavBackend */ |
|
40 | - private $calDavBackend; |
|
41 | - |
|
42 | - /** @var ILogger */ |
|
43 | - private $logger; |
|
44 | - |
|
45 | - /** @var IJobList */ |
|
46 | - private $jobList; |
|
47 | - |
|
48 | - /** @var ITimeFactory */ |
|
49 | - private $timeFactory; |
|
50 | - |
|
51 | - /** |
|
52 | - * @param IDBConnection $db |
|
53 | - * @param CalDavBackend $calDavBackend |
|
54 | - * @param ILogger $logger |
|
55 | - * @param IJobList $jobList |
|
56 | - * @param ITimeFactory $timeFactory |
|
57 | - */ |
|
58 | - public function __construct(IDBConnection $db, |
|
59 | - CalDavBackend $calDavBackend, |
|
60 | - ILogger $logger, |
|
61 | - IJobList $jobList, |
|
62 | - ITimeFactory $timeFactory) { |
|
63 | - $this->db = $db; |
|
64 | - $this->calDavBackend = $calDavBackend; |
|
65 | - $this->logger = $logger; |
|
66 | - $this->jobList = $jobList; |
|
67 | - $this->timeFactory = $timeFactory; |
|
68 | - } |
|
69 | - |
|
70 | - public function run($arguments) { |
|
71 | - $offset = $arguments['offset']; |
|
72 | - $stopAt = $arguments['stopAt']; |
|
73 | - |
|
74 | - $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
75 | - |
|
76 | - $offset = $this->buildIndex($offset, $stopAt); |
|
77 | - |
|
78 | - if ($offset >= $stopAt) { |
|
79 | - $this->logger->info('Building calendar index done'); |
|
80 | - } else { |
|
81 | - $this->jobList->add(self::class, [ |
|
82 | - 'offset' => $offset, |
|
83 | - 'stopAt' => $stopAt |
|
84 | - ]); |
|
85 | - $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @param int $offset |
|
91 | - * @param int $stopAt |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - private function buildIndex($offset, $stopAt) { |
|
95 | - $startTime = $this->timeFactory->getTime(); |
|
96 | - |
|
97 | - $query = $this->db->getQueryBuilder(); |
|
98 | - $query->select(['id', 'calendarid', 'uri', 'calendardata']) |
|
99 | - ->from('calendarobjects') |
|
100 | - ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt))) |
|
101 | - ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset))) |
|
102 | - ->orderBy('id', 'ASC'); |
|
103 | - |
|
104 | - $stmt = $query->execute(); |
|
105 | - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
106 | - $offset = $row['id']; |
|
107 | - |
|
108 | - $calendarData = $row['calendardata']; |
|
109 | - if (is_resource($calendarData)) { |
|
110 | - $calendarData = stream_get_contents($calendarData); |
|
111 | - } |
|
112 | - |
|
113 | - $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData); |
|
114 | - |
|
115 | - if (($this->timeFactory->getTime() - $startTime) > 15) { |
|
116 | - return $offset; |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - return $stopAt; |
|
121 | - } |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $db; |
|
38 | + |
|
39 | + /** @var CalDavBackend */ |
|
40 | + private $calDavBackend; |
|
41 | + |
|
42 | + /** @var ILogger */ |
|
43 | + private $logger; |
|
44 | + |
|
45 | + /** @var IJobList */ |
|
46 | + private $jobList; |
|
47 | + |
|
48 | + /** @var ITimeFactory */ |
|
49 | + private $timeFactory; |
|
50 | + |
|
51 | + /** |
|
52 | + * @param IDBConnection $db |
|
53 | + * @param CalDavBackend $calDavBackend |
|
54 | + * @param ILogger $logger |
|
55 | + * @param IJobList $jobList |
|
56 | + * @param ITimeFactory $timeFactory |
|
57 | + */ |
|
58 | + public function __construct(IDBConnection $db, |
|
59 | + CalDavBackend $calDavBackend, |
|
60 | + ILogger $logger, |
|
61 | + IJobList $jobList, |
|
62 | + ITimeFactory $timeFactory) { |
|
63 | + $this->db = $db; |
|
64 | + $this->calDavBackend = $calDavBackend; |
|
65 | + $this->logger = $logger; |
|
66 | + $this->jobList = $jobList; |
|
67 | + $this->timeFactory = $timeFactory; |
|
68 | + } |
|
69 | + |
|
70 | + public function run($arguments) { |
|
71 | + $offset = $arguments['offset']; |
|
72 | + $stopAt = $arguments['stopAt']; |
|
73 | + |
|
74 | + $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
75 | + |
|
76 | + $offset = $this->buildIndex($offset, $stopAt); |
|
77 | + |
|
78 | + if ($offset >= $stopAt) { |
|
79 | + $this->logger->info('Building calendar index done'); |
|
80 | + } else { |
|
81 | + $this->jobList->add(self::class, [ |
|
82 | + 'offset' => $offset, |
|
83 | + 'stopAt' => $stopAt |
|
84 | + ]); |
|
85 | + $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @param int $offset |
|
91 | + * @param int $stopAt |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + private function buildIndex($offset, $stopAt) { |
|
95 | + $startTime = $this->timeFactory->getTime(); |
|
96 | + |
|
97 | + $query = $this->db->getQueryBuilder(); |
|
98 | + $query->select(['id', 'calendarid', 'uri', 'calendardata']) |
|
99 | + ->from('calendarobjects') |
|
100 | + ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt))) |
|
101 | + ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset))) |
|
102 | + ->orderBy('id', 'ASC'); |
|
103 | + |
|
104 | + $stmt = $query->execute(); |
|
105 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
106 | + $offset = $row['id']; |
|
107 | + |
|
108 | + $calendarData = $row['calendardata']; |
|
109 | + if (is_resource($calendarData)) { |
|
110 | + $calendarData = stream_get_contents($calendarData); |
|
111 | + } |
|
112 | + |
|
113 | + $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData); |
|
114 | + |
|
115 | + if (($this->timeFactory->getTime() - $startTime) > 15) { |
|
116 | + return $offset; |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + return $stopAt; |
|
121 | + } |
|
122 | 122 | } |
@@ -29,47 +29,47 @@ |
||
29 | 29 | */ |
30 | 30 | interface IShareable extends INode { |
31 | 31 | |
32 | - /** |
|
33 | - * Updates the list of shares. |
|
34 | - * |
|
35 | - * The first array is a list of people that are to be added to the |
|
36 | - * resource. |
|
37 | - * |
|
38 | - * Every element in the add array has the following properties: |
|
39 | - * * href - A url. Usually a mailto: address |
|
40 | - * * commonName - Usually a first and last name, or false |
|
41 | - * * summary - A description of the share, can also be false |
|
42 | - * * readOnly - A boolean value |
|
43 | - * |
|
44 | - * Every element in the remove array is just the address string. |
|
45 | - * |
|
46 | - * @param array $add |
|
47 | - * @param array $remove |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - public function updateShares(array $add, array $remove); |
|
32 | + /** |
|
33 | + * Updates the list of shares. |
|
34 | + * |
|
35 | + * The first array is a list of people that are to be added to the |
|
36 | + * resource. |
|
37 | + * |
|
38 | + * Every element in the add array has the following properties: |
|
39 | + * * href - A url. Usually a mailto: address |
|
40 | + * * commonName - Usually a first and last name, or false |
|
41 | + * * summary - A description of the share, can also be false |
|
42 | + * * readOnly - A boolean value |
|
43 | + * |
|
44 | + * Every element in the remove array is just the address string. |
|
45 | + * |
|
46 | + * @param array $add |
|
47 | + * @param array $remove |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + public function updateShares(array $add, array $remove); |
|
51 | 51 | |
52 | - /** |
|
53 | - * Returns the list of people whom this resource is shared with. |
|
54 | - * |
|
55 | - * Every element in this array should have the following properties: |
|
56 | - * * href - Often a mailto: address |
|
57 | - * * commonName - Optional, for example a first + last name |
|
58 | - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
59 | - * * readOnly - boolean |
|
60 | - * * summary - Optional, a description for the share |
|
61 | - * |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function getShares(); |
|
52 | + /** |
|
53 | + * Returns the list of people whom this resource is shared with. |
|
54 | + * |
|
55 | + * Every element in this array should have the following properties: |
|
56 | + * * href - Often a mailto: address |
|
57 | + * * commonName - Optional, for example a first + last name |
|
58 | + * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. |
|
59 | + * * readOnly - boolean |
|
60 | + * * summary - Optional, a description for the share |
|
61 | + * |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function getShares(); |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - public function getResourceId(); |
|
66 | + /** |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + public function getResourceId(); |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getOwner(); |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getOwner(); |
|
75 | 75 | } |
@@ -41,120 +41,120 @@ |
||
41 | 41 | */ |
42 | 42 | class Invite implements XmlSerializable { |
43 | 43 | |
44 | - /** |
|
45 | - * The list of users a calendar has been shared to. |
|
46 | - * |
|
47 | - * @var array |
|
48 | - */ |
|
49 | - protected $users; |
|
44 | + /** |
|
45 | + * The list of users a calendar has been shared to. |
|
46 | + * |
|
47 | + * @var array |
|
48 | + */ |
|
49 | + protected $users; |
|
50 | 50 | |
51 | - /** |
|
52 | - * The organizer contains information about the person who shared the |
|
53 | - * object. |
|
54 | - * |
|
55 | - * @var array|null |
|
56 | - */ |
|
57 | - protected $organizer; |
|
51 | + /** |
|
52 | + * The organizer contains information about the person who shared the |
|
53 | + * object. |
|
54 | + * |
|
55 | + * @var array|null |
|
56 | + */ |
|
57 | + protected $organizer; |
|
58 | 58 | |
59 | - /** |
|
60 | - * Creates the property. |
|
61 | - * |
|
62 | - * Users is an array. Each element of the array has the following |
|
63 | - * properties: |
|
64 | - * |
|
65 | - * * href - Often a mailto: address |
|
66 | - * * commonName - Optional, for example a first and lastname for a user. |
|
67 | - * * status - One of the SharingPlugin::STATUS_* constants. |
|
68 | - * * readOnly - true or false |
|
69 | - * * summary - Optional, description of the share |
|
70 | - * |
|
71 | - * The organizer key is optional to specify. It's only useful when a |
|
72 | - * 'sharee' requests the sharing information. |
|
73 | - * |
|
74 | - * The organizer may have the following properties: |
|
75 | - * * href - Often a mailto: address. |
|
76 | - * * commonName - Optional human-readable name. |
|
77 | - * * firstName - Optional first name. |
|
78 | - * * lastName - Optional last name. |
|
79 | - * |
|
80 | - * If you wonder why these two structures are so different, I guess a |
|
81 | - * valid answer is that the current spec is still a draft. |
|
82 | - * |
|
83 | - * @param array $users |
|
84 | - */ |
|
85 | - public function __construct(array $users, array $organizer = null) { |
|
86 | - $this->users = $users; |
|
87 | - $this->organizer = $organizer; |
|
88 | - } |
|
59 | + /** |
|
60 | + * Creates the property. |
|
61 | + * |
|
62 | + * Users is an array. Each element of the array has the following |
|
63 | + * properties: |
|
64 | + * |
|
65 | + * * href - Often a mailto: address |
|
66 | + * * commonName - Optional, for example a first and lastname for a user. |
|
67 | + * * status - One of the SharingPlugin::STATUS_* constants. |
|
68 | + * * readOnly - true or false |
|
69 | + * * summary - Optional, description of the share |
|
70 | + * |
|
71 | + * The organizer key is optional to specify. It's only useful when a |
|
72 | + * 'sharee' requests the sharing information. |
|
73 | + * |
|
74 | + * The organizer may have the following properties: |
|
75 | + * * href - Often a mailto: address. |
|
76 | + * * commonName - Optional human-readable name. |
|
77 | + * * firstName - Optional first name. |
|
78 | + * * lastName - Optional last name. |
|
79 | + * |
|
80 | + * If you wonder why these two structures are so different, I guess a |
|
81 | + * valid answer is that the current spec is still a draft. |
|
82 | + * |
|
83 | + * @param array $users |
|
84 | + */ |
|
85 | + public function __construct(array $users, array $organizer = null) { |
|
86 | + $this->users = $users; |
|
87 | + $this->organizer = $organizer; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Returns the list of users, as it was passed to the constructor. |
|
92 | - * |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - public function getValue() { |
|
96 | - return $this->users; |
|
97 | - } |
|
90 | + /** |
|
91 | + * Returns the list of users, as it was passed to the constructor. |
|
92 | + * |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + public function getValue() { |
|
96 | + return $this->users; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * The xmlSerialize metod is called during xml writing. |
|
101 | - * |
|
102 | - * Use the $writer argument to write its own xml serialization. |
|
103 | - * |
|
104 | - * An important note: do _not_ create a parent element. Any element |
|
105 | - * implementing XmlSerializble should only ever write what's considered |
|
106 | - * its 'inner xml'. |
|
107 | - * |
|
108 | - * The parent of the current element is responsible for writing a |
|
109 | - * containing element. |
|
110 | - * |
|
111 | - * This allows serializers to be re-used for different element names. |
|
112 | - * |
|
113 | - * If you are opening new elements, you must also close them again. |
|
114 | - * |
|
115 | - * @param Writer $writer |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - public function xmlSerialize(Writer $writer) { |
|
119 | - $cs = '{' . Plugin::NS_OWNCLOUD . '}'; |
|
99 | + /** |
|
100 | + * The xmlSerialize metod is called during xml writing. |
|
101 | + * |
|
102 | + * Use the $writer argument to write its own xml serialization. |
|
103 | + * |
|
104 | + * An important note: do _not_ create a parent element. Any element |
|
105 | + * implementing XmlSerializble should only ever write what's considered |
|
106 | + * its 'inner xml'. |
|
107 | + * |
|
108 | + * The parent of the current element is responsible for writing a |
|
109 | + * containing element. |
|
110 | + * |
|
111 | + * This allows serializers to be re-used for different element names. |
|
112 | + * |
|
113 | + * If you are opening new elements, you must also close them again. |
|
114 | + * |
|
115 | + * @param Writer $writer |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + public function xmlSerialize(Writer $writer) { |
|
119 | + $cs = '{' . Plugin::NS_OWNCLOUD . '}'; |
|
120 | 120 | |
121 | - if (!is_null($this->organizer)) { |
|
122 | - $writer->startElement($cs . 'organizer'); |
|
123 | - $writer->writeElement('{DAV:}href', $this->organizer['href']); |
|
121 | + if (!is_null($this->organizer)) { |
|
122 | + $writer->startElement($cs . 'organizer'); |
|
123 | + $writer->writeElement('{DAV:}href', $this->organizer['href']); |
|
124 | 124 | |
125 | - if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
|
126 | - $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
127 | - } |
|
128 | - if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
|
129 | - $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
130 | - } |
|
131 | - if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
|
132 | - $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
133 | - } |
|
134 | - $writer->endElement(); // organizer |
|
135 | - } |
|
125 | + if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
|
126 | + $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
127 | + } |
|
128 | + if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
|
129 | + $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
130 | + } |
|
131 | + if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
|
132 | + $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
133 | + } |
|
134 | + $writer->endElement(); // organizer |
|
135 | + } |
|
136 | 136 | |
137 | - foreach ($this->users as $user) { |
|
138 | - $writer->startElement($cs . 'user'); |
|
139 | - $writer->writeElement('{DAV:}href', $user['href']); |
|
140 | - if (isset($user['commonName']) && $user['commonName']) { |
|
141 | - $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
142 | - } |
|
143 | - $writer->writeElement($cs . 'invite-accepted'); |
|
137 | + foreach ($this->users as $user) { |
|
138 | + $writer->startElement($cs . 'user'); |
|
139 | + $writer->writeElement('{DAV:}href', $user['href']); |
|
140 | + if (isset($user['commonName']) && $user['commonName']) { |
|
141 | + $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
142 | + } |
|
143 | + $writer->writeElement($cs . 'invite-accepted'); |
|
144 | 144 | |
145 | - $writer->startElement($cs . 'access'); |
|
146 | - if ($user['readOnly']) { |
|
147 | - $writer->writeElement($cs . 'read'); |
|
148 | - } else { |
|
149 | - $writer->writeElement($cs . 'read-write'); |
|
150 | - } |
|
151 | - $writer->endElement(); // access |
|
145 | + $writer->startElement($cs . 'access'); |
|
146 | + if ($user['readOnly']) { |
|
147 | + $writer->writeElement($cs . 'read'); |
|
148 | + } else { |
|
149 | + $writer->writeElement($cs . 'read-write'); |
|
150 | + } |
|
151 | + $writer->endElement(); // access |
|
152 | 152 | |
153 | - if (isset($user['summary']) && $user['summary']) { |
|
154 | - $writer->writeElement($cs . 'summary', $user['summary']); |
|
155 | - } |
|
153 | + if (isset($user['summary']) && $user['summary']) { |
|
154 | + $writer->writeElement($cs . 'summary', $user['summary']); |
|
155 | + } |
|
156 | 156 | |
157 | - $writer->endElement(); //user |
|
158 | - } |
|
159 | - } |
|
157 | + $writer->endElement(); //user |
|
158 | + } |
|
159 | + } |
|
160 | 160 | } |
@@ -116,42 +116,42 @@ |
||
116 | 116 | * @return void |
117 | 117 | */ |
118 | 118 | public function xmlSerialize(Writer $writer) { |
119 | - $cs = '{' . Plugin::NS_OWNCLOUD . '}'; |
|
119 | + $cs = '{'.Plugin::NS_OWNCLOUD.'}'; |
|
120 | 120 | |
121 | 121 | if (!is_null($this->organizer)) { |
122 | - $writer->startElement($cs . 'organizer'); |
|
122 | + $writer->startElement($cs.'organizer'); |
|
123 | 123 | $writer->writeElement('{DAV:}href', $this->organizer['href']); |
124 | 124 | |
125 | 125 | if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
126 | - $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
126 | + $writer->writeElement($cs.'common-name', $this->organizer['commonName']); |
|
127 | 127 | } |
128 | 128 | if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
129 | - $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
129 | + $writer->writeElement($cs.'first-name', $this->organizer['firstName']); |
|
130 | 130 | } |
131 | 131 | if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
132 | - $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
132 | + $writer->writeElement($cs.'last-name', $this->organizer['lastName']); |
|
133 | 133 | } |
134 | 134 | $writer->endElement(); // organizer |
135 | 135 | } |
136 | 136 | |
137 | 137 | foreach ($this->users as $user) { |
138 | - $writer->startElement($cs . 'user'); |
|
138 | + $writer->startElement($cs.'user'); |
|
139 | 139 | $writer->writeElement('{DAV:}href', $user['href']); |
140 | 140 | if (isset($user['commonName']) && $user['commonName']) { |
141 | - $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
141 | + $writer->writeElement($cs.'common-name', $user['commonName']); |
|
142 | 142 | } |
143 | - $writer->writeElement($cs . 'invite-accepted'); |
|
143 | + $writer->writeElement($cs.'invite-accepted'); |
|
144 | 144 | |
145 | - $writer->startElement($cs . 'access'); |
|
145 | + $writer->startElement($cs.'access'); |
|
146 | 146 | if ($user['readOnly']) { |
147 | - $writer->writeElement($cs . 'read'); |
|
147 | + $writer->writeElement($cs.'read'); |
|
148 | 148 | } else { |
149 | - $writer->writeElement($cs . 'read-write'); |
|
149 | + $writer->writeElement($cs.'read-write'); |
|
150 | 150 | } |
151 | 151 | $writer->endElement(); // access |
152 | 152 | |
153 | 153 | if (isset($user['summary']) && $user['summary']) { |
154 | - $writer->writeElement($cs . 'summary', $user['summary']); |
|
154 | + $writer->writeElement($cs.'summary', $user['summary']); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $writer->endElement(); //user |
@@ -63,7 +63,7 @@ |
||
63 | 63 | private function setupUserFs($userId) { |
64 | 64 | \OC_Util::setupFS($userId); |
65 | 65 | $this->session->close(); |
66 | - return $this->principalPrefix . $userId; |
|
66 | + return $this->principalPrefix.$userId; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -31,66 +31,66 @@ |
||
31 | 31 | use Sabre\HTTP\ResponseInterface; |
32 | 32 | |
33 | 33 | class BearerAuth extends AbstractBearer { |
34 | - /** @var IUserSession */ |
|
35 | - private $userSession; |
|
36 | - /** @var ISession */ |
|
37 | - private $session; |
|
38 | - /** @var IRequest */ |
|
39 | - private $request; |
|
40 | - /** @var string */ |
|
41 | - private $principalPrefix; |
|
34 | + /** @var IUserSession */ |
|
35 | + private $userSession; |
|
36 | + /** @var ISession */ |
|
37 | + private $session; |
|
38 | + /** @var IRequest */ |
|
39 | + private $request; |
|
40 | + /** @var string */ |
|
41 | + private $principalPrefix; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param IUserSession $userSession |
|
45 | - * @param ISession $session |
|
46 | - * @param string $principalPrefix |
|
47 | - * @param IRequest $request |
|
48 | - */ |
|
49 | - public function __construct(IUserSession $userSession, |
|
50 | - ISession $session, |
|
51 | - IRequest $request, |
|
52 | - $principalPrefix = 'principals/users/') { |
|
53 | - $this->userSession = $userSession; |
|
54 | - $this->session = $session; |
|
55 | - $this->request = $request; |
|
56 | - $this->principalPrefix = $principalPrefix; |
|
43 | + /** |
|
44 | + * @param IUserSession $userSession |
|
45 | + * @param ISession $session |
|
46 | + * @param string $principalPrefix |
|
47 | + * @param IRequest $request |
|
48 | + */ |
|
49 | + public function __construct(IUserSession $userSession, |
|
50 | + ISession $session, |
|
51 | + IRequest $request, |
|
52 | + $principalPrefix = 'principals/users/') { |
|
53 | + $this->userSession = $userSession; |
|
54 | + $this->session = $session; |
|
55 | + $this->request = $request; |
|
56 | + $this->principalPrefix = $principalPrefix; |
|
57 | 57 | |
58 | - // setup realm |
|
59 | - $defaults = new \OCP\Defaults(); |
|
60 | - $this->realm = $defaults->getName(); |
|
61 | - } |
|
58 | + // setup realm |
|
59 | + $defaults = new \OCP\Defaults(); |
|
60 | + $this->realm = $defaults->getName(); |
|
61 | + } |
|
62 | 62 | |
63 | - private function setupUserFs($userId) { |
|
64 | - \OC_Util::setupFS($userId); |
|
65 | - $this->session->close(); |
|
66 | - return $this->principalPrefix . $userId; |
|
67 | - } |
|
63 | + private function setupUserFs($userId) { |
|
64 | + \OC_Util::setupFS($userId); |
|
65 | + $this->session->close(); |
|
66 | + return $this->principalPrefix . $userId; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * {@inheritdoc} |
|
71 | - */ |
|
72 | - public function validateBearerToken($bearerToken) { |
|
73 | - \OC_Util::setupFS(); |
|
69 | + /** |
|
70 | + * {@inheritdoc} |
|
71 | + */ |
|
72 | + public function validateBearerToken($bearerToken) { |
|
73 | + \OC_Util::setupFS(); |
|
74 | 74 | |
75 | - if (!$this->userSession->isLoggedIn()) { |
|
76 | - $this->userSession->tryTokenLogin($this->request); |
|
77 | - } |
|
78 | - if ($this->userSession->isLoggedIn()) { |
|
79 | - return $this->setupUserFs($this->userSession->getUser()->getUID()); |
|
80 | - } |
|
75 | + if (!$this->userSession->isLoggedIn()) { |
|
76 | + $this->userSession->tryTokenLogin($this->request); |
|
77 | + } |
|
78 | + if ($this->userSession->isLoggedIn()) { |
|
79 | + return $this->setupUserFs($this->userSession->getUser()->getUID()); |
|
80 | + } |
|
81 | 81 | |
82 | - return false; |
|
83 | - } |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * \Sabre\DAV\Auth\Backend\AbstractBearer::challenge sets an WWW-Authenticate |
|
87 | - * header which some DAV clients can't handle. Thus we override this function |
|
88 | - * and make it simply return a 401. |
|
89 | - * |
|
90 | - * @param RequestInterface $request |
|
91 | - * @param ResponseInterface $response |
|
92 | - */ |
|
93 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
94 | - $response->setStatus(401); |
|
95 | - } |
|
85 | + /** |
|
86 | + * \Sabre\DAV\Auth\Backend\AbstractBearer::challenge sets an WWW-Authenticate |
|
87 | + * header which some DAV clients can't handle. Thus we override this function |
|
88 | + * and make it simply return a 401. |
|
89 | + * |
|
90 | + * @param RequestInterface $request |
|
91 | + * @param ResponseInterface $response |
|
92 | + */ |
|
93 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
94 | + $response->setStatus(401); |
|
95 | + } |
|
96 | 96 | } |
@@ -29,19 +29,19 @@ |
||
29 | 29 | use Exception; |
30 | 30 | |
31 | 31 | class FileLocked extends \Sabre\DAV\Exception { |
32 | - public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
33 | - if ($previous instanceof \OCP\Files\LockNotAcquiredException) { |
|
34 | - $message = sprintf('Target file %s is locked by another process.', $previous->path); |
|
35 | - } |
|
36 | - parent::__construct($message, $code, $previous); |
|
37 | - } |
|
32 | + public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
33 | + if ($previous instanceof \OCP\Files\LockNotAcquiredException) { |
|
34 | + $message = sprintf('Target file %s is locked by another process.', $previous->path); |
|
35 | + } |
|
36 | + parent::__construct($message, $code, $previous); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Returns the HTTP status code for this exception |
|
41 | - * |
|
42 | - * @return int |
|
43 | - */ |
|
44 | - public function getHTTPCode() { |
|
45 | - return 423; |
|
46 | - } |
|
39 | + /** |
|
40 | + * Returns the HTTP status code for this exception |
|
41 | + * |
|
42 | + * @return int |
|
43 | + */ |
|
44 | + public function getHTTPCode() { |
|
45 | + return 423; |
|
46 | + } |
|
47 | 47 | } |