Merge pull request #5719 from annando/notices-yeah
[friendica.git/.git] / mod / settings.php
index 5fd67af..84bc230 100644 (file)
@@ -6,30 +6,32 @@
 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\Database\DBA;
+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'];
+       $base_theme = defaults($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 ($base_theme && file_exists("view/theme/$base_theme/config.php")) {
                return "view/theme/$base_theme/config.php";
        }
        return null;
@@ -58,6 +60,13 @@ function settings_init(App $a)
                ],
        ];
 
+       $tabs[] =       [
+               'label' => L10n::t('Profiles'),
+               'url'   => 'profiles',
+               'selected'      => (($a->argc == 1) && ($a->argv[0] === 'profiles')?'active':''),
+               'accesskey' => 'p',
+       ];
+
        if (Feature::get()) {
                $tabs[] =       [
                                        'label' => L10n::t('Additional features'),
@@ -147,9 +156,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;
        }
@@ -175,23 +182,23 @@ function settings_post(App $a)
                                                        icon='%s',
                                                        uid=%d
                                                WHERE client_id='%s'",
-                                       dbesc($key),
-                                       dbesc($secret),
-                                       dbesc($name),
-                                       dbesc($redirect),
-                                       dbesc($icon),
+                                       DBA::escape($key),
+                                       DBA::escape($secret),
+                                       DBA::escape($name),
+                                       DBA::escape($redirect),
+                                       DBA::escape($icon),
                                        local_user(),
-                                       dbesc($key)
+                                       DBA::escape($key)
                                );
                        } else {
                                q("INSERT INTO clients
                                                        (client_id, pw, name, redirect_uri, icon, uid)
                                                VALUES ('%s', '%s', '%s', '%s', '%s',%d)",
-                                       dbesc($key),
-                                       dbesc($secret),
-                                       dbesc($name),
-                                       dbesc($redirect),
-                                       dbesc($icon),
+                                       DBA::escape($key),
+                                       DBA::escape($secret),
+                                       DBA::escape($name),
+                                       DBA::escape($redirect),
+                                       DBA::escape($icon),
                                        local_user()
                                );
                        }
@@ -211,6 +218,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']);
@@ -238,24 +246,24 @@ function settings_post(App $a)
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval(local_user())
                                );
-                               if (!DBM::is_result($r)) {
-                                       dba::insert('mailacct', ['uid' => local_user()]);
+                               if (!DBA::isResult($r)) {
+                                       DBA::insert('mailacct', ['uid' => local_user()]);
                                }
                                if (strlen($mail_pass)) {
                                        $pass = '';
                                        openssl_public_encrypt($mail_pass, $pass, $a->user['pubkey']);
-                                       dba::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]);
+                                       DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]);
                                }
                                $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
                                        `action` = %d, `movetofolder` = '%s',
                                        `mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d",
-                                       dbesc($mail_server),
+                                       DBA::escape($mail_server),
                                        intval($mail_port),
-                                       dbesc($mail_ssl),
-                                       dbesc($mail_user),
+                                       DBA::escape($mail_ssl),
+                                       DBA::escape($mail_user),
                                        intval($mail_action),
-                                       dbesc($mail_movetofolder),
-                                       dbesc($mail_replyto),
+                                       DBA::escape($mail_movetofolder),
+                                       DBA::escape($mail_replyto),
                                        intval($mail_pubmail),
                                        intval(local_user())
                                );
@@ -263,7 +271,7 @@ function settings_post(App $a)
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval(local_user())
                                );
-                               if (DBM::is_result($r)) {
+                               if (DBA::isResult($r)) {
                                        $eacct = $r[0];
                                        $mb = Email::constructMailboxName($eacct);
 
@@ -352,9 +360,10 @@ function settings_post(App $a)
                                theme_post($a);
                        }
                }
+               Theme::install($theme);
 
                $r = q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d",
-                               dbesc($theme),
+                               DBA::escape($theme),
                                intval(local_user())
                );
 
@@ -386,17 +395,22 @@ 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);
-                       if (DBM::is_result($result)) {
+                       if (DBA::isResult($result)) {
                                info(L10n::t('Password changed.') . EOL);
                        } else {
                                notice(L10n::t('Password update failed. Please try again.') . EOL);
@@ -435,9 +449,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);
@@ -470,24 +481,21 @@ function settings_post(App $a)
        }
 
        // Adjust the page flag if the account type doesn't fit to the page flag.
-       if (($account_type == ACCOUNT_TYPE_PERSON) && !in_array($page_flags, [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE])) {
-               $page_flags = PAGE_NORMAL;
-       } elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, [PAGE_SOAPBOX])) {
-               $page_flags = PAGE_SOAPBOX;
-       } elseif (($account_type == ACCOUNT_TYPE_NEWS) && !in_array($page_flags, [PAGE_SOAPBOX])) {
-               $page_flags = PAGE_SOAPBOX;
-       } elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
-               $page_flags = PAGE_COMMUNITY;
+       if (($account_type == Contact::ACCOUNT_TYPE_PERSON) && !in_array($page_flags, [Contact::PAGE_NORMAL, Contact::PAGE_SOAPBOX, Contact::PAGE_FREELOVE])) {
+               $page_flags = Contact::PAGE_NORMAL;
+       } elseif (($account_type == Contact::ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, [Contact::PAGE_SOAPBOX])) {
+               $page_flags = Contact::PAGE_SOAPBOX;
+       } elseif (($account_type == Contact::ACCOUNT_TYPE_NEWS) && !in_array($page_flags, [Contact::PAGE_SOAPBOX])) {
+               $page_flags = Contact::PAGE_SOAPBOX;
+       } elseif (($account_type == Contact::ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) {
+               $page_flags = Contact::PAGE_COMMUNITY;
        }
 
        $email_changed = false;
 
        $err = '';
 
-       $name_change = false;
-
        if ($username != $a->user['username']) {
-               $name_change = true;
                if (strlen($username) > 40) {
                        $err .= L10n::t(' Please use a shorter name.');
                }
@@ -508,9 +516,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'];
@@ -527,10 +534,10 @@ function settings_post(App $a)
                date_default_timezone_set($timezone);
        }
 
-       $str_group_allow   = perms2str($_POST['group_allow']);
-       $str_contact_allow = perms2str($_POST['contact_allow']);
-       $str_group_deny    = perms2str($_POST['group_deny']);
-       $str_contact_deny  = perms2str($_POST['contact_deny']);
+       $str_group_allow   = !empty($_POST['group_allow'])   ? perms2str($_POST['group_allow'])   : '';
+       $str_contact_allow = !empty($_POST['contact_allow']) ? perms2str($_POST['contact_allow']) : '';
+       $str_group_deny    = !empty($_POST['group_deny'])    ? perms2str($_POST['group_deny'])    : '';
+       $str_contact_deny  = !empty($_POST['contact_deny'])  ? perms2str($_POST['contact_deny'])  : '';
 
        $openidserver = $a->user['openidserver'];
        //$openid = normalise_openid($openid);
@@ -539,7 +546,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 {
@@ -554,14 +561,11 @@ 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);
 
-       if ($page_flags == PAGE_PRVGROUP) {
+       if ($page_flags == Contact::PAGE_PRVGROUP) {
                $hidewall = 1;
                if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) {
                        if ($def_gid) {
@@ -582,32 +586,32 @@ function settings_post(App $a)
                                `def_gid` = %d, `blockwall` = %d, `hidewall` = %d, `blocktags` = %d,
                                `unkmail` = %d, `cntunkmail` = %d, `language` = '%s'
                        WHERE `uid` = %d",
-                       dbesc($username),
-                       dbesc($email),
-                       dbesc($openid),
-                       dbesc($timezone),
-                       dbesc($str_contact_allow),
-                       dbesc($str_group_allow),
-                       dbesc($str_contact_deny),
-                       dbesc($str_group_deny),
+                       DBA::escape($username),
+                       DBA::escape($email),
+                       DBA::escape($openid),
+                       DBA::escape($timezone),
+                       DBA::escape($str_contact_allow),
+                       DBA::escape($str_group_allow),
+                       DBA::escape($str_contact_deny),
+                       DBA::escape($str_group_deny),
                        intval($notify),
                        intval($page_flags),
                        intval($account_type),
-                       dbesc($defloc),
+                       DBA::escape($defloc),
                        intval($allow_location),
                        intval($maxreq),
                        intval($expire),
-                       dbesc($openidserver),
+                       DBA::escape($openidserver),
                        intval($def_gid),
                        intval($blockwall),
                        intval($hidewall),
                        intval($blocktags),
                        intval($unkmail),
                        intval($cntunkmail),
-                       dbesc($language),
+                       DBA::escape($language),
                        intval(local_user())
        );
-       if (DBM::is_result($r)) {
+       if (DBA::isResult($r)) {
                info(L10n::t('Settings updated.') . EOL);
        }
 
@@ -621,20 +625,13 @@ function settings_post(App $a)
                `hide-friends` = %d
                WHERE `is-default` = 1 AND `uid` = %d",
                intval($publish),
-               dbesc($username),
+               DBA::escape($username),
                intval($net_publish),
                intval($hide_friends),
                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
@@ -688,10 +685,10 @@ function settings_content(App $a)
 
                if (($a->argc > 3) && ($a->argv[2] === 'edit')) {
                        $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d",
-                                       dbesc($a->argv[3]),
+                                       DBA::escape($a->argv[3]),
                                        local_user());
 
-                       if (!DBM::is_result($r)) {
+                       if (!DBA::isResult($r)) {
                                notice(L10n::t("You can't edit this application."));
                                return;
                        }
@@ -715,14 +712,12 @@ 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;
                }
 
-               /// @TODO validate result with DBM::is_result()
+               /// @TODO validate result with DBA::isResult()
                $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my
                                FROM clients
                                LEFT JOIN tokens ON clients.client_id=tokens.client_id
@@ -751,7 +746,7 @@ function settings_content(App $a)
                $settings_addons = "";
 
                $r = q("SELECT * FROM `hook` WHERE `hook` = 'addon_settings' ");
-               if (!DBM::is_result($r)) {
+               if (!DBA::isResult($r)) {
                        $settings_addons = L10n::t('No Addon settings configured');
                }
 
@@ -790,6 +785,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');
@@ -823,15 +819,15 @@ function settings_content(App $a)
                        $r = null;
                }
 
-               $mail_server       = ((DBM::is_result($r)) ? $r[0]['server'] : '');
-               $mail_port         = ((DBM::is_result($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
-               $mail_ssl          = ((DBM::is_result($r)) ? $r[0]['ssltype'] : '');
-               $mail_user         = ((DBM::is_result($r)) ? $r[0]['user'] : '');
-               $mail_replyto      = ((DBM::is_result($r)) ? $r[0]['reply_to'] : '');
-               $mail_pubmail      = ((DBM::is_result($r)) ? $r[0]['pubmail'] : 0);
-               $mail_action       = ((DBM::is_result($r)) ? $r[0]['action'] : 0);
-               $mail_movetofolder = ((DBM::is_result($r)) ? $r[0]['movetofolder'] : '');
-               $mail_chk          = ((DBM::is_result($r)) ? $r[0]['last_check'] : NULL_DATE);
+               $mail_server       = ((DBA::isResult($r)) ? $r[0]['server'] : '');
+               $mail_port         = ((DBA::isResult($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
+               $mail_ssl          = ((DBA::isResult($r)) ? $r[0]['ssltype'] : '');
+               $mail_user         = ((DBA::isResult($r)) ? $r[0]['user'] : '');
+               $mail_replyto      = ((DBA::isResult($r)) ? $r[0]['reply_to'] : '');
+               $mail_pubmail      = ((DBA::isResult($r)) ? $r[0]['pubmail'] : 0);
+               $mail_action       = ((DBA::isResult($r)) ? $r[0]['action'] : 0);
+               $mail_movetofolder = ((DBA::isResult($r)) ? $r[0]['movetofolder'] : '');
+               $mail_chk          = ((DBA::isResult($r)) ? $r[0]['last_check'] : NULL_DATE);
 
 
                $tpl = get_markup_template('settings/connectors.tpl');
@@ -847,6 +843,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")),
@@ -975,7 +972,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'),
@@ -998,10 +995,8 @@ 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)) {
+       $profile = DBA::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
+       if (!DBA::isResult($profile)) {
                notice(L10n::t('Unable to find your profile. Please contact your admin.') . EOL);
                return;
        }
@@ -1025,9 +1020,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
 
@@ -1037,9 +1029,9 @@ function settings_content(App $a)
 
        // Set the account type to "Community" when the page is a community page but the account type doesn't fit
        // This is only happening on the first visit after the update
-       if (in_array($a->user['page-flags'], [PAGE_COMMUNITY, PAGE_PRVGROUP]) &&
-               ($a->user['account-type'] != ACCOUNT_TYPE_COMMUNITY))
-               $a->user['account-type'] = ACCOUNT_TYPE_COMMUNITY;
+       if (in_array($a->user['page-flags'], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]) &&
+               ($a->user['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY))
+               $a->user['account-type'] = Contact::ACCOUNT_TYPE_COMMUNITY;
 
        $pageset_tpl = get_markup_template('settings/pagetypes.tpl');
 
@@ -1048,46 +1040,46 @@ function settings_content(App $a)
                '$user'                 => L10n::t("Personal Page Subtypes"),
                '$community'            => L10n::t("Community Forum Subtypes"),
                '$account_type'         => $a->user['account-type'],
-               '$type_person'          => ACCOUNT_TYPE_PERSON,
-               '$type_organisation'    => ACCOUNT_TYPE_ORGANISATION,
-               '$type_news'            => ACCOUNT_TYPE_NEWS,
-               '$type_community'       => ACCOUNT_TYPE_COMMUNITY,
+               '$type_person'          => Contact::ACCOUNT_TYPE_PERSON,
+               '$type_organisation'    => Contact::ACCOUNT_TYPE_ORGANISATION,
+               '$type_news'            => Contact::ACCOUNT_TYPE_NEWS,
+               '$type_community'       => Contact::ACCOUNT_TYPE_COMMUNITY,
 
-               '$account_person'       => ['account-type', L10n::t('Personal Page'), ACCOUNT_TYPE_PERSON,
+               '$account_person'       => ['account-type', L10n::t('Personal Page'), Contact::ACCOUNT_TYPE_PERSON,
                                                                        L10n::t('Account for a personal profile.'),
-                                                                       ($a->user['account-type'] == ACCOUNT_TYPE_PERSON)],
+                                                                       ($a->user['account-type'] == Contact::ACCOUNT_TYPE_PERSON)],
 
-               '$account_organisation' => ['account-type', L10n::t('Organisation Page'), ACCOUNT_TYPE_ORGANISATION,
+               '$account_organisation' => ['account-type', L10n::t('Organisation Page'), Contact::ACCOUNT_TYPE_ORGANISATION,
                                                                        L10n::t('Account for an organisation that automatically approves contact requests as "Followers".'),
-                                                                       ($a->user['account-type'] == ACCOUNT_TYPE_ORGANISATION)],
+                                                                       ($a->user['account-type'] == Contact::ACCOUNT_TYPE_ORGANISATION)],
 
-               '$account_news'         => ['account-type', L10n::t('News Page'), ACCOUNT_TYPE_NEWS,
+               '$account_news'         => ['account-type', L10n::t('News Page'), Contact::ACCOUNT_TYPE_NEWS,
                                                                        L10n::t('Account for a news reflector that automatically approves contact requests as "Followers".'),
-                                                                       ($a->user['account-type'] == ACCOUNT_TYPE_NEWS)],
+                                                                       ($a->user['account-type'] == Contact::ACCOUNT_TYPE_NEWS)],
 
-               '$account_community'    => ['account-type', L10n::t('Community Forum'), ACCOUNT_TYPE_COMMUNITY,
+               '$account_community'    => ['account-type', L10n::t('Community Forum'), Contact::ACCOUNT_TYPE_COMMUNITY,
                                                                        L10n::t('Account for community discussions.'),
-                                                                       ($a->user['account-type'] == ACCOUNT_TYPE_COMMUNITY)],
+                                                                       ($a->user['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY)],
 
-               '$page_normal'          => ['page-flags', L10n::t('Normal Account Page'), PAGE_NORMAL,
+               '$page_normal'          => ['page-flags', L10n::t('Normal Account Page'), Contact::PAGE_NORMAL,
                                                                        L10n::t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'),
-                                                                       ($a->user['page-flags'] == PAGE_NORMAL)],
+                                                                       ($a->user['page-flags'] == Contact::PAGE_NORMAL)],
 
-               '$page_soapbox'         => ['page-flags', L10n::t('Soapbox Page'), PAGE_SOAPBOX,
+               '$page_soapbox'         => ['page-flags', L10n::t('Soapbox Page'), Contact::PAGE_SOAPBOX,
                                                                        L10n::t('Account for a public profile that automatically approves contact requests as "Followers".'),
-                                                                       ($a->user['page-flags'] == PAGE_SOAPBOX)],
+                                                                       ($a->user['page-flags'] == Contact::PAGE_SOAPBOX)],
 
-               '$page_community'       => ['page-flags', L10n::t('Public Forum'), PAGE_COMMUNITY,
+               '$page_community'       => ['page-flags', L10n::t('Public Forum'), Contact::PAGE_COMMUNITY,
                                                                        L10n::t('Automatically approves all contact requests.'),
-                                                                       ($a->user['page-flags'] == PAGE_COMMUNITY)],
+                                                                       ($a->user['page-flags'] == Contact::PAGE_COMMUNITY)],
 
-               '$page_freelove'        => ['page-flags', L10n::t('Automatic Friend Page'), PAGE_FREELOVE,
+               '$page_freelove'        => ['page-flags', L10n::t('Automatic Friend Page'), Contact::PAGE_FREELOVE,
                                                                        L10n::t('Account for a popular profile that automatically approves contact requests as "Friends".'),
-                                                                       ($a->user['page-flags'] == PAGE_FREELOVE)],
+                                                                       ($a->user['page-flags'] == Contact::PAGE_FREELOVE)],
 
-               '$page_prvgroup'        => ['page-flags', L10n::t('Private Forum [Experimental]'), PAGE_PRVGROUP,
+               '$page_prvgroup'        => ['page-flags', L10n::t('Private Forum [Experimental]'), Contact::PAGE_PRVGROUP,
                                                                        L10n::t('Requires manual approval of contact requests.'),
-                                                                       ($a->user['page-flags'] == PAGE_PRVGROUP)],
+                                                                       ($a->user['page-flags'] == Contact::PAGE_PRVGROUP)],
 
 
        ]);
@@ -1105,13 +1097,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 = '';
@@ -1122,7 +1114,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, [
@@ -1169,7 +1161,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;
        }
 
@@ -1223,7 +1215,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, ''),
@@ -1252,10 +1244,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, ''],
@@ -1274,7 +1262,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'),