]> git.mxchange.org Git - friendica.git/blob - src/Module/Settings/Account.php
Use constants
[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\Core\ACL;
26 use Friendica\Core\Logger;
27 use Friendica\Core\Renderer;
28 use Friendica\Core\Search;
29 use Friendica\Core\Worker;
30 use Friendica\Database\DBA;
31 use Friendica\DI;
32 use Friendica\Model\Group;
33 use Friendica\Model\Notification;
34 use Friendica\Model\Post\UserNotification;
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                 $redirectUrl = '/settings' . (isset($this->parameters['open']) ? '/account/' . $this->parameters['open'] : '');
53
54                 self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'settings');
55
56                 $a = DI::app();
57
58                 $user = User::getById($a->getLoggedInUserId());
59
60                 if (!empty($request['password-submit'])) {
61                         $newpass = $request['password'];
62                         $confirm = $request['confirm'];
63
64                         try {
65                                 if ($newpass != $confirm) {
66                                         throw new Exception(DI::l10n()->t('Passwords do not match.'));
67                                 }
68
69                                 //  check if the old password was supplied correctly before changing it to the new value
70                                 User::getIdFromPasswordAuthentication(local_user(), $request['opassword']);
71
72                                 $result = User::updatePassword(local_user(), $newpass);
73                                 if (!DBA::isResult($result)) {
74                                         throw new Exception(DI::l10n()->t('Password update failed. Please try again.'));
75                                 }
76
77                                 info(DI::l10n()->t('Password changed.'));
78                         } catch (Exception $e) {
79                                 notice($e->getMessage());
80                                 notice(DI::l10n()->t('Password unchanged.'));
81                         }
82
83                         DI::baseUrl()->redirect($redirectUrl);
84                 }
85
86                 if (!empty($request['basic-submit'])) {
87                         $username = trim($request['username'] ?? '');
88                         $email    = trim($request['email'] ?? '');
89                         $timezone = trim($request['timezone'] ?? '');
90
91
92                         $err = '';
93                         if ($username != $user['username']) {
94                                 if (strlen($username) > 40) {
95                                         $err .= DI::l10n()->t('Please use a shorter name.');
96                                 }
97                                 if (strlen($username) < 3) {
98                                         $err .= DI::l10n()->t('Name too short.');
99                                 }
100                         }
101
102                         if ($email != $user['email']) {
103                                 //  check for the correct password
104                                 try {
105                                         User::getIdFromPasswordAuthentication(local_user(), $request['mpassword']);
106                                 } catch (Exception $ex) {
107                                         $err .= DI::l10n()->t('Wrong Password.');
108                                         $email = $user['email'];
109                                 }
110                                 //  check the email is valid
111                                 if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
112                                         $err .= DI::l10n()->t('Invalid email.');
113                                 }
114                                 //  ensure new email is not the admin mail
115                                 if (DI::config()->get('config', 'admin_email')) {
116                                         $adminlist = explode(",", str_replace(" ", "", strtolower(DI::config()->get('config', 'admin_email'))));
117                                         if (in_array(strtolower($email), $adminlist)) {
118                                                 $err .= DI::l10n()->t('Cannot change to that email.');
119                                                 $email = $user['email'];
120                                         }
121                                 }
122                         }
123
124                         if (strlen($err)) {
125                                 notice($err);
126                                 return;
127                         }
128
129                         if (strlen($timezone) && $timezone != $user['timezone']) {
130                                 $a->setTimeZone($timezone);
131                         }
132
133                         $fields = [
134                                 'username'         => $username,
135                                 'email'            => $email,
136                                 'timezone'         => $timezone,
137                                 'default-location' => trim($request['default_location'] ?? ''),
138                                 'allow_location'   => !empty($request['allow_location']),
139                                 'language'         => trim($request['language'] ?? ''),
140                         ];
141
142                         if (!empty($request['delete_openid'])) {
143                                 $fields['openid']       = '';
144                                 $fields['openidserver'] = '';
145                         }
146
147                         if (!User::update($fields, local_user())) {
148                                 notice(DI::l10n()->t('Settings were not updated.'));
149                         }
150
151                         // clear session language
152                         unset($_SESSION['language']);
153
154                         DI::baseUrl()->redirect($redirectUrl);
155                 }
156
157                 if (!empty($request['privacy-submit'])) {
158                         $maxreq       = intval($request['maxreq'] ?? 0);
159                         $publish      = !empty($request['profile_in_directory']);
160                         $net_publish  = !empty($request['profile_in_netdirectory']);
161                         $hide_friends = !empty($request['hide-friends']);
162                         $hidewall     = !empty($request['hidewall']);
163                         $blockwall    = empty($request['blockwall']); // this setting is inverted!
164                         $blocktags    = empty($request['blocktags']); // this setting is inverted!
165                         $unkmail      = !empty($request['unkmail']);
166                         $cntunkmail   = intval($request['cntunkmail'] ?? 0);
167                         $def_gid      = intval($request['group-selection'] ?? 0);
168
169                         $aclFormatter = DI::aclFormatter();
170
171                         $str_group_allow   = !empty($request['group_allow']) ? $aclFormatter->toString($request['group_allow']) : '';
172                         $str_contact_allow = !empty($request['contact_allow']) ? $aclFormatter->toString($request['contact_allow']) : '';
173                         $str_group_deny    = !empty($request['group_deny']) ? $aclFormatter->toString($request['group_deny']) : '';
174                         $str_contact_deny  = !empty($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : '';
175
176                         DI::pConfig()->set(local_user(), 'system', 'unlisted', !empty($request['unlisted']));
177                         DI::pConfig()->set(local_user(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
178
179                         $fields = [
180                                 'allow_cid'  => $str_contact_allow,
181                                 'allow_gid'  => $str_group_allow,
182                                 'deny_cid'   => $str_contact_deny,
183                                 'deny_gid'   => $str_group_deny,
184                                 'maxreq'     => $maxreq,
185                                 'def_gid'    => $def_gid,
186                                 'blockwall'  => $blockwall,
187                                 'hidewall'   => $hidewall,
188                                 'blocktags'  => $blocktags,
189                                 'unkmail'    => $unkmail,
190                                 'cntunkmail' => $cntunkmail,
191                         ];
192
193                         $profile_fields = [
194                                 'publish'      => $publish,
195                                 'net-publish'  => $net_publish,
196                                 'hide-friends' => $hide_friends
197                         ];
198
199                         if (!User::update($fields, local_user()) || !Profile::update($profile_fields, local_user())) {
200                                 notice(DI::l10n()->t('Settings were not updated.'));
201                         }
202
203                         DI::baseUrl()->redirect($redirectUrl);
204                 }
205
206                 if (!empty($request['expire-submit'])) {
207                         $expire = intval($request['expire'] ?? 0);
208
209                         $expire_items        = !empty($request['expire_items']);
210                         $expire_notes        = !empty($request['expire_notes']);
211                         $expire_starred      = !empty($request['expire_starred']);
212                         $expire_network_only = !empty($request['expire_network_only']);
213
214                         DI::pConfig()->set(local_user(), 'expire', 'items', $expire_items);
215                         DI::pConfig()->set(local_user(), 'expire', 'notes', $expire_notes);
216                         DI::pConfig()->set(local_user(), 'expire', 'starred', $expire_starred);
217                         DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only);
218
219                         if (!User::update(['expire' => $expire], local_user())) {
220                                 notice(DI::l10n()->t('Settings were not updated.'));
221                         }
222
223                         DI::baseUrl()->redirect($redirectUrl);
224                 }
225
226                 if (!empty($request['notification-submit'])) {
227                         $notify = 0;
228
229                         if (!empty($request['notify1'])) {
230                                 $notify += intval($request['notify1']);
231                         }
232                         if (!empty($request['notify2'])) {
233                                 $notify += intval($request['notify2']);
234                         }
235                         if (!empty($request['notify3'])) {
236                                 $notify += intval($request['notify3']);
237                         }
238                         if (!empty($request['notify4'])) {
239                                 $notify += intval($request['notify4']);
240                         }
241                         if (!empty($request['notify5'])) {
242                                 $notify += intval($request['notify5']);
243                         }
244                         if (!empty($request['notify6'])) {
245                                 $notify += intval($request['notify6']);
246                         }
247                         if (!empty($request['notify7'])) {
248                                 $notify += intval($request['notify7']);
249                         }
250                         if (!empty($request['notify8'])) {
251                                 $notify += intval($request['notify8']);
252                         }
253
254                         $notify_like     = !empty($request['notify_like']);
255                         $notify_announce = !empty($request['notify_announce']);
256
257                         $notify_type = 0;
258
259                         if (!empty($request['notify_tagged'])) {
260                                 $notify_type = $notify_type | (UserNotification::TYPE_EXPLICIT_TAGGED + UserNotification::TYPE_IMPLICIT_TAGGED);
261                         }
262                         if (!empty($request['notify_direct_comment'])) {
263                                 $notify_type = $notify_type | (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT);
264                         }
265                         if (!empty($request['notify_thread_comment'])) {
266                                 $notify_type = $notify_type | UserNotification::TYPE_THREAD_COMMENT;
267                         }
268                         if (!empty($request['notify_comment_participation'])) {
269                                 $notify_type = $notify_type | UserNotification::TYPE_COMMENT_PARTICIPATION;
270                         }
271                         if (!empty($request['notify_activity_participation'])) {
272                                 $notify_type = $notify_type | UserNotification::TYPE_ACTIVITY_PARTICIPATION;
273                         }
274                         DI::pConfig()->set(local_user(), 'system', 'notify_type', $notify_type);
275
276                         if (!($notify_type & (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT))) {
277                                 $notify_like     = false;
278                                 $notify_announce = false;
279                         }
280
281                         // Reset like notifications when they are going to be shown again
282                         if (!DI::pConfig()->get(local_user(), 'system', 'notify_like') && $notify_like) {
283                                 DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::LIKE)]);
284                         }
285
286                         DI::pConfig()->set(local_user(), 'system', 'notify_like', $notify_like);
287
288                         // Reset share notifications when they are going to be shown again
289                         if (!DI::pConfig()->get(local_user(), 'system', 'notify_announce') && $notify_announce) {
290                                 DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
291                         }
292
293                         DI::pConfig()->set(local_user(), 'system', 'notify_announce', $notify_announce);
294
295                         DI::pConfig()->set(local_user(), 'system', 'email_textonly', !empty($request['email_textonly']));
296                         DI::pConfig()->set(local_user(), 'system', 'detailed_notif', !empty($request['detailed_notif']));
297                         DI::pConfig()->set(local_user(), 'system', 'notify_ignored', !empty($request['notify_ignored']));
298
299                         $fields = [
300                                 'notify-flags' => $notify,
301                         ];
302
303                         if (!User::update($fields, local_user())) {
304                                 notice(DI::l10n()->t('Settings were not updated.'));
305                         }
306
307                         DI::baseUrl()->redirect($redirectUrl);
308                 }
309
310                 if (!empty($request['advanced-submit'])) {
311                         $account_type = intval($request['account-type'] ?? 0);
312                         $page_flags   = intval($request['page-flags'] ?? 0);
313
314                         // Adjust the page flag if the account type doesn't fit to the page flag.
315                         if ($account_type == User::ACCOUNT_TYPE_PERSON && !in_array($page_flags, [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE])) {
316                                 $page_flags = User::PAGE_FLAGS_NORMAL;
317                         } elseif ($account_type == User::ACCOUNT_TYPE_ORGANISATION && $page_flags != User::PAGE_FLAGS_SOAPBOX) {
318                                 $page_flags = User::PAGE_FLAGS_SOAPBOX;
319                         } elseif ($account_type == User::ACCOUNT_TYPE_NEWS && $page_flags != User::PAGE_FLAGS_SOAPBOX) {
320                                 $page_flags = User::PAGE_FLAGS_SOAPBOX;
321                         } elseif ($account_type == User::ACCOUNT_TYPE_COMMUNITY && !in_array($page_flags, [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
322                                 $page_flags = User::PAGE_FLAGS_COMMUNITY;
323                         }
324
325                         $fields         = [];
326                         $profile_fields = [];
327
328                         if ($account_type == User::ACCOUNT_TYPE_COMMUNITY) {
329                                 DI::pConfig()->set(local_user(), 'system', 'unlisted', true);
330
331                                 $fields = [
332                                         'allow_cid' => '',
333                                         'allow_gid' => $page_flags == User::PAGE_FLAGS_PRVGROUP ?
334                                                         '<' . Group::FOLLOWERS . '>'
335                                                         : '',
336                                         'deny_cid'  => '',
337                                         'deny_gid'  => '',
338                                         'blockwall' => true,
339                                         'blocktags' => true,
340                                 ];
341
342                                 $profile_fields = [
343                                         'hide-friends' => true,
344                                 ];
345                         }
346
347                         $fields = array_merge($fields, [
348                                 'page-flags'   => $page_flags,
349                                 'account-type' => $account_type,
350                         ]);
351
352                         if (!User::update($fields, local_user()) || !empty($profile_fields) && !Profile::update($profile_fields, local_user())) {
353                                 notice(DI::l10n()->t('Settings were not updated.'));
354                         }
355
356                         DI::baseUrl()->redirect($redirectUrl);
357                 }
358
359                 // Import Contacts from CSV file
360                 if (!empty($request['importcontact-submit'])) {
361                         if (isset($_FILES['importcontact-filename'])) {
362                                 // was there an error
363                                 if ($_FILES['importcontact-filename']['error'] > 0) {
364                                         Logger::notice('Contact CSV file upload error', ['error' => $_FILES['importcontact-filename']['error']]);
365                                         notice(DI::l10n()->t('Contact CSV file upload error'));
366                                 } else {
367                                         $csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name']));
368                                         Logger::notice('Import started', ['lines' => count($csvArray)]);
369                                         // import contacts
370                                         foreach ($csvArray as $csvRow) {
371                                                 // The 1st row may, or may not contain the headers of the table
372                                                 // We expect the 1st field of the row to contain either the URL
373                                                 // or the handle of the account, therefore we check for either
374                                                 // "http" or "@" to be present in the string.
375                                                 // All other fields from the row will be ignored
376                                                 if ((strpos($csvRow[0], '@') !== false) || in_array(parse_url($csvRow[0], PHP_URL_SCHEME), ['http', 'https'])) {
377                                                         Worker::add(PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]);
378                                                 } else {
379                                                         Logger::notice('Invalid account', ['url' => $csvRow[0]]);
380                                                 }
381                                         }
382                                         Logger::notice('Import done');
383
384                                         info(DI::l10n()->t('Importing Contacts done'));
385                                         // delete temp file
386                                         unlink($_FILES['importcontact-filename']['tmp_name']);
387                                 }
388                         } else {
389                                 Logger::notice('Import triggered, but no import file was found.');
390                         }
391
392                         DI::baseUrl()->redirect($redirectUrl);
393                 }
394
395                 if (!empty($request['relocate-submit'])) {
396                         Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
397                         info(DI::l10n()->t("Relocate message has been send to your contacts"));
398                         DI::baseUrl()->redirect($redirectUrl);
399                 }
400
401                 DI::baseUrl()->redirect($redirectUrl);
402         }
403
404         protected function content(array $request = []): string
405         {
406                 parent::content();
407
408                 if (!local_user()) {
409                         throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
410                 }
411
412                 $profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
413                 if (!DBA::isResult($profile)) {
414                         notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
415                         return '';
416                 }
417
418                 $a = DI::app();
419
420                 $user = User::getById($a->getLoggedInUserId());
421
422                 $username         = $user['username'];
423                 $email            = $user['email'];
424                 $nickname         = $a->getLoggedInUserNickname();
425                 $timezone         = $user['timezone'];
426                 $language         = $user['language'];
427                 $notify           = $user['notify-flags'];
428                 $default_location = $user['default-location'];
429                 $openid           = $user['openid'];
430                 $maxreq           = $user['maxreq'];
431                 $expire           = $user['expire'] ?: '';
432                 $unkmail          = $user['unkmail'];
433                 $cntunkmail       = $user['cntunkmail'];
434
435                 $expire_items        = DI::pConfig()->get(local_user(), 'expire', 'items', true);
436                 $expire_notes        = DI::pConfig()->get(local_user(), 'expire', 'notes', true);
437                 $expire_starred      = DI::pConfig()->get(local_user(), 'expire', 'starred', true);
438                 $expire_network_only = DI::pConfig()->get(local_user(), 'expire', 'network_only', false);
439
440                 if (!strlen($user['timezone'])) {
441                         $timezone = $a->getTimeZone();
442                 }
443
444                 // Set the account type to "Community" when the page is a community page but the account type doesn't fit
445                 // This is only happening on the first visit after the update
446                 if (
447                         in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])
448                         && $user['account-type'] != User::ACCOUNT_TYPE_COMMUNITY
449                 ) {
450                         $user['account-type'] = User::ACCOUNT_TYPE_COMMUNITY;
451                 }
452
453                 $pageset_tpl = Renderer::getMarkupTemplate('settings/pagetypes.tpl');
454                 $pagetype    = Renderer::replaceMacros($pageset_tpl, [
455                         '$account_types'     => DI::l10n()->t("Account Types"),
456                         '$user'              => DI::l10n()->t("Personal Page Subtypes"),
457                         '$community'         => DI::l10n()->t("Community Forum Subtypes"),
458                         '$account_type'      => $user['account-type'],
459                         '$type_person'       => User::ACCOUNT_TYPE_PERSON,
460                         '$type_organisation' => User::ACCOUNT_TYPE_ORGANISATION,
461                         '$type_news'         => User::ACCOUNT_TYPE_NEWS,
462                         '$type_community'    => User::ACCOUNT_TYPE_COMMUNITY,
463                         '$account_person'    => [
464                                 'account-type',
465                                 DI::l10n()->t('Personal Page'),
466                                 User::ACCOUNT_TYPE_PERSON,
467                                 DI::l10n()->t('Account for a personal profile.'),
468                                 $user['account-type'] == User::ACCOUNT_TYPE_PERSON
469                         ],
470                         '$account_organisation' => [
471                                 'account-type',
472                                 DI::l10n()->t('Organisation Page'),
473                                 User::ACCOUNT_TYPE_ORGANISATION,
474                                 DI::l10n()->t('Account for an organisation that automatically approves contact requests as "Followers".'),
475                                 $user['account-type'] == User::ACCOUNT_TYPE_ORGANISATION
476                         ],
477                         '$account_news' => [
478                                 'account-type',
479                                 DI::l10n()->t('News Page'),
480                                 User::ACCOUNT_TYPE_NEWS,
481                                 DI::l10n()->t('Account for a news reflector that automatically approves contact requests as "Followers".'),
482                                 $user['account-type'] == User::ACCOUNT_TYPE_NEWS
483                         ],
484                         '$account_community' => [
485                                 'account-type',
486                                 DI::l10n()->t('Community Forum'),
487                                 User::ACCOUNT_TYPE_COMMUNITY,
488                                 DI::l10n()->t('Account for community discussions.'),
489                                 $user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY
490                         ],
491                         '$page_normal' => [
492                                 'page-flags',
493                                 DI::l10n()->t('Normal Account Page'),
494                                 User::PAGE_FLAGS_NORMAL,
495                                 DI::l10n()->t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'),
496                                 $user['page-flags'] == User::PAGE_FLAGS_NORMAL
497                         ],
498                         '$page_soapbox' => [
499                                 'page-flags',
500                                 DI::l10n()->t('Soapbox Page'),
501                                 User::PAGE_FLAGS_SOAPBOX,
502                                 DI::l10n()->t('Account for a public profile that automatically approves contact requests as "Followers".'),
503                                 $user['page-flags'] == User::PAGE_FLAGS_SOAPBOX
504                         ],
505                         '$page_community' => [
506                                 'page-flags',
507                                 DI::l10n()->t('Public Forum'),
508                                 User::PAGE_FLAGS_COMMUNITY,
509                                 DI::l10n()->t('Automatically approves all contact requests.'),
510                                 $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY
511                         ],
512                         '$page_freelove' => [
513                                 'page-flags',
514                                 DI::l10n()->t('Automatic Friend Page'),
515                                 User::PAGE_FLAGS_FREELOVE,
516                                 DI::l10n()->t('Account for a popular profile that automatically approves contact requests as "Friends".'),
517                                 $user['page-flags'] == User::PAGE_FLAGS_FREELOVE
518                         ],
519                         '$page_prvgroup' => [
520                                 'page-flags',
521                                 DI::l10n()->t('Private Forum [Experimental]'),
522                                 User::PAGE_FLAGS_PRVGROUP,
523                                 DI::l10n()->t('Requires manual approval of contact requests.'),
524                                 $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP
525                         ],
526                 ]);
527
528                 $noid = DI::config()->get('system', 'no_openid');
529                 if ($noid) {
530                         $openid_field = false;
531                 } else {
532                         $openid_field = ['openid_url', DI::l10n()->t('OpenID:'), $openid, DI::l10n()->t("(Optional) Allow this OpenID to login to this account."), "", "readonly", "url"];
533                 }
534
535                 if (DI::config()->get('system', 'publish_all')) {
536                         $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
537                 } else {
538                         $opt_tpl        = Renderer::getMarkupTemplate("field_checkbox.tpl");
539                         $profile_in_dir = Renderer::replaceMacros($opt_tpl, [
540                                 '$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')]
541                         ]);
542                 }
543
544                 $net_pub_desc = '';
545                 if (Search::getGlobalDirectory()) {
546                         $net_pub_desc = ' ' . DI::l10n()->t('Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).', Search::getGlobalDirectory(), Search::getGlobalDirectory());
547                 }
548
549                 /* Installed langs */
550                 $lang_choices = DI::l10n()->getAvailableLanguages();
551
552                 $notify_type = DI::pConfig()->get(local_user(), 'system', 'notify_type', 3 | 72 | 4 | 16 | 32);
553
554                 $tpl = Renderer::getMarkupTemplate('settings/account.tpl');
555                 $o   = Renderer::replaceMacros($tpl, [
556                         '$ptitle' => DI::l10n()->t('Account Settings'),
557                         '$desc'   => DI::l10n()->t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . DI::baseUrl()->getHostname() . DI::baseUrl()->getUrlPath(), DI::baseUrl() . '/profile/' . $nickname),
558
559                         '$submit'              => DI::l10n()->t('Save Settings'),
560                         '$baseurl'             => DI::baseUrl()->get(true),
561                         '$uid'                 => local_user(),
562                         '$form_security_token' => self::getFormSecurityToken('settings'),
563                         '$open'                => $this->parameters['open'] ?? 'password',
564
565                         '$h_pass'        => DI::l10n()->t('Password Settings'),
566                         '$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"'],
567                         '$password2'     => ['confirm', DI::l10n()->t('Confirm:'), '', DI::l10n()->t('Leave password fields blank unless changing'), false, 'autocomplete="off"'],
568                         '$password3'     => ['opassword', DI::l10n()->t('Current Password:'), '', DI::l10n()->t('Your current password to confirm the changes'), false, 'autocomplete="off"'],
569                         '$password4'     => ['mpassword', DI::l10n()->t('Password:'), '', DI::l10n()->t('Your current password to confirm the changes of the email address'), false, 'autocomplete="off"'],
570                         '$oid_enable'    => (!DI::config()->get('system', 'no_openid')),
571                         '$openid'        => $openid_field,
572                         '$delete_openid' => ['delete_openid', DI::l10n()->t('Delete OpenID URL'), false, ''],
573
574                         '$h_basic'          => DI::l10n()->t('Basic Settings'),
575                         '$username'         => ['username', DI::l10n()->t('Full Name:'), $username, '', false, 'autocomplete="off"'],
576                         '$email'            => ['email', DI::l10n()->t('Email Address:'), $email, '', '', 'autocomplete="off"', 'email'],
577                         '$timezone'         => ['timezone_select', DI::l10n()->t('Your Timezone:'), Temporal::getTimezoneSelect($timezone), ''],
578                         '$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],
579                         '$default_location' => ['default_location', DI::l10n()->t('Default Post Location:'), $default_location, ''],
580                         '$allow_location'   => ['allow_location', DI::l10n()->t('Use Browser Location:'), ($user['allow_location'] == 1), ''],
581
582                         '$h_prv'              => DI::l10n()->t('Security and Privacy Settings'),
583                         '$is_community'       => ($user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY),
584                         '$maxreq'             => ['maxreq', DI::l10n()->t('Maximum Friend Requests/Day:'), $maxreq, DI::l10n()->t("(to prevent spam abuse)")],
585                         '$profile_in_dir'     => $profile_in_dir,
586                         '$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],
587                         '$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.')],
588                         '$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.')],
589                         '$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.')],
590                         '$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.")],
591                         '$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')],
592                         '$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.')],
593                         '$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.')],
594                         '$cntunkmail'         => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
595                         '$group_select'       => Group::displayGroupSelection(local_user(), $user['def_gid']),
596                         '$permissions'        => DI::l10n()->t('Default Post Permissions'),
597                         '$aclselect'          => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
598
599                         '$expire' => [
600                                 'label'        => DI::l10n()->t('Expiration settings'),
601                                 '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')],
602                                 'items'        => ['expire_items', DI::l10n()->t('Expire posts'), $expire_items, DI::l10n()->t('When activated, posts and comments will be expired.')],
603                                 '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.')],
604                                 '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.')],
605                                 '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.')],
606                         ],
607
608                         '$h_not'   => DI::l10n()->t('Notification Settings'),
609                         '$lbl_not' => DI::l10n()->t('Send a notification email when:'),
610                         '$notify1' => ['notify1', DI::l10n()->t('You receive an introduction'), ($notify & Notification\Type::INTRO), Notification\Type::INTRO, ''],
611                         '$notify2' => ['notify2', DI::l10n()->t('Your introductions are confirmed'), ($notify & Notification\Type::CONFIRM), Notification\Type::CONFIRM, ''],
612                         '$notify3' => ['notify3', DI::l10n()->t('Someone writes on your profile wall'), ($notify & Notification\Type::WALL), Notification\Type::WALL, ''],
613                         '$notify4' => ['notify4', DI::l10n()->t('Someone writes a followup comment'), ($notify & Notification\Type::COMMENT), Notification\Type::COMMENT, ''],
614                         '$notify5' => ['notify5', DI::l10n()->t('You receive a private message'), ($notify & Notification\Type::MAIL), Notification\Type::MAIL, ''],
615                         '$notify6' => ['notify6', DI::l10n()->t('You receive a friend suggestion'), ($notify & Notification\Type::SUGGEST), Notification\Type::SUGGEST, ''],
616                         '$notify7' => ['notify7', DI::l10n()->t('You are tagged in a post'), ($notify & Notification\Type::TAG_SELF), Notification\Type::TAG_SELF, ''],
617                         '$notify8' => ['notify8', DI::l10n()->t('You are poked/prodded/etc. in a post'), ($notify & Notification\Type::POKE), Notification\Type::POKE, ''],
618
619                         '$lbl_notify'                    => DI::l10n()->t('Create a desktop notification when:'),
620                         '$notify_tagged'                 => ['notify_tagged', DI::l10n()->t('Someone tagged you'), $notify_type & (UserNotification::TYPE_EXPLICIT_TAGGED + UserNotification::TYPE_IMPLICIT_TAGGED), ''],
621                         '$notify_direct_comment'         => ['notify_direct_comment', DI::l10n()->t('Someone directly commented on your post'), $notify_type & (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT), ''],
622                         '$notify_like'                   => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(local_user(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
623                         '$notify_announce'               => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(local_user(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
624                         '$notify_thread_comment'         => ['notify_thread_comment', DI::l10n()->t('Someone commented on your thread'), $notify_type & UserNotification::TYPE_THREAD_COMMENT, ''],
625                         '$notify_comment_participation'  => ['notify_comment_participation', DI::l10n()->t('Someone commented in a thread where you commented'), $notify_type & UserNotification::TYPE_COMMENT_PARTICIPATION, ''],
626                         '$notify_activity_participation' => ['notify_activity_participation', DI::l10n()->t('Someone commented on a thread where you interacted'), $notify_type & UserNotification::TYPE_ACTIVITY_PARTICIPATION, ''],
627
628                         '$desktop_notifications' => ['desktop_notifications', DI::l10n()->t('Activate desktop notifications'), false, DI::l10n()->t('Show desktop popup on new notifications')],
629
630                         '$email_textonly' => [
631                                 'email_textonly',
632                                 DI::l10n()->t('Text-only notification emails'),
633                                 DI::pConfig()->get(local_user(), 'system', 'email_textonly'),
634                                 DI::l10n()->t('Send text only notification emails, without the html part')
635                         ],
636                         '$detailed_notif' => [
637                                 'detailed_notif',
638                                 DI::l10n()->t('Show detailled notifications'),
639                                 DI::pConfig()->get(local_user(), 'system', 'detailed_notif'),
640                                 DI::l10n()->t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.')
641                         ],
642                         '$notify_ignored' => [
643                                 'notify_ignored',
644                                 DI::l10n()->t('Show notifications of ignored contacts'),
645                                 DI::pConfig()->get(local_user(), 'system', 'notify_ignored', true),
646                                 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.")
647                         ],
648
649                         '$h_advn'     => DI::l10n()->t('Advanced Account/Page Type Settings'),
650                         '$h_descadvn' => DI::l10n()->t('Change the behaviour of this account for special situations'),
651                         '$pagetype'   => $pagetype,
652
653                         '$importcontact'         => DI::l10n()->t('Import Contacts'),
654                         '$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.'),
655                         '$importcontact_button'  => DI::l10n()->t('Upload File'),
656                         '$importcontact_maxsize' => DI::config()->get('system', 'max_csv_file_size', 30720),
657
658                         '$relocate'        => DI::l10n()->t('Relocate'),
659                         '$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."),
660                         '$relocate_button' => DI::l10n()->t("Resend relocate message to contacts"),
661                 ]);
662
663                 return $o;
664         }
665 }