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