]> git.mxchange.org Git - friendica.git/blob - src/Module/Tos.php
Merge pull request #8302 from annando/allowed-chars
[friendica.git] / src / Module / Tos.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
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;
23
24 use Friendica\BaseModule;
25 use Friendica\Core\Renderer;
26 use Friendica\Content\Text\BBCode;
27 use Friendica\DI;
28
29 class Tos extends BaseModule
30 {
31         // Some text elements we need more than once to keep updating them easy.
32         public $privacy_operate;
33         public $privacy_distribute;
34         public $privacy_delete;
35         public $privacy_complete;
36
37         /**
38          * constructor for the module, initializing the text variables
39          *
40          * To make the text variables available outside of the module, they need to
41          * be properties of the class, however cannot be set directly as the property
42          * cannot depend on a function result when declaring the variable.
43          **/
44         public function __construct()
45         {
46                 $this->privacy_operate = DI::l10n()->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.');
47                 $this->privacy_distribute = DI::l10n()->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.');
48                 $this->privacy_delete = DI::l10n()->t('At any point in time a logged in user can export their account data from the <a href="%1$s/settings/userexport">account settings</a>. If the user wants to delete their account they can do so at <a href="%1$s/removeme">%1$s/removeme</a>. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', DI::baseUrl());
49                 // In some cases we don't need every single one of the above separate, but all in one block.
50                 // So here is an array to look over
51                 $this->privacy_complete = [DI::l10n()->t('Privacy Statement'), $this->privacy_operate, $this->privacy_distribute, $this->privacy_delete];
52         }
53
54         /**
55          * initialize the TOS module.
56          *
57          * If this is a single user instance, we expect the user to know their
58          * dealings with their own node so a TOS is not necessary.
59          *
60          **/
61         public static function init(array $parameters = [])
62         {
63                 if (strlen(DI::config()->get('system','singleuser'))) {
64                         DI::baseUrl()->redirect('profile/' . DI::config()->get('system','singleuser'));
65                 }
66         }
67
68         /**
69          * generate the content of the /tos page
70          *
71          * The content of the /tos page is generated from two parts.
72          * (1) a free form part the admin of the node can set in the admin panel
73          * (2) an optional privacy statement that gives some transparency about
74          *     what information are needed by the software to provide the service.
75          *     This privacy statement has fixed text, so it can be translated easily.
76          *
77          * @return string
78          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
79          */
80         public static function content(array $parameters = []) {
81                 $tpl = Renderer::getMarkupTemplate('tos.tpl');
82                 if (DI::config()->get('system', 'tosdisplay')) {
83                         return Renderer::replaceMacros($tpl, [
84                                 '$title' => DI::l10n()->t('Terms of Service'),
85                                 '$tostext' => BBCode::convert(DI::config()->get('system', 'tostext')),
86                                 '$displayprivstatement' => DI::config()->get('system', 'tosprivstatement'),
87                                 '$privstatementtitle' => DI::l10n()->t('Privacy Statement'),
88                                 '$privacy_operate' => DI::l10n()->t('At the time of registration, and for providing communications between the user account and their contacts, the user has to provide a display name (pen name), an username (nickname) and a working email address. The names will be accessible on the profile page of the account by any visitor of the page, even if other profile details are not displayed. The email address will only be used to send the user notifications about interactions, but wont be visibly displayed. The listing of an account in the node\'s user directory or the global user directory is optional and can be controlled in the user settings, it is not necessary for communication.'),
89                                 '$privacy_distribute' => DI::l10n()->t('This data is required for communication and is passed on to the nodes of the communication partners and is stored there. Users can enter additional private data that may be transmitted to the communication partners accounts.'),
90                                 '$privacy_delete' => DI::l10n()->t('At any point in time a logged in user can export their account data from the <a href="%1$s/settings/userexport">account settings</a>. If the user wants to delete their account they can do so at <a href="%1$s/removeme">%1$s/removeme</a>. The deletion of the account will be permanent. Deletion of the data will also be requested from the nodes of the communication partners.', DI::baseUrl())
91                         ]);
92                 } else {
93                         return;
94                 }
95         }
96 }