Mail.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license GNU AGPL version 3 or any later version
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. namespace OCA\Settings\Settings\Admin;
  29. use OCP\AppFramework\Http\TemplateResponse;
  30. use OCP\IConfig;
  31. use OCP\Settings\ISettings;
  32. class Mail implements ISettings {
  33. /** @var IConfig */
  34. private $config;
  35. /**
  36. * @param IConfig $config
  37. */
  38. public function __construct(IConfig $config) {
  39. $this->config = $config;
  40. }
  41. /**
  42. * @return TemplateResponse
  43. */
  44. public function getForm() {
  45. $parameters = [
  46. // Mail
  47. 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
  48. 'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
  49. 'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
  50. 'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
  51. 'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''),
  52. 'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''),
  53. 'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''),
  54. 'mail_smtpauthtype' => $this->config->getSystemValue('mail_smtpauthtype', ''),
  55. 'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false),
  56. 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''),
  57. 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''),
  58. 'mail_sendmailmode' => $this->config->getSystemValue('mail_sendmailmode', 'smtp'),
  59. ];
  60. if ($parameters['mail_smtppassword'] !== '') {
  61. $parameters['mail_smtppassword'] = '********';
  62. }
  63. if ($parameters['mail_smtpmode'] === '' || $parameters['mail_smtpmode'] === 'php') {
  64. $parameters['mail_smtpmode'] = 'smtp';
  65. }
  66. return new TemplateResponse('settings', 'settings/admin/additional-mail', $parameters, '');
  67. }
  68. /**
  69. * @return string the section ID, e.g. 'sharing'
  70. */
  71. public function getSection() {
  72. return 'server';
  73. }
  74. /**
  75. * @return int whether the form should be rather on the top or bottom of
  76. * the admin section. The forms are arranged in ascending order of the
  77. * priority values. It is required to return a value between 0 and 100.
  78. *
  79. * E.g.: 70
  80. */
  81. public function getPriority() {
  82. return 10;
  83. }
  84. }