3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
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.
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.
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/>.
22 namespace Friendica\Module\Admin;
25 use Friendica\Core\Config\Capability\IManageConfigValues;
26 use Friendica\Core\L10n;
27 use Friendica\Core\Renderer;
28 use Friendica\Module\BaseAdmin;
29 use Friendica\Module\Response;
30 use Friendica\Util\Profiler;
31 use Psr\Log\LoggerInterface;
33 class Tos extends BaseAdmin
35 /** @var \Friendica\Module\Tos */
37 /** @var IManageConfigValues */
40 public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = [])
42 parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
44 $this->tos = new \Friendica\Module\Tos($l10n, $baseUrl, $args, $logger, $profiler, $response, $config, $server, $parameters);
45 $this->config = $config;
48 protected function post(array $request = [])
50 self::checkAdminAccess();
52 if (empty($_POST['page_tos'])) {
56 self::checkFormSecurityTokenRedirectOnError('/admin/tos', 'admin_tos');
58 $displaytos = !empty($_POST['displaytos']);
59 $displayprivstatement = !empty($_POST['displayprivstatement']);
60 $tostext = (!empty($_POST['tostext']) ? strip_tags(trim($_POST['tostext'])) : '');
62 $this->config->set('system', 'tosdisplay', $displaytos);
63 $this->config->set('system', 'tosprivstatement', $displayprivstatement);
64 $this->config->set('system', 'tostext', $tostext);
66 $this->baseUrl->redirect('admin/tos');
69 protected function content(array $request = []): string
73 $t = Renderer::getMarkupTemplate('admin/tos.tpl');
74 return Renderer::replaceMacros($t, [
75 '$title' => $this->t('Administration'),
76 '$page' => $this->t('Terms of Service'),
77 '$displaytos' => ['displaytos', $this->t('Display Terms of Service'), $this->config->get('system', 'tosdisplay'), $this->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->t('Display Privacy Statement'), $this->config->get('system', 'tosprivstatement'), $this->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->t('Privacy Statement Preview'),
80 '$privtext' => $this->tos->privacy_complete,
81 '$tostext' => ['tostext', $this->t('The Terms of Service'), $this->config->get('system', 'tostext'), $this->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->t('Save Settings'),