rewording
[friendica.git/.git] / mod / settings.php
index 9aa2c0b..9c1142a 100644 (file)
@@ -6,18 +6,20 @@
 use Friendica\App;
 use Friendica\Content\Feature;
 use Friendica\Content\Nav;
+use Friendica\Core\ACL;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
+use Friendica\Core\Theme;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
+use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 use Friendica\Model\Group;
 use Friendica\Model\User;
 use Friendica\Protocol\Email;
-use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\Temporal;
 
@@ -147,9 +149,7 @@ function settings_post(App $a)
                check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
 
                $key = $_POST['remove'];
-               q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
-                       dbesc($key),
-                       local_user());
+               dba::delete('tokens', ['id' => $key, 'uid' => local_user()]);
                goaway(System::baseUrl(true)."/settings/oauth/");
                return;
        }
@@ -207,11 +207,11 @@ function settings_post(App $a)
                return;
        }
 
-       if (($a->argc > 1) && ($a->argv[1] == 'connectors'))
-       {
+       if (($a->argc > 1) && ($a->argv[1] == 'connectors')) {
                check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors');
 
                if (x($_POST, 'general-submit')) {
+                       PConfig::set(local_user(), 'system', 'disable_cw', intval($_POST['disable_cw']));
                        PConfig::set(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening']));
                        PConfig::set(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow']));
                        PConfig::set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
@@ -353,6 +353,7 @@ function settings_post(App $a)
                                theme_post($a);
                        }
                }
+               Theme::install($theme);
 
                $r = q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d",
                                dbesc($theme),
@@ -387,13 +388,18 @@ function settings_post(App $a)
                if (!x($newpass) || !x($confirm)) {
                        notice(L10n::t('Empty passwords are not allowed. Password unchanged.') . EOL);
                        $err = true;
-        }
+               }
+
+               if (!Config::get('system', 'disable_password_exposed', false) && User::isPasswordExposed($newpass)) {
+                       notice(L10n::t('The new password has been exposed in a public data dump, please choose another.') . EOL);
+                       $err = true;
+               }
 
-        //  check if the old password was supplied correctly before changing it to the new value
-        if (!User::authenticate(intval(local_user()), $_POST['opassword'])) {
-            notice(L10n::t('Wrong password.') . EOL);
-            $err = true;
-        }
+               //  check if the old password was supplied correctly before changing it to the new value
+               if (!User::authenticate(intval(local_user()), $_POST['opassword'])) {
+                       notice(L10n::t('Wrong password.') . EOL);
+                       $err = true;
+               }
 
                if (!$err) {
                        $result = User::updatePassword(local_user(), $newpass);
@@ -436,9 +442,6 @@ function settings_post(App $a)
        $suggestme        = ((x($_POST, 'suggestme')) ? intval($_POST['suggestme'])  : 0);
        $hide_friends     = (($_POST['hide-friends'] == 1) ? 1: 0);
        $hidewall         = (($_POST['hidewall'] == 1) ? 1: 0);
-       $post_newfriend   = (($_POST['post_newfriend'] == 1) ? 1: 0);
-       $post_joingroup   = (($_POST['post_joingroup'] == 1) ? 1: 0);
-       $post_profilechange   = (($_POST['post_profilechange'] == 1) ? 1: 0);
 
        $email_textonly   = (($_POST['email_textonly'] == 1) ? 1 : 0);
        $detailed_notif   = (($_POST['detailed_notif'] == 1) ? 1 : 0);
@@ -485,10 +488,7 @@ function settings_post(App $a)
 
        $err = '';
 
-       $name_change = false;
-
        if ($username != $a->user['username']) {
-               $name_change = true;
                if (strlen($username) > 40) {
                        $err .= L10n::t(' Please use a shorter name.');
                }
@@ -540,7 +540,7 @@ function settings_post(App $a)
        if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {
                if (Network::isUrlValid($openid)) {
                        logger('updating openidserver');
-                       $open_id_obj = new LightOpenID;
+                       $open_id_obj = new LightOpenID($a->get_hostname());
                        $open_id_obj->identity = $openid;
                        $openidserver = $open_id_obj->discover($open_id_obj->identity);
                } else {
@@ -555,9 +555,6 @@ function settings_post(App $a)
        PConfig::set(local_user(), 'expire', 'network_only', $expire_network_only);
 
        PConfig::set(local_user(), 'system', 'suggestme', $suggestme);
-       PConfig::set(local_user(), 'system', 'post_newfriend', $post_newfriend);
-       PConfig::set(local_user(), 'system', 'post_joingroup', $post_joingroup);
-       PConfig::set(local_user(), 'system', 'post_profilechange', $post_profilechange);
 
        PConfig::set(local_user(), 'system', 'email_textonly', $email_textonly);
        PConfig::set(local_user(), 'system', 'detailed_notif', $detailed_notif);
@@ -628,14 +625,7 @@ function settings_post(App $a)
                intval(local_user())
        );
 
-
-       if ($name_change) {
-               q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`",
-                       dbesc($username),
-                       dbesc(DateTimeFormat::utcNow()),
-                       intval(local_user())
-               );
-       }
+       Contact::updateSelfFromUserID(local_user());
 
        if (($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
                // Update global directory in background
@@ -716,9 +706,7 @@ function settings_content(App $a)
                if (($a->argc > 3) && ($a->argv[2] === 'delete')) {
                        check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
 
-                       q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
-                                       dbesc($a->argv[3]),
-                                       local_user());
+                       dba::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]);
                        goaway(System::baseUrl(true)."/settings/oauth/");
                        return;
                }
@@ -791,6 +779,7 @@ function settings_content(App $a)
        }
 
        if (($a->argc > 1) && ($a->argv[1] === 'connectors')) {
+               $disable_cw                = intval(PConfig::get(local_user(), 'system', 'disable_cw'));
                $no_intelligent_shortening = intval(PConfig::get(local_user(), 'system', 'no_intelligent_shortening'));
                $ostatus_autofriend        = intval(PConfig::get(local_user(), 'system', 'ostatus_autofriend'));
                $default_group             = PConfig::get(local_user(), 'ostatus', 'default_group');
@@ -848,6 +837,7 @@ function settings_content(App $a)
                        '$ostat_enabled' => $ostat_enabled,
 
                        '$general_settings' => L10n::t('General Social Media Settings'),
+                       '$disable_cw' => ['disable_cw', L10n::t('Disable Content Warning'), $disable_cw, L10n::t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This disables the automatic collapsing and sets the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')],
                        '$no_intelligent_shortening' => ['no_intelligent_shortening', L10n::t('Disable intelligent shortening'), $no_intelligent_shortening, L10n::t('Normally the system tries to find the best link to add to shortened posts. If this option is enabled then every shortened post will always point to the original friendica post.')],
                        '$ostatus_autofriend' => ['snautofollow', L10n::t("Automatically follow any GNU Social \x28OStatus\x29 followers/mentioners"), $ostatus_autofriend, L10n::t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.')],
                        '$default_group' => Group::displayGroupSelection(local_user(), $default_group, L10n::t("Default group for OStatus contacts")),
@@ -999,8 +989,6 @@ function settings_content(App $a)
         * ACCOUNT SETTINGS
         */
 
-       require_once('include/acl_selectors.php');
-
        $profile = dba::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
        if (!DBM::is_result($profile)) {
                notice(L10n::t('Unable to find your profile. Please contact your admin.') . EOL);
@@ -1026,9 +1014,6 @@ function settings_content(App $a)
        $expire_photos = PConfig::get(local_user(), 'expire', 'photos', false);
        $expire_network_only = PConfig::get(local_user(), 'expire', 'network_only', false);
        $suggestme = PConfig::get(local_user(), 'system', 'suggestme', false);
-       $post_newfriend = PConfig::get(local_user(), 'system', 'post_newfriend', false);
-       $post_joingroup = PConfig::get(local_user(), 'system', 'post_joingroup', false);
-       $post_profilechange = PConfig::get(local_user(), 'system', 'post_profilechange', false);
 
        // nowarn_insecure
 
@@ -1106,40 +1091,40 @@ function settings_content(App $a)
                $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
        } else {
                $profile_in_dir = replace_macros($opt_tpl, [
-                       '$field' => ['profile_in_directory', L10n::t('Publish your default profile in your local site directory?'), $profile['publish'], L10n::t("Your profile may be visible in public."), [L10n::t('No'), L10n::t('Yes')]]
+                       '$field' => ['profile_in_directory', L10n::t('Publish your default profile in your local site directory?'), $profile['publish'], 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.', System::baseUrl().'/directory'), [L10n::t('No'), L10n::t('Yes')]]
                ]);
        }
 
        if (strlen(Config::get('system', 'directory'))) {
                $profile_in_net_dir = replace_macros($opt_tpl, [
-                       '$field' => ['profile_in_netdirectory', L10n::t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', [L10n::t('No'), L10n::t('Yes')]]
+                       '$field' => ['profile_in_netdirectory', L10n::t('Publish your default profile in the global social directory?'), $profile['net-publish'], L10n::t('Your profile will be published in the global friendica directories (e.g. <a href="%s">%s</a>). Your profile will be visible in public.', Config::get('system', 'directory'), Config::get('system', 'directory')), [L10n::t('No'), L10n::t('Yes')]]
                ]);
        } else {
                $profile_in_net_dir = '';
        }
 
        $hide_friends = replace_macros($opt_tpl, [
-               '$field' => ['hide-friends', L10n::t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', [L10n::t('No'), L10n::t('Yes')]],
+               '$field' => ['hide-friends', L10n::t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], L10n::t('Your contact list won\'t be shown in your default profile page. You can decide to show your contact list separately for each additional profile you create'), [L10n::t('No'), L10n::t('Yes')]],
        ]);
 
        $hide_wall = replace_macros($opt_tpl, [
-               '$field' => ['hidewall', L10n::t('Hide your profile details from unknown viewers?'), $a->user['hidewall'], L10n::t("If enabled, posting public messages to Diaspora and other networks isn't possible."), [L10n::t('No'), L10n::t('Yes')]],
+               '$field' => ['hidewall', L10n::t('Hide your profile details from anonymous viewers?'), $a->user['hidewall'], 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.'), [L10n::t('No'), L10n::t('Yes')]],
        ]);
 
        $blockwall = replace_macros($opt_tpl, [
-               '$field' => ['blockwall', L10n::t('Allow friends to post to your profile page?'), (intval($a->user['blockwall']) ? '0' : '1'), '', [L10n::t('No'), L10n::t('Yes')]],
+               '$field' => ['blockwall', L10n::t('Allow friends to post to your profile page?'), (intval($a->user['blockwall']) ? '0' : '1'), L10n::t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts'), [L10n::t('No'), L10n::t('Yes')]],
        ]);
 
        $blocktags = replace_macros($opt_tpl, [
-               '$field' => ['blocktags', L10n::t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), '', [L10n::t('No'), L10n::t('Yes')]],
+               '$field' => ['blocktags', L10n::t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), L10n::t('Your contacts can add additional tags to your posts.'), [L10n::t('No'), L10n::t('Yes')]],
        ]);
 
        $suggestme = replace_macros($opt_tpl, [
-               '$field' => ['suggestme', L10n::t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', [L10n::t('No'), L10n::t('Yes')]],
+               '$field' => ['suggestme', L10n::t('Allow us to suggest you as a potential friend to new members?'), $suggestme, L10n::t('If you like, Friendica may suggest new members to add you as a contact.'), [L10n::t('No'), L10n::t('Yes')]],
        ]);
 
        $unkmail = replace_macros($opt_tpl, [
-               '$field' => ['unkmail', L10n::t('Permit unknown people to send you private mail?'), $unkmail, '', [L10n::t('No'), L10n::t('Yes')]],
+               '$field' => ['unkmail', L10n::t('Permit unknown people to send you private mail?'), $unkmail, L10n::t('Friendica network users may send you private messages even if they are not in your contact list.'), [L10n::t('No'), L10n::t('Yes')]],
        ]);
 
        if (!$profile['publish'] && !$profile['net-publish']) {
@@ -1224,7 +1209,7 @@ function settings_content(App $a)
                '$permissions' => L10n::t('Default Post Permissions'),
                '$permdesc' => L10n::t("\x28click to open/close\x29"),
                '$visibility' => $profile['net-publish'],
-               '$aclselect' => populate_acl($a->user),
+               '$aclselect' => ACL::getFullSelectorHTML($a->user),
                '$suggestme' => $suggestme,
                '$blockwall'=> $blockwall, // array('blockwall', L10n::t('Allow friends to post to your profile page:'), !$blockwall, ''),
                '$blocktags'=> $blocktags, // array('blocktags', L10n::t('Allow friends to tag your posts:'), !$blocktags, ''),
@@ -1253,10 +1238,6 @@ function settings_content(App $a)
 
 
                '$h_not'        => L10n::t('Notification Settings'),
-               '$activity_options' => L10n::t('By default post a status message when:'),
-               '$post_newfriend' => ['post_newfriend',  L10n::t('accepting a friend request'), $post_newfriend, ''],
-               '$post_joingroup' => ['post_joingroup',  L10n::t('joining a forum/community'), $post_joingroup, ''],
-               '$post_profilechange' => ['post_profilechange',  L10n::t('making an <em>interesting</em> profile change'), $post_profilechange, ''],
                '$lbl_not'      => L10n::t('Send a notification email when:'),
                '$notify1'      => ['notify1', L10n::t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''],
                '$notify2'      => ['notify2', L10n::t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''],
@@ -1275,7 +1256,7 @@ function settings_content(App $a)
 
                '$detailed_notif' => ['detailed_notif', L10n::t('Show detailled notifications'),
                                                                        PConfig::get(local_user(), 'system', 'detailed_notif'),
-                                                                       L10n::t('Per default the notificiation are condensed to a single notification per item. When enabled, every notification is displayed.')],
+                                                                       L10n::t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.')],
 
                '$h_advn' => L10n::t('Advanced Account/Page Type Settings'),
                '$h_descadvn' => L10n::t('Change the behaviour of this account for special situations'),