]> git.mxchange.org Git - friendica.git/blobdiff - mod/settings.php
Replace global $lang with system.language
[friendica.git] / mod / settings.php
index 8def780a592a6f85cba0acb803ba011aec26626c..34e9ce41ec0f7e780e403f5d6ad190b25396e7f8 100644 (file)
@@ -12,25 +12,28 @@ 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;
 
 function get_theme_config_file($theme)
 {
        $a = get_app();
-       $base_theme = $a->theme_info['extends'];
+       if (!empty($a->theme_info['extends'])) {
+               $base_theme = $a->theme_info['extends'];
+       }
 
        if (file_exists("view/theme/$theme/config.php")) {
                return "view/theme/$theme/config.php";
        }
-       if (file_exists("view/theme/$base_theme/config.php")) {
+       if (!empty($base_theme) && file_exists("view/theme/$base_theme/config.php")) {
                return "view/theme/$base_theme/config.php";
        }
        return null;
@@ -148,9 +151,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 +213,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 +355,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 +444,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 +490,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.');
                }
@@ -514,9 +511,8 @@ function settings_post(App $a)
                        $err .= L10n::t('Invalid email.');
                }
                //  ensure new email is not the admin mail
-               //if ((x($a->config, 'admin_email')) && (strcasecmp($email, $a->config['admin_email']) == 0)) {
-               if (x($a->config, 'admin_email')) {
-                       $adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
+               if (Config::get('config', 'admin_email')) {
+                       $adminlist = explode(",", str_replace(" ", "", strtolower(Config::get('config', 'admin_email'))));
                        if (in_array(strtolower($email), $adminlist)) {
                                $err .= L10n::t('Cannot change to that email.');
                                $email = $a->user['email'];
@@ -545,7 +541,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 +556,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 +626,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 +707,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 +780,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 +838,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")),
@@ -981,7 +967,7 @@ function settings_content(App $a)
                        '$noinfo'       => ['noinfo', L10n::t("Don't show notices"), $noinfo, ''],
                        '$infinite_scroll'      => ['infinite_scroll', L10n::t("Infinite scroll"), $infinite_scroll, ''],
                        '$no_auto_update'       => ['no_auto_update', L10n::t("Automatic updates only at the top of the network page"), $no_auto_update, L10n::t('When disabled, the network page is updated all the time, which could be confusing while reading.')],
-                       '$bandwidth_saver' => ['bandwidth_saver', L10n::t('Bandwith Saver Mode'), $bandwidth_saver, L10n::t('When enabled, embedded content is not displayed on automatic updates, they only show on page reload.')],
+                       '$bandwidth_saver' => ['bandwidth_saver', L10n::t('Bandwidth Saver Mode'), $bandwidth_saver, L10n::t('When enabled, embedded content is not displayed on automatic updates, they only show on page reload.')],
                        '$smart_threading' => ['smart_threading', L10n::t('Smart Threading'), $smart_threading, L10n::t('When enabled, suppress extraneous thread indentation while keeping it where it matters. Only works if threading is available and enabled.')],
 
                        '$d_tset' => L10n::t('General Theme Settings'),
@@ -1029,9 +1015,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 +1092,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 +1109,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, [
@@ -1173,7 +1156,7 @@ function settings_content(App $a)
 
        // Private/public post links for the non-JS ACL form
        $private_post = 1;
-       if ($_REQUEST['public']) {
+       if (!empty($_REQUEST['public']) && !$_REQUEST['public']) {
                $private_post = 0;
        }
 
@@ -1256,10 +1239,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, ''],