* @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Christoph Wurst * @author Daniel Kesselberg * @author Joas Schilling * @author Lukas Reschke * @author Morris Jobke * @author Roeland Jago Douma * * @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 * */ 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(); } }