@@ -28,30 +28,30 @@ |
||
28 | 28 | |
29 | 29 | class RootCollection extends AbstractPrincipalCollection { |
30 | 30 | |
31 | - /** |
|
32 | - * This method returns a node for a principal. |
|
33 | - * |
|
34 | - * The passed array contains principal information, and is guaranteed to |
|
35 | - * at least contain a uri item. Other properties may or may not be |
|
36 | - * supplied by the authentication backend. |
|
37 | - * |
|
38 | - * @param array $principalInfo |
|
39 | - * @return INode |
|
40 | - */ |
|
41 | - function getChildForPrincipal(array $principalInfo) { |
|
42 | - list(,$name) = URLUtil::splitPath($principalInfo['uri']); |
|
43 | - $user = \OC::$server->getUserSession()->getUser(); |
|
44 | - if (is_null($user) || $name !== $user->getUID()) { |
|
45 | - // a user is only allowed to see their own home contents, so in case another collection |
|
46 | - // is accessed, we return a simple empty collection for now |
|
47 | - // in the future this could be considered to be used for accessing shared files |
|
48 | - return new SimpleCollection($name); |
|
49 | - } |
|
50 | - return new FilesHome($principalInfo); |
|
51 | - } |
|
31 | + /** |
|
32 | + * This method returns a node for a principal. |
|
33 | + * |
|
34 | + * The passed array contains principal information, and is guaranteed to |
|
35 | + * at least contain a uri item. Other properties may or may not be |
|
36 | + * supplied by the authentication backend. |
|
37 | + * |
|
38 | + * @param array $principalInfo |
|
39 | + * @return INode |
|
40 | + */ |
|
41 | + function getChildForPrincipal(array $principalInfo) { |
|
42 | + list(,$name) = URLUtil::splitPath($principalInfo['uri']); |
|
43 | + $user = \OC::$server->getUserSession()->getUser(); |
|
44 | + if (is_null($user) || $name !== $user->getUID()) { |
|
45 | + // a user is only allowed to see their own home contents, so in case another collection |
|
46 | + // is accessed, we return a simple empty collection for now |
|
47 | + // in the future this could be considered to be used for accessing shared files |
|
48 | + return new SimpleCollection($name); |
|
49 | + } |
|
50 | + return new FilesHome($principalInfo); |
|
51 | + } |
|
52 | 52 | |
53 | - function getName() { |
|
54 | - return 'files'; |
|
55 | - } |
|
53 | + function getName() { |
|
54 | + return 'files'; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | } |
@@ -32,33 +32,33 @@ |
||
32 | 32 | * Verify that the public link share is valid |
33 | 33 | */ |
34 | 34 | class PublicLinkCheckPlugin extends ServerPlugin { |
35 | - /** |
|
36 | - * @var FileInfo |
|
37 | - */ |
|
38 | - private $fileInfo; |
|
35 | + /** |
|
36 | + * @var FileInfo |
|
37 | + */ |
|
38 | + private $fileInfo; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param FileInfo $fileInfo |
|
42 | - */ |
|
43 | - public function setFileInfo($fileInfo) { |
|
44 | - $this->fileInfo = $fileInfo; |
|
45 | - } |
|
40 | + /** |
|
41 | + * @param FileInfo $fileInfo |
|
42 | + */ |
|
43 | + public function setFileInfo($fileInfo) { |
|
44 | + $this->fileInfo = $fileInfo; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * This initializes the plugin. |
|
49 | - * |
|
50 | - * @param \Sabre\DAV\Server $server Sabre server |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function initialize(\Sabre\DAV\Server $server) { |
|
55 | - $server->on('beforeMethod', [$this, 'beforeMethod']); |
|
56 | - } |
|
47 | + /** |
|
48 | + * This initializes the plugin. |
|
49 | + * |
|
50 | + * @param \Sabre\DAV\Server $server Sabre server |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function initialize(\Sabre\DAV\Server $server) { |
|
55 | + $server->on('beforeMethod', [$this, 'beforeMethod']); |
|
56 | + } |
|
57 | 57 | |
58 | - public function beforeMethod(RequestInterface $request, ResponseInterface $response){ |
|
59 | - // verify that the owner didn't have his share permissions revoked |
|
60 | - if ($this->fileInfo && !$this->fileInfo->isShareable()) { |
|
61 | - throw new NotFound(); |
|
62 | - } |
|
63 | - } |
|
58 | + public function beforeMethod(RequestInterface $request, ResponseInterface $response){ |
|
59 | + // verify that the owner didn't have his share permissions revoked |
|
60 | + if ($this->fileInfo && !$this->fileInfo->isShareable()) { |
|
61 | + throw new NotFound(); |
|
62 | + } |
|
63 | + } |
|
64 | 64 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $server->on('beforeMethod', [$this, 'beforeMethod']); |
56 | 56 | } |
57 | 57 | |
58 | - public function beforeMethod(RequestInterface $request, ResponseInterface $response){ |
|
58 | + public function beforeMethod(RequestInterface $request, ResponseInterface $response) { |
|
59 | 59 | // verify that the owner didn't have his share permissions revoked |
60 | 60 | if ($this->fileInfo && !$this->fileInfo->isShareable()) { |
61 | 61 | throw new NotFound(); |
@@ -33,52 +33,52 @@ |
||
33 | 33 | */ |
34 | 34 | class FilesDropPlugin extends ServerPlugin { |
35 | 35 | |
36 | - /** @var View */ |
|
37 | - private $view; |
|
36 | + /** @var View */ |
|
37 | + private $view; |
|
38 | 38 | |
39 | - /** @var bool */ |
|
40 | - private $enabled = false; |
|
39 | + /** @var bool */ |
|
40 | + private $enabled = false; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param View $view |
|
44 | - */ |
|
45 | - public function setView($view) { |
|
46 | - $this->view = $view; |
|
47 | - } |
|
42 | + /** |
|
43 | + * @param View $view |
|
44 | + */ |
|
45 | + public function setView($view) { |
|
46 | + $this->view = $view; |
|
47 | + } |
|
48 | 48 | |
49 | - public function enable() { |
|
50 | - $this->enabled = true; |
|
51 | - } |
|
49 | + public function enable() { |
|
50 | + $this->enabled = true; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * This initializes the plugin. |
|
56 | - * |
|
57 | - * @param \Sabre\DAV\Server $server Sabre server |
|
58 | - * |
|
59 | - * @return void |
|
60 | - * @throws MethodNotAllowed |
|
61 | - */ |
|
62 | - public function initialize(\Sabre\DAV\Server $server) { |
|
63 | - $server->on('beforeMethod', [$this, 'beforeMethod'], 999); |
|
64 | - $this->enabled = false; |
|
65 | - } |
|
54 | + /** |
|
55 | + * This initializes the plugin. |
|
56 | + * |
|
57 | + * @param \Sabre\DAV\Server $server Sabre server |
|
58 | + * |
|
59 | + * @return void |
|
60 | + * @throws MethodNotAllowed |
|
61 | + */ |
|
62 | + public function initialize(\Sabre\DAV\Server $server) { |
|
63 | + $server->on('beforeMethod', [$this, 'beforeMethod'], 999); |
|
64 | + $this->enabled = false; |
|
65 | + } |
|
66 | 66 | |
67 | - public function beforeMethod(RequestInterface $request, ResponseInterface $response){ |
|
67 | + public function beforeMethod(RequestInterface $request, ResponseInterface $response){ |
|
68 | 68 | |
69 | - if (!$this->enabled) { |
|
70 | - return; |
|
71 | - } |
|
69 | + if (!$this->enabled) { |
|
70 | + return; |
|
71 | + } |
|
72 | 72 | |
73 | - if ($request->getMethod() !== 'PUT') { |
|
74 | - throw new MethodNotAllowed('Only PUT is allowed on files drop'); |
|
75 | - } |
|
73 | + if ($request->getMethod() !== 'PUT') { |
|
74 | + throw new MethodNotAllowed('Only PUT is allowed on files drop'); |
|
75 | + } |
|
76 | 76 | |
77 | - $path = explode('/', $request->getPath()); |
|
78 | - $path = array_pop($path); |
|
77 | + $path = explode('/', $request->getPath()); |
|
78 | + $path = array_pop($path); |
|
79 | 79 | |
80 | - $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); |
|
81 | - $url = $request->getBaseUrl() . $newName; |
|
82 | - $request->setUrl($url); |
|
83 | - } |
|
80 | + $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); |
|
81 | + $url = $request->getBaseUrl() . $newName; |
|
82 | + $request->setUrl($url); |
|
83 | + } |
|
84 | 84 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->enabled = false; |
65 | 65 | } |
66 | 66 | |
67 | - public function beforeMethod(RequestInterface $request, ResponseInterface $response){ |
|
67 | + public function beforeMethod(RequestInterface $request, ResponseInterface $response) { |
|
68 | 68 | |
69 | 69 | if (!$this->enabled) { |
70 | 70 | return; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $path = array_pop($path); |
79 | 79 | |
80 | 80 | $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); |
81 | - $url = $request->getBaseUrl() . $newName; |
|
81 | + $url = $request->getBaseUrl().$newName; |
|
82 | 82 | $request->setUrl($url); |
83 | 83 | } |
84 | 84 | } |
@@ -28,54 +28,54 @@ |
||
28 | 28 | |
29 | 29 | class UploadFolder implements ICollection { |
30 | 30 | |
31 | - private $node; |
|
31 | + private $node; |
|
32 | 32 | |
33 | - function __construct(Directory $node) { |
|
34 | - $this->node = $node; |
|
35 | - } |
|
33 | + function __construct(Directory $node) { |
|
34 | + $this->node = $node; |
|
35 | + } |
|
36 | 36 | |
37 | - function createFile($name, $data = null) { |
|
38 | - // TODO: verify name - should be a simple number |
|
39 | - $this->node->createFile($name, $data); |
|
40 | - } |
|
37 | + function createFile($name, $data = null) { |
|
38 | + // TODO: verify name - should be a simple number |
|
39 | + $this->node->createFile($name, $data); |
|
40 | + } |
|
41 | 41 | |
42 | - function createDirectory($name) { |
|
43 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
44 | - } |
|
42 | + function createDirectory($name) { |
|
43 | + throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
44 | + } |
|
45 | 45 | |
46 | - function getChild($name) { |
|
47 | - if ($name === '.file') { |
|
48 | - return new FutureFile($this->node, '.file'); |
|
49 | - } |
|
50 | - return $this->node->getChild($name); |
|
51 | - } |
|
46 | + function getChild($name) { |
|
47 | + if ($name === '.file') { |
|
48 | + return new FutureFile($this->node, '.file'); |
|
49 | + } |
|
50 | + return $this->node->getChild($name); |
|
51 | + } |
|
52 | 52 | |
53 | - function getChildren() { |
|
54 | - $children = $this->node->getChildren(); |
|
55 | - $children[] = new FutureFile($this->node, '.file'); |
|
56 | - return $children; |
|
57 | - } |
|
53 | + function getChildren() { |
|
54 | + $children = $this->node->getChildren(); |
|
55 | + $children[] = new FutureFile($this->node, '.file'); |
|
56 | + return $children; |
|
57 | + } |
|
58 | 58 | |
59 | - function childExists($name) { |
|
60 | - if ($name === '.file') { |
|
61 | - return true; |
|
62 | - } |
|
63 | - return $this->node->childExists($name); |
|
64 | - } |
|
59 | + function childExists($name) { |
|
60 | + if ($name === '.file') { |
|
61 | + return true; |
|
62 | + } |
|
63 | + return $this->node->childExists($name); |
|
64 | + } |
|
65 | 65 | |
66 | - function delete() { |
|
67 | - $this->node->delete(); |
|
68 | - } |
|
66 | + function delete() { |
|
67 | + $this->node->delete(); |
|
68 | + } |
|
69 | 69 | |
70 | - function getName() { |
|
71 | - return $this->node->getName(); |
|
72 | - } |
|
70 | + function getName() { |
|
71 | + return $this->node->getName(); |
|
72 | + } |
|
73 | 73 | |
74 | - function setName($name) { |
|
75 | - throw new Forbidden('Permission denied to rename this folder'); |
|
76 | - } |
|
74 | + function setName($name) { |
|
75 | + throw new Forbidden('Permission denied to rename this folder'); |
|
76 | + } |
|
77 | 77 | |
78 | - function getLastModified() { |
|
79 | - return $this->node->getLastModified(); |
|
80 | - } |
|
78 | + function getLastModified() { |
|
79 | + return $this->node->getLastModified(); |
|
80 | + } |
|
81 | 81 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | function createDirectory($name) { |
43 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
43 | + throw new Forbidden('Permission denied to create file (filename '.$name.')'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function getChild($name) { |
@@ -29,66 +29,66 @@ |
||
29 | 29 | use Sabre\DAV\ICollection; |
30 | 30 | |
31 | 31 | class UploadHome implements ICollection { |
32 | - /** |
|
33 | - * UploadHome constructor. |
|
34 | - * |
|
35 | - * @param array $principalInfo |
|
36 | - */ |
|
37 | - public function __construct($principalInfo) { |
|
38 | - $this->principalInfo = $principalInfo; |
|
39 | - } |
|
32 | + /** |
|
33 | + * UploadHome constructor. |
|
34 | + * |
|
35 | + * @param array $principalInfo |
|
36 | + */ |
|
37 | + public function __construct($principalInfo) { |
|
38 | + $this->principalInfo = $principalInfo; |
|
39 | + } |
|
40 | 40 | |
41 | - function createFile($name, $data = null) { |
|
42 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
43 | - } |
|
41 | + function createFile($name, $data = null) { |
|
42 | + throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
43 | + } |
|
44 | 44 | |
45 | - function createDirectory($name) { |
|
46 | - $this->impl()->createDirectory($name); |
|
47 | - } |
|
45 | + function createDirectory($name) { |
|
46 | + $this->impl()->createDirectory($name); |
|
47 | + } |
|
48 | 48 | |
49 | - function getChild($name) { |
|
50 | - return new UploadFolder($this->impl()->getChild($name)); |
|
51 | - } |
|
49 | + function getChild($name) { |
|
50 | + return new UploadFolder($this->impl()->getChild($name)); |
|
51 | + } |
|
52 | 52 | |
53 | - function getChildren() { |
|
54 | - return array_map(function($node) { |
|
55 | - return new UploadFolder($node); |
|
56 | - }, $this->impl()->getChildren()); |
|
57 | - } |
|
53 | + function getChildren() { |
|
54 | + return array_map(function($node) { |
|
55 | + return new UploadFolder($node); |
|
56 | + }, $this->impl()->getChildren()); |
|
57 | + } |
|
58 | 58 | |
59 | - function childExists($name) { |
|
60 | - return !is_null($this->getChild($name)); |
|
61 | - } |
|
59 | + function childExists($name) { |
|
60 | + return !is_null($this->getChild($name)); |
|
61 | + } |
|
62 | 62 | |
63 | - function delete() { |
|
64 | - $this->impl()->delete(); |
|
65 | - } |
|
63 | + function delete() { |
|
64 | + $this->impl()->delete(); |
|
65 | + } |
|
66 | 66 | |
67 | - function getName() { |
|
68 | - return 'uploads'; |
|
69 | - } |
|
67 | + function getName() { |
|
68 | + return 'uploads'; |
|
69 | + } |
|
70 | 70 | |
71 | - function setName($name) { |
|
72 | - throw new Forbidden('Permission denied to rename this folder'); |
|
73 | - } |
|
71 | + function setName($name) { |
|
72 | + throw new Forbidden('Permission denied to rename this folder'); |
|
73 | + } |
|
74 | 74 | |
75 | - function getLastModified() { |
|
76 | - return $this->impl()->getLastModified(); |
|
77 | - } |
|
75 | + function getLastModified() { |
|
76 | + return $this->impl()->getLastModified(); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return Directory |
|
81 | - */ |
|
82 | - private function impl() { |
|
83 | - $rootView = new View(); |
|
84 | - $user = \OC::$server->getUserSession()->getUser(); |
|
85 | - Filesystem::initMountPoints($user->getUID()); |
|
86 | - if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { |
|
87 | - $rootView->mkdir('/' . $user->getUID() . '/uploads'); |
|
88 | - } |
|
89 | - $view = new View('/' . $user->getUID() . '/uploads'); |
|
90 | - $rootInfo = $view->getFileInfo(''); |
|
91 | - $impl = new Directory($view, $rootInfo); |
|
92 | - return $impl; |
|
93 | - } |
|
79 | + /** |
|
80 | + * @return Directory |
|
81 | + */ |
|
82 | + private function impl() { |
|
83 | + $rootView = new View(); |
|
84 | + $user = \OC::$server->getUserSession()->getUser(); |
|
85 | + Filesystem::initMountPoints($user->getUID()); |
|
86 | + if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { |
|
87 | + $rootView->mkdir('/' . $user->getUID() . '/uploads'); |
|
88 | + } |
|
89 | + $view = new View('/' . $user->getUID() . '/uploads'); |
|
90 | + $rootInfo = $view->getFileInfo(''); |
|
91 | + $impl = new Directory($view, $rootInfo); |
|
92 | + return $impl; |
|
93 | + } |
|
94 | 94 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | function createFile($name, $data = null) { |
42 | - throw new Forbidden('Permission denied to create file (filename ' . $name . ')'); |
|
42 | + throw new Forbidden('Permission denied to create file (filename '.$name.')'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function createDirectory($name) { |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | $rootView = new View(); |
84 | 84 | $user = \OC::$server->getUserSession()->getUser(); |
85 | 85 | Filesystem::initMountPoints($user->getUID()); |
86 | - if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) { |
|
87 | - $rootView->mkdir('/' . $user->getUID() . '/uploads'); |
|
86 | + if (!$rootView->file_exists('/'.$user->getUID().'/uploads')) { |
|
87 | + $rootView->mkdir('/'.$user->getUID().'/uploads'); |
|
88 | 88 | } |
89 | - $view = new View('/' . $user->getUID() . '/uploads'); |
|
89 | + $view = new View('/'.$user->getUID().'/uploads'); |
|
90 | 90 | $rootInfo = $view->getFileInfo(''); |
91 | 91 | $impl = new Directory($view, $rootInfo); |
92 | 92 | return $impl; |
@@ -26,18 +26,18 @@ |
||
26 | 26 | |
27 | 27 | class RootCollection extends AbstractPrincipalCollection { |
28 | 28 | |
29 | - /** |
|
30 | - * @inheritdoc |
|
31 | - */ |
|
32 | - function getChildForPrincipal(array $principalInfo) { |
|
33 | - return new UploadHome($principalInfo); |
|
34 | - } |
|
29 | + /** |
|
30 | + * @inheritdoc |
|
31 | + */ |
|
32 | + function getChildForPrincipal(array $principalInfo) { |
|
33 | + return new UploadHome($principalInfo); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @inheritdoc |
|
38 | - */ |
|
39 | - function getName() { |
|
40 | - return 'uploads'; |
|
41 | - } |
|
36 | + /** |
|
37 | + * @inheritdoc |
|
38 | + */ |
|
39 | + function getName() { |
|
40 | + return 'uploads'; |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
@@ -37,87 +37,87 @@ |
||
37 | 37 | */ |
38 | 38 | class FutureFile implements \Sabre\DAV\IFile { |
39 | 39 | |
40 | - /** @var Directory */ |
|
41 | - private $root; |
|
42 | - /** @var string */ |
|
43 | - private $name; |
|
40 | + /** @var Directory */ |
|
41 | + private $root; |
|
42 | + /** @var string */ |
|
43 | + private $name; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param Directory $root |
|
47 | - * @param string $name |
|
48 | - */ |
|
49 | - function __construct(Directory $root, $name) { |
|
50 | - $this->root = $root; |
|
51 | - $this->name = $name; |
|
52 | - } |
|
45 | + /** |
|
46 | + * @param Directory $root |
|
47 | + * @param string $name |
|
48 | + */ |
|
49 | + function __construct(Directory $root, $name) { |
|
50 | + $this->root = $root; |
|
51 | + $this->name = $name; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @inheritdoc |
|
56 | - */ |
|
57 | - function put($data) { |
|
58 | - throw new Forbidden('Permission denied to put into this file'); |
|
59 | - } |
|
54 | + /** |
|
55 | + * @inheritdoc |
|
56 | + */ |
|
57 | + function put($data) { |
|
58 | + throw new Forbidden('Permission denied to put into this file'); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @inheritdoc |
|
63 | - */ |
|
64 | - function get() { |
|
65 | - $nodes = $this->root->getChildren(); |
|
66 | - return AssemblyStream::wrap($nodes); |
|
67 | - } |
|
61 | + /** |
|
62 | + * @inheritdoc |
|
63 | + */ |
|
64 | + function get() { |
|
65 | + $nodes = $this->root->getChildren(); |
|
66 | + return AssemblyStream::wrap($nodes); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @inheritdoc |
|
71 | - */ |
|
72 | - function getContentType() { |
|
73 | - return 'application/octet-stream'; |
|
74 | - } |
|
69 | + /** |
|
70 | + * @inheritdoc |
|
71 | + */ |
|
72 | + function getContentType() { |
|
73 | + return 'application/octet-stream'; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @inheritdoc |
|
78 | - */ |
|
79 | - function getETag() { |
|
80 | - return $this->root->getETag(); |
|
81 | - } |
|
76 | + /** |
|
77 | + * @inheritdoc |
|
78 | + */ |
|
79 | + function getETag() { |
|
80 | + return $this->root->getETag(); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @inheritdoc |
|
85 | - */ |
|
86 | - function getSize() { |
|
87 | - $children = $this->root->getChildren(); |
|
88 | - $sizes = array_map(function($node) { |
|
89 | - /** @var IFile $node */ |
|
90 | - return $node->getSize(); |
|
91 | - }, $children); |
|
83 | + /** |
|
84 | + * @inheritdoc |
|
85 | + */ |
|
86 | + function getSize() { |
|
87 | + $children = $this->root->getChildren(); |
|
88 | + $sizes = array_map(function($node) { |
|
89 | + /** @var IFile $node */ |
|
90 | + return $node->getSize(); |
|
91 | + }, $children); |
|
92 | 92 | |
93 | - return array_sum($sizes); |
|
94 | - } |
|
93 | + return array_sum($sizes); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @inheritdoc |
|
98 | - */ |
|
99 | - function delete() { |
|
100 | - $this->root->delete(); |
|
101 | - } |
|
96 | + /** |
|
97 | + * @inheritdoc |
|
98 | + */ |
|
99 | + function delete() { |
|
100 | + $this->root->delete(); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @inheritdoc |
|
105 | - */ |
|
106 | - function getName() { |
|
107 | - return $this->name; |
|
108 | - } |
|
103 | + /** |
|
104 | + * @inheritdoc |
|
105 | + */ |
|
106 | + function getName() { |
|
107 | + return $this->name; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @inheritdoc |
|
112 | - */ |
|
113 | - function setName($name) { |
|
114 | - throw new Forbidden('Permission denied to rename this file'); |
|
115 | - } |
|
110 | + /** |
|
111 | + * @inheritdoc |
|
112 | + */ |
|
113 | + function setName($name) { |
|
114 | + throw new Forbidden('Permission denied to rename this file'); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * @inheritdoc |
|
119 | - */ |
|
120 | - function getLastModified() { |
|
121 | - return $this->root->getLastModified(); |
|
122 | - } |
|
117 | + /** |
|
118 | + * @inheritdoc |
|
119 | + */ |
|
120 | + function getLastModified() { |
|
121 | + return $this->root->getLastModified(); |
|
122 | + } |
|
123 | 123 | } |
@@ -31,169 +31,169 @@ |
||
31 | 31 | |
32 | 32 | class Calendar extends Base { |
33 | 33 | |
34 | - const SUBJECT_ADD = 'calendar_add'; |
|
35 | - const SUBJECT_UPDATE = 'calendar_update'; |
|
36 | - const SUBJECT_DELETE = 'calendar_delete'; |
|
37 | - const SUBJECT_SHARE_USER = 'calendar_user_share'; |
|
38 | - const SUBJECT_SHARE_GROUP = 'calendar_group_share'; |
|
39 | - const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; |
|
40 | - const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; |
|
41 | - |
|
42 | - /** @var IFactory */ |
|
43 | - protected $languageFactory; |
|
44 | - |
|
45 | - /** @var IL10N */ |
|
46 | - protected $l; |
|
47 | - |
|
48 | - /** @var IURLGenerator */ |
|
49 | - protected $url; |
|
50 | - |
|
51 | - /** @var IManager */ |
|
52 | - protected $activityManager; |
|
53 | - |
|
54 | - /** @var IEventMerger */ |
|
55 | - protected $eventMerger; |
|
56 | - |
|
57 | - /** |
|
58 | - * @param IFactory $languageFactory |
|
59 | - * @param IURLGenerator $url |
|
60 | - * @param IManager $activityManager |
|
61 | - * @param IUserManager $userManager |
|
62 | - * @param IEventMerger $eventMerger |
|
63 | - */ |
|
64 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) { |
|
65 | - parent::__construct($userManager); |
|
66 | - $this->languageFactory = $languageFactory; |
|
67 | - $this->url = $url; |
|
68 | - $this->activityManager = $activityManager; |
|
69 | - $this->eventMerger = $eventMerger; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param string $language |
|
74 | - * @param IEvent $event |
|
75 | - * @param IEvent|null $previousEvent |
|
76 | - * @return IEvent |
|
77 | - * @throws \InvalidArgumentException |
|
78 | - * @since 11.0.0 |
|
79 | - */ |
|
80 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
81 | - if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { |
|
82 | - throw new \InvalidArgumentException(); |
|
83 | - } |
|
84 | - |
|
85 | - $this->l = $this->languageFactory->get('dav', $language); |
|
86 | - |
|
87 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg'))); |
|
88 | - |
|
89 | - if ($event->getSubject() === self::SUBJECT_ADD) { |
|
90 | - $subject = $this->l->t('{actor} created calendar {calendar}'); |
|
91 | - } else if ($event->getSubject() === self::SUBJECT_ADD . '_self') { |
|
92 | - $subject = $this->l->t('You created calendar {calendar}'); |
|
93 | - } else if ($event->getSubject() === self::SUBJECT_DELETE) { |
|
94 | - $subject = $this->l->t('{actor} deleted calendar {calendar}'); |
|
95 | - } else if ($event->getSubject() === self::SUBJECT_DELETE . '_self') { |
|
96 | - $subject = $this->l->t('You deleted calendar {calendar}'); |
|
97 | - } else if ($event->getSubject() === self::SUBJECT_UPDATE) { |
|
98 | - $subject = $this->l->t('{actor} updated calendar {calendar}'); |
|
99 | - } else if ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { |
|
100 | - $subject = $this->l->t('You updated calendar {calendar}'); |
|
101 | - |
|
102 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER) { |
|
103 | - $subject = $this->l->t('{actor} shared calendar {calendar} with you'); |
|
104 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { |
|
105 | - $subject = $this->l->t('You shared calendar {calendar} with {user}'); |
|
106 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') { |
|
107 | - $subject = $this->l->t('{actor} shared calendar {calendar} with {user}'); |
|
108 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER) { |
|
109 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from you'); |
|
110 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') { |
|
111 | - $subject = $this->l->t('You unshared calendar {calendar} from {user}'); |
|
112 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') { |
|
113 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); |
|
114 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { |
|
115 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); |
|
116 | - |
|
117 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { |
|
118 | - $subject = $this->l->t('You shared calendar {calendar} with group {group}'); |
|
119 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { |
|
120 | - $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}'); |
|
121 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') { |
|
122 | - $subject = $this->l->t('You unshared calendar {calendar} from group {group}'); |
|
123 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { |
|
124 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); |
|
125 | - } else { |
|
126 | - throw new \InvalidArgumentException(); |
|
127 | - } |
|
128 | - |
|
129 | - $parsedParameters = $this->getParameters($event); |
|
130 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
131 | - |
|
132 | - $event = $this->eventMerger->mergeEvents('calendar', $event, $previousEvent); |
|
133 | - |
|
134 | - if ($event->getChildEvent() === null) { |
|
135 | - if (isset($parsedParameters['user'])) { |
|
136 | - // Couldn't group by calendar, maybe we can group by users |
|
137 | - $event = $this->eventMerger->mergeEvents('user', $event, $previousEvent); |
|
138 | - } else if (isset($parsedParameters['group'])) { |
|
139 | - // Couldn't group by calendar, maybe we can group by groups |
|
140 | - $event = $this->eventMerger->mergeEvents('group', $event, $previousEvent); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - return $event; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @param IEvent $event |
|
149 | - * @return array |
|
150 | - */ |
|
151 | - protected function getParameters(IEvent $event) { |
|
152 | - $subject = $event->getSubject(); |
|
153 | - $parameters = $event->getSubjectParameters(); |
|
154 | - |
|
155 | - switch ($subject) { |
|
156 | - case self::SUBJECT_ADD: |
|
157 | - case self::SUBJECT_ADD . '_self': |
|
158 | - case self::SUBJECT_DELETE: |
|
159 | - case self::SUBJECT_DELETE . '_self': |
|
160 | - case self::SUBJECT_UPDATE: |
|
161 | - case self::SUBJECT_UPDATE . '_self': |
|
162 | - case self::SUBJECT_SHARE_USER: |
|
163 | - case self::SUBJECT_UNSHARE_USER: |
|
164 | - case self::SUBJECT_UNSHARE_USER . '_self': |
|
165 | - return [ |
|
166 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
167 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
168 | - ]; |
|
169 | - case self::SUBJECT_SHARE_USER . '_you': |
|
170 | - case self::SUBJECT_UNSHARE_USER . '_you': |
|
171 | - return [ |
|
172 | - 'user' => $this->generateUserParameter($parameters[0]), |
|
173 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
174 | - ]; |
|
175 | - case self::SUBJECT_SHARE_USER . '_by': |
|
176 | - case self::SUBJECT_UNSHARE_USER . '_by': |
|
177 | - return [ |
|
178 | - 'user' => $this->generateUserParameter($parameters[0]), |
|
179 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
180 | - 'actor' => $this->generateUserParameter($parameters[2]), |
|
181 | - ]; |
|
182 | - case self::SUBJECT_SHARE_GROUP . '_you': |
|
183 | - case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
184 | - return [ |
|
185 | - 'group' => $this->generateGroupParameter($parameters[0]), |
|
186 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
187 | - ]; |
|
188 | - case self::SUBJECT_SHARE_GROUP . '_by': |
|
189 | - case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
190 | - return [ |
|
191 | - 'group' => $this->generateGroupParameter($parameters[0]), |
|
192 | - 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
193 | - 'actor' => $this->generateUserParameter($parameters[2]), |
|
194 | - ]; |
|
195 | - } |
|
196 | - |
|
197 | - throw new \InvalidArgumentException(); |
|
198 | - } |
|
34 | + const SUBJECT_ADD = 'calendar_add'; |
|
35 | + const SUBJECT_UPDATE = 'calendar_update'; |
|
36 | + const SUBJECT_DELETE = 'calendar_delete'; |
|
37 | + const SUBJECT_SHARE_USER = 'calendar_user_share'; |
|
38 | + const SUBJECT_SHARE_GROUP = 'calendar_group_share'; |
|
39 | + const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; |
|
40 | + const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; |
|
41 | + |
|
42 | + /** @var IFactory */ |
|
43 | + protected $languageFactory; |
|
44 | + |
|
45 | + /** @var IL10N */ |
|
46 | + protected $l; |
|
47 | + |
|
48 | + /** @var IURLGenerator */ |
|
49 | + protected $url; |
|
50 | + |
|
51 | + /** @var IManager */ |
|
52 | + protected $activityManager; |
|
53 | + |
|
54 | + /** @var IEventMerger */ |
|
55 | + protected $eventMerger; |
|
56 | + |
|
57 | + /** |
|
58 | + * @param IFactory $languageFactory |
|
59 | + * @param IURLGenerator $url |
|
60 | + * @param IManager $activityManager |
|
61 | + * @param IUserManager $userManager |
|
62 | + * @param IEventMerger $eventMerger |
|
63 | + */ |
|
64 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IEventMerger $eventMerger) { |
|
65 | + parent::__construct($userManager); |
|
66 | + $this->languageFactory = $languageFactory; |
|
67 | + $this->url = $url; |
|
68 | + $this->activityManager = $activityManager; |
|
69 | + $this->eventMerger = $eventMerger; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param string $language |
|
74 | + * @param IEvent $event |
|
75 | + * @param IEvent|null $previousEvent |
|
76 | + * @return IEvent |
|
77 | + * @throws \InvalidArgumentException |
|
78 | + * @since 11.0.0 |
|
79 | + */ |
|
80 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
81 | + if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { |
|
82 | + throw new \InvalidArgumentException(); |
|
83 | + } |
|
84 | + |
|
85 | + $this->l = $this->languageFactory->get('dav', $language); |
|
86 | + |
|
87 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg'))); |
|
88 | + |
|
89 | + if ($event->getSubject() === self::SUBJECT_ADD) { |
|
90 | + $subject = $this->l->t('{actor} created calendar {calendar}'); |
|
91 | + } else if ($event->getSubject() === self::SUBJECT_ADD . '_self') { |
|
92 | + $subject = $this->l->t('You created calendar {calendar}'); |
|
93 | + } else if ($event->getSubject() === self::SUBJECT_DELETE) { |
|
94 | + $subject = $this->l->t('{actor} deleted calendar {calendar}'); |
|
95 | + } else if ($event->getSubject() === self::SUBJECT_DELETE . '_self') { |
|
96 | + $subject = $this->l->t('You deleted calendar {calendar}'); |
|
97 | + } else if ($event->getSubject() === self::SUBJECT_UPDATE) { |
|
98 | + $subject = $this->l->t('{actor} updated calendar {calendar}'); |
|
99 | + } else if ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { |
|
100 | + $subject = $this->l->t('You updated calendar {calendar}'); |
|
101 | + |
|
102 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER) { |
|
103 | + $subject = $this->l->t('{actor} shared calendar {calendar} with you'); |
|
104 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { |
|
105 | + $subject = $this->l->t('You shared calendar {calendar} with {user}'); |
|
106 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') { |
|
107 | + $subject = $this->l->t('{actor} shared calendar {calendar} with {user}'); |
|
108 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER) { |
|
109 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from you'); |
|
110 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') { |
|
111 | + $subject = $this->l->t('You unshared calendar {calendar} from {user}'); |
|
112 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') { |
|
113 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); |
|
114 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { |
|
115 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); |
|
116 | + |
|
117 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { |
|
118 | + $subject = $this->l->t('You shared calendar {calendar} with group {group}'); |
|
119 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { |
|
120 | + $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}'); |
|
121 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') { |
|
122 | + $subject = $this->l->t('You unshared calendar {calendar} from group {group}'); |
|
123 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { |
|
124 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); |
|
125 | + } else { |
|
126 | + throw new \InvalidArgumentException(); |
|
127 | + } |
|
128 | + |
|
129 | + $parsedParameters = $this->getParameters($event); |
|
130 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
131 | + |
|
132 | + $event = $this->eventMerger->mergeEvents('calendar', $event, $previousEvent); |
|
133 | + |
|
134 | + if ($event->getChildEvent() === null) { |
|
135 | + if (isset($parsedParameters['user'])) { |
|
136 | + // Couldn't group by calendar, maybe we can group by users |
|
137 | + $event = $this->eventMerger->mergeEvents('user', $event, $previousEvent); |
|
138 | + } else if (isset($parsedParameters['group'])) { |
|
139 | + // Couldn't group by calendar, maybe we can group by groups |
|
140 | + $event = $this->eventMerger->mergeEvents('group', $event, $previousEvent); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + return $event; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @param IEvent $event |
|
149 | + * @return array |
|
150 | + */ |
|
151 | + protected function getParameters(IEvent $event) { |
|
152 | + $subject = $event->getSubject(); |
|
153 | + $parameters = $event->getSubjectParameters(); |
|
154 | + |
|
155 | + switch ($subject) { |
|
156 | + case self::SUBJECT_ADD: |
|
157 | + case self::SUBJECT_ADD . '_self': |
|
158 | + case self::SUBJECT_DELETE: |
|
159 | + case self::SUBJECT_DELETE . '_self': |
|
160 | + case self::SUBJECT_UPDATE: |
|
161 | + case self::SUBJECT_UPDATE . '_self': |
|
162 | + case self::SUBJECT_SHARE_USER: |
|
163 | + case self::SUBJECT_UNSHARE_USER: |
|
164 | + case self::SUBJECT_UNSHARE_USER . '_self': |
|
165 | + return [ |
|
166 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
167 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
168 | + ]; |
|
169 | + case self::SUBJECT_SHARE_USER . '_you': |
|
170 | + case self::SUBJECT_UNSHARE_USER . '_you': |
|
171 | + return [ |
|
172 | + 'user' => $this->generateUserParameter($parameters[0]), |
|
173 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
174 | + ]; |
|
175 | + case self::SUBJECT_SHARE_USER . '_by': |
|
176 | + case self::SUBJECT_UNSHARE_USER . '_by': |
|
177 | + return [ |
|
178 | + 'user' => $this->generateUserParameter($parameters[0]), |
|
179 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
180 | + 'actor' => $this->generateUserParameter($parameters[2]), |
|
181 | + ]; |
|
182 | + case self::SUBJECT_SHARE_GROUP . '_you': |
|
183 | + case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
184 | + return [ |
|
185 | + 'group' => $this->generateGroupParameter($parameters[0]), |
|
186 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
187 | + ]; |
|
188 | + case self::SUBJECT_SHARE_GROUP . '_by': |
|
189 | + case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
190 | + return [ |
|
191 | + 'group' => $this->generateGroupParameter($parameters[0]), |
|
192 | + 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
|
193 | + 'actor' => $this->generateUserParameter($parameters[2]), |
|
194 | + ]; |
|
195 | + } |
|
196 | + |
|
197 | + throw new \InvalidArgumentException(); |
|
198 | + } |
|
199 | 199 | } |
@@ -88,39 +88,39 @@ discard block |
||
88 | 88 | |
89 | 89 | if ($event->getSubject() === self::SUBJECT_ADD) { |
90 | 90 | $subject = $this->l->t('{actor} created calendar {calendar}'); |
91 | - } else if ($event->getSubject() === self::SUBJECT_ADD . '_self') { |
|
91 | + } else if ($event->getSubject() === self::SUBJECT_ADD.'_self') { |
|
92 | 92 | $subject = $this->l->t('You created calendar {calendar}'); |
93 | 93 | } else if ($event->getSubject() === self::SUBJECT_DELETE) { |
94 | 94 | $subject = $this->l->t('{actor} deleted calendar {calendar}'); |
95 | - } else if ($event->getSubject() === self::SUBJECT_DELETE . '_self') { |
|
95 | + } else if ($event->getSubject() === self::SUBJECT_DELETE.'_self') { |
|
96 | 96 | $subject = $this->l->t('You deleted calendar {calendar}'); |
97 | 97 | } else if ($event->getSubject() === self::SUBJECT_UPDATE) { |
98 | 98 | $subject = $this->l->t('{actor} updated calendar {calendar}'); |
99 | - } else if ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { |
|
99 | + } else if ($event->getSubject() === self::SUBJECT_UPDATE.'_self') { |
|
100 | 100 | $subject = $this->l->t('You updated calendar {calendar}'); |
101 | 101 | |
102 | 102 | } else if ($event->getSubject() === self::SUBJECT_SHARE_USER) { |
103 | 103 | $subject = $this->l->t('{actor} shared calendar {calendar} with you'); |
104 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { |
|
104 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER.'_you') { |
|
105 | 105 | $subject = $this->l->t('You shared calendar {calendar} with {user}'); |
106 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') { |
|
106 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_USER.'_by') { |
|
107 | 107 | $subject = $this->l->t('{actor} shared calendar {calendar} with {user}'); |
108 | 108 | } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER) { |
109 | 109 | $subject = $this->l->t('{actor} unshared calendar {calendar} from you'); |
110 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') { |
|
110 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER.'_you') { |
|
111 | 111 | $subject = $this->l->t('You unshared calendar {calendar} from {user}'); |
112 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') { |
|
112 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER.'_by') { |
|
113 | 113 | $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); |
114 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { |
|
114 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER.'_self') { |
|
115 | 115 | $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); |
116 | 116 | |
117 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { |
|
117 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP.'_you') { |
|
118 | 118 | $subject = $this->l->t('You shared calendar {calendar} with group {group}'); |
119 | - } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { |
|
119 | + } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP.'_by') { |
|
120 | 120 | $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}'); |
121 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') { |
|
121 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP.'_you') { |
|
122 | 122 | $subject = $this->l->t('You unshared calendar {calendar} from group {group}'); |
123 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { |
|
123 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP.'_by') { |
|
124 | 124 | $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); |
125 | 125 | } else { |
126 | 126 | throw new \InvalidArgumentException(); |
@@ -154,39 +154,39 @@ discard block |
||
154 | 154 | |
155 | 155 | switch ($subject) { |
156 | 156 | case self::SUBJECT_ADD: |
157 | - case self::SUBJECT_ADD . '_self': |
|
157 | + case self::SUBJECT_ADD.'_self': |
|
158 | 158 | case self::SUBJECT_DELETE: |
159 | - case self::SUBJECT_DELETE . '_self': |
|
159 | + case self::SUBJECT_DELETE.'_self': |
|
160 | 160 | case self::SUBJECT_UPDATE: |
161 | - case self::SUBJECT_UPDATE . '_self': |
|
161 | + case self::SUBJECT_UPDATE.'_self': |
|
162 | 162 | case self::SUBJECT_SHARE_USER: |
163 | 163 | case self::SUBJECT_UNSHARE_USER: |
164 | - case self::SUBJECT_UNSHARE_USER . '_self': |
|
164 | + case self::SUBJECT_UNSHARE_USER.'_self': |
|
165 | 165 | return [ |
166 | 166 | 'actor' => $this->generateUserParameter($parameters[0]), |
167 | 167 | 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
168 | 168 | ]; |
169 | - case self::SUBJECT_SHARE_USER . '_you': |
|
170 | - case self::SUBJECT_UNSHARE_USER . '_you': |
|
169 | + case self::SUBJECT_SHARE_USER.'_you': |
|
170 | + case self::SUBJECT_UNSHARE_USER.'_you': |
|
171 | 171 | return [ |
172 | 172 | 'user' => $this->generateUserParameter($parameters[0]), |
173 | 173 | 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
174 | 174 | ]; |
175 | - case self::SUBJECT_SHARE_USER . '_by': |
|
176 | - case self::SUBJECT_UNSHARE_USER . '_by': |
|
175 | + case self::SUBJECT_SHARE_USER.'_by': |
|
176 | + case self::SUBJECT_UNSHARE_USER.'_by': |
|
177 | 177 | return [ |
178 | 178 | 'user' => $this->generateUserParameter($parameters[0]), |
179 | 179 | 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
180 | 180 | 'actor' => $this->generateUserParameter($parameters[2]), |
181 | 181 | ]; |
182 | - case self::SUBJECT_SHARE_GROUP . '_you': |
|
183 | - case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
182 | + case self::SUBJECT_SHARE_GROUP.'_you': |
|
183 | + case self::SUBJECT_UNSHARE_GROUP.'_you': |
|
184 | 184 | return [ |
185 | 185 | 'group' => $this->generateGroupParameter($parameters[0]), |
186 | 186 | 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
187 | 187 | ]; |
188 | - case self::SUBJECT_SHARE_GROUP . '_by': |
|
189 | - case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
188 | + case self::SUBJECT_SHARE_GROUP.'_by': |
|
189 | + case self::SUBJECT_UNSHARE_GROUP.'_by': |
|
190 | 190 | return [ |
191 | 191 | 'group' => $this->generateGroupParameter($parameters[0]), |
192 | 192 | 'calendar' => $this->generateCalendarParameter($event->getObjectId(), $parameters[1]), |
@@ -28,102 +28,102 @@ |
||
28 | 28 | |
29 | 29 | abstract class Base implements IProvider { |
30 | 30 | |
31 | - /** @var IUserManager */ |
|
32 | - protected $userManager; |
|
31 | + /** @var IUserManager */ |
|
32 | + protected $userManager; |
|
33 | 33 | |
34 | - /** @var string[] cached displayNames - key is the UID and value the displayname */ |
|
35 | - protected $displayNames = []; |
|
34 | + /** @var string[] cached displayNames - key is the UID and value the displayname */ |
|
35 | + protected $displayNames = []; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param IUserManager $userManager |
|
39 | - */ |
|
40 | - public function __construct(IUserManager $userManager) { |
|
41 | - $this->userManager = $userManager; |
|
42 | - } |
|
37 | + /** |
|
38 | + * @param IUserManager $userManager |
|
39 | + */ |
|
40 | + public function __construct(IUserManager $userManager) { |
|
41 | + $this->userManager = $userManager; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param IEvent $event |
|
46 | - * @param string $subject |
|
47 | - * @param array $parameters |
|
48 | - */ |
|
49 | - protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
50 | - $placeholders = $replacements = []; |
|
51 | - foreach ($parameters as $placeholder => $parameter) { |
|
52 | - $placeholders[] = '{' . $placeholder . '}'; |
|
53 | - $replacements[] = $parameter['name']; |
|
54 | - } |
|
44 | + /** |
|
45 | + * @param IEvent $event |
|
46 | + * @param string $subject |
|
47 | + * @param array $parameters |
|
48 | + */ |
|
49 | + protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
50 | + $placeholders = $replacements = []; |
|
51 | + foreach ($parameters as $placeholder => $parameter) { |
|
52 | + $placeholders[] = '{' . $placeholder . '}'; |
|
53 | + $replacements[] = $parameter['name']; |
|
54 | + } |
|
55 | 55 | |
56 | - $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
57 | - ->setRichSubject($subject, $parameters); |
|
58 | - } |
|
56 | + $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
57 | + ->setRichSubject($subject, $parameters); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param array $eventData |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - protected function generateObjectParameter($eventData) { |
|
65 | - if (!is_array($eventData) || !isset($eventData['id']) || !isset($eventData['name'])) { |
|
66 | - throw new \InvalidArgumentException(); |
|
67 | - }; |
|
60 | + /** |
|
61 | + * @param array $eventData |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + protected function generateObjectParameter($eventData) { |
|
65 | + if (!is_array($eventData) || !isset($eventData['id']) || !isset($eventData['name'])) { |
|
66 | + throw new \InvalidArgumentException(); |
|
67 | + }; |
|
68 | 68 | |
69 | - return [ |
|
70 | - 'type' => 'calendar-event', |
|
71 | - 'id' => $eventData['id'], |
|
72 | - 'name' => $eventData['name'], |
|
73 | - ]; |
|
74 | - } |
|
69 | + return [ |
|
70 | + 'type' => 'calendar-event', |
|
71 | + 'id' => $eventData['id'], |
|
72 | + 'name' => $eventData['name'], |
|
73 | + ]; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param int $id |
|
78 | - * @param string $name |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - protected function generateCalendarParameter($id, $name) { |
|
82 | - return [ |
|
83 | - 'type' => 'calendar', |
|
84 | - 'id' => $id, |
|
85 | - 'name' => $name, |
|
86 | - ]; |
|
87 | - } |
|
76 | + /** |
|
77 | + * @param int $id |
|
78 | + * @param string $name |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + protected function generateCalendarParameter($id, $name) { |
|
82 | + return [ |
|
83 | + 'type' => 'calendar', |
|
84 | + 'id' => $id, |
|
85 | + 'name' => $name, |
|
86 | + ]; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param string $id |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - protected function generateGroupParameter($id) { |
|
94 | - return [ |
|
95 | - 'type' => 'group', |
|
96 | - 'id' => $id, |
|
97 | - 'name' => $id, |
|
98 | - ]; |
|
99 | - } |
|
89 | + /** |
|
90 | + * @param string $id |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + protected function generateGroupParameter($id) { |
|
94 | + return [ |
|
95 | + 'type' => 'group', |
|
96 | + 'id' => $id, |
|
97 | + 'name' => $id, |
|
98 | + ]; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param string $uid |
|
103 | - * @return array |
|
104 | - */ |
|
105 | - protected function generateUserParameter($uid) { |
|
106 | - if (!isset($this->displayNames[$uid])) { |
|
107 | - $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
108 | - } |
|
101 | + /** |
|
102 | + * @param string $uid |
|
103 | + * @return array |
|
104 | + */ |
|
105 | + protected function generateUserParameter($uid) { |
|
106 | + if (!isset($this->displayNames[$uid])) { |
|
107 | + $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
108 | + } |
|
109 | 109 | |
110 | - return [ |
|
111 | - 'type' => 'user', |
|
112 | - 'id' => $uid, |
|
113 | - 'name' => $this->displayNames[$uid], |
|
114 | - ]; |
|
115 | - } |
|
110 | + return [ |
|
111 | + 'type' => 'user', |
|
112 | + 'id' => $uid, |
|
113 | + 'name' => $this->displayNames[$uid], |
|
114 | + ]; |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * @param string $uid |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - protected function getDisplayName($uid) { |
|
122 | - $user = $this->userManager->get($uid); |
|
123 | - if ($user instanceof IUser) { |
|
124 | - return $user->getDisplayName(); |
|
125 | - } else { |
|
126 | - return $uid; |
|
127 | - } |
|
128 | - } |
|
117 | + /** |
|
118 | + * @param string $uid |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + protected function getDisplayName($uid) { |
|
122 | + $user = $this->userManager->get($uid); |
|
123 | + if ($user instanceof IUser) { |
|
124 | + return $user->getDisplayName(); |
|
125 | + } else { |
|
126 | + return $uid; |
|
127 | + } |
|
128 | + } |
|
129 | 129 | } |
@@ -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 |