rewording
[friendica.git/.git] / mod / settings.php
index 8def780..9c1142a 100644 (file)
@@ -12,13 +12,14 @@ 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;
 
@@ -148,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;
        }
@@ -212,6 +211,7 @@ function settings_post(App $a)
                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),
@@ -441,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);
@@ -490,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.');
                }
@@ -545,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 {
@@ -560,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);
@@ -633,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
@@ -721,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;
                }
@@ -796,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');
@@ -853,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")),
@@ -1029,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
 
@@ -1109,13 +1091,13 @@ 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 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')]]
+                       '$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('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')]]
+                       '$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 = '';
@@ -1126,7 +1108,7 @@ function settings_content(App $a)
        ]);
 
        $hide_wall = replace_macros($opt_tpl, [
-               '$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. Disables posting public messages to Diaspora and other networks.'), [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, [
@@ -1256,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, ''],