pref_item_map = [
__('General') => [
Prefs::USER_LANGUAGE,
Prefs::USER_TIMEZONE,
'BLOCK_SEPARATOR',
Prefs::USER_CSS_THEME,
'BLOCK_SEPARATOR',
Prefs::ENABLE_API_ACCESS,
],
__('Feeds') => [
Prefs::DEFAULT_UPDATE_INTERVAL,
Prefs::FRESH_ARTICLE_MAX_AGE,
Prefs::DEFAULT_SEARCH_LANGUAGE,
'BLOCK_SEPARATOR',
Prefs::ENABLE_FEED_CATS,
'BLOCK_SEPARATOR',
Prefs::CONFIRM_FEED_CATCHUP,
Prefs::ON_CATCHUP_SHOW_NEXT_FEED,
'BLOCK_SEPARATOR',
Prefs::HIDE_READ_FEEDS,
Prefs::HIDE_READ_SHOWS_SPECIAL,
],
__('Articles') => [
Prefs::PURGE_OLD_DAYS,
Prefs::PURGE_UNREAD_ARTICLES,
'BLOCK_SEPARATOR',
Prefs::COMBINED_DISPLAY_MODE,
Prefs::CDM_EXPANDED,
'BLOCK_SEPARATOR',
Prefs::CDM_AUTO_CATCHUP,
Prefs::VFEED_GROUP_BY_FEED,
'BLOCK_SEPARATOR',
Prefs::SHOW_CONTENT_PREVIEW,
Prefs::STRIP_IMAGES,
],
__('Digest') => [
Prefs::DIGEST_ENABLE,
Prefs::DIGEST_CATCHUP,
Prefs::DIGEST_PREFERRED_TIME,
],
__('Advanced') => [
Prefs::BLACKLISTED_TAGS,
'BLOCK_SEPARATOR',
Prefs::LONG_DATE_FORMAT,
Prefs::SHORT_DATE_FORMAT,
'BLOCK_SEPARATOR',
Prefs::SSL_CERT_SERIAL,
'BLOCK_SEPARATOR',
Prefs::DISABLE_CONDITIONAL_COUNTERS,
Prefs::HEADLINES_NO_DISTINCT,
],
__('Debugging') => [
Prefs::DEBUG_HEADLINE_IDS,
],
];
$this->pref_help_bottom = [
Prefs::BLACKLISTED_TAGS => __("Never apply these tags automatically (comma-separated list)."),
];
$this->pref_help = [
Prefs::BLACKLISTED_TAGS => array(__("Blacklisted tags"), ""),
Prefs::DEFAULT_SEARCH_LANGUAGE => array(__("Default language"), __("Used for full-text search")),
Prefs::CDM_AUTO_CATCHUP => array(__("Mark read on scroll"), __("Mark articles as read as you scroll past them")),
Prefs::CDM_EXPANDED => array(__("Always expand articles")),
Prefs::COMBINED_DISPLAY_MODE => array(__("Combined mode"), __("Show flat list of articles instead of separate panels")),
Prefs::CONFIRM_FEED_CATCHUP => array(__("Confirm marking feeds as read")),
Prefs::DEFAULT_UPDATE_INTERVAL => array(__("Default update interval")),
Prefs::DIGEST_CATCHUP => array(__("Mark sent articles as read")),
Prefs::DIGEST_ENABLE => array(__("Enable digest"), __("Send daily digest of new (and unread) headlines to your e-mail address")),
Prefs::DIGEST_PREFERRED_TIME => array(__("Try to send around this time"), __("Time in UTC")),
Prefs::ENABLE_API_ACCESS => array(__("Enable API"), __("Allows accessing this account through the API")),
Prefs::ENABLE_FEED_CATS => array(__("Enable categories")),
Prefs::FRESH_ARTICLE_MAX_AGE => array(__("Maximum age of fresh articles"), "" . __("hours") . ""),
Prefs::HIDE_READ_FEEDS => array(__("Hide read feeds")),
Prefs::HIDE_READ_SHOWS_SPECIAL => array(__("Always show special feeds"), __("While hiding read feeds")),
Prefs::LONG_DATE_FORMAT => array(__("Long date format"), __("Syntax is identical to PHP date() function.")),
Prefs::ON_CATCHUP_SHOW_NEXT_FEED => array(__("Automatically show next feed"), __("After marking one as read")),
Prefs::PURGE_OLD_DAYS => array(__("Purge articles older than"), __("days (0 disables)")),
Prefs::PURGE_UNREAD_ARTICLES => array(__("Purge unread articles")),
Prefs::SHORT_DATE_FORMAT => array(__("Short date format")),
Prefs::SHOW_CONTENT_PREVIEW => array(__("Show content preview in headlines")),
Prefs::SSL_CERT_SERIAL => array(__("SSL client certificate")),
Prefs::STRIP_IMAGES => array(__("Do not embed media")),
Prefs::USER_TIMEZONE => array(__("Time zone")),
Prefs::VFEED_GROUP_BY_FEED => array(__("Group by feed"), __("Group multiple-feed output by originating feed")),
Prefs::USER_LANGUAGE => array(__("Language")),
Prefs::USER_CSS_THEME => array(__("Theme")),
Prefs::HEADLINES_NO_DISTINCT => array(__("Don't enforce DISTINCT headlines"), __("May produce duplicate entries")),
Prefs::DEBUG_HEADLINE_IDS => array(__("Show article and feed IDs"), __("In the headlines buffer")),
Prefs::DISABLE_CONDITIONAL_COUNTERS => array(__("Disable conditional counter updates"), __("May increase server load")),
];
// hidden in the main prefs UI (use to hide things that have description set above)
$this->pref_blacklist = [
//
];
}
function changepassword() {
if (Config::get(Config::FORBID_PASSWORD_CHANGES)) {
print "ERROR: ".format_error("Access forbidden.");
return;
}
$old_pw = clean($_POST["old_password"]);
$new_pw = clean($_POST["new_password"]);
$new_unclean_pw = $_POST["new_password"];
$con_pw = clean($_POST["confirm_password"]);
if ($new_unclean_pw != $new_pw) {
print "ERROR: ".format_error("New password contains disallowed characters.");
return;
}
if ($old_pw == $new_pw) {
print "ERROR: ".format_error("New password must be different from the old one.");
return;
}
if ($old_pw == "") {
print "ERROR: ".format_error("Old password cannot be blank.");
return;
}
if ($new_pw == "") {
print "ERROR: ".format_error("New password cannot be blank.");
return;
}
if ($new_pw != $con_pw) {
print "ERROR: ".format_error("Entered passwords do not match.");
return;
}
$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
if (method_exists($authenticator, "change_password")) {
print format_notice($authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw));
} else {
print "ERROR: ".format_error("Function not supported by authentication module.");
}
}
function saveconfig() {
$boolean_prefs = explode(",", clean($_POST["boolean_prefs"]));
foreach ($boolean_prefs as $pref) {
if (!isset($_POST[$pref])) $_POST[$pref] = 'false';
}
$need_reload = false;
foreach (array_keys($_POST) as $pref_name) {
$value = $_POST[$pref_name];
switch ($pref_name) {
case Prefs::DIGEST_PREFERRED_TIME:
if (get_pref(Prefs::DIGEST_PREFERRED_TIME) != $value) {
$sth = $this->pdo->prepare("UPDATE ttrss_users SET
last_digest_sent = NULL WHERE id = ?");
$sth->execute([$_SESSION['uid']]);
}
break;
case Prefs::USER_LANGUAGE:
if (!$need_reload) $need_reload = $_SESSION["language"] != $value;
break;
case Prefs::USER_CSS_THEME:
if (!$need_reload) $need_reload = get_pref($pref_name) != $value;
break;
case Prefs::BLACKLISTED_TAGS:
$cats = FeedItem_Common::normalize_categories(explode(",", $value));
asort($cats);
$value = implode(", ", $cats);
break;
}
if (Prefs::is_valid($pref_name)) {
Prefs::set($pref_name, $value, $_SESSION["uid"], $_SESSION["profile"] ?? null);
}
}
if ($need_reload) {
print "PREFS_NEED_RELOAD";
} else {
print __("The configuration was saved.");
}
}
function changePersonalData() {
$user = ORM::for_table('ttrss_users')->find_one($_SESSION['uid']);
$new_email = clean($_POST['email']);
if ($user) {
$user->full_name = clean($_POST['full_name']);
if ($user->email != $new_email)
Logger::log(E_USER_NOTICE, "Email address of user ".$user->login." has been changed to ${new_email}.");
if ($user->email && $user->email != $new_email) {
$mailer = new Mailer();
$tpl = new Templator();
$tpl->readTemplateFromFile("mail_change_template.txt");
$tpl->setVariable('LOGIN', $user->login);
$tpl->setVariable('NEWMAIL', $new_email);
$tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH));
$tpl->addBlock('message');
$tpl->generateOutputToString($message);
$mailer->mail(["to_name" => $user->login,
"to_address" => $user->email,
"subject" => "[tt-rss] Email address change notification",
"message" => $message]);
$user->email = $new_email;
}
$user->save();
}
print __("Your personal data has been saved.");
}
function resetconfig() {
Prefs::reset($_SESSION["uid"], $_SESSION["profile"]);
print "PREFS_NEED_RELOAD";
}
private function index_auth_personal() {
$user = ORM::for_table('ttrss_users')->find_one($_SESSION['uid']);
?>
get_plugin($_SESSION["auth_module"]);
} else {
$authenticator = false;
}
$otp_enabled = UserHelper::is_otp_enabled($_SESSION["uid"]);
if ($authenticator && method_exists($authenticator, "change_password")) {
?>
%s) does not provide an ability to set passwords.",
$_SESSION["auth_module"]));
}
}
private function index_auth_app_passwords() {
print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP.");
?>
appPasswordList() ?>
" . __("Scan the following code by the Authenticator application or copy the key manually") . "";
print "";
} else {
print_error("PHP GD functions are required to generate QR codes.");
print "
" . __("Use the following OTP key with a compatible Authenticator application") . "