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\Protocol\Email;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
+use Friendica\Module\Login;
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;
],
];
+ $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'),
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
$key = $_POST['remove'];
- dba::delete('tokens', ['id' => $key, 'uid' => local_user()]);
+ DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]);
goaway(System::baseUrl(true)."/settings/oauth/");
return;
}
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()
);
}
$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())
);
$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);
Theme::install($theme);
$r = q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d",
- dbesc($theme),
+ DBA::escape($theme),
intval(local_user())
);
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);
}
// 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 .= 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'];
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);
if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {
if (Network::isUrlValid($openid)) {
logger('updating openidserver');
- $open_id_obj = new LightOpenID($a->get_hostname());
+ $open_id_obj = new LightOpenID($a->getHostName());
$open_id_obj->identity = $openid;
$openidserver = $open_id_obj->discover($open_id_obj->identity);
} else {
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) {
`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);
}
`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 (!local_user()) {
//notice(L10n::t('Permission denied.') . EOL);
- return;
+ return Login::form();
}
if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
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;
}
if (($a->argc > 3) && ($a->argv[2] === 'delete')) {
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
- dba::delete('clients', ['client_id' => $a->argv[3], 'uid' => 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
$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');
}
$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');
'$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'),
'$theme_config' => $theme_config,
]);
- $tpl = get_markup_template('settings/display_end.tpl');
- $a->page['end'] .= replace_macros($tpl, [
- '$theme' => ['theme', L10n::t('Display Theme:'), $theme_selected, '', $themes]
- ]);
-
return $o;
}
* ACCOUNT SETTINGS
*/
- $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;
}
// 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');
'$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)],
]);
]);
$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, [
$tpl_addr = get_markup_template('settings/nick_set.tpl');
$prof_addr = replace_macros($tpl_addr,[
- '$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->get_hostname() . $a->get_path(), System::baseUrl() . '/profile/' . $nickname),
- '$basepath' => $a->get_hostname()
+ '$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->getHostName() . $a->getURLpath(), System::baseUrl() . '/profile/' . $nickname),
+ '$basepath' => $a->getHostName()
]);
$stpl = get_markup_template('settings/settings.tpl');
// 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;
}