@@ -33,52 +33,52 @@ |
||
33 | 33 | |
34 | 34 | class RootCollection extends AbstractPrincipalCollection { |
35 | 35 | |
36 | - /** @var IRootFolder */ |
|
37 | - private $rootFolder; |
|
36 | + /** @var IRootFolder */ |
|
37 | + private $rootFolder; |
|
38 | 38 | |
39 | - /** @var IUserManager */ |
|
40 | - private $userManager; |
|
39 | + /** @var IUserManager */ |
|
40 | + private $userManager; |
|
41 | 41 | |
42 | - /** @var IVersionManager */ |
|
43 | - private $versionManager; |
|
42 | + /** @var IVersionManager */ |
|
43 | + private $versionManager; |
|
44 | 44 | |
45 | - public function __construct( |
|
46 | - PrincipalBackend\BackendInterface $principalBackend, |
|
47 | - IRootFolder $rootFolder, |
|
48 | - IConfig $config, |
|
49 | - IUserManager $userManager, |
|
50 | - IVersionManager $versionManager |
|
51 | - ) { |
|
52 | - parent::__construct($principalBackend, 'principals/users'); |
|
45 | + public function __construct( |
|
46 | + PrincipalBackend\BackendInterface $principalBackend, |
|
47 | + IRootFolder $rootFolder, |
|
48 | + IConfig $config, |
|
49 | + IUserManager $userManager, |
|
50 | + IVersionManager $versionManager |
|
51 | + ) { |
|
52 | + parent::__construct($principalBackend, 'principals/users'); |
|
53 | 53 | |
54 | - $this->rootFolder = $rootFolder; |
|
55 | - $this->userManager = $userManager; |
|
56 | - $this->versionManager = $versionManager; |
|
54 | + $this->rootFolder = $rootFolder; |
|
55 | + $this->userManager = $userManager; |
|
56 | + $this->versionManager = $versionManager; |
|
57 | 57 | |
58 | - $this->disableListing = !$config->getSystemValue('debug', false); |
|
59 | - } |
|
58 | + $this->disableListing = !$config->getSystemValue('debug', false); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * This method returns a node for a principal. |
|
63 | - * |
|
64 | - * The passed array contains principal information, and is guaranteed to |
|
65 | - * at least contain a uri item. Other properties may or may not be |
|
66 | - * supplied by the authentication backend. |
|
67 | - * |
|
68 | - * @param array $principalInfo |
|
69 | - * @return INode |
|
70 | - */ |
|
71 | - public function getChildForPrincipal(array $principalInfo) { |
|
72 | - list(, $name) = \Sabre\Uri\split($principalInfo['uri']); |
|
73 | - $user = \OC::$server->getUserSession()->getUser(); |
|
74 | - if (is_null($user) || $name !== $user->getUID()) { |
|
75 | - throw new \Sabre\DAV\Exception\Forbidden(); |
|
76 | - } |
|
77 | - return new VersionHome($principalInfo, $this->rootFolder, $this->userManager, $this->versionManager); |
|
78 | - } |
|
61 | + /** |
|
62 | + * This method returns a node for a principal. |
|
63 | + * |
|
64 | + * The passed array contains principal information, and is guaranteed to |
|
65 | + * at least contain a uri item. Other properties may or may not be |
|
66 | + * supplied by the authentication backend. |
|
67 | + * |
|
68 | + * @param array $principalInfo |
|
69 | + * @return INode |
|
70 | + */ |
|
71 | + public function getChildForPrincipal(array $principalInfo) { |
|
72 | + list(, $name) = \Sabre\Uri\split($principalInfo['uri']); |
|
73 | + $user = \OC::$server->getUserSession()->getUser(); |
|
74 | + if (is_null($user) || $name !== $user->getUID()) { |
|
75 | + throw new \Sabre\DAV\Exception\Forbidden(); |
|
76 | + } |
|
77 | + return new VersionHome($principalInfo, $this->rootFolder, $this->userManager, $this->versionManager); |
|
78 | + } |
|
79 | 79 | |
80 | - public function getName() { |
|
81 | - return 'versions'; |
|
82 | - } |
|
80 | + public function getName() { |
|
81 | + return 'versions'; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
@@ -33,74 +33,74 @@ |
||
33 | 33 | |
34 | 34 | class VersionRoot implements ICollection { |
35 | 35 | |
36 | - /** @var IUser */ |
|
37 | - private $user; |
|
36 | + /** @var IUser */ |
|
37 | + private $user; |
|
38 | 38 | |
39 | - /** @var IRootFolder */ |
|
40 | - private $rootFolder; |
|
39 | + /** @var IRootFolder */ |
|
40 | + private $rootFolder; |
|
41 | 41 | |
42 | - /** @var IVersionManager */ |
|
43 | - private $versionManager; |
|
42 | + /** @var IVersionManager */ |
|
43 | + private $versionManager; |
|
44 | 44 | |
45 | - public function __construct(IUser $user, IRootFolder $rootFolder, IVersionManager $versionManager) { |
|
46 | - $this->user = $user; |
|
47 | - $this->rootFolder = $rootFolder; |
|
48 | - $this->versionManager = $versionManager; |
|
49 | - } |
|
45 | + public function __construct(IUser $user, IRootFolder $rootFolder, IVersionManager $versionManager) { |
|
46 | + $this->user = $user; |
|
47 | + $this->rootFolder = $rootFolder; |
|
48 | + $this->versionManager = $versionManager; |
|
49 | + } |
|
50 | 50 | |
51 | - public function delete() { |
|
52 | - throw new Forbidden(); |
|
53 | - } |
|
51 | + public function delete() { |
|
52 | + throw new Forbidden(); |
|
53 | + } |
|
54 | 54 | |
55 | - public function getName(): string { |
|
56 | - return 'versions'; |
|
57 | - } |
|
55 | + public function getName(): string { |
|
56 | + return 'versions'; |
|
57 | + } |
|
58 | 58 | |
59 | - public function setName($name) { |
|
60 | - throw new Forbidden(); |
|
61 | - } |
|
59 | + public function setName($name) { |
|
60 | + throw new Forbidden(); |
|
61 | + } |
|
62 | 62 | |
63 | - public function createFile($name, $data = null) { |
|
64 | - throw new Forbidden(); |
|
65 | - } |
|
63 | + public function createFile($name, $data = null) { |
|
64 | + throw new Forbidden(); |
|
65 | + } |
|
66 | 66 | |
67 | - public function createDirectory($name) { |
|
68 | - throw new Forbidden(); |
|
69 | - } |
|
67 | + public function createDirectory($name) { |
|
68 | + throw new Forbidden(); |
|
69 | + } |
|
70 | 70 | |
71 | - public function getChild($name) { |
|
72 | - $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
|
71 | + public function getChild($name) { |
|
72 | + $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
|
73 | 73 | |
74 | - $fileId = (int)$name; |
|
75 | - $nodes = $userFolder->getById($fileId); |
|
74 | + $fileId = (int)$name; |
|
75 | + $nodes = $userFolder->getById($fileId); |
|
76 | 76 | |
77 | - if ($nodes === []) { |
|
78 | - throw new NotFound(); |
|
79 | - } |
|
77 | + if ($nodes === []) { |
|
78 | + throw new NotFound(); |
|
79 | + } |
|
80 | 80 | |
81 | - $node = array_pop($nodes); |
|
81 | + $node = array_pop($nodes); |
|
82 | 82 | |
83 | - if (!$node instanceof File) { |
|
84 | - throw new NotFound(); |
|
85 | - } |
|
83 | + if (!$node instanceof File) { |
|
84 | + throw new NotFound(); |
|
85 | + } |
|
86 | 86 | |
87 | - return new VersionCollection($userFolder, $node, $this->user, $this->versionManager); |
|
88 | - } |
|
87 | + return new VersionCollection($userFolder, $node, $this->user, $this->versionManager); |
|
88 | + } |
|
89 | 89 | |
90 | - public function getChildren(): array { |
|
91 | - return []; |
|
92 | - } |
|
90 | + public function getChildren(): array { |
|
91 | + return []; |
|
92 | + } |
|
93 | 93 | |
94 | - public function childExists($name): bool { |
|
95 | - try { |
|
96 | - $this->getChild($name); |
|
97 | - return true; |
|
98 | - } catch (NotFound $e) { |
|
99 | - return false; |
|
100 | - } |
|
101 | - } |
|
94 | + public function childExists($name): bool { |
|
95 | + try { |
|
96 | + $this->getChild($name); |
|
97 | + return true; |
|
98 | + } catch (NotFound $e) { |
|
99 | + return false; |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - public function getLastModified(): int { |
|
104 | - return 0; |
|
105 | - } |
|
103 | + public function getLastModified(): int { |
|
104 | + return 0; |
|
105 | + } |
|
106 | 106 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | public function getChild($name) { |
72 | 72 | $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); |
73 | 73 | |
74 | - $fileId = (int)$name; |
|
74 | + $fileId = (int) $name; |
|
75 | 75 | $nodes = $userFolder->getById($fileId); |
76 | 76 | |
77 | 77 | if ($nodes === []) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | public function getETag(): string { |
63 | - return (string)$this->version->getRevisionId(); |
|
63 | + return (string) $this->version->getRevisionId(); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public function getSize(): int { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | public function getName(): string { |
75 | - return (string)$this->version->getRevisionId(); |
|
75 | + return (string) $this->version->getRevisionId(); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | public function setName($name) { |
@@ -32,62 +32,62 @@ |
||
32 | 32 | use Sabre\DAV\IFile; |
33 | 33 | |
34 | 34 | class VersionFile implements IFile { |
35 | - /** @var IVersion */ |
|
36 | - private $version; |
|
37 | - |
|
38 | - /** @var IVersionManager */ |
|
39 | - private $versionManager; |
|
40 | - |
|
41 | - public function __construct(IVersion $version, IVersionManager $versionManager) { |
|
42 | - $this->version = $version; |
|
43 | - $this->versionManager = $versionManager; |
|
44 | - } |
|
45 | - |
|
46 | - public function put($data) { |
|
47 | - throw new Forbidden(); |
|
48 | - } |
|
49 | - |
|
50 | - public function get() { |
|
51 | - try { |
|
52 | - return $this->versionManager->read($this->version); |
|
53 | - } catch (NotFoundException $e) { |
|
54 | - throw new NotFound(); |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - public function getContentType(): string { |
|
59 | - return $this->version->getMimeType(); |
|
60 | - } |
|
61 | - |
|
62 | - public function getETag(): string { |
|
63 | - return (string)$this->version->getRevisionId(); |
|
64 | - } |
|
65 | - |
|
66 | - public function getSize(): int { |
|
67 | - return $this->version->getSize(); |
|
68 | - } |
|
69 | - |
|
70 | - public function delete() { |
|
71 | - throw new Forbidden(); |
|
72 | - } |
|
73 | - |
|
74 | - public function getName(): string { |
|
75 | - return (string)$this->version->getRevisionId(); |
|
76 | - } |
|
77 | - |
|
78 | - public function setName($name) { |
|
79 | - throw new Forbidden(); |
|
80 | - } |
|
81 | - |
|
82 | - public function getLastModified(): int { |
|
83 | - return $this->version->getTimestamp(); |
|
84 | - } |
|
85 | - |
|
86 | - public function rollBack() { |
|
87 | - $this->versionManager->rollback($this->version); |
|
88 | - } |
|
89 | - |
|
90 | - public function getVersion(): IVersion { |
|
91 | - return $this->version; |
|
92 | - } |
|
35 | + /** @var IVersion */ |
|
36 | + private $version; |
|
37 | + |
|
38 | + /** @var IVersionManager */ |
|
39 | + private $versionManager; |
|
40 | + |
|
41 | + public function __construct(IVersion $version, IVersionManager $versionManager) { |
|
42 | + $this->version = $version; |
|
43 | + $this->versionManager = $versionManager; |
|
44 | + } |
|
45 | + |
|
46 | + public function put($data) { |
|
47 | + throw new Forbidden(); |
|
48 | + } |
|
49 | + |
|
50 | + public function get() { |
|
51 | + try { |
|
52 | + return $this->versionManager->read($this->version); |
|
53 | + } catch (NotFoundException $e) { |
|
54 | + throw new NotFound(); |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + public function getContentType(): string { |
|
59 | + return $this->version->getMimeType(); |
|
60 | + } |
|
61 | + |
|
62 | + public function getETag(): string { |
|
63 | + return (string)$this->version->getRevisionId(); |
|
64 | + } |
|
65 | + |
|
66 | + public function getSize(): int { |
|
67 | + return $this->version->getSize(); |
|
68 | + } |
|
69 | + |
|
70 | + public function delete() { |
|
71 | + throw new Forbidden(); |
|
72 | + } |
|
73 | + |
|
74 | + public function getName(): string { |
|
75 | + return (string)$this->version->getRevisionId(); |
|
76 | + } |
|
77 | + |
|
78 | + public function setName($name) { |
|
79 | + throw new Forbidden(); |
|
80 | + } |
|
81 | + |
|
82 | + public function getLastModified(): int { |
|
83 | + return $this->version->getTimestamp(); |
|
84 | + } |
|
85 | + |
|
86 | + public function rollBack() { |
|
87 | + $this->versionManager->rollback($this->version); |
|
88 | + } |
|
89 | + |
|
90 | + public function getVersion(): IVersion { |
|
91 | + return $this->version; |
|
92 | + } |
|
93 | 93 | } |
@@ -35,76 +35,76 @@ |
||
35 | 35 | use Sabre\DAV\ICollection; |
36 | 36 | |
37 | 37 | class VersionCollection implements ICollection { |
38 | - /** @var Folder */ |
|
39 | - private $userFolder; |
|
40 | - |
|
41 | - /** @var File */ |
|
42 | - private $file; |
|
43 | - |
|
44 | - /** @var IUser */ |
|
45 | - private $user; |
|
46 | - |
|
47 | - /** @var IVersionManager */ |
|
48 | - private $versionManager; |
|
49 | - |
|
50 | - public function __construct(Folder $userFolder, File $file, IUser $user, IVersionManager $versionManager) { |
|
51 | - $this->userFolder = $userFolder; |
|
52 | - $this->file = $file; |
|
53 | - $this->user = $user; |
|
54 | - $this->versionManager = $versionManager; |
|
55 | - } |
|
56 | - |
|
57 | - public function createFile($name, $data = null) { |
|
58 | - throw new Forbidden(); |
|
59 | - } |
|
60 | - |
|
61 | - public function createDirectory($name) { |
|
62 | - throw new Forbidden(); |
|
63 | - } |
|
64 | - |
|
65 | - public function getChild($name) { |
|
66 | - /** @var VersionFile[] $versions */ |
|
67 | - $versions = $this->getChildren(); |
|
68 | - |
|
69 | - foreach ($versions as $version) { |
|
70 | - if ($version->getName() === $name) { |
|
71 | - return $version; |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - throw new NotFound(); |
|
76 | - } |
|
77 | - |
|
78 | - public function getChildren(): array { |
|
79 | - $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
80 | - |
|
81 | - return array_map(function (IVersion $version) { |
|
82 | - return new VersionFile($version, $this->versionManager); |
|
83 | - }, $versions); |
|
84 | - } |
|
85 | - |
|
86 | - public function childExists($name): bool { |
|
87 | - try { |
|
88 | - $this->getChild($name); |
|
89 | - return true; |
|
90 | - } catch (NotFound $e) { |
|
91 | - return false; |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - public function delete() { |
|
96 | - throw new Forbidden(); |
|
97 | - } |
|
98 | - |
|
99 | - public function getName(): string { |
|
100 | - return (string)$this->file->getId(); |
|
101 | - } |
|
102 | - |
|
103 | - public function setName($name) { |
|
104 | - throw new Forbidden(); |
|
105 | - } |
|
106 | - |
|
107 | - public function getLastModified(): int { |
|
108 | - return 0; |
|
109 | - } |
|
38 | + /** @var Folder */ |
|
39 | + private $userFolder; |
|
40 | + |
|
41 | + /** @var File */ |
|
42 | + private $file; |
|
43 | + |
|
44 | + /** @var IUser */ |
|
45 | + private $user; |
|
46 | + |
|
47 | + /** @var IVersionManager */ |
|
48 | + private $versionManager; |
|
49 | + |
|
50 | + public function __construct(Folder $userFolder, File $file, IUser $user, IVersionManager $versionManager) { |
|
51 | + $this->userFolder = $userFolder; |
|
52 | + $this->file = $file; |
|
53 | + $this->user = $user; |
|
54 | + $this->versionManager = $versionManager; |
|
55 | + } |
|
56 | + |
|
57 | + public function createFile($name, $data = null) { |
|
58 | + throw new Forbidden(); |
|
59 | + } |
|
60 | + |
|
61 | + public function createDirectory($name) { |
|
62 | + throw new Forbidden(); |
|
63 | + } |
|
64 | + |
|
65 | + public function getChild($name) { |
|
66 | + /** @var VersionFile[] $versions */ |
|
67 | + $versions = $this->getChildren(); |
|
68 | + |
|
69 | + foreach ($versions as $version) { |
|
70 | + if ($version->getName() === $name) { |
|
71 | + return $version; |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + throw new NotFound(); |
|
76 | + } |
|
77 | + |
|
78 | + public function getChildren(): array { |
|
79 | + $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
|
80 | + |
|
81 | + return array_map(function (IVersion $version) { |
|
82 | + return new VersionFile($version, $this->versionManager); |
|
83 | + }, $versions); |
|
84 | + } |
|
85 | + |
|
86 | + public function childExists($name): bool { |
|
87 | + try { |
|
88 | + $this->getChild($name); |
|
89 | + return true; |
|
90 | + } catch (NotFound $e) { |
|
91 | + return false; |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + public function delete() { |
|
96 | + throw new Forbidden(); |
|
97 | + } |
|
98 | + |
|
99 | + public function getName(): string { |
|
100 | + return (string)$this->file->getId(); |
|
101 | + } |
|
102 | + |
|
103 | + public function setName($name) { |
|
104 | + throw new Forbidden(); |
|
105 | + } |
|
106 | + |
|
107 | + public function getLastModified(): int { |
|
108 | + return 0; |
|
109 | + } |
|
110 | 110 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function getChildren(): array { |
79 | 79 | $versions = $this->versionManager->getVersionsForFile($this->user, $this->file); |
80 | 80 | |
81 | - return array_map(function (IVersion $version) { |
|
81 | + return array_map(function(IVersion $version) { |
|
82 | 82 | return new VersionFile($version, $this->versionManager); |
83 | 83 | }, $versions); |
84 | 84 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function getName(): string { |
100 | - return (string)$this->file->getId(); |
|
100 | + return (string) $this->file->getId(); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function setName($name) { |
@@ -33,22 +33,22 @@ |
||
33 | 33 | |
34 | 34 | class Version1008Date20181030113700 extends SimpleMigrationStep { |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * @return null|ISchemaWrapper |
|
41 | - */ |
|
42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | - /** @var ISchemaWrapper $schema */ |
|
44 | - $schema = $schemaClosure(); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * @return null|ISchemaWrapper |
|
41 | + */ |
|
42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | + /** @var ISchemaWrapper $schema */ |
|
44 | + $schema = $schemaClosure(); |
|
45 | 45 | |
46 | - $table = $schema->getTable('cards'); |
|
47 | - $table->addColumn('uid', Type::STRING, [ |
|
48 | - 'notnull' => false, |
|
49 | - 'length' => 255 |
|
50 | - ]); |
|
46 | + $table = $schema->getTable('cards'); |
|
47 | + $table->addColumn('uid', Type::STRING, [ |
|
48 | + 'notnull' => false, |
|
49 | + 'length' => 255 |
|
50 | + ]); |
|
51 | 51 | |
52 | - return $schema; |
|
53 | - } |
|
52 | + return $schema; |
|
53 | + } |
|
54 | 54 | } |
@@ -32,60 +32,60 @@ |
||
32 | 32 | use OCP\User\Backend\IPasswordConfirmationBackend; |
33 | 33 | |
34 | 34 | class PasswordConfirmationMiddleware extends Middleware { |
35 | - /** @var ControllerMethodReflector */ |
|
36 | - private $reflector; |
|
37 | - /** @var ISession */ |
|
38 | - private $session; |
|
39 | - /** @var IUserSession */ |
|
40 | - private $userSession; |
|
41 | - /** @var ITimeFactory */ |
|
42 | - private $timeFactory; |
|
43 | - /** @var array */ |
|
44 | - private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true]; |
|
35 | + /** @var ControllerMethodReflector */ |
|
36 | + private $reflector; |
|
37 | + /** @var ISession */ |
|
38 | + private $session; |
|
39 | + /** @var IUserSession */ |
|
40 | + private $userSession; |
|
41 | + /** @var ITimeFactory */ |
|
42 | + private $timeFactory; |
|
43 | + /** @var array */ |
|
44 | + private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true]; |
|
45 | 45 | |
46 | - /** |
|
47 | - * PasswordConfirmationMiddleware constructor. |
|
48 | - * |
|
49 | - * @param ControllerMethodReflector $reflector |
|
50 | - * @param ISession $session |
|
51 | - * @param IUserSession $userSession |
|
52 | - * @param ITimeFactory $timeFactory |
|
53 | - */ |
|
54 | - public function __construct(ControllerMethodReflector $reflector, |
|
55 | - ISession $session, |
|
56 | - IUserSession $userSession, |
|
57 | - ITimeFactory $timeFactory) { |
|
58 | - $this->reflector = $reflector; |
|
59 | - $this->session = $session; |
|
60 | - $this->userSession = $userSession; |
|
61 | - $this->timeFactory = $timeFactory; |
|
62 | - } |
|
46 | + /** |
|
47 | + * PasswordConfirmationMiddleware constructor. |
|
48 | + * |
|
49 | + * @param ControllerMethodReflector $reflector |
|
50 | + * @param ISession $session |
|
51 | + * @param IUserSession $userSession |
|
52 | + * @param ITimeFactory $timeFactory |
|
53 | + */ |
|
54 | + public function __construct(ControllerMethodReflector $reflector, |
|
55 | + ISession $session, |
|
56 | + IUserSession $userSession, |
|
57 | + ITimeFactory $timeFactory) { |
|
58 | + $this->reflector = $reflector; |
|
59 | + $this->session = $session; |
|
60 | + $this->userSession = $userSession; |
|
61 | + $this->timeFactory = $timeFactory; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param Controller $controller |
|
66 | - * @param string $methodName |
|
67 | - * @throws NotConfirmedException |
|
68 | - */ |
|
69 | - public function beforeController($controller, $methodName) { |
|
70 | - if ($this->reflector->hasAnnotation('PasswordConfirmationRequired')) { |
|
71 | - $user = $this->userSession->getUser(); |
|
72 | - $backendClassName = ''; |
|
73 | - if ($user !== null) { |
|
74 | - $backend = $user->getBackend(); |
|
75 | - if ($backend instanceof IPasswordConfirmationBackend) { |
|
76 | - if (!$backend->canConfirmPassword($user->getUID())) { |
|
77 | - return; |
|
78 | - } |
|
79 | - } |
|
64 | + /** |
|
65 | + * @param Controller $controller |
|
66 | + * @param string $methodName |
|
67 | + * @throws NotConfirmedException |
|
68 | + */ |
|
69 | + public function beforeController($controller, $methodName) { |
|
70 | + if ($this->reflector->hasAnnotation('PasswordConfirmationRequired')) { |
|
71 | + $user = $this->userSession->getUser(); |
|
72 | + $backendClassName = ''; |
|
73 | + if ($user !== null) { |
|
74 | + $backend = $user->getBackend(); |
|
75 | + if ($backend instanceof IPasswordConfirmationBackend) { |
|
76 | + if (!$backend->canConfirmPassword($user->getUID())) { |
|
77 | + return; |
|
78 | + } |
|
79 | + } |
|
80 | 80 | |
81 | - $backendClassName = $user->getBackendClassName(); |
|
82 | - } |
|
81 | + $backendClassName = $user->getBackendClassName(); |
|
82 | + } |
|
83 | 83 | |
84 | - $lastConfirm = (int) $this->session->get('last-password-confirm'); |
|
85 | - // we can't check the password against a SAML backend, so skip password confirmation in this case |
|
86 | - if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay |
|
87 | - throw new NotConfirmedException(); |
|
88 | - } |
|
89 | - } |
|
90 | - } |
|
84 | + $lastConfirm = (int) $this->session->get('last-password-confirm'); |
|
85 | + // we can't check the password against a SAML backend, so skip password confirmation in this case |
|
86 | + if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay |
|
87 | + throw new NotConfirmedException(); |
|
88 | + } |
|
89 | + } |
|
90 | + } |
|
91 | 91 | } |
@@ -29,8 +29,8 @@ |
||
29 | 29 | */ |
30 | 30 | interface IPasswordConfirmationBackend { |
31 | 31 | |
32 | - /** |
|
33 | - * @since 15.0.0 |
|
34 | - */ |
|
35 | - public function canConfirmPassword(string $uid): bool; |
|
32 | + /** |
|
33 | + * @since 15.0.0 |
|
34 | + */ |
|
35 | + public function canConfirmPassword(string $uid): bool; |
|
36 | 36 | } |
@@ -213,18 +213,18 @@ |
||
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | |
216 | - $pattern = '/(^|\s)(' . '@' . $mention['id'] . ')(\b)/'; |
|
216 | + $pattern = '/(^|\s)('.'@'.$mention['id'].')(\b)/'; |
|
217 | 217 | if (strpos($mention['id'], ' ') !== false) { |
218 | - $pattern = '/(^|\s)(' . '@"' . $mention['id'] . '"' . ')(\b)?/'; |
|
218 | + $pattern = '/(^|\s)('.'@"'.$mention['id'].'"'.')(\b)?/'; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | $message = preg_replace( |
222 | 222 | $pattern, |
223 | 223 | //'${1}' . $this->regexSafeUser($mention['id'], $displayName) . '${3}', |
224 | - '${1}' . '{mention' . $mentionCount . '}' . '${3}', |
|
224 | + '${1}'.'{mention'.$mentionCount.'}'.'${3}', |
|
225 | 225 | $message |
226 | 226 | ); |
227 | - $mentions['mention' . $mentionCount] = $this->generateUserParameter($mention['id']); |
|
227 | + $mentions['mention'.$mentionCount] = $this->generateUserParameter($mention['id']); |
|
228 | 228 | $mentionCount++; |
229 | 229 | } |
230 | 230 |
@@ -36,244 +36,244 @@ |
||
36 | 36 | |
37 | 37 | class Provider implements IProvider { |
38 | 38 | |
39 | - /** @var IFactory */ |
|
40 | - protected $languageFactory; |
|
41 | - |
|
42 | - /** @var IL10N */ |
|
43 | - protected $l; |
|
44 | - |
|
45 | - /** @var IURLGenerator */ |
|
46 | - protected $url; |
|
47 | - |
|
48 | - /** @var ICommentsManager */ |
|
49 | - protected $commentsManager; |
|
50 | - |
|
51 | - /** @var IUserManager */ |
|
52 | - protected $userManager; |
|
53 | - |
|
54 | - /** @var IManager */ |
|
55 | - protected $activityManager; |
|
56 | - |
|
57 | - /** @var string[] */ |
|
58 | - protected $displayNames = []; |
|
59 | - |
|
60 | - /** |
|
61 | - * @param IFactory $languageFactory |
|
62 | - * @param IURLGenerator $url |
|
63 | - * @param ICommentsManager $commentsManager |
|
64 | - * @param IUserManager $userManager |
|
65 | - * @param IManager $activityManager |
|
66 | - */ |
|
67 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, ICommentsManager $commentsManager, IUserManager $userManager, IManager $activityManager) { |
|
68 | - $this->languageFactory = $languageFactory; |
|
69 | - $this->url = $url; |
|
70 | - $this->commentsManager = $commentsManager; |
|
71 | - $this->userManager = $userManager; |
|
72 | - $this->activityManager = $activityManager; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @param string $language |
|
77 | - * @param IEvent $event |
|
78 | - * @param IEvent|null $previousEvent |
|
79 | - * @return IEvent |
|
80 | - * @throws \InvalidArgumentException |
|
81 | - * @since 11.0.0 |
|
82 | - */ |
|
83 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
84 | - if ($event->getApp() !== 'comments') { |
|
85 | - throw new \InvalidArgumentException(); |
|
86 | - } |
|
87 | - |
|
88 | - $this->l = $this->languageFactory->get('comments', $language); |
|
89 | - |
|
90 | - if ($event->getSubject() === 'add_comment_subject') { |
|
91 | - $this->parseMessage($event); |
|
92 | - if ($this->activityManager->getRequirePNG()) { |
|
93 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.png'))); |
|
94 | - } else { |
|
95 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg'))); |
|
96 | - } |
|
97 | - |
|
98 | - if ($this->activityManager->isFormattingFilteredObject()) { |
|
99 | - try { |
|
100 | - return $this->parseShortVersion($event); |
|
101 | - } catch (\InvalidArgumentException $e) { |
|
102 | - // Ignore and simply use the long version... |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - return $this->parseLongVersion($event); |
|
107 | - } else { |
|
108 | - throw new \InvalidArgumentException(); |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @param IEvent $event |
|
114 | - * @return IEvent |
|
115 | - * @throws \InvalidArgumentException |
|
116 | - */ |
|
117 | - protected function parseShortVersion(IEvent $event) { |
|
118 | - $subjectParameters = $this->getSubjectParameters($event); |
|
119 | - |
|
120 | - if ($event->getSubject() === 'add_comment_subject') { |
|
121 | - if ($subjectParameters['actor'] === $this->activityManager->getCurrentUserId()) { |
|
122 | - $event->setParsedSubject($this->l->t('You commented')) |
|
123 | - ->setRichSubject($this->l->t('You commented'), []); |
|
124 | - } else { |
|
125 | - $author = $this->generateUserParameter($subjectParameters['actor']); |
|
126 | - $event->setParsedSubject($this->l->t('%1$s commented', [$author['name']])) |
|
127 | - ->setRichSubject($this->l->t('{author} commented'), [ |
|
128 | - 'author' => $author, |
|
129 | - ]); |
|
130 | - } |
|
131 | - } else { |
|
132 | - throw new \InvalidArgumentException(); |
|
133 | - } |
|
134 | - |
|
135 | - return $event; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @param IEvent $event |
|
140 | - * @return IEvent |
|
141 | - * @throws \InvalidArgumentException |
|
142 | - */ |
|
143 | - protected function parseLongVersion(IEvent $event) { |
|
144 | - $subjectParameters = $this->getSubjectParameters($event); |
|
145 | - |
|
146 | - if ($event->getSubject() === 'add_comment_subject') { |
|
147 | - if ($subjectParameters['actor'] === $this->activityManager->getCurrentUserId()) { |
|
148 | - $event->setParsedSubject($this->l->t('You commented on %1$s', [ |
|
149 | - $subjectParameters['filePath'], |
|
150 | - ])) |
|
151 | - ->setRichSubject($this->l->t('You commented on {file}'), [ |
|
152 | - 'file' => $this->generateFileParameter($subjectParameters['fileId'], $subjectParameters['filePath']), |
|
153 | - ]); |
|
154 | - } else { |
|
155 | - $author = $this->generateUserParameter($subjectParameters['actor']); |
|
156 | - $event->setParsedSubject($this->l->t('%1$s commented on %2$s', [ |
|
157 | - $author['name'], |
|
158 | - $subjectParameters['filePath'], |
|
159 | - ])) |
|
160 | - ->setRichSubject($this->l->t('{author} commented on {file}'), [ |
|
161 | - 'author' => $author, |
|
162 | - 'file' => $this->generateFileParameter($subjectParameters['fileId'], $subjectParameters['filePath']), |
|
163 | - ]); |
|
164 | - } |
|
165 | - } else { |
|
166 | - throw new \InvalidArgumentException(); |
|
167 | - } |
|
168 | - |
|
169 | - return $event; |
|
170 | - } |
|
171 | - |
|
172 | - protected function getSubjectParameters(IEvent $event) { |
|
173 | - $subjectParameters = $event->getSubjectParameters(); |
|
174 | - if (isset($subjectParameters['fileId'])) { |
|
175 | - return $subjectParameters; |
|
176 | - } |
|
177 | - |
|
178 | - // Fix subjects from 12.0.3 and older |
|
179 | - // |
|
180 | - // Do NOT Remove unless necessary |
|
181 | - // Removing this will break parsing of activities that were created on |
|
182 | - // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
183 | - // Otherwise if people upgrade over multiple releases in a short period, |
|
184 | - // they will get the dead entries in their stream. |
|
185 | - return [ |
|
186 | - 'actor' => $subjectParameters[0], |
|
187 | - 'fileId' => (int) $event->getObjectId(), |
|
188 | - 'filePath' => trim($subjectParameters[1], '/'), |
|
189 | - ]; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @param IEvent $event |
|
194 | - */ |
|
195 | - protected function parseMessage(IEvent $event) { |
|
196 | - $messageParameters = $event->getMessageParameters(); |
|
197 | - if (empty($messageParameters)) { |
|
198 | ||
199 | - return; |
|
200 | - } |
|
201 | - |
|
202 | - $commentId = isset($messageParameters['commentId']) ? $messageParameters['commentId'] : $messageParameters[0]; |
|
203 | - |
|
204 | - try { |
|
205 | - $comment = $this->commentsManager->get((string) $commentId); |
|
206 | - $message = $comment->getMessage(); |
|
207 | - |
|
208 | - $mentionCount = 1; |
|
209 | - $mentions = []; |
|
210 | - foreach ($comment->getMentions() as $mention) { |
|
211 | - if ($mention['type'] !== 'user') { |
|
212 | - continue; |
|
213 | - } |
|
214 | - |
|
215 | - $pattern = '/(^|\s)(' . '@' . $mention['id'] . ')(\b)/'; |
|
216 | - if (strpos($mention['id'], ' ') !== false) { |
|
217 | - $pattern = '/(^|\s)(' . '@"' . $mention['id'] . '"' . ')(\b)?/'; |
|
218 | - } |
|
219 | - |
|
220 | - $message = preg_replace( |
|
221 | - $pattern, |
|
222 | - //'${1}' . $this->regexSafeUser($mention['id'], $displayName) . '${3}', |
|
223 | - '${1}' . '{mention' . $mentionCount . '}' . '${3}', |
|
224 | - $message |
|
225 | - ); |
|
226 | - $mentions['mention' . $mentionCount] = $this->generateUserParameter($mention['id']); |
|
227 | - $mentionCount++; |
|
228 | - } |
|
229 | - |
|
230 | - $event->setParsedMessage($comment->getMessage()) |
|
231 | - ->setRichMessage($message, $mentions); |
|
232 | - } catch (NotFoundException $e) { |
|
233 | - } |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * @param int $id |
|
238 | - * @param string $path |
|
239 | - * @return array |
|
240 | - */ |
|
241 | - protected function generateFileParameter($id, $path) { |
|
242 | - return [ |
|
243 | - 'type' => 'file', |
|
244 | - 'id' => $id, |
|
245 | - 'name' => basename($path), |
|
246 | - 'path' => $path, |
|
247 | - 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]), |
|
248 | - ]; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * @param string $uid |
|
253 | - * @return array |
|
254 | - */ |
|
255 | - protected function generateUserParameter($uid) { |
|
256 | - if (!isset($this->displayNames[$uid])) { |
|
257 | - $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
258 | - } |
|
259 | - |
|
260 | - return [ |
|
261 | - 'type' => 'user', |
|
262 | - 'id' => $uid, |
|
263 | - 'name' => $this->displayNames[$uid], |
|
264 | - ]; |
|
265 | - } |
|
266 | - |
|
267 | - /** |
|
268 | - * @param string $uid |
|
269 | - * @return string |
|
270 | - */ |
|
271 | - protected function getDisplayName($uid) { |
|
272 | - $user = $this->userManager->get($uid); |
|
273 | - if ($user instanceof IUser) { |
|
274 | - return $user->getDisplayName(); |
|
275 | - } else { |
|
276 | - return $uid; |
|
277 | - } |
|
278 | - } |
|
39 | + /** @var IFactory */ |
|
40 | + protected $languageFactory; |
|
41 | + |
|
42 | + /** @var IL10N */ |
|
43 | + protected $l; |
|
44 | + |
|
45 | + /** @var IURLGenerator */ |
|
46 | + protected $url; |
|
47 | + |
|
48 | + /** @var ICommentsManager */ |
|
49 | + protected $commentsManager; |
|
50 | + |
|
51 | + /** @var IUserManager */ |
|
52 | + protected $userManager; |
|
53 | + |
|
54 | + /** @var IManager */ |
|
55 | + protected $activityManager; |
|
56 | + |
|
57 | + /** @var string[] */ |
|
58 | + protected $displayNames = []; |
|
59 | + |
|
60 | + /** |
|
61 | + * @param IFactory $languageFactory |
|
62 | + * @param IURLGenerator $url |
|
63 | + * @param ICommentsManager $commentsManager |
|
64 | + * @param IUserManager $userManager |
|
65 | + * @param IManager $activityManager |
|
66 | + */ |
|
67 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, ICommentsManager $commentsManager, IUserManager $userManager, IManager $activityManager) { |
|
68 | + $this->languageFactory = $languageFactory; |
|
69 | + $this->url = $url; |
|
70 | + $this->commentsManager = $commentsManager; |
|
71 | + $this->userManager = $userManager; |
|
72 | + $this->activityManager = $activityManager; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @param string $language |
|
77 | + * @param IEvent $event |
|
78 | + * @param IEvent|null $previousEvent |
|
79 | + * @return IEvent |
|
80 | + * @throws \InvalidArgumentException |
|
81 | + * @since 11.0.0 |
|
82 | + */ |
|
83 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
84 | + if ($event->getApp() !== 'comments') { |
|
85 | + throw new \InvalidArgumentException(); |
|
86 | + } |
|
87 | + |
|
88 | + $this->l = $this->languageFactory->get('comments', $language); |
|
89 | + |
|
90 | + if ($event->getSubject() === 'add_comment_subject') { |
|
91 | + $this->parseMessage($event); |
|
92 | + if ($this->activityManager->getRequirePNG()) { |
|
93 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.png'))); |
|
94 | + } else { |
|
95 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg'))); |
|
96 | + } |
|
97 | + |
|
98 | + if ($this->activityManager->isFormattingFilteredObject()) { |
|
99 | + try { |
|
100 | + return $this->parseShortVersion($event); |
|
101 | + } catch (\InvalidArgumentException $e) { |
|
102 | + // Ignore and simply use the long version... |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + return $this->parseLongVersion($event); |
|
107 | + } else { |
|
108 | + throw new \InvalidArgumentException(); |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @param IEvent $event |
|
114 | + * @return IEvent |
|
115 | + * @throws \InvalidArgumentException |
|
116 | + */ |
|
117 | + protected function parseShortVersion(IEvent $event) { |
|
118 | + $subjectParameters = $this->getSubjectParameters($event); |
|
119 | + |
|
120 | + if ($event->getSubject() === 'add_comment_subject') { |
|
121 | + if ($subjectParameters['actor'] === $this->activityManager->getCurrentUserId()) { |
|
122 | + $event->setParsedSubject($this->l->t('You commented')) |
|
123 | + ->setRichSubject($this->l->t('You commented'), []); |
|
124 | + } else { |
|
125 | + $author = $this->generateUserParameter($subjectParameters['actor']); |
|
126 | + $event->setParsedSubject($this->l->t('%1$s commented', [$author['name']])) |
|
127 | + ->setRichSubject($this->l->t('{author} commented'), [ |
|
128 | + 'author' => $author, |
|
129 | + ]); |
|
130 | + } |
|
131 | + } else { |
|
132 | + throw new \InvalidArgumentException(); |
|
133 | + } |
|
134 | + |
|
135 | + return $event; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @param IEvent $event |
|
140 | + * @return IEvent |
|
141 | + * @throws \InvalidArgumentException |
|
142 | + */ |
|
143 | + protected function parseLongVersion(IEvent $event) { |
|
144 | + $subjectParameters = $this->getSubjectParameters($event); |
|
145 | + |
|
146 | + if ($event->getSubject() === 'add_comment_subject') { |
|
147 | + if ($subjectParameters['actor'] === $this->activityManager->getCurrentUserId()) { |
|
148 | + $event->setParsedSubject($this->l->t('You commented on %1$s', [ |
|
149 | + $subjectParameters['filePath'], |
|
150 | + ])) |
|
151 | + ->setRichSubject($this->l->t('You commented on {file}'), [ |
|
152 | + 'file' => $this->generateFileParameter($subjectParameters['fileId'], $subjectParameters['filePath']), |
|
153 | + ]); |
|
154 | + } else { |
|
155 | + $author = $this->generateUserParameter($subjectParameters['actor']); |
|
156 | + $event->setParsedSubject($this->l->t('%1$s commented on %2$s', [ |
|
157 | + $author['name'], |
|
158 | + $subjectParameters['filePath'], |
|
159 | + ])) |
|
160 | + ->setRichSubject($this->l->t('{author} commented on {file}'), [ |
|
161 | + 'author' => $author, |
|
162 | + 'file' => $this->generateFileParameter($subjectParameters['fileId'], $subjectParameters['filePath']), |
|
163 | + ]); |
|
164 | + } |
|
165 | + } else { |
|
166 | + throw new \InvalidArgumentException(); |
|
167 | + } |
|
168 | + |
|
169 | + return $event; |
|
170 | + } |
|
171 | + |
|
172 | + protected function getSubjectParameters(IEvent $event) { |
|
173 | + $subjectParameters = $event->getSubjectParameters(); |
|
174 | + if (isset($subjectParameters['fileId'])) { |
|
175 | + return $subjectParameters; |
|
176 | + } |
|
177 | + |
|
178 | + // Fix subjects from 12.0.3 and older |
|
179 | + // |
|
180 | + // Do NOT Remove unless necessary |
|
181 | + // Removing this will break parsing of activities that were created on |
|
182 | + // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
183 | + // Otherwise if people upgrade over multiple releases in a short period, |
|
184 | + // they will get the dead entries in their stream. |
|
185 | + return [ |
|
186 | + 'actor' => $subjectParameters[0], |
|
187 | + 'fileId' => (int) $event->getObjectId(), |
|
188 | + 'filePath' => trim($subjectParameters[1], '/'), |
|
189 | + ]; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * @param IEvent $event |
|
194 | + */ |
|
195 | + protected function parseMessage(IEvent $event) { |
|
196 | + $messageParameters = $event->getMessageParameters(); |
|
197 | + if (empty($messageParameters)) { |
|
198 | ||
199 | + return; |
|
200 | + } |
|
201 | + |
|
202 | + $commentId = isset($messageParameters['commentId']) ? $messageParameters['commentId'] : $messageParameters[0]; |
|
203 | + |
|
204 | + try { |
|
205 | + $comment = $this->commentsManager->get((string) $commentId); |
|
206 | + $message = $comment->getMessage(); |
|
207 | + |
|
208 | + $mentionCount = 1; |
|
209 | + $mentions = []; |
|
210 | + foreach ($comment->getMentions() as $mention) { |
|
211 | + if ($mention['type'] !== 'user') { |
|
212 | + continue; |
|
213 | + } |
|
214 | + |
|
215 | + $pattern = '/(^|\s)(' . '@' . $mention['id'] . ')(\b)/'; |
|
216 | + if (strpos($mention['id'], ' ') !== false) { |
|
217 | + $pattern = '/(^|\s)(' . '@"' . $mention['id'] . '"' . ')(\b)?/'; |
|
218 | + } |
|
219 | + |
|
220 | + $message = preg_replace( |
|
221 | + $pattern, |
|
222 | + //'${1}' . $this->regexSafeUser($mention['id'], $displayName) . '${3}', |
|
223 | + '${1}' . '{mention' . $mentionCount . '}' . '${3}', |
|
224 | + $message |
|
225 | + ); |
|
226 | + $mentions['mention' . $mentionCount] = $this->generateUserParameter($mention['id']); |
|
227 | + $mentionCount++; |
|
228 | + } |
|
229 | + |
|
230 | + $event->setParsedMessage($comment->getMessage()) |
|
231 | + ->setRichMessage($message, $mentions); |
|
232 | + } catch (NotFoundException $e) { |
|
233 | + } |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * @param int $id |
|
238 | + * @param string $path |
|
239 | + * @return array |
|
240 | + */ |
|
241 | + protected function generateFileParameter($id, $path) { |
|
242 | + return [ |
|
243 | + 'type' => 'file', |
|
244 | + 'id' => $id, |
|
245 | + 'name' => basename($path), |
|
246 | + 'path' => $path, |
|
247 | + 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]), |
|
248 | + ]; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * @param string $uid |
|
253 | + * @return array |
|
254 | + */ |
|
255 | + protected function generateUserParameter($uid) { |
|
256 | + if (!isset($this->displayNames[$uid])) { |
|
257 | + $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
258 | + } |
|
259 | + |
|
260 | + return [ |
|
261 | + 'type' => 'user', |
|
262 | + 'id' => $uid, |
|
263 | + 'name' => $this->displayNames[$uid], |
|
264 | + ]; |
|
265 | + } |
|
266 | + |
|
267 | + /** |
|
268 | + * @param string $uid |
|
269 | + * @return string |
|
270 | + */ |
|
271 | + protected function getDisplayName($uid) { |
|
272 | + $user = $this->userManager->get($uid); |
|
273 | + if ($user instanceof IUser) { |
|
274 | + return $user->getDisplayName(); |
|
275 | + } else { |
|
276 | + return $uid; |
|
277 | + } |
|
278 | + } |
|
279 | 279 | } |
@@ -31,40 +31,40 @@ |
||
31 | 31 | |
32 | 32 | class ClearFrontendCaches implements IRepairStep { |
33 | 33 | |
34 | - /** @var ICacheFactory */ |
|
35 | - protected $cacheFactory; |
|
34 | + /** @var ICacheFactory */ |
|
35 | + protected $cacheFactory; |
|
36 | 36 | |
37 | - /** @var SCSSCacher */ |
|
38 | - protected $scssCacher; |
|
37 | + /** @var SCSSCacher */ |
|
38 | + protected $scssCacher; |
|
39 | 39 | |
40 | - /** @var JSCombiner */ |
|
41 | - protected $jsCombiner; |
|
40 | + /** @var JSCombiner */ |
|
41 | + protected $jsCombiner; |
|
42 | 42 | |
43 | - public function __construct(ICacheFactory $cacheFactory, |
|
44 | - SCSSCacher $SCSSCacher, |
|
45 | - JSCombiner $JSCombiner) { |
|
46 | - $this->cacheFactory = $cacheFactory; |
|
47 | - $this->scssCacher = $SCSSCacher; |
|
48 | - $this->jsCombiner = $JSCombiner; |
|
49 | - } |
|
43 | + public function __construct(ICacheFactory $cacheFactory, |
|
44 | + SCSSCacher $SCSSCacher, |
|
45 | + JSCombiner $JSCombiner) { |
|
46 | + $this->cacheFactory = $cacheFactory; |
|
47 | + $this->scssCacher = $SCSSCacher; |
|
48 | + $this->jsCombiner = $JSCombiner; |
|
49 | + } |
|
50 | 50 | |
51 | - public function getName() { |
|
52 | - return 'Clear frontend caches'; |
|
53 | - } |
|
51 | + public function getName() { |
|
52 | + return 'Clear frontend caches'; |
|
53 | + } |
|
54 | 54 | |
55 | - public function run(IOutput $output) { |
|
56 | - try { |
|
57 | - $c = $this->cacheFactory->createDistributed('imagePath'); |
|
58 | - $c->clear(); |
|
59 | - $output->info('Image cache cleared'); |
|
55 | + public function run(IOutput $output) { |
|
56 | + try { |
|
57 | + $c = $this->cacheFactory->createDistributed('imagePath'); |
|
58 | + $c->clear(); |
|
59 | + $output->info('Image cache cleared'); |
|
60 | 60 | |
61 | - $this->scssCacher->resetCache(); |
|
62 | - $output->info('SCSS cache cleared'); |
|
61 | + $this->scssCacher->resetCache(); |
|
62 | + $output->info('SCSS cache cleared'); |
|
63 | 63 | |
64 | - $this->jsCombiner->resetCache(); |
|
65 | - $output->info('JS cache cleared'); |
|
66 | - } catch (\Exception $e) { |
|
67 | - $output->warning('Unable to clear the frontend cache'); |
|
68 | - } |
|
69 | - } |
|
64 | + $this->jsCombiner->resetCache(); |
|
65 | + $output->info('JS cache cleared'); |
|
66 | + } catch (\Exception $e) { |
|
67 | + $output->warning('Unable to clear the frontend cache'); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |