]> git.mxchange.org Git - friendica.git/blob - src/Module/Admin/Tos.php
Replace Module::init() with Constructors
[friendica.git] / src / Module / Admin / Tos.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2021, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Module\Admin;
23
24 use Friendica\App\BaseURL;
25 use Friendica\Core\Config\Capability\IManageConfigValues;
26 use Friendica\Core\L10n;
27 use Friendica\Core\Renderer;
28 use Friendica\Module\BaseAdmin;
29
30 class Tos extends BaseAdmin
31 {
32         /** @var \Friendica\Module\Tos */
33         protected $tos;
34         /** @var IManageConfigValues */
35         protected $config;
36         /** @var BaseURL */
37         protected $baseUrl;
38
39         public function __construct(\Friendica\Module\Tos $tos, IManageConfigValues $config, BaseURL $baseUrl, L10n $l10n, array $parameters = [])
40         {
41                 parent::__construct($l10n, $parameters);
42
43                 $this->tos     = $tos;
44                 $this->config  = $config;
45                 $this->baseUrl = $baseUrl;
46         }
47
48         public function post()
49         {
50                 self::checkAdminAccess();
51
52                 if (empty($_POST['page_tos'])) {
53                         return;
54                 }
55
56                 self::checkFormSecurityTokenRedirectOnError('/admin/tos', 'admin_tos');
57
58                 $displaytos = !empty($_POST['displaytos']);
59                 $displayprivstatement = !empty($_POST['displayprivstatement']);
60                 $tostext = (!empty($_POST['tostext']) ? strip_tags(trim($_POST['tostext'])) : '');
61
62                 $this->config->set('system', 'tosdisplay', $displaytos);
63                 $this->config->set('system', 'tosprivstatement', $displayprivstatement);
64                 $this->config->set('system', 'tostext', $tostext);
65
66                 $this->baseUrl->redirect('admin/tos');
67         }
68
69         public function content(): string
70         {
71                 parent::content();
72
73                 $t = Renderer::getMarkupTemplate('admin/tos.tpl');
74                 return Renderer::replaceMacros($t, [
75                         '$title' => $this->l10n->t('Administration'),
76                         '$page' => $this->l10n->t('Terms of Service'),
77                         '$displaytos' => ['displaytos', $this->l10n->t('Display Terms of Service'), $this->config->get('system', 'tosdisplay'), $this->l10n->t('Enable the Terms of Service page. If this is enabled a link to the terms will be added to the registration form and the general information page.')],
78                         '$displayprivstatement' => ['displayprivstatement', $this->l10n->t('Display Privacy Statement'), $this->config->get('system', 'tosprivstatement'), $this->l10n->t('Show some informations regarding the needed information to operate the node according e.g. to <a href="%s" target="_blank" rel="noopener noreferrer">EU-GDPR</a>.', 'https://en.wikipedia.org/wiki/General_Data_Protection_Regulation')],
79                         '$preview' => $this->l10n->t('Privacy Statement Preview'),
80                         '$privtext' => $this->tos->privacy_complete,
81                         '$tostext' => ['tostext', $this->l10n->t('The Terms of Service'), $this->config->get('system', 'tostext'), $this->l10n->t('Enter the Terms of Service for your node here. You can use BBCode. Headers of sections should be [h2] and below.')],
82                         '$form_security_token' => self::getFormSecurityToken('admin_tos'),
83                         '$submit' => $this->l10n->t('Save Settings'),
84                 ]);
85         }
86 }