diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-10-27 13:50:38 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-10-27 13:50:38 +0200 |
commit | ca72c0150b3ea490c06c8c4824aebf0d0da33088 (patch) | |
tree | 19ee5efb85bcf2a97e60b0372320df129ac0f447 /apps/comments/lib | |
parent | bd951e926f7913568257f321f2894dfcc66aa3b3 (diff) | |
download | nextcloud-server-ca72c0150b3ea490c06c8c4824aebf0d0da33088.tar.gz nextcloud-server-ca72c0150b3ea490c06c8c4824aebf0d0da33088.zip |
configurable amount of autocomplete results in comments
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/comments/lib')
-rw-r--r-- | apps/comments/lib/AppInfo/Application.php | 5 | ||||
-rw-r--r-- | apps/comments/lib/JSSettingsHelper.php | 45 |
2 files changed, 50 insertions, 0 deletions
diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php index f168779cd0d..a863ca506b7 100644 --- a/apps/comments/lib/AppInfo/Application.php +++ b/apps/comments/lib/AppInfo/Application.php @@ -22,7 +22,9 @@ namespace OCA\Comments\AppInfo; use OCA\Comments\Controller\Notifications; +use OCA\Comments\JSSettingsHelper; use OCP\AppFramework\App; +use OCP\Util; class Application extends App { @@ -31,5 +33,8 @@ class Application extends App { $container = $this->getContainer(); $container->registerAlias('NotificationsController', Notifications::class); + + $jsSettingsHelper = new JSSettingsHelper($container->getServer()); + Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend'); } } diff --git a/apps/comments/lib/JSSettingsHelper.php b/apps/comments/lib/JSSettingsHelper.php new file mode 100644 index 00000000000..dab68a48925 --- /dev/null +++ b/apps/comments/lib/JSSettingsHelper.php @@ -0,0 +1,45 @@ +<?php +/** + * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Comments; + + +use OCP\IServerContainer; + +class JSSettingsHelper { + /** @var IServerContainer */ + private $c; + + public function __construct(IServerContainer $c) { + $this->c = $c; + } + + public function extend(array $settings) { + $appConfig = json_decode($settings['array']['oc_appconfig'], true); + + $value = (int)$this->c->getConfig()->getAppValue('comments', 'maxAutoCompleteResults', 10); + $appConfig['comments']['maxAutoCompleteResults'] = $value; + + $settings['array']['oc_appconfig'] = json_encode($appConfig); + } +} |