]> git.mxchange.org Git - friendica.git/blob - src/Module/Settings/Account.php
Move /settings to src/
[friendica.git] / src / Module / Settings / Account.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, 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\Settings;
23
24 use Exception;
25 use Friendica\BaseModule;
26 use Friendica\Core\ACL;
27 use Friendica\Core\Hook;
28 use Friendica\Core\Logger;
29 use Friendica\Core\Renderer;
30 use Friendica\Core\Worker;
31 use Friendica\Database\DBA;
32 use Friendica\DI;
33 use Friendica\Model\Group;
34 use Friendica\Model\Notification;
35 use Friendica\Model\Profile;
36 use Friendica\Model\User;
37 use Friendica\Model\Verb;
38 use Friendica\Module\BaseSettings;
39 use Friendica\Network\HTTPException;
40 use Friendica\Protocol\Activity;
41 use Friendica\Util\Temporal;
42 use Friendica\Worker\Delivery;
43
44 class Account extends BaseSettings
45 {
46         protected function post(array $request = [])
47         {
48                 if (!DI::app()->isLoggedIn()) {
49                         throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
50                 }
51
52                 self::checkFormSecurityTokenRedirectOnError('/settings', 'settings');
53
54                 $a = DI::app();
55
56                 $user = User::getById($a->getLoggedInUserId());
57
58                 // Import Contacts from CSV file
59                 if (!empty($_POST['importcontact-submit'])) {
60                         if (isset($_FILES['importcontact-filename'])) {
61                                 // was there an error
62                                 if ($_FILES['importcontact-filename']['error'] > 0) {
63                                         Logger::notice('Contact CSV file upload error', ['error' => $_FILES['importcontact-filename']['error']]);
64                                         notice(DI::l10n()->t('Contact CSV file upload error'));
65                                 } else {
66                                         $csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name']));
67                                         Logger::notice('Import started', ['lines' => count($csvArray)]);
68                                         // import contacts
69                                         foreach ($csvArray as $csvRow) {
70                                                 // The 1st row may, or may not contain the headers of the table
71                                                 // We expect the 1st field of the row to contain either the URL
72                                                 // or the handle of the account, therefore we check for either
73                                                 // "http" or "@" to be present in the string.
74                                                 // All other fields from the row will be ignored
75                                                 if ((strpos($csvRow[0],'@') !== false) || in_array(parse_url($csvRow[0], PHP_URL_SCHEME), ['http', 'https'])) {
76                                                         Worker::add(PRIORITY_LOW, 'AddContact', $_SESSION['uid'], $csvRow[0]);
77                                                 } else {
78                                                         Logger::notice('Invalid account', ['url' => $csvRow[0]]);
79                                                 }
80                                         }
81                                         Logger::notice('Import done');
82
83                                         info(DI::l10n()->t('Importing Contacts done'));
84                                         // delete temp file
85                                         unlink($_FILES['importcontact-filename']['tmp_name']);
86                                 }
87                         } else {
88                                 Logger::notice('Import triggered, but no import file was found.');
89                         }
90
91                         return;
92                 }
93
94                 if (!empty($_POST['resend_relocate'])) {
95                         Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
96                         info(DI::l10n()->t("Relocate message has been send to your contacts"));
97                         DI::baseUrl()->redirect('settings');
98                 }
99
100                 Hook::callAll('settings_post', $_POST);
101
102                 if (!empty($_POST['password']) || !empty($_POST['confirm'])) {
103                         $newpass = $_POST['password'];
104                         $confirm = $_POST['confirm'];
105
106                         try {
107                                 if ($newpass != $confirm) {
108                                         throw new Exception(DI::l10n()->t('Passwords do not match.'));
109                                 }
110
111                                 //  check if the old password was supplied correctly before changing it to the new value
112                                 User::getIdFromPasswordAuthentication(local_user(), $_POST['opassword']);
113
114                                 $result = User::updatePassword(local_user(), $newpass);
115                                 if (!DBA::isResult($result)) {
116                                         throw new Exception(DI::l10n()->t('Password update failed. Please try again.'));
117                                 }
118
119                                 info(DI::l10n()->t('Password changed.'));
120                         } catch (Exception $e) {
121                                 notice($e->getMessage());
122                                 notice(DI::l10n()->t('Password unchanged.'));
123                         }
124                 }
125
126                 $username         = (!empty($_POST['username'])        ? trim($_POST['username'])          : '');
127                 $email            = (!empty($_POST['email'])           ? trim($_POST['email'])             : '');
128                 $timezone         = (!empty($_POST['timezone'])        ? trim($_POST['timezone'])          : '');
129                 $language         = (!empty($_POST['language'])        ? trim($_POST['language'])          : '');
130
131                 $defloc           = (!empty($_POST['defloc'])          ? trim($_POST['defloc'])            : '');
132                 $maxreq           = (!empty($_POST['maxreq'])          ? intval($_POST['maxreq'])          : 0);
133                 $expire           = (!empty($_POST['expire'])          ? intval($_POST['expire'])          : 0);
134                 $def_gid          = (!empty($_POST['group-selection']) ? intval($_POST['group-selection']) : 0);
135
136
137                 $expire_items     = (!empty($_POST['expire_items']) ? intval($_POST['expire_items'])     : 0);
138                 $expire_notes     = (!empty($_POST['expire_notes']) ? intval($_POST['expire_notes'])     : 0);
139                 $expire_starred   = (!empty($_POST['expire_starred']) ? intval($_POST['expire_starred']) : 0);
140                 $expire_photos    = (!empty($_POST['expire_photos'])? intval($_POST['expire_photos'])    : 0);
141                 $expire_network_only    = (!empty($_POST['expire_network_only'])? intval($_POST['expire_network_only'])  : 0);
142
143                 $delete_openid    = ((!empty($_POST['delete_openid']) && (intval($_POST['delete_openid']) == 1)) ? 1: 0);
144
145                 $allow_location   = ((!empty($_POST['allow_location']) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
146                 $publish          = ((!empty($_POST['profile_in_directory']) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
147                 $net_publish      = ((!empty($_POST['profile_in_netdirectory']) && (intval($_POST['profile_in_netdirectory']) == 1)) ? 1: 0);
148                 $account_type     = ((!empty($_POST['account-type']) && (intval($_POST['account-type']))) ? intval($_POST['account-type']) : 0);
149                 $page_flags       = ((!empty($_POST['page-flags']) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
150                 $blockwall        = ((!empty($_POST['blockwall']) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
151                 $blocktags        = ((!empty($_POST['blocktags']) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
152                 $unkmail          = ((!empty($_POST['unkmail']) && (intval($_POST['unkmail']) == 1)) ? 1: 0);
153                 $cntunkmail       = (!empty($_POST['cntunkmail']) ? intval($_POST['cntunkmail']) : 0);
154                 $hide_friends     = (($_POST['hide-friends'] == 1) ? 1: 0);
155                 $hidewall         = (($_POST['hidewall'] == 1) ? 1: 0);
156                 $unlisted         = (($_POST['unlisted'] == 1) ? 1: 0);
157                 $accessiblephotos = (($_POST['accessible-photos'] == 1) ? 1: 0);
158
159                 $notify_like      = (($_POST['notify_like'] == 1) ? 1 : 0);
160                 $notify_announce  = (($_POST['notify_announce'] == 1) ? 1 : 0);
161
162                 $email_textonly   = (($_POST['email_textonly'] == 1) ? 1 : 0);
163                 $detailed_notif   = (($_POST['detailed_notif'] == 1) ? 1 : 0);
164
165                 $notify_ignored   = (($_POST['notify_ignored'] == 1) ? 1 : 0);
166
167                 $notify = 0;
168
169                 if (!empty($_POST['notify1'])) {
170                         $notify += intval($_POST['notify1']);
171                 }
172                 if (!empty($_POST['notify2'])) {
173                         $notify += intval($_POST['notify2']);
174                 }
175                 if (!empty($_POST['notify3'])) {
176                         $notify += intval($_POST['notify3']);
177                 }
178                 if (!empty($_POST['notify4'])) {
179                         $notify += intval($_POST['notify4']);
180                 }
181                 if (!empty($_POST['notify5'])) {
182                         $notify += intval($_POST['notify5']);
183                 }
184                 if (!empty($_POST['notify6'])) {
185                         $notify += intval($_POST['notify6']);
186                 }
187                 if (!empty($_POST['notify7'])) {
188                         $notify += intval($_POST['notify7']);
189                 }
190                 if (!empty($_POST['notify8'])) {
191                         $notify += intval($_POST['notify8']);
192                 }
193
194                 // Adjust the page flag if the account type doesn't fit to the page flag.
195                 if ($account_type == User::ACCOUNT_TYPE_PERSON && !in_array($page_flags, [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE])) {
196                         $page_flags = User::PAGE_FLAGS_NORMAL;
197                 } elseif ($account_type == User::ACCOUNT_TYPE_ORGANISATION && $page_flags != User::PAGE_FLAGS_SOAPBOX) {
198                         $page_flags = User::PAGE_FLAGS_SOAPBOX;
199                 } elseif ($account_type == User::ACCOUNT_TYPE_NEWS && $page_flags != User::PAGE_FLAGS_SOAPBOX) {
200                         $page_flags = User::PAGE_FLAGS_SOAPBOX;
201                 } elseif ($account_type == User::ACCOUNT_TYPE_COMMUNITY && !in_array($page_flags, [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
202                         $page_flags = User::PAGE_FLAGS_COMMUNITY;
203                 }
204
205                 $err = '';
206
207                 if ($username != $user['username']) {
208                         if (strlen($username) > 40) {
209                                 $err .= DI::l10n()->t('Please use a shorter name.');
210                         }
211                         if (strlen($username) < 3) {
212                                 $err .= DI::l10n()->t('Name too short.');
213                         }
214                 }
215
216                 if ($email != $user['email']) {
217                         //  check for the correct password
218                         try {
219                                 User::getIdFromPasswordAuthentication(local_user(), $_POST['mpassword']);
220                         } catch (Exception $ex) {
221                                 $err .= DI::l10n()->t('Wrong Password.');
222                                 $email = $user['email'];
223                         }
224                         //  check the email is valid
225                         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
226                                 $err .= DI::l10n()->t('Invalid email.');
227                         }
228                         //  ensure new email is not the admin mail
229                         if (DI::config()->get('config', 'admin_email')) {
230                                 $adminlist = explode(",", str_replace(" ", "", strtolower(DI::config()->get('config', 'admin_email'))));
231                                 if (in_array(strtolower($email), $adminlist)) {
232                                         $err .= DI::l10n()->t('Cannot change to that email.');
233                                         $email = $user['email'];
234                                 }
235                         }
236                 }
237
238                 if (strlen($err)) {
239                         notice($err);
240                         return;
241                 }
242
243                 if (($timezone != $user['timezone']) && strlen($timezone)) {
244                         $a->setTimeZone($timezone);
245                 }
246
247                 $aclFormatter = DI::aclFormatter();
248
249                 $str_group_allow   = !empty($_POST['group_allow'])   ? $aclFormatter->toString($_POST['group_allow'])   : '';
250                 $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : '';
251                 $str_group_deny    = !empty($_POST['group_deny'])    ? $aclFormatter->toString($_POST['group_deny'])    : '';
252                 $str_contact_deny  = !empty($_POST['contact_deny'])  ? $aclFormatter->toString($_POST['contact_deny'])  : '';
253
254                 DI::pConfig()->set(local_user(), 'expire', 'items', $expire_items);
255                 DI::pConfig()->set(local_user(), 'expire', 'notes', $expire_notes);
256                 DI::pConfig()->set(local_user(), 'expire', 'starred', $expire_starred);
257                 DI::pConfig()->set(local_user(), 'expire', 'photos', $expire_photos);
258                 DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only);
259
260                 // Reset like notifications when they are going to be shown again
261                 if (!DI::pConfig()->get(local_user(), 'system', 'notify_like') && $notify_like) {
262                         DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::LIKE)]);
263                 }
264
265                 DI::pConfig()->set(local_user(), 'system', 'notify_like', $notify_like);
266
267                 // Reset share notifications when they are going to be shown again
268                 if (!DI::pConfig()->get(local_user(), 'system', 'notify_announce') && $notify_announce) {
269                         DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
270                 }
271
272                 DI::pConfig()->set(local_user(), 'system', 'notify_announce', $notify_announce);
273
274                 DI::pConfig()->set(local_user(), 'system', 'email_textonly', $email_textonly);
275                 DI::pConfig()->set(local_user(), 'system', 'detailed_notif', $detailed_notif);
276                 DI::pConfig()->set(local_user(), 'system', 'notify_ignored', $notify_ignored);
277                 DI::pConfig()->set(local_user(), 'system', 'unlisted', $unlisted);
278                 DI::pConfig()->set(local_user(), 'system', 'accessible-photos', $accessiblephotos);
279
280                 if ($account_type == User::ACCOUNT_TYPE_COMMUNITY) {
281                         $str_group_allow   = '';
282                         $str_contact_allow = '';
283                         $str_group_deny    = '';
284                         $str_contact_deny  = '';
285
286                         DI::pConfig()->set(local_user(), 'system', 'unlisted', true);
287
288                         $blockwall    = true;
289                         $blocktags    = true;
290                         $hide_friends = true;
291                 }
292
293                 if ($page_flags == User::PAGE_FLAGS_PRVGROUP) {
294                         $str_group_allow = '<' . Group::FOLLOWERS . '>';
295                 }
296
297                 $fields = ['username' => $username, 'email' => $email, 'timezone' => $timezone,
298                            'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
299                            'notify-flags' => $notify, 'page-flags' => $page_flags, 'account-type' => $account_type, 'default-location' => $defloc,
300                            'allow_location' => $allow_location, 'maxreq' => $maxreq, 'expire' => $expire, 'def_gid' => $def_gid, 'blockwall' => $blockwall,
301                            'hidewall' => $hidewall, 'blocktags' => $blocktags, 'unkmail' => $unkmail, 'cntunkmail' => $cntunkmail, 'language' => $language];
302
303                 if ($delete_openid) {
304                         $fields['openid'] = '';
305                         $fields['openidserver'] = '';
306                 }
307
308                 $profile_fields = ['publish' => $publish, 'net-publish' => $net_publish, 'hide-friends' => $hide_friends];
309
310                 if (!User::update($fields, local_user()) || !Profile::update($profile_fields, local_user())) {
311                         notice(DI::l10n()->t('Settings were not updated.'));
312                 }
313
314                 // clear session language
315                 unset($_SESSION['language']);
316
317                 DI::baseUrl()->redirect('settings');
318         }
319
320         protected function content(array $request = []): string
321         {
322                 parent::content();
323
324                 if (!local_user()) {
325                         throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
326                 }
327
328                 $profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
329                 if (!DBA::isResult($profile)) {
330                         notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
331                         return '';
332                 }
333
334                 $a = DI::app();
335
336                 $user = User::getById($a->getLoggedInUserId());
337
338                 $username   = $user['username'];
339                 $email      = $user['email'];
340                 $nickname   = $a->getLoggedInUserNickname();
341                 $timezone   = $user['timezone'];
342                 $language   = $user['language'];
343                 $notify     = $user['notify-flags'];
344                 $defloc     = $user['default-location'];
345                 $openid     = $user['openid'];
346                 $maxreq     = $user['maxreq'];
347                 $expire     = (intval($user['expire'])) ? $user['expire'] : '';
348                 $unkmail    = $user['unkmail'];
349                 $cntunkmail = $user['cntunkmail'];
350
351                 $expire_items        = DI::pConfig()->get(local_user(), 'expire', 'items', true);
352                 $expire_notes        = DI::pConfig()->get(local_user(), 'expire', 'notes', true);
353                 $expire_starred      = DI::pConfig()->get(local_user(), 'expire', 'starred', true);
354                 $expire_photos       = DI::pConfig()->get(local_user(), 'expire', 'photos', false);
355                 $expire_network_only = DI::pConfig()->get(local_user(), 'expire', 'network_only', false);
356
357                 if (!strlen($user['timezone'])) {
358                         $timezone = $a->getTimeZone();
359                 }
360
361                 // Set the account type to "Community" when the page is a community page but the account type doesn't fit
362                 // This is only happening on the first visit after the update
363                 if (
364                         in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])
365                         && $user['account-type'] != User::ACCOUNT_TYPE_COMMUNITY
366                 ) {
367                         $user['account-type'] = User::ACCOUNT_TYPE_COMMUNITY;
368                 }
369
370
371                 $pageset_tpl = Renderer::getMarkupTemplate('settings/pagetypes.tpl');
372
373                 $pagetype = Renderer::replaceMacros($pageset_tpl, [
374                         '$account_types'        => DI::l10n()->t("Account Types"),
375                         '$user'                 => DI::l10n()->t("Personal Page Subtypes"),
376                         '$community'            => DI::l10n()->t("Community Forum Subtypes"),
377                         '$account_type'         => $user['account-type'],
378                         '$type_person'          => User::ACCOUNT_TYPE_PERSON,
379                         '$type_organisation'    => User::ACCOUNT_TYPE_ORGANISATION,
380                         '$type_news'            => User::ACCOUNT_TYPE_NEWS,
381                         '$type_community'       => User::ACCOUNT_TYPE_COMMUNITY,
382                         '$account_person'       => [
383                                 'account-type',
384                                 DI::l10n()->t('Personal Page'),
385                                 User::ACCOUNT_TYPE_PERSON,
386                                 DI::l10n()->t('Account for a personal profile.'),
387                                 $user['account-type'] == User::ACCOUNT_TYPE_PERSON
388                         ],
389                         '$account_organisation' => [
390                                 'account-type',
391                                 DI::l10n()->t('Organisation Page'),
392                                 User::ACCOUNT_TYPE_ORGANISATION,
393                                 DI::l10n()->t('Account for an organisation that automatically approves contact requests as "Followers".'),
394                                 $user['account-type'] == User::ACCOUNT_TYPE_ORGANISATION
395                         ],
396                         '$account_news'         => [
397                                 'account-type',
398                                 DI::l10n()->t('News Page'),
399                                 User::ACCOUNT_TYPE_NEWS,
400                                 DI::l10n()->t('Account for a news reflector that automatically approves contact requests as "Followers".'),
401                                 $user['account-type'] == User::ACCOUNT_TYPE_NEWS
402                         ],
403                         '$account_community'    => [
404                                 'account-type',
405                                 DI::l10n()->t('Community Forum'),
406                                 User::ACCOUNT_TYPE_COMMUNITY,
407                                 DI::l10n()->t('Account for community discussions.'),
408                                 $user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY
409                         ],
410                         '$page_normal'          => [
411                                 'page-flags',
412                                 DI::l10n()->t('Normal Account Page'),
413                                 User::PAGE_FLAGS_NORMAL,
414                                 DI::l10n()->t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'),
415                                 $user['page-flags'] == User::PAGE_FLAGS_NORMAL
416                         ],
417                         '$page_soapbox'         => [
418                                 'page-flags',
419                                 DI::l10n()->t('Soapbox Page'),
420                                 User::PAGE_FLAGS_SOAPBOX,
421                                 DI::l10n()->t('Account for a public profile that automatically approves contact requests as "Followers".'),
422                                 $user['page-flags'] == User::PAGE_FLAGS_SOAPBOX
423                         ],
424                         '$page_community'       => [
425                                 'page-flags',
426                                 DI::l10n()->t('Public Forum'),
427                                 User::PAGE_FLAGS_COMMUNITY,
428                                 DI::l10n()->t('Automatically approves all contact requests.'),
429                                 $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY
430                         ],
431                         '$page_freelove'        => [
432                                 'page-flags',
433                                 DI::l10n()->t('Automatic Friend Page'),
434                                 User::PAGE_FLAGS_FREELOVE,
435                                 DI::l10n()->t('Account for a popular profile that automatically approves contact requests as "Friends".'),
436                                 $user['page-flags'] == User::PAGE_FLAGS_FREELOVE
437                         ],
438                         '$page_prvgroup'        => [
439                                 'page-flags',
440                                 DI::l10n()->t('Private Forum [Experimental]'),
441                                 User::PAGE_FLAGS_PRVGROUP,
442                                 DI::l10n()->t('Requires manual approval of contact requests.'),
443                                 $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP
444                         ],
445                 ]);
446
447                 $noid = DI::config()->get('system', 'no_openid');
448
449                 if ($noid) {
450                         $openid_field = false;
451                 } else {
452                         $openid_field = ['openid_url', DI::l10n()->t('OpenID:'), $openid, DI::l10n()->t("(Optional) Allow this OpenID to login to this account."), "", "readonly", "url"];
453                 }
454
455                 $opt_tpl = Renderer::getMarkupTemplate("field_checkbox.tpl");
456                 if (DI::config()->get('system', 'publish_all')) {
457                         $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
458                 } else {
459                         $profile_in_dir = Renderer::replaceMacros($opt_tpl, [
460                                 '$field' => ['profile_in_directory', DI::l10n()->t('Publish your profile in your local site directory?'), $profile['publish'], DI::l10n()->t('Your profile will be published in this node\'s <a href="%s">local directory</a>. Your profile details may be publicly visible depending on the system settings.', DI::baseUrl().'/directory')]
461                         ]);
462                 }
463
464                 $net_pub_desc = '';
465                 if (strlen(DI::config()->get('system', 'directory'))) {
466                         $net_pub_desc = ' ' . DI::l10n()->t('Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).', DI::config()->get('system', 'directory'), DI::config()->get('system', 'directory'));
467                 }
468
469                 $tpl_addr = Renderer::getMarkupTemplate('settings/nick_set.tpl');
470
471                 $prof_addr = Renderer::replaceMacros($tpl_addr,[
472                         '$desc' => DI::l10n()->t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . DI::baseUrl()->getHostname() . DI::baseUrl()->getUrlPath(), DI::baseUrl() . '/profile/' . $nickname),
473                         '$basepath' => DI::baseUrl()->getHostname()
474                 ]);
475
476                 $stpl = Renderer::getMarkupTemplate('settings/settings.tpl');
477
478                 /* Installed langs */
479                 $lang_choices = DI::l10n()->getAvailableLanguages();
480
481                 /// @TODO Fix indending (or so)
482                 $o = Renderer::replaceMacros($stpl, [
483                         '$ptitle'       => DI::l10n()->t('Account Settings'),
484
485                         '$submit'       => DI::l10n()->t('Save Settings'),
486                         '$baseurl' => DI::baseUrl()->get(true),
487                         '$uid' => local_user(),
488                         '$form_security_token' => BaseModule::getFormSecurityToken("settings"),
489                         '$nickname_block' => $prof_addr,
490
491                         '$h_pass'       => DI::l10n()->t('Password Settings'),
492                         '$password1'=> ['password', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).'), false, 'autocomplete="off"'],
493                         '$password2'=> ['confirm', DI::l10n()->t('Confirm:'), '', DI::l10n()->t('Leave password fields blank unless changing'), false, 'autocomplete="off"'],
494                         '$password3'=> ['opassword', DI::l10n()->t('Current Password:'), '', DI::l10n()->t('Your current password to confirm the changes'), false, 'autocomplete="off"'],
495                         '$password4'=> ['mpassword', DI::l10n()->t('Password:'), '', DI::l10n()->t('Your current password to confirm the changes of the email address'), false, 'autocomplete="off"'],
496                         '$oid_enable' => (!DI::config()->get('system', 'no_openid')),
497                         '$openid'       => $openid_field,
498                         '$delete_openid' => ['delete_openid', DI::l10n()->t('Delete OpenID URL'), false, ''],
499
500                         '$h_basic'      => DI::l10n()->t('Basic Settings'),
501                         '$username' => ['username',  DI::l10n()->t('Full Name:'), $username, '', false, 'autocomplete="off"'],
502                         '$email'        => ['email', DI::l10n()->t('Email Address:'), $email, '', '', 'autocomplete="off"', 'email'],
503                         '$timezone' => ['timezone_select' , DI::l10n()->t('Your Timezone:'), Temporal::getTimezoneSelect($timezone), ''],
504                         '$language' => ['language', DI::l10n()->t('Your Language:'), $language, DI::l10n()->t('Set the language we use to show you friendica interface and to send you emails'), $lang_choices],
505                         '$defloc'       => ['defloc', DI::l10n()->t('Default Post Location:'), $defloc, ''],
506                         '$allowloc' => ['allow_location', DI::l10n()->t('Use Browser Location:'), ($user['allow_location'] == 1), ''],
507
508                         '$h_prv'                  => DI::l10n()->t('Security and Privacy Settings'),
509                         '$is_community'       => ($user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY),
510                         '$maxreq'                 => ['maxreq', DI::l10n()->t('Maximum Friend Requests/Day:'), $maxreq , DI::l10n()->t("(to prevent spam abuse)")],
511                         '$profile_in_dir'     => $profile_in_dir,
512                         '$profile_in_net_dir' => ['profile_in_netdirectory', DI::l10n()->t('Allow your profile to be searchable globally?'), $profile['net-publish'], DI::l10n()->t("Activate this setting if you want others to easily find and follow you. Your profile will be searchable on remote systems. This setting also determines whether Friendica will inform search engines that your profile should be indexed or not.") . $net_pub_desc],
513                         '$hide_friends'       => ['hide-friends', DI::l10n()->t('Hide your contact/friend list from viewers of your profile?'), $profile['hide-friends'], DI::l10n()->t('A list of your contacts is displayed on your profile page. Activate this option to disable the display of your contact list.')],
514                         '$hide_wall'          => ['hidewall', DI::l10n()->t('Hide your profile details from anonymous viewers?'), $user['hidewall'], DI::l10n()->t('Anonymous visitors will only see your profile picture, your display name and the nickname you are using on your profile page. Your public posts and replies will still be accessible by other means.')],
515                         '$unlisted'           => ['unlisted', DI::l10n()->t('Make public posts unlisted'), DI::pConfig()->get(local_user(), 'system', 'unlisted'), DI::l10n()->t('Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.')],
516                         '$accessiblephotos'   => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(local_user(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")],
517                         '$blockwall'          => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')],
518                         '$blocktags'          => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
519                         '$unkmail'            => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
520                         '$cntunkmail'         => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail , DI::l10n()->t("(to prevent spam abuse)")],
521                         '$group_select'       => Group::displayGroupSelection(local_user(), $user['def_gid']),
522                         '$permissions'        => DI::l10n()->t('Default Post Permissions'),
523                         '$aclselect'          => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
524
525                         '$expire' => [
526                                 'label'        => DI::l10n()->t('Expiration settings'),
527                                 'days'         => ['expire',  DI::l10n()->t("Automatically expire posts after this many days:"), $expire, DI::l10n()->t('If empty, posts will not expire. Expired posts will be deleted')],
528                                 'items'        => ['expire_items', DI::l10n()->t('Expire posts'), $expire_items, DI::l10n()->t('When activated, posts and comments will be expired.')],
529                                 'notes'        => ['expire_notes', DI::l10n()->t('Expire personal notes'), $expire_notes, DI::l10n()->t('When activated, the personal notes on your profile page will be expired.')],
530                                 'starred'      => ['expire_starred', DI::l10n()->t('Expire starred posts'), $expire_starred, DI::l10n()->t('Starring posts keeps them from being expired. That behaviour is overwritten by this setting.')],
531                                 'photos'       => ['expire_photos', DI::l10n()->t('Expire photos'), $expire_photos, DI::l10n()->t('When activated, photos will be expired.')],
532                                 'network_only' => ['expire_network_only', DI::l10n()->t('Only expire posts by others'), $expire_network_only, DI::l10n()->t('When activated, your own posts never expire. Then the settings above are only valid for posts you received.')],
533                         ],
534
535                         '$h_not'        => DI::l10n()->t('Notification Settings'),
536                         '$lbl_not'      => DI::l10n()->t('Send a notification email when:'),
537                         '$notify1'      => ['notify1', DI::l10n()->t('You receive an introduction'), ($notify & Notification\Type::INTRO), Notification\Type::INTRO, ''],
538                         '$notify2'      => ['notify2', DI::l10n()->t('Your introductions are confirmed'), ($notify & Notification\Type::CONFIRM), Notification\Type::CONFIRM, ''],
539                         '$notify3'      => ['notify3', DI::l10n()->t('Someone writes on your profile wall'), ($notify & Notification\Type::WALL), Notification\Type::WALL, ''],
540                         '$notify4'      => ['notify4', DI::l10n()->t('Someone writes a followup comment'), ($notify & Notification\Type::COMMENT), Notification\Type::COMMENT, ''],
541                         '$notify5'      => ['notify5', DI::l10n()->t('You receive a private message'), ($notify & Notification\Type::MAIL), Notification\Type::MAIL, ''],
542                         '$notify6'  => ['notify6', DI::l10n()->t('You receive a friend suggestion'), ($notify & Notification\Type::SUGGEST), Notification\Type::SUGGEST, ''],
543                         '$notify7'  => ['notify7', DI::l10n()->t('You are tagged in a post'), ($notify & Notification\Type::TAG_SELF), Notification\Type::TAG_SELF, ''],
544                         '$notify8'  => ['notify8', DI::l10n()->t('You are poked/prodded/etc. in a post'), ($notify & Notification\Type::POKE), Notification\Type::POKE, ''],
545
546                         '$lbl_notify'      => DI::l10n()->t('Create a desktop notification when:'),
547                         '$notify_like'     => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(local_user(), 'system', 'notify_like'), ''],
548                         '$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(local_user(), 'system', 'notify_announce'), ''],
549
550                         '$desktop_notifications' => ['desktop_notifications', DI::l10n()->t('Activate desktop notifications') , false, DI::l10n()->t('Show desktop popup on new notifications')],
551
552                         '$email_textonly' => ['email_textonly', DI::l10n()->t('Text-only notification emails'),
553                                               DI::pConfig()->get(local_user(), 'system', 'email_textonly'),
554                                               DI::l10n()->t('Send text only notification emails, without the html part')],
555
556                         '$detailed_notif' => ['detailed_notif', DI::l10n()->t('Show detailled notifications'),
557                                               DI::pConfig()->get(local_user(), 'system', 'detailed_notif'),
558                                               DI::l10n()->t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.')],
559
560                         '$notify_ignored' => ['notify_ignored', DI::l10n()->t('Show notifications of ignored contacts') ,
561                                               DI::pConfig()->get(local_user(), 'system', 'notify_ignored', true),
562                                               DI::l10n()->t("You don't see posts from ignored contacts. But you still see their comments. This setting controls if you want to still receive regular notifications that are caused by ignored contacts or not.")],
563
564                         '$h_advn' => DI::l10n()->t('Advanced Account/Page Type Settings'),
565                         '$h_descadvn' => DI::l10n()->t('Change the behaviour of this account for special situations'),
566                         '$pagetype' => $pagetype,
567
568                         '$importcontact' => DI::l10n()->t('Import Contacts'),
569                         '$importcontact_text' => DI::l10n()->t('Upload a CSV file that contains the handle of your followed accounts in the first column you exported from the old account.'),
570                         '$importcontact_button' => DI::l10n()->t('Upload File'),
571                         '$importcontact_maxsize' => DI::config()->get('system', 'max_csv_file_size', 30720),
572                         '$relocate' => DI::l10n()->t('Relocate'),
573                         '$relocate_text' => DI::l10n()->t("If you have moved this profile from another server, and some of your contacts don't receive your updates, try pushing this button."),
574                         '$relocate_button' => DI::l10n()->t("Resend relocate message to contacts"),
575                 ]);
576
577                 Hook::callAll('settings_form', $o);
578
579                 $o .= '</form>' . "\r\n";
580
581                 return $o;
582         }
583 }