Skip to content

Commit 17abbc2

Browse files
Merge pull request #678 from nextcloud/bugfix/noid/allow-to-grant-log-access
Allow to grant log access
2 parents e517fc4 + c875e6c commit 17abbc2

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

lib/Controller/LogController.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function __construct($appName,
4949
}
5050

5151
/**
52+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
5253
* @param int $count
5354
* @param int $offset
5455
* @param string $levels
@@ -71,6 +72,7 @@ private function getLastItem($levels) {
7172
}
7273

7374
/**
75+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
7476
* @brief polls for a new log message since $lastReqId.
7577
* This method will sleep for maximum 20 seconds before returning an empty
7678
* result.
@@ -121,6 +123,7 @@ public function poll(string $lastReqId, string $levels = '11111'): JSONResponse
121123
}
122124

123125
/**
126+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
124127
* @param string $query
125128
* @param int $count
126129
* @param int $offset
@@ -138,11 +141,17 @@ public function search($query = '', $count = 50, $offset = 0, $levels = '11111')
138141
return $this->responseFromIterator($iterator, $count, $offset);
139142
}
140143

141-
public function getLevels() {
144+
/**
145+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
146+
*/
147+
public function getLevels(): JSONResponse {
142148
return new JSONResponse($this->config->getAppValue('logreader', 'levels', '11111'));
143149
}
144150

145-
public function getSettings() {
151+
/**
152+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
153+
*/
154+
public function getSettings(): JSONResponse {
146155
return new JSONResponse([
147156
'levels' => $this->config->getAppValue('logreader', 'levels', '11111'),
148157
'dateformat' => $this->config->getSystemValue('logdateformat', \DateTime::ISO8601),
@@ -153,20 +162,25 @@ public function getSettings() {
153162
}
154163

155164
/**
165+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
156166
* @param bool $relative
157167
*/
158168
public function setRelative($relative) {
159169
$this->config->setAppValue('logreader', 'relativedates', $relative);
160170
}
161171

162172
/**
173+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
163174
* @param bool $live
164175
*/
165176
public function setLive($live) {
166177
$this->config->setAppValue('logreader', 'live', $live);
167178
}
168179

169-
public function setLevels($levels) {
180+
/**
181+
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
182+
*/
183+
public function setLevels(string $levels): int {
170184
$intLevels = array_map('intval', str_split($levels));
171185
$minLevel = 4;
172186
foreach ($intLevels as $level => $log) {

lib/Settings/Admin.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@
2222
namespace OCA\LogReader\Settings;
2323

2424
use OCP\AppFramework\Http\TemplateResponse;
25-
use OCP\Settings\ISettings;
25+
use OCP\IL10N;
26+
use OCP\Settings\IDelegatedSettings;
2627

27-
class Admin implements ISettings {
28+
class Admin implements IDelegatedSettings {
29+
/** @var IL10N */
30+
private $l;
31+
32+
public function __construct(IL10N $l) {
33+
$this->l = $l;
34+
}
2835
/**
2936
* @return TemplateResponse
3037
*/
@@ -52,4 +59,12 @@ public function getSection() {
5259
public function getPriority() {
5360
return 90;
5461
}
62+
63+
public function getName(): ?string {
64+
return null;
65+
}
66+
67+
public function getAuthorizedAppConfig(): array {
68+
return [];
69+
}
5570
}

0 commit comments

Comments
 (0)