use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\ACL;
-use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
function get_theme_config_file($theme)
{
- $a = get_app();
+ $theme = Strings::sanitizeFilePathItem($theme);
+
+ $a = \get_app();
$base_theme = defaults($a->theme_info, 'extends');
if (file_exists("view/theme/$theme/config.php")) {
],
];
+ $tabs[] = [
+ 'label' => L10n::t('Two-factor authentication'),
+ 'url' => 'settings/2fa',
+ 'selected' => (($a->argc > 1) && ($a->argv[1] === '2fa') ? 'active' : ''),
+ 'accesskey' => 'o',
+ ];
+
$tabs[] = [
'label' => L10n::t('Profiles'),
'url' => 'profiles',
if (($a->argc > 1) && ($a->argv[1] == 'addon')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/addon', 'settings_addon');
- Addon::callHooks('addon_settings_post', $_POST);
+ Hook::callAll('addon_settings_post', $_POST);
return;
}
}
}
- Addon::callHooks('connector_settings_post', $_POST);
+ Hook::callAll('connector_settings_post', $_POST);
return;
}
}
Theme::install($theme);
- $r = q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d",
+ q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d",
DBA::escape($theme),
intval(local_user())
);
- Addon::callHooks('display_settings_post', $_POST);
+ Hook::callAll('display_settings_post', $_POST);
$a->internalRedirect('settings/display');
return; // NOTREACHED
}
$a->internalRedirect('settings');
}
- Addon::callHooks('settings_post', $_POST);
+ Hook::callAll('settings_post', $_POST);
if (!empty($_POST['password']) || !empty($_POST['confirm'])) {
$newpass = $_POST['password'];
$confirm = $_POST['confirm'];
- $err = false;
- if ($newpass != $confirm) {
- notice(L10n::t('Passwords do not match. Password unchanged.') . EOL);
- $err = true;
- }
-
- if (empty($newpass) || empty($confirm)) {
- notice(L10n::t('Empty passwords are not allowed. Password unchanged.') . EOL);
- $err = true;
- }
+ try {
+ if ($newpass != $confirm) {
+ throw new Exception(L10n::t('Passwords do not match.'));
+ }
- 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
+ User::getIdFromPasswordAuthentication(local_user(), $_POST['opassword']);
- // 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 (DBA::isResult($result)) {
- info(L10n::t('Password changed.') . EOL);
- } else {
- notice(L10n::t('Password update failed. Please try again.') . EOL);
+ if (!DBA::isResult($result)) {
+ throw new Exception(L10n::t('Password update failed. Please try again.'));
}
+
+ info(L10n::t('Password changed.'));
+ } catch (Exception $e) {
+ notice($e->getMessage());
+ notice(L10n::t('Password unchanged.'));
}
}
}
// Adjust the page flag if the account type doesn't fit to the page flag.
- 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;
+ if (($account_type == User::ACCOUNT_TYPE_PERSON) && !in_array($page_flags, [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE])) {
+ $page_flags = User::PAGE_FLAGS_NORMAL;
+ } elseif (($account_type == User::ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, [User::PAGE_FLAGS_SOAPBOX])) {
+ $page_flags = User::PAGE_FLAGS_SOAPBOX;
+ } elseif (($account_type == User::ACCOUNT_TYPE_NEWS) && !in_array($page_flags, [User::PAGE_FLAGS_SOAPBOX])) {
+ $page_flags = User::PAGE_FLAGS_SOAPBOX;
+ } elseif (($account_type == User::ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
+ $page_flags = User::PAGE_FLAGS_COMMUNITY;
}
- $email_changed = false;
-
$err = '';
if ($username != $a->user['username']) {
}
if ($email != $a->user['email']) {
- $email_changed = true;
// check for the correct password
if (!User::authenticate(intval(local_user()), $_POST['mpassword'])) {
$err .= L10n::t('Wrong Password') . EOL;
PConfig::set(local_user(), 'system', 'email_textonly', $email_textonly);
PConfig::set(local_user(), 'system', 'detailed_notif', $detailed_notif);
- if ($page_flags == Contact::PAGE_PRVGROUP) {
+ if ($page_flags == User::PAGE_FLAGS_PRVGROUP) {
$hidewall = 1;
if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) {
if ($def_gid) {
// clear session language
unset($_SESSION['language']);
- $r = q("UPDATE `profile`
+ q("UPDATE `profile`
SET `publish` = %d,
`name` = '%s',
`net-publish` = %d,
$settings_addons = L10n::t('No Addon settings configured');
}
- Addon::callHooks('addon_settings', $settings_addons);
+ Hook::callAll('addon_settings', $settings_addons);
$tpl = Renderer::getMarkupTemplate('settings/addons.tpl');
}
$settings_connectors = '';
- Addon::callHooks('connector_settings', $settings_connectors);
+ Hook::callAll('connector_settings', $settings_connectors);
if (is_site_admin()) {
$diasp_enabled = L10n::t('Built-in support for %s connectivity is %s', L10n::t('Diaspora'), ((Config::get('system', 'diaspora_enabled')) ? L10n::t('enabled') : L10n::t('disabled')));
'$submit' => L10n::t('Save Settings'),
]);
- Addon::callHooks('display_settings', $o);
+ Hook::callAll('display_settings', $o);
return $o;
}
$default_mobile_theme = 'none';
}
- $allowed_themes_str = Config::get('system', 'allowed_themes');
- $allowed_themes_raw = explode(',', $allowed_themes_str);
- $allowed_themes = [];
- if (count($allowed_themes_raw)) {
- foreach ($allowed_themes_raw as $x) {
- if (strlen(trim($x)) && is_dir("view/theme/$x")) {
- $allowed_themes[] = trim($x);
- }
- }
- }
-
+ $allowed_themes = Theme::getAllowedList();
$themes = [];
$mobile_themes = ["---" => L10n::t('No special theme for mobile devices')];
- if ($allowed_themes) {
- foreach ($allowed_themes as $theme) {
- $is_experimental = file_exists('view/theme/' . $theme . '/experimental');
- $is_unsupported = file_exists('view/theme/' . $theme . '/unsupported');
- $is_mobile = file_exists('view/theme/' . $theme . '/mobile');
- if (!$is_experimental || ($is_experimental && (Config::get('experimentals', 'exp_themes')==1 || is_null(Config::get('experimentals', 'exp_themes'))))) {
- $theme_name = ucfirst($theme);
- if ($is_unsupported) {
- $theme_name = L10n::t("%s - \x28Unsupported\x29", $theme_name);
- } elseif ($is_experimental) {
- $theme_name = L10n::t("%s - \x28Experimental\x29", $theme_name);
- }
- if ($is_mobile) {
- $mobile_themes[$theme] = $theme_name;
- } else {
- $themes[$theme] = $theme_name;
- }
+ foreach ($allowed_themes as $theme) {
+ $is_experimental = file_exists('view/theme/' . $theme . '/experimental');
+ $is_unsupported = file_exists('view/theme/' . $theme . '/unsupported');
+ $is_mobile = file_exists('view/theme/' . $theme . '/mobile');
+ if (!$is_experimental || ($is_experimental && (Config::get('experimentals', 'exp_themes')==1 || is_null(Config::get('experimentals', 'exp_themes'))))) {
+ $theme_name = ucfirst($theme);
+ if ($is_unsupported) {
+ $theme_name = L10n::t('%s - (Unsupported)', $theme_name);
+ } elseif ($is_experimental) {
+ $theme_name = L10n::t('%s - (Experimental)', $theme_name);
+ }
+
+ if ($is_mobile) {
+ $mobile_themes[$theme] = $theme_name;
+ } else {
+ $themes[$theme] = $theme_name;
}
}
}
+
$theme_selected = defaults($_SESSION, 'theme' , $default_theme);
$mobile_theme_selected = defaults($_SESSION, 'mobile-theme', $default_mobile_theme);
// 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'], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]) &&
- ($a->user['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY))
- $a->user['account-type'] = Contact::ACCOUNT_TYPE_COMMUNITY;
+ if (in_array($a->user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]) &&
+ ($a->user['account-type'] != User::ACCOUNT_TYPE_COMMUNITY))
+ $a->user['account-type'] = User::ACCOUNT_TYPE_COMMUNITY;
$pageset_tpl = Renderer::getMarkupTemplate('settings/pagetypes.tpl');
'$user' => L10n::t("Personal Page Subtypes"),
'$community' => L10n::t("Community Forum Subtypes"),
'$account_type' => $a->user['account-type'],
- '$type_person' => Contact::ACCOUNT_TYPE_PERSON,
- '$type_organisation' => Contact::ACCOUNT_TYPE_ORGANISATION,
- '$type_news' => Contact::ACCOUNT_TYPE_NEWS,
- '$type_community' => Contact::ACCOUNT_TYPE_COMMUNITY,
+ '$type_person' => User::ACCOUNT_TYPE_PERSON,
+ '$type_organisation' => User::ACCOUNT_TYPE_ORGANISATION,
+ '$type_news' => User::ACCOUNT_TYPE_NEWS,
+ '$type_community' => User::ACCOUNT_TYPE_COMMUNITY,
- '$account_person' => ['account-type', L10n::t('Personal Page'), Contact::ACCOUNT_TYPE_PERSON,
+ '$account_person' => ['account-type', L10n::t('Personal Page'), User::ACCOUNT_TYPE_PERSON,
L10n::t('Account for a personal profile.'),
- ($a->user['account-type'] == Contact::ACCOUNT_TYPE_PERSON)],
+ ($a->user['account-type'] == User::ACCOUNT_TYPE_PERSON)],
- '$account_organisation' => ['account-type', L10n::t('Organisation Page'), Contact::ACCOUNT_TYPE_ORGANISATION,
+ '$account_organisation' => ['account-type', L10n::t('Organisation Page'), User::ACCOUNT_TYPE_ORGANISATION,
L10n::t('Account for an organisation that automatically approves contact requests as "Followers".'),
- ($a->user['account-type'] == Contact::ACCOUNT_TYPE_ORGANISATION)],
+ ($a->user['account-type'] == User::ACCOUNT_TYPE_ORGANISATION)],
- '$account_news' => ['account-type', L10n::t('News Page'), Contact::ACCOUNT_TYPE_NEWS,
+ '$account_news' => ['account-type', L10n::t('News Page'), User::ACCOUNT_TYPE_NEWS,
L10n::t('Account for a news reflector that automatically approves contact requests as "Followers".'),
- ($a->user['account-type'] == Contact::ACCOUNT_TYPE_NEWS)],
+ ($a->user['account-type'] == User::ACCOUNT_TYPE_NEWS)],
- '$account_community' => ['account-type', L10n::t('Community Forum'), Contact::ACCOUNT_TYPE_COMMUNITY,
+ '$account_community' => ['account-type', L10n::t('Community Forum'), User::ACCOUNT_TYPE_COMMUNITY,
L10n::t('Account for community discussions.'),
- ($a->user['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY)],
+ ($a->user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY)],
- '$page_normal' => ['page-flags', L10n::t('Normal Account Page'), Contact::PAGE_NORMAL,
+ '$page_normal' => ['page-flags', L10n::t('Normal Account Page'), User::PAGE_FLAGS_NORMAL,
L10n::t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'),
- ($a->user['page-flags'] == Contact::PAGE_NORMAL)],
+ ($a->user['page-flags'] == User::PAGE_FLAGS_NORMAL)],
- '$page_soapbox' => ['page-flags', L10n::t('Soapbox Page'), Contact::PAGE_SOAPBOX,
+ '$page_soapbox' => ['page-flags', L10n::t('Soapbox Page'), User::PAGE_FLAGS_SOAPBOX,
L10n::t('Account for a public profile that automatically approves contact requests as "Followers".'),
- ($a->user['page-flags'] == Contact::PAGE_SOAPBOX)],
+ ($a->user['page-flags'] == User::PAGE_FLAGS_SOAPBOX)],
- '$page_community' => ['page-flags', L10n::t('Public Forum'), Contact::PAGE_COMMUNITY,
+ '$page_community' => ['page-flags', L10n::t('Public Forum'), User::PAGE_FLAGS_COMMUNITY,
L10n::t('Automatically approves all contact requests.'),
- ($a->user['page-flags'] == Contact::PAGE_COMMUNITY)],
+ ($a->user['page-flags'] == User::PAGE_FLAGS_COMMUNITY)],
- '$page_freelove' => ['page-flags', L10n::t('Automatic Friend Page'), Contact::PAGE_FREELOVE,
+ '$page_freelove' => ['page-flags', L10n::t('Automatic Friend Page'), User::PAGE_FLAGS_FREELOVE,
L10n::t('Account for a popular profile that automatically approves contact requests as "Friends".'),
- ($a->user['page-flags'] == Contact::PAGE_FREELOVE)],
+ ($a->user['page-flags'] == User::PAGE_FLAGS_FREELOVE)],
- '$page_prvgroup' => ['page-flags', L10n::t('Private Forum [Experimental]'), Contact::PAGE_PRVGROUP,
+ '$page_prvgroup' => ['page-flags', L10n::t('Private Forum [Experimental]'), User::PAGE_FLAGS_PRVGROUP,
L10n::t('Requires manual approval of contact requests.'),
- ($a->user['page-flags'] == Contact::PAGE_PRVGROUP)],
+ ($a->user['page-flags'] == User::PAGE_FLAGS_PRVGROUP)],
]);
'$nickname_block' => $prof_addr,
'$h_pass' => L10n::t('Password Settings'),
- '$password1'=> ['password', L10n::t('New Password:'), '', ''],
+ '$password1'=> ['password', L10n::t('New Password:'), '', L10n::t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).')],
'$password2'=> ['confirm', L10n::t('Confirm:'), '', L10n::t('Leave password fields blank unless changing')],
'$password3'=> ['opassword', L10n::t('Current Password:'), '', L10n::t('Your current password to confirm the changes')],
'$password4'=> ['mpassword', L10n::t('Password:'), '', L10n::t('Your current password to confirm the changes')],
]);
- Addon::callHooks('settings_form', $o);
+ Hook::callAll('settings_form', $o);
$o .= '</form>' . "\r\n";