2016-08-12 18:59:04 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2024-06-03 04:23:34 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2016-08-12 18:59:04 -04:00
|
|
|
*/
|
2020-01-31 10:55:17 -05:00
|
|
|
namespace OCA\Settings\Settings\Admin;
|
2016-08-12 18:59:04 -04:00
|
|
|
|
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
|
|
|
use OCP\IConfig;
|
2021-07-22 05:41:29 -04:00
|
|
|
use OCP\IL10N;
|
|
|
|
|
use OCP\Settings\IDelegatedSettings;
|
2016-08-12 18:59:04 -04:00
|
|
|
|
2021-07-22 05:41:29 -04:00
|
|
|
class Mail implements IDelegatedSettings {
|
2016-08-12 18:59:04 -04:00
|
|
|
/** @var IConfig */
|
|
|
|
|
private $config;
|
|
|
|
|
|
2021-07-22 05:41:29 -04:00
|
|
|
/** @var IL10N $l */
|
|
|
|
|
private $l;
|
|
|
|
|
|
2016-08-15 10:24:56 -04:00
|
|
|
/**
|
|
|
|
|
* @param IConfig $config
|
2021-07-22 05:41:29 -04:00
|
|
|
* @param IL10N $l
|
2016-08-15 10:24:56 -04:00
|
|
|
*/
|
2021-07-22 05:41:29 -04:00
|
|
|
public function __construct(IConfig $config, IL10N $l) {
|
2016-08-12 18:59:04 -04:00
|
|
|
$this->config = $config;
|
2021-07-22 05:41:29 -04:00
|
|
|
$this->l = $l;
|
2016-08-12 18:59:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return TemplateResponse
|
|
|
|
|
*/
|
|
|
|
|
public function getForm() {
|
|
|
|
|
$parameters = [
|
|
|
|
|
// Mail
|
|
|
|
|
'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
|
2020-10-05 09:12:57 -04:00
|
|
|
'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
|
|
|
|
|
'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
|
|
|
|
|
'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
|
|
|
|
|
'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''),
|
|
|
|
|
'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''),
|
|
|
|
|
'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''),
|
|
|
|
|
'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false),
|
|
|
|
|
'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''),
|
|
|
|
|
'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''),
|
|
|
|
|
'mail_sendmailmode' => $this->config->getSystemValue('mail_sendmailmode', 'smtp'),
|
2016-08-12 18:59:04 -04:00
|
|
|
];
|
|
|
|
|
|
2017-04-18 09:44:20 -04:00
|
|
|
if ($parameters['mail_smtppassword'] !== '') {
|
|
|
|
|
$parameters['mail_smtppassword'] = '********';
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-07 14:36:17 -04:00
|
|
|
if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') {
|
|
|
|
|
$parameters['mail_smtpmode'] = 'smtp';
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-27 06:25:37 -04:00
|
|
|
return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, '');
|
2016-08-12 18:59:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string the section ID, e.g. 'sharing'
|
|
|
|
|
*/
|
|
|
|
|
public function getSection() {
|
2018-03-29 11:12:03 -04:00
|
|
|
return 'server';
|
2016-08-12 18:59:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return int whether the form should be rather on the top or bottom of
|
|
|
|
|
* the admin section. The forms are arranged in ascending order of the
|
|
|
|
|
* priority values. It is required to return a value between 0 and 100.
|
|
|
|
|
*
|
|
|
|
|
* E.g.: 70
|
|
|
|
|
*/
|
|
|
|
|
public function getPriority() {
|
2018-03-29 11:23:22 -04:00
|
|
|
return 10;
|
2016-08-12 18:59:04 -04:00
|
|
|
}
|
2021-07-22 05:41:29 -04:00
|
|
|
|
|
|
|
|
public function getName(): ?string {
|
|
|
|
|
return $this->l->t('Email server');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAuthorizedAppConfig(): array {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
2016-08-12 18:59:04 -04:00
|
|
|
}
|