@@ -29,22 +29,22 @@ |
||
29 | 29 | use OCP\IImage; |
30 | 30 | |
31 | 31 | class OpenDocument extends Bundled { |
32 | - /** |
|
33 | - * {@inheritDoc} |
|
34 | - */ |
|
35 | - public function getMimeType(): string { |
|
36 | - return '/application\/vnd.oasis.opendocument.*/'; |
|
37 | - } |
|
32 | + /** |
|
33 | + * {@inheritDoc} |
|
34 | + */ |
|
35 | + public function getMimeType(): string { |
|
36 | + return '/application\/vnd.oasis.opendocument.*/'; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @inheritDoc |
|
42 | - */ |
|
43 | - public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
44 | - $image = $this->extractThumbnail($file, 'Thumbnails/thumbnail.png'); |
|
45 | - if (($image !== null) && $image->valid()) { |
|
46 | - return $image; |
|
47 | - } |
|
48 | - return null; |
|
49 | - } |
|
40 | + /** |
|
41 | + * @inheritDoc |
|
42 | + */ |
|
43 | + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
44 | + $image = $this->extractThumbnail($file, 'Thumbnails/thumbnail.png'); |
|
45 | + if (($image !== null) && $image->valid()) { |
|
46 | + return $image; |
|
47 | + } |
|
48 | + return null; |
|
49 | + } |
|
50 | 50 | } |
@@ -26,26 +26,26 @@ |
||
26 | 26 | use OCP\IImage; |
27 | 27 | |
28 | 28 | class Krita extends Bundled { |
29 | - /** |
|
30 | - * {@inheritDoc} |
|
31 | - */ |
|
32 | - public function getMimeType(): string { |
|
33 | - return '/application\/x-krita/'; |
|
34 | - } |
|
29 | + /** |
|
30 | + * {@inheritDoc} |
|
31 | + */ |
|
32 | + public function getMimeType(): string { |
|
33 | + return '/application\/x-krita/'; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @inheritDoc |
|
39 | - */ |
|
40 | - public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
41 | - $image = $this->extractThumbnail($file, 'mergedimage.png'); |
|
42 | - if (($image !== null) && $image->valid()) { |
|
43 | - return $image; |
|
44 | - } |
|
45 | - $image = $this->extractThumbnail($file, 'preview.png'); |
|
46 | - if (($image !== null) && $image->valid()) { |
|
47 | - return $image; |
|
48 | - } |
|
49 | - return null; |
|
50 | - } |
|
37 | + /** |
|
38 | + * @inheritDoc |
|
39 | + */ |
|
40 | + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
41 | + $image = $this->extractThumbnail($file, 'mergedimage.png'); |
|
42 | + if (($image !== null) && $image->valid()) { |
|
43 | + return $image; |
|
44 | + } |
|
45 | + $image = $this->extractThumbnail($file, 'preview.png'); |
|
46 | + if (($image !== null) && $image->valid()) { |
|
47 | + return $image; |
|
48 | + } |
|
49 | + return null; |
|
50 | + } |
|
51 | 51 | } |
@@ -28,17 +28,17 @@ |
||
28 | 28 | * @since 13.0.0 |
29 | 29 | */ |
30 | 30 | interface ICachedMountFileInfo extends ICachedMountInfo { |
31 | - /** |
|
32 | - * Return the path for the file within the cached mount |
|
33 | - * |
|
34 | - * @return string |
|
35 | - * @since 13.0.0 |
|
36 | - */ |
|
37 | - public function getInternalPath(): string; |
|
31 | + /** |
|
32 | + * Return the path for the file within the cached mount |
|
33 | + * |
|
34 | + * @return string |
|
35 | + * @since 13.0.0 |
|
36 | + */ |
|
37 | + public function getInternalPath(): string; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - * @since 13.0.0 |
|
42 | - */ |
|
43 | - public function getPath(): string; |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + * @since 13.0.0 |
|
42 | + */ |
|
43 | + public function getPath(): string; |
|
44 | 44 | } |
@@ -78,7 +78,7 @@ |
||
78 | 78 | * @param string $userSearch the pattern users are search for |
79 | 79 | */ |
80 | 80 | public function get(string $groupSearch = '', string $userSearch = ''): array { |
81 | - $key = $groupSearch . '::' . $userSearch; |
|
81 | + $key = $groupSearch.'::'.$userSearch; |
|
82 | 82 | if (isset($this->metaData[$key])) { |
83 | 83 | return $this->metaData[$key]; |
84 | 84 | } |
@@ -13,155 +13,155 @@ |
||
13 | 13 | use OCP\IUserSession; |
14 | 14 | |
15 | 15 | class MetaData { |
16 | - public const SORT_NONE = 0; |
|
17 | - public const SORT_USERCOUNT = 1; // May have performance issues on LDAP backends |
|
18 | - public const SORT_GROUPNAME = 2; |
|
19 | - |
|
20 | - /** @var array */ |
|
21 | - protected $metaData = []; |
|
22 | - /** @var int */ |
|
23 | - protected $sorting = self::SORT_NONE; |
|
24 | - |
|
25 | - /** |
|
26 | - * @param string $user the uid of the current user |
|
27 | - * @param bool $isAdmin whether the current users is an admin |
|
28 | - */ |
|
29 | - public function __construct( |
|
30 | - private string $user, |
|
31 | - private bool $isAdmin, |
|
32 | - private bool $isDelegatedAdmin, |
|
33 | - private IGroupManager $groupManager, |
|
34 | - private IUserSession $userSession, |
|
35 | - ) { |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * returns an array with meta data about all available groups |
|
40 | - * the array is structured as follows: |
|
41 | - * [0] array containing meta data about admin groups |
|
42 | - * [1] array containing meta data about unprivileged groups |
|
43 | - * @param string $groupSearch only effective when instance was created with |
|
44 | - * isAdmin being true |
|
45 | - * @param string $userSearch the pattern users are search for |
|
46 | - */ |
|
47 | - public function get(string $groupSearch = '', string $userSearch = ''): array { |
|
48 | - $key = $groupSearch . '::' . $userSearch; |
|
49 | - if (isset($this->metaData[$key])) { |
|
50 | - return $this->metaData[$key]; |
|
51 | - } |
|
52 | - |
|
53 | - $adminGroups = []; |
|
54 | - $groups = []; |
|
55 | - $sortGroupsIndex = 0; |
|
56 | - $sortGroupsKeys = []; |
|
57 | - $sortAdminGroupsIndex = 0; |
|
58 | - $sortAdminGroupsKeys = []; |
|
59 | - |
|
60 | - foreach ($this->getGroups($groupSearch) as $group) { |
|
61 | - $groupMetaData = $this->generateGroupMetaData($group, $userSearch); |
|
62 | - if (strtolower($group->getGID()) !== 'admin') { |
|
63 | - $this->addEntry( |
|
64 | - $groups, |
|
65 | - $sortGroupsKeys, |
|
66 | - $sortGroupsIndex, |
|
67 | - $groupMetaData); |
|
68 | - } else { |
|
69 | - //admin group is hard coded to 'admin' for now. In future, |
|
70 | - //backends may define admin groups too. Then the if statement |
|
71 | - //has to be adjusted accordingly. |
|
72 | - $this->addEntry( |
|
73 | - $adminGroups, |
|
74 | - $sortAdminGroupsKeys, |
|
75 | - $sortAdminGroupsIndex, |
|
76 | - $groupMetaData); |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - //whether sorting is necessary is will be checked in sort() |
|
81 | - $this->sort($groups, $sortGroupsKeys); |
|
82 | - $this->sort($adminGroups, $sortAdminGroupsKeys); |
|
83 | - |
|
84 | - $this->metaData[$key] = [$adminGroups, $groups]; |
|
85 | - return $this->metaData[$key]; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * sets the sort mode, see SORT_* constants for supported modes |
|
90 | - */ |
|
91 | - public function setSorting(int $sortMode): void { |
|
92 | - switch ($sortMode) { |
|
93 | - case self::SORT_USERCOUNT: |
|
94 | - case self::SORT_GROUPNAME: |
|
95 | - $this->sorting = $sortMode; |
|
96 | - break; |
|
97 | - |
|
98 | - default: |
|
99 | - $this->sorting = self::SORT_NONE; |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * adds an group entry to the resulting array |
|
105 | - * @param array $entries the resulting array, by reference |
|
106 | - * @param array $sortKeys the sort key array, by reference |
|
107 | - * @param int $sortIndex the sort key index, by reference |
|
108 | - * @param array $data the group's meta data as returned by generateGroupMetaData() |
|
109 | - */ |
|
110 | - private function addEntry(array &$entries, array &$sortKeys, int &$sortIndex, array $data): void { |
|
111 | - $entries[] = $data; |
|
112 | - if ($this->sorting === self::SORT_USERCOUNT) { |
|
113 | - $sortKeys[$sortIndex] = $data['usercount']; |
|
114 | - $sortIndex++; |
|
115 | - } elseif ($this->sorting === self::SORT_GROUPNAME) { |
|
116 | - $sortKeys[$sortIndex] = $data['name']; |
|
117 | - $sortIndex++; |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * creates an array containing the group meta data |
|
123 | - * @return array with the keys 'id', 'name', 'usercount' and 'disabled' |
|
124 | - */ |
|
125 | - private function generateGroupMetaData(IGroup $group, string $userSearch): array { |
|
126 | - return [ |
|
127 | - 'id' => $group->getGID(), |
|
128 | - 'name' => $group->getDisplayName(), |
|
129 | - 'usercount' => $this->sorting === self::SORT_USERCOUNT ? $group->count($userSearch) : 0, |
|
130 | - 'disabled' => $group->countDisabled(), |
|
131 | - 'canAdd' => $group->canAddUser(), |
|
132 | - 'canRemove' => $group->canRemoveUser(), |
|
133 | - ]; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * sorts the result array, if applicable |
|
138 | - * @param array $entries the result array, by reference |
|
139 | - * @param array $sortKeys the array containing the sort keys |
|
140 | - */ |
|
141 | - private function sort(array &$entries, array $sortKeys): void { |
|
142 | - if ($this->sorting === self::SORT_USERCOUNT) { |
|
143 | - array_multisort($sortKeys, SORT_DESC, $entries); |
|
144 | - } elseif ($this->sorting === self::SORT_GROUPNAME) { |
|
145 | - array_multisort($sortKeys, SORT_ASC, $entries); |
|
146 | - } |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * returns the available groups |
|
151 | - * @return IGroup[] |
|
152 | - */ |
|
153 | - public function getGroups(string $search = ''): array { |
|
154 | - if ($this->isAdmin || $this->isDelegatedAdmin) { |
|
155 | - return $this->groupManager->search($search); |
|
156 | - } else { |
|
157 | - $userObject = $this->userSession->getUser(); |
|
158 | - if ($userObject !== null && $this->groupManager instanceof GroupManager) { |
|
159 | - $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($userObject); |
|
160 | - } else { |
|
161 | - $groups = []; |
|
162 | - } |
|
163 | - |
|
164 | - return $groups; |
|
165 | - } |
|
166 | - } |
|
16 | + public const SORT_NONE = 0; |
|
17 | + public const SORT_USERCOUNT = 1; // May have performance issues on LDAP backends |
|
18 | + public const SORT_GROUPNAME = 2; |
|
19 | + |
|
20 | + /** @var array */ |
|
21 | + protected $metaData = []; |
|
22 | + /** @var int */ |
|
23 | + protected $sorting = self::SORT_NONE; |
|
24 | + |
|
25 | + /** |
|
26 | + * @param string $user the uid of the current user |
|
27 | + * @param bool $isAdmin whether the current users is an admin |
|
28 | + */ |
|
29 | + public function __construct( |
|
30 | + private string $user, |
|
31 | + private bool $isAdmin, |
|
32 | + private bool $isDelegatedAdmin, |
|
33 | + private IGroupManager $groupManager, |
|
34 | + private IUserSession $userSession, |
|
35 | + ) { |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * returns an array with meta data about all available groups |
|
40 | + * the array is structured as follows: |
|
41 | + * [0] array containing meta data about admin groups |
|
42 | + * [1] array containing meta data about unprivileged groups |
|
43 | + * @param string $groupSearch only effective when instance was created with |
|
44 | + * isAdmin being true |
|
45 | + * @param string $userSearch the pattern users are search for |
|
46 | + */ |
|
47 | + public function get(string $groupSearch = '', string $userSearch = ''): array { |
|
48 | + $key = $groupSearch . '::' . $userSearch; |
|
49 | + if (isset($this->metaData[$key])) { |
|
50 | + return $this->metaData[$key]; |
|
51 | + } |
|
52 | + |
|
53 | + $adminGroups = []; |
|
54 | + $groups = []; |
|
55 | + $sortGroupsIndex = 0; |
|
56 | + $sortGroupsKeys = []; |
|
57 | + $sortAdminGroupsIndex = 0; |
|
58 | + $sortAdminGroupsKeys = []; |
|
59 | + |
|
60 | + foreach ($this->getGroups($groupSearch) as $group) { |
|
61 | + $groupMetaData = $this->generateGroupMetaData($group, $userSearch); |
|
62 | + if (strtolower($group->getGID()) !== 'admin') { |
|
63 | + $this->addEntry( |
|
64 | + $groups, |
|
65 | + $sortGroupsKeys, |
|
66 | + $sortGroupsIndex, |
|
67 | + $groupMetaData); |
|
68 | + } else { |
|
69 | + //admin group is hard coded to 'admin' for now. In future, |
|
70 | + //backends may define admin groups too. Then the if statement |
|
71 | + //has to be adjusted accordingly. |
|
72 | + $this->addEntry( |
|
73 | + $adminGroups, |
|
74 | + $sortAdminGroupsKeys, |
|
75 | + $sortAdminGroupsIndex, |
|
76 | + $groupMetaData); |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + //whether sorting is necessary is will be checked in sort() |
|
81 | + $this->sort($groups, $sortGroupsKeys); |
|
82 | + $this->sort($adminGroups, $sortAdminGroupsKeys); |
|
83 | + |
|
84 | + $this->metaData[$key] = [$adminGroups, $groups]; |
|
85 | + return $this->metaData[$key]; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * sets the sort mode, see SORT_* constants for supported modes |
|
90 | + */ |
|
91 | + public function setSorting(int $sortMode): void { |
|
92 | + switch ($sortMode) { |
|
93 | + case self::SORT_USERCOUNT: |
|
94 | + case self::SORT_GROUPNAME: |
|
95 | + $this->sorting = $sortMode; |
|
96 | + break; |
|
97 | + |
|
98 | + default: |
|
99 | + $this->sorting = self::SORT_NONE; |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * adds an group entry to the resulting array |
|
105 | + * @param array $entries the resulting array, by reference |
|
106 | + * @param array $sortKeys the sort key array, by reference |
|
107 | + * @param int $sortIndex the sort key index, by reference |
|
108 | + * @param array $data the group's meta data as returned by generateGroupMetaData() |
|
109 | + */ |
|
110 | + private function addEntry(array &$entries, array &$sortKeys, int &$sortIndex, array $data): void { |
|
111 | + $entries[] = $data; |
|
112 | + if ($this->sorting === self::SORT_USERCOUNT) { |
|
113 | + $sortKeys[$sortIndex] = $data['usercount']; |
|
114 | + $sortIndex++; |
|
115 | + } elseif ($this->sorting === self::SORT_GROUPNAME) { |
|
116 | + $sortKeys[$sortIndex] = $data['name']; |
|
117 | + $sortIndex++; |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * creates an array containing the group meta data |
|
123 | + * @return array with the keys 'id', 'name', 'usercount' and 'disabled' |
|
124 | + */ |
|
125 | + private function generateGroupMetaData(IGroup $group, string $userSearch): array { |
|
126 | + return [ |
|
127 | + 'id' => $group->getGID(), |
|
128 | + 'name' => $group->getDisplayName(), |
|
129 | + 'usercount' => $this->sorting === self::SORT_USERCOUNT ? $group->count($userSearch) : 0, |
|
130 | + 'disabled' => $group->countDisabled(), |
|
131 | + 'canAdd' => $group->canAddUser(), |
|
132 | + 'canRemove' => $group->canRemoveUser(), |
|
133 | + ]; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * sorts the result array, if applicable |
|
138 | + * @param array $entries the result array, by reference |
|
139 | + * @param array $sortKeys the array containing the sort keys |
|
140 | + */ |
|
141 | + private function sort(array &$entries, array $sortKeys): void { |
|
142 | + if ($this->sorting === self::SORT_USERCOUNT) { |
|
143 | + array_multisort($sortKeys, SORT_DESC, $entries); |
|
144 | + } elseif ($this->sorting === self::SORT_GROUPNAME) { |
|
145 | + array_multisort($sortKeys, SORT_ASC, $entries); |
|
146 | + } |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * returns the available groups |
|
151 | + * @return IGroup[] |
|
152 | + */ |
|
153 | + public function getGroups(string $search = ''): array { |
|
154 | + if ($this->isAdmin || $this->isDelegatedAdmin) { |
|
155 | + return $this->groupManager->search($search); |
|
156 | + } else { |
|
157 | + $userObject = $this->userSession->getUser(); |
|
158 | + if ($userObject !== null && $this->groupManager instanceof GroupManager) { |
|
159 | + $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($userObject); |
|
160 | + } else { |
|
161 | + $groups = []; |
|
162 | + } |
|
163 | + |
|
164 | + return $groups; |
|
165 | + } |
|
166 | + } |
|
167 | 167 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $logFile = $config->getSystemValueString('logfile_audit', ''); |
43 | 43 | |
44 | 44 | if ($auditType === 'file' && !$logFile) { |
45 | - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
45 | + $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/audit.log'; |
|
46 | 46 | // Legacy way was appconfig, now it's paralleled with the normal log config |
47 | 47 | $logFile = $config->getAppValue('admin_audit', 'logfile', $default); |
48 | 48 | } |
@@ -18,56 +18,56 @@ |
||
18 | 18 | */ |
19 | 19 | class AuditLogger implements IAuditLogger { |
20 | 20 | |
21 | - private LoggerInterface $parentLogger; |
|
22 | - |
|
23 | - public function __construct(ILogFactory $logFactory, IConfig $config) { |
|
24 | - $auditType = $config->getSystemValueString('log_type_audit', 'file'); |
|
25 | - $defaultTag = $config->getSystemValueString('syslog_tag', 'Nextcloud'); |
|
26 | - $auditTag = $config->getSystemValueString('syslog_tag_audit', $defaultTag); |
|
27 | - $logFile = $config->getSystemValueString('logfile_audit', ''); |
|
28 | - |
|
29 | - if ($auditType === 'file' && !$logFile) { |
|
30 | - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
31 | - // Legacy way was appconfig, now it's paralleled with the normal log config |
|
32 | - $logFile = $config->getAppValue('admin_audit', 'logfile', $default); |
|
33 | - } |
|
34 | - |
|
35 | - $this->parentLogger = $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag); |
|
36 | - } |
|
37 | - |
|
38 | - public function emergency($message, array $context = []): void { |
|
39 | - $this->parentLogger->emergency($message, $context); |
|
40 | - } |
|
41 | - |
|
42 | - public function alert($message, array $context = []): void { |
|
43 | - $this->parentLogger->alert($message, $context); |
|
44 | - } |
|
45 | - |
|
46 | - public function critical($message, array $context = []): void { |
|
47 | - $this->parentLogger->critical($message, $context); |
|
48 | - } |
|
49 | - |
|
50 | - public function error($message, array $context = []): void { |
|
51 | - $this->parentLogger->error($message, $context); |
|
52 | - } |
|
53 | - |
|
54 | - public function warning($message, array $context = []): void { |
|
55 | - $this->parentLogger->warning($message, $context); |
|
56 | - } |
|
57 | - |
|
58 | - public function notice($message, array $context = []): void { |
|
59 | - $this->parentLogger->notice($message, $context); |
|
60 | - } |
|
61 | - |
|
62 | - public function info($message, array $context = []): void { |
|
63 | - $this->parentLogger->info($message, $context); |
|
64 | - } |
|
65 | - |
|
66 | - public function debug($message, array $context = []): void { |
|
67 | - $this->parentLogger->debug($message, $context); |
|
68 | - } |
|
69 | - |
|
70 | - public function log($level, $message, array $context = []): void { |
|
71 | - $this->parentLogger->log($level, $message, $context); |
|
72 | - } |
|
21 | + private LoggerInterface $parentLogger; |
|
22 | + |
|
23 | + public function __construct(ILogFactory $logFactory, IConfig $config) { |
|
24 | + $auditType = $config->getSystemValueString('log_type_audit', 'file'); |
|
25 | + $defaultTag = $config->getSystemValueString('syslog_tag', 'Nextcloud'); |
|
26 | + $auditTag = $config->getSystemValueString('syslog_tag_audit', $defaultTag); |
|
27 | + $logFile = $config->getSystemValueString('logfile_audit', ''); |
|
28 | + |
|
29 | + if ($auditType === 'file' && !$logFile) { |
|
30 | + $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
31 | + // Legacy way was appconfig, now it's paralleled with the normal log config |
|
32 | + $logFile = $config->getAppValue('admin_audit', 'logfile', $default); |
|
33 | + } |
|
34 | + |
|
35 | + $this->parentLogger = $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag); |
|
36 | + } |
|
37 | + |
|
38 | + public function emergency($message, array $context = []): void { |
|
39 | + $this->parentLogger->emergency($message, $context); |
|
40 | + } |
|
41 | + |
|
42 | + public function alert($message, array $context = []): void { |
|
43 | + $this->parentLogger->alert($message, $context); |
|
44 | + } |
|
45 | + |
|
46 | + public function critical($message, array $context = []): void { |
|
47 | + $this->parentLogger->critical($message, $context); |
|
48 | + } |
|
49 | + |
|
50 | + public function error($message, array $context = []): void { |
|
51 | + $this->parentLogger->error($message, $context); |
|
52 | + } |
|
53 | + |
|
54 | + public function warning($message, array $context = []): void { |
|
55 | + $this->parentLogger->warning($message, $context); |
|
56 | + } |
|
57 | + |
|
58 | + public function notice($message, array $context = []): void { |
|
59 | + $this->parentLogger->notice($message, $context); |
|
60 | + } |
|
61 | + |
|
62 | + public function info($message, array $context = []): void { |
|
63 | + $this->parentLogger->info($message, $context); |
|
64 | + } |
|
65 | + |
|
66 | + public function debug($message, array $context = []): void { |
|
67 | + $this->parentLogger->debug($message, $context); |
|
68 | + } |
|
69 | + |
|
70 | + public function log($level, $message, array $context = []): void { |
|
71 | + $this->parentLogger->log($level, $message, $context); |
|
72 | + } |
|
73 | 73 | } |
@@ -33,66 +33,66 @@ |
||
33 | 33 | use OCP\Migration\SimpleMigrationStep; |
34 | 34 | |
35 | 35 | class Version24000Date20211222112246 extends SimpleMigrationStep { |
36 | - private const TABLE_NAME = 'reactions'; |
|
36 | + private const TABLE_NAME = 'reactions'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IOutput $output |
|
40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | - * @param array $options |
|
42 | - * @return null|ISchemaWrapper |
|
43 | - */ |
|
44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
45 | - /** @var ISchemaWrapper $schema */ |
|
46 | - $schema = $schemaClosure(); |
|
38 | + /** |
|
39 | + * @param IOutput $output |
|
40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | + * @param array $options |
|
42 | + * @return null|ISchemaWrapper |
|
43 | + */ |
|
44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
45 | + /** @var ISchemaWrapper $schema */ |
|
46 | + $schema = $schemaClosure(); |
|
47 | 47 | |
48 | - $action = false; |
|
49 | - $comments = $schema->getTable('comments'); |
|
50 | - if (!$comments->hasColumn('reactions')) { |
|
51 | - $comments->addColumn('reactions', Types::STRING, [ |
|
52 | - 'notnull' => false, |
|
53 | - 'length' => 4000, |
|
54 | - ]); |
|
55 | - $action = true; |
|
56 | - } |
|
48 | + $action = false; |
|
49 | + $comments = $schema->getTable('comments'); |
|
50 | + if (!$comments->hasColumn('reactions')) { |
|
51 | + $comments->addColumn('reactions', Types::STRING, [ |
|
52 | + 'notnull' => false, |
|
53 | + 'length' => 4000, |
|
54 | + ]); |
|
55 | + $action = true; |
|
56 | + } |
|
57 | 57 | |
58 | - if (!$schema->hasTable(self::TABLE_NAME)) { |
|
59 | - $table = $schema->createTable(self::TABLE_NAME); |
|
60 | - $table->addColumn('id', Types::BIGINT, [ |
|
61 | - 'autoincrement' => true, |
|
62 | - 'notnull' => true, |
|
63 | - 'length' => 11, |
|
64 | - 'unsigned' => true, |
|
65 | - ]); |
|
66 | - $table->addColumn('parent_id', Types::BIGINT, [ |
|
67 | - 'notnull' => true, |
|
68 | - 'length' => 11, |
|
69 | - 'unsigned' => true, |
|
70 | - ]); |
|
71 | - $table->addColumn('message_id', Types::BIGINT, [ |
|
72 | - 'notnull' => true, |
|
73 | - 'length' => 11, |
|
74 | - 'unsigned' => true, |
|
75 | - ]); |
|
76 | - $table->addColumn('actor_type', Types::STRING, [ |
|
77 | - 'notnull' => true, |
|
78 | - 'length' => 64, |
|
79 | - 'default' => '', |
|
80 | - ]); |
|
81 | - $table->addColumn('actor_id', Types::STRING, [ |
|
82 | - 'notnull' => true, |
|
83 | - 'length' => 64, |
|
84 | - 'default' => '', |
|
85 | - ]); |
|
86 | - $table->addColumn('reaction', Types::STRING, [ |
|
87 | - 'notnull' => true, |
|
88 | - 'length' => 32, |
|
89 | - ]); |
|
90 | - $table->setPrimaryKey(['id']); |
|
91 | - $table->addIndex(['reaction'], 'comment_reaction'); |
|
92 | - $table->addIndex(['parent_id'], 'comment_reaction_parent_id'); |
|
93 | - $table->addUniqueIndex(['parent_id', 'actor_type', 'actor_id', 'reaction'], 'comment_reaction_unique'); |
|
94 | - $action = true; |
|
95 | - } |
|
96 | - return $action ? $schema : null; |
|
97 | - } |
|
58 | + if (!$schema->hasTable(self::TABLE_NAME)) { |
|
59 | + $table = $schema->createTable(self::TABLE_NAME); |
|
60 | + $table->addColumn('id', Types::BIGINT, [ |
|
61 | + 'autoincrement' => true, |
|
62 | + 'notnull' => true, |
|
63 | + 'length' => 11, |
|
64 | + 'unsigned' => true, |
|
65 | + ]); |
|
66 | + $table->addColumn('parent_id', Types::BIGINT, [ |
|
67 | + 'notnull' => true, |
|
68 | + 'length' => 11, |
|
69 | + 'unsigned' => true, |
|
70 | + ]); |
|
71 | + $table->addColumn('message_id', Types::BIGINT, [ |
|
72 | + 'notnull' => true, |
|
73 | + 'length' => 11, |
|
74 | + 'unsigned' => true, |
|
75 | + ]); |
|
76 | + $table->addColumn('actor_type', Types::STRING, [ |
|
77 | + 'notnull' => true, |
|
78 | + 'length' => 64, |
|
79 | + 'default' => '', |
|
80 | + ]); |
|
81 | + $table->addColumn('actor_id', Types::STRING, [ |
|
82 | + 'notnull' => true, |
|
83 | + 'length' => 64, |
|
84 | + 'default' => '', |
|
85 | + ]); |
|
86 | + $table->addColumn('reaction', Types::STRING, [ |
|
87 | + 'notnull' => true, |
|
88 | + 'length' => 32, |
|
89 | + ]); |
|
90 | + $table->setPrimaryKey(['id']); |
|
91 | + $table->addIndex(['reaction'], 'comment_reaction'); |
|
92 | + $table->addIndex(['parent_id'], 'comment_reaction_parent_id'); |
|
93 | + $table->addUniqueIndex(['parent_id', 'actor_type', 'actor_id', 'reaction'], 'comment_reaction_unique'); |
|
94 | + $action = true; |
|
95 | + } |
|
96 | + return $action ? $schema : null; |
|
97 | + } |
|
98 | 98 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | use OCP\IConfig; |
30 | 30 | |
31 | 31 | trait TProfileHelper { |
32 | - protected function isProfileEnabledByDefault(IConfig $config): ?bool { |
|
33 | - return filter_var( |
|
34 | - $config->getAppValue('settings', 'profile_enabled_by_default', '1'), |
|
35 | - FILTER_VALIDATE_BOOLEAN, |
|
36 | - FILTER_NULL_ON_FAILURE, |
|
37 | - ); |
|
38 | - } |
|
32 | + protected function isProfileEnabledByDefault(IConfig $config): ?bool { |
|
33 | + return filter_var( |
|
34 | + $config->getAppValue('settings', 'profile_enabled_by_default', '1'), |
|
35 | + FILTER_VALIDATE_BOOLEAN, |
|
36 | + FILTER_NULL_ON_FAILURE, |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | } |
@@ -89,11 +89,11 @@ |
||
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function () { |
|
92 | + $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function() { |
|
93 | 93 | return $this->jsDataService; |
94 | 94 | }); |
95 | 95 | |
96 | - $this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function () use ($user) { |
|
96 | + $this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function() use ($user) { |
|
97 | 97 | return ['profileEnabled' => $this->profileManager->isProfileEnabled($user)]; |
98 | 98 | }); |
99 | 99 |
@@ -23,53 +23,53 @@ |
||
23 | 23 | /** @template-implements IEventListener<BeforeTemplateRenderedEvent> */ |
24 | 24 | class BeforeTemplateRenderedListener implements IEventListener { |
25 | 25 | |
26 | - /** @var ProfileManager */ |
|
27 | - private $profileManager; |
|
26 | + /** @var ProfileManager */ |
|
27 | + private $profileManager; |
|
28 | 28 | |
29 | - /** |
|
30 | - * BeforeTemplateRenderedListener constructor. |
|
31 | - * |
|
32 | - * @param ProfileManager $profileManager |
|
33 | - * @param IUserSession $userSession |
|
34 | - * @param IInitialStateService $initialState |
|
35 | - * @param JSDataService $jsDataService |
|
36 | - */ |
|
37 | - public function __construct( |
|
38 | - ProfileManager $profileManager, |
|
39 | - private IUserSession $userSession, |
|
40 | - private IInitialStateService $initialState, |
|
41 | - private JSDataService $jsDataService, |
|
42 | - ) { |
|
43 | - $this->profileManager = $profileManager; |
|
44 | - } |
|
29 | + /** |
|
30 | + * BeforeTemplateRenderedListener constructor. |
|
31 | + * |
|
32 | + * @param ProfileManager $profileManager |
|
33 | + * @param IUserSession $userSession |
|
34 | + * @param IInitialStateService $initialState |
|
35 | + * @param JSDataService $jsDataService |
|
36 | + */ |
|
37 | + public function __construct( |
|
38 | + ProfileManager $profileManager, |
|
39 | + private IUserSession $userSession, |
|
40 | + private IInitialStateService $initialState, |
|
41 | + private JSDataService $jsDataService, |
|
42 | + ) { |
|
43 | + $this->profileManager = $profileManager; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @inheritDoc |
|
48 | - */ |
|
49 | - public function handle(Event $event): void { |
|
50 | - $user = $this->userSession->getUser(); |
|
51 | - if ($user === null) { |
|
52 | - return; |
|
53 | - } |
|
46 | + /** |
|
47 | + * @inheritDoc |
|
48 | + */ |
|
49 | + public function handle(Event $event): void { |
|
50 | + $user = $this->userSession->getUser(); |
|
51 | + if ($user === null) { |
|
52 | + return; |
|
53 | + } |
|
54 | 54 | |
55 | - if (!($event instanceof BeforeTemplateRenderedEvent)) { |
|
56 | - // Unrelated |
|
57 | - return; |
|
58 | - } |
|
55 | + if (!($event instanceof BeforeTemplateRenderedEvent)) { |
|
56 | + // Unrelated |
|
57 | + return; |
|
58 | + } |
|
59 | 59 | |
60 | - if (!$event->isLoggedIn() || $event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_USER) { |
|
61 | - return; |
|
62 | - } |
|
60 | + if (!$event->isLoggedIn() || $event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_USER) { |
|
61 | + return; |
|
62 | + } |
|
63 | 63 | |
64 | - $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function () { |
|
65 | - return $this->jsDataService; |
|
66 | - }); |
|
64 | + $this->initialState->provideLazyInitialState(Application::APP_ID, 'status', function () { |
|
65 | + return $this->jsDataService; |
|
66 | + }); |
|
67 | 67 | |
68 | - $this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function () use ($user) { |
|
69 | - return ['profileEnabled' => $this->profileManager->isProfileEnabled($user)]; |
|
70 | - }); |
|
68 | + $this->initialState->provideLazyInitialState(Application::APP_ID, 'profileEnabled', function () use ($user) { |
|
69 | + return ['profileEnabled' => $this->profileManager->isProfileEnabled($user)]; |
|
70 | + }); |
|
71 | 71 | |
72 | - Util::addScript('user_status', 'menu'); |
|
73 | - Util::addStyle('user_status', 'user-status-menu'); |
|
74 | - } |
|
72 | + Util::addScript('user_status', 'menu'); |
|
73 | + Util::addStyle('user_status', 'user-status-menu'); |
|
74 | + } |
|
75 | 75 | } |
@@ -28,12 +28,12 @@ |
||
28 | 28 | * @since 24.0.0 |
29 | 29 | */ |
30 | 30 | interface IRequestId { |
31 | - /** |
|
32 | - * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging |
|
33 | - * If `mod_unique_id` is installed this value will be taken. |
|
34 | - * |
|
35 | - * @return string |
|
36 | - * @since 24.0.0 |
|
37 | - */ |
|
38 | - public function getId(): string; |
|
31 | + /** |
|
32 | + * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging |
|
33 | + * If `mod_unique_id` is installed this value will be taken. |
|
34 | + * |
|
35 | + * @return string |
|
36 | + * @since 24.0.0 |
|
37 | + */ |
|
38 | + public function getId(): string; |
|
39 | 39 | } |