aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/Controller/AISettingsController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/lib/Controller/AISettingsController.php')
-rw-r--r--apps/settings/lib/Controller/AISettingsController.php105
1 files changed, 105 insertions, 0 deletions
diff --git a/apps/settings/lib/Controller/AISettingsController.php b/apps/settings/lib/Controller/AISettingsController.php
new file mode 100644
index 00000000000..53aca66c946
--- /dev/null
+++ b/apps/settings/lib/Controller/AISettingsController.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ *
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Daniel Kesselberg <mail@danielkesselberg.de>
+ * @author Joas Schilling <coding@schilljs.com>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OCA\Settings\Controller;
+
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IRequest;
+use OCP\IURLGenerator;
+use OCP\IUserSession;
+use OCP\Mail\IMailer;
+
+class AISettingsController extends Controller {
+
+ /** @var IL10N */
+ private $l10n;
+ /** @var IConfig */
+ private $config;
+ /** @var IUserSession */
+ private $userSession;
+ /** @var IMailer */
+ private $mailer;
+ /** @var IURLGenerator */
+ private $urlGenerator;
+
+ /**
+ * @param string $appName
+ * @param IRequest $request
+ * @param IL10N $l10n
+ * @param IConfig $config
+ * @param IUserSession $userSession
+ * @param IURLGenerator $urlGenerator,
+ * @param IMailer $mailer
+ */
+ public function __construct($appName,
+ IRequest $request,
+ IL10N $l10n,
+ IConfig $config,
+ IUserSession $userSession,
+ IURLGenerator $urlGenerator,
+ IMailer $mailer) {
+ parent::__construct($appName, $request);
+ $this->l10n = $l10n;
+ $this->config = $config;
+ $this->userSession = $userSession;
+ $this->urlGenerator = $urlGenerator;
+ $this->mailer = $mailer;
+ }
+
+ /**
+ * Sets the email settings
+ *
+ * @PasswordConfirmationRequired
+ * @AuthorizedAdminSetting(settings=OCA\Settings\Settings\Admin\ArtificialIntelligence)
+ *
+ * @param array $settings
+ * @return DataResponse
+ */
+ public function setAISettings($settings) {
+ $params = get_defined_vars();
+ $configs = [];
+ foreach ($params as $key => $value) {
+ $configs[$key] = empty($value) ? null : $value;
+ }
+
+ // Delete passwords from config in case no auth is specified
+ if ($params['mail_smtpauth'] !== 1) {
+ $configs['mail_smtpname'] = null;
+ $configs['mail_smtppassword'] = null;
+ }
+
+ $this->config->setSystemValues($configs);
+
+ $this->config->setAppValue('core', 'emailTestSuccessful', '0');
+
+ return new DataResponse();
+ }
+}