summaryrefslogtreecommitdiff
path: root/classes/pref
diff options
context:
space:
mode:
Diffstat (limited to 'classes/pref')
-rwxr-xr-xclasses/pref/feeds.php24
-rwxr-xr-xclasses/pref/filters.php2
-rw-r--r--classes/pref/prefs.php268
-rw-r--r--classes/pref/system.php2
4 files changed, 102 insertions, 194 deletions
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index 755413f13..c7d4f1925 100755
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -122,7 +122,7 @@ class Pref_Feeds extends Handler_Protected {
$root['param'] = 0;
$root['type'] = 'category';
- $enable_cats = get_pref('ENABLE_FEED_CATS');
+ $enable_cats = get_pref(Prefs::ENABLE_FEED_CATS);
if (clean($_REQUEST['mode'] ?? 0) == 2) {
@@ -171,7 +171,7 @@ class Pref_Feeds extends Handler_Protected {
ttrss_labels2 WHERE owner_uid = ? ORDER by caption");
$sth->execute([$_SESSION['uid']]);
- if (get_pref('ENABLE_FEED_CATS')) {
+ if (get_pref(Prefs::ENABLE_FEED_CATS)) {
$cat = $this->feedlist_init_cat(-2);
} else {
$cat['items'] = array();
@@ -527,11 +527,11 @@ class Pref_Feeds extends Handler_Protected {
$row["icon"] = Feeds::_get_icon($feed_id);
$local_update_intervals = $update_intervals;
- $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]);
+ $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref(Prefs::DEFAULT_UPDATE_INTERVAL)]);
if (Config::get(Config::FORCE_ARTICLE_PURGE) == 0) {
$local_purge_intervals = $purge_intervals;
- $default_purge_interval = get_pref("PURGE_OLD_DAYS");
+ $default_purge_interval = get_pref(Prefs::PURGE_OLD_DAYS);
if ($default_purge_interval > 0)
$local_purge_intervals[0] .= " " . T_nsprintf('(%d day)', '(%d days)', $default_purge_interval, $default_purge_interval);
@@ -546,7 +546,7 @@ class Pref_Feeds extends Handler_Protected {
print json_encode([
"feed" => $row,
"cats" => [
- "enabled" => get_pref('ENABLE_FEED_CATS'),
+ "enabled" => get_pref(Prefs::ENABLE_FEED_CATS),
"select" => \Controls\select_feeds_cats("cat_id", $row["cat_id"]),
],
"plugin_data" => $plugin_data,
@@ -557,7 +557,7 @@ class Pref_Feeds extends Handler_Protected {
],
"lang" => [
"enabled" => Config::get(Config::DB_TYPE) == "pgsql",
- "default" => get_pref('DEFAULT_SEARCH_LANGUAGE'),
+ "default" => get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE),
"all" => $this::get_ts_languages(),
]
]);
@@ -576,10 +576,10 @@ class Pref_Feeds extends Handler_Protected {
$feed_ids = clean($_REQUEST["ids"]);
$local_update_intervals = $update_intervals;
- $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]);
+ $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref(Prefs::DEFAULT_UPDATE_INTERVAL)]);
$local_purge_intervals = $purge_intervals;
- $default_purge_interval = get_pref("PURGE_OLD_DAYS");
+ $default_purge_interval = get_pref(Prefs::PURGE_OLD_DAYS);
if ($default_purge_interval > 0)
$local_purge_intervals[0] .= " " . T_sprintf("(%d days)", $default_purge_interval);
@@ -604,7 +604,7 @@ class Pref_Feeds extends Handler_Protected {
<div dojoType="dijit.layout.TabContainer" style="height : 450px">
<div dojoType="dijit.layout.ContentPane" title="<?= __('General') ?>">
<section>
- <?php if (get_pref('ENABLE_FEED_CATS')) { ?>
+ <?php if (get_pref(Prefs::ENABLE_FEED_CATS)) { ?>
<fieldset>
<label><?= __('Place in category:') ?></label>
<?= \Controls\select_feeds_cats("cat_id", null, ['disabled' => '1']) ?>
@@ -830,7 +830,7 @@ class Pref_Feeds extends Handler_Protected {
break;
case "cat_id":
- if (get_pref('ENABLE_FEED_CATS')) {
+ if (get_pref(Prefs::ENABLE_FEED_CATS)) {
if ($cat_id) {
$qpart = "cat_id = " . $this->pdo->quote($cat_id);
} else {
@@ -946,7 +946,7 @@ class Pref_Feeds extends Handler_Protected {
</div>
</div>
- <?php if (get_pref('ENABLE_FEED_CATS')) { ?>
+ <?php if (get_pref(Prefs::ENABLE_FEED_CATS)) { ?>
<div dojoType="fox.form.DropDownButton">
<span><?= __('Categories') ?></span>
<div dojoType="dijit.Menu" style="display: none">
@@ -1237,7 +1237,7 @@ class Pref_Feeds extends Handler_Protected {
function batchSubscribe() {
print json_encode([
- "enable_cats" => (int)get_pref('ENABLE_FEED_CATS'),
+ "enable_cats" => (int)get_pref(Prefs::ENABLE_FEED_CATS),
"cat_select" => \Controls\select_feeds_cats("cat")
]);
}
diff --git a/classes/pref/filters.php b/classes/pref/filters.php
index fda4a6513..a6ea9f982 100755
--- a/classes/pref/filters.php
+++ b/classes/pref/filters.php
@@ -848,7 +848,7 @@ class Pref_Filters extends Handler_Protected {
}
}
- if (get_pref('ENABLE_FEED_CATS')) {
+ if (get_pref(Prefs::ENABLE_FEED_CATS)) {
if (!$root_id) $root_id = null;
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index 0d0dcadbc..ba63d76b3 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -6,7 +6,6 @@ class Pref_Prefs extends Handler_Protected {
private $pref_item_map = [];
private $pref_help_bottom = [];
private $pref_blacklist = [];
- private $profile_blacklist = [];
function csrf_ignore($method) {
$csrf_ignored = array("index", "updateself", "otpqrcode");
@@ -19,106 +18,99 @@ class Pref_Prefs extends Handler_Protected {
$this->pref_item_map = [
__('General') => [
- 'USER_LANGUAGE',
- 'USER_TIMEZONE',
+ Prefs::USER_LANGUAGE,
+ Prefs::USER_TIMEZONE,
'BLOCK_SEPARATOR',
- 'USER_CSS_THEME',
+ Prefs::USER_CSS_THEME,
'BLOCK_SEPARATOR',
- 'ENABLE_API_ACCESS',
+ Prefs::ENABLE_API_ACCESS,
],
__('Feeds') => [
- 'DEFAULT_UPDATE_INTERVAL',
- 'FRESH_ARTICLE_MAX_AGE',
- 'DEFAULT_SEARCH_LANGUAGE',
+ Prefs::DEFAULT_UPDATE_INTERVAL,
+ Prefs::FRESH_ARTICLE_MAX_AGE,
+ Prefs::DEFAULT_SEARCH_LANGUAGE,
'BLOCK_SEPARATOR',
- 'ENABLE_FEED_CATS',
+ Prefs::ENABLE_FEED_CATS,
'BLOCK_SEPARATOR',
- 'CONFIRM_FEED_CATCHUP',
- 'ON_CATCHUP_SHOW_NEXT_FEED',
+ Prefs::CONFIRM_FEED_CATCHUP,
+ Prefs::ON_CATCHUP_SHOW_NEXT_FEED,
'BLOCK_SEPARATOR',
- 'HIDE_READ_FEEDS',
- 'HIDE_READ_SHOWS_SPECIAL',
+ Prefs::HIDE_READ_FEEDS,
+ Prefs::HIDE_READ_SHOWS_SPECIAL,
],
__('Articles') => [
- 'PURGE_OLD_DAYS',
- 'PURGE_UNREAD_ARTICLES',
+ Prefs::PURGE_OLD_DAYS,
+ Prefs::PURGE_UNREAD_ARTICLES,
'BLOCK_SEPARATOR',
- 'COMBINED_DISPLAY_MODE',
- 'CDM_EXPANDED',
+ Prefs::COMBINED_DISPLAY_MODE,
+ Prefs::CDM_EXPANDED,
'BLOCK_SEPARATOR',
- 'CDM_AUTO_CATCHUP',
- 'VFEED_GROUP_BY_FEED',
+ Prefs::CDM_AUTO_CATCHUP,
+ Prefs::VFEED_GROUP_BY_FEED,
'BLOCK_SEPARATOR',
- 'SHOW_CONTENT_PREVIEW',
- 'STRIP_IMAGES',
+ Prefs::SHOW_CONTENT_PREVIEW,
+ Prefs::STRIP_IMAGES,
],
__('Digest') => [
- 'DIGEST_ENABLE',
- 'DIGEST_CATCHUP',
- 'DIGEST_PREFERRED_TIME',
+ Prefs::DIGEST_ENABLE,
+ Prefs::DIGEST_CATCHUP,
+ Prefs::DIGEST_PREFERRED_TIME,
],
__('Advanced') => [
- 'BLACKLISTED_TAGS',
+ Prefs::BLACKLISTED_TAGS,
'BLOCK_SEPARATOR',
- 'LONG_DATE_FORMAT',
- 'SHORT_DATE_FORMAT',
+ Prefs::LONG_DATE_FORMAT,
+ Prefs::SHORT_DATE_FORMAT,
'BLOCK_SEPARATOR',
- 'SSL_CERT_SERIAL',
- ]
+ Prefs::SSL_CERT_SERIAL,
+ 'BLOCK_SEPARATOR',
+ Prefs::HEADLINES_NO_DISTINCT,
+ ],
+ __('Debugging') => [
+ Prefs::DEBUG_HEADLINE_IDS,
+ ],
];
$this->pref_help_bottom = [
- "BLACKLISTED_TAGS" => __("Never apply these tags automatically (comma-separated list)."),
+ Prefs::BLACKLISTED_TAGS => __("Never apply these tags automatically (comma-separated list)."),
];
$this->pref_help = [
- "ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate articles"), ""),
- "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), ""),
- "DEFAULT_SEARCH_LANGUAGE" => array(__("Default language"), __("Used for full-text search")),
- "CDM_AUTO_CATCHUP" => array(__("Mark read on scroll"), __("Mark articles as read as you scroll past them")),
- "CDM_EXPANDED" => array(__("Always expand articles")),
- "COMBINED_DISPLAY_MODE" => array(__("Combined mode"), __("Show flat list of articles instead of separate panels")),
- "CONFIRM_FEED_CATCHUP" => array(__("Confirm marking feeds as read")),
- "DEFAULT_ARTICLE_LIMIT" => array(__("Amount of articles to display at once")),
- "DEFAULT_UPDATE_INTERVAL" => array(__("Default update interval")),
- "DIGEST_CATCHUP" => array(__("Mark sent articles as read")),
- "DIGEST_ENABLE" => array(__("Enable digest"), __("Send daily digest of new (and unread) headlines to your e-mail address")),
- "DIGEST_PREFERRED_TIME" => array(__("Try to send around this time"), __("Time in UTC")),
- "ENABLE_API_ACCESS" => array(__("Enable API"), __("Allows accessing this account through the API")),
- "ENABLE_FEED_CATS" => array(__("Enable categories")),
- "FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), ""),
- "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles"), "<strong>" . __("hours") . "</strong>"),
- "HIDE_READ_FEEDS" => array(__("Hide read feeds")),
- "HIDE_READ_SHOWS_SPECIAL" => array(__("Always show special feeds"), __("While hiding read feeds")),
- "LONG_DATE_FORMAT" => array(__("Long date format"), __("Syntax is identical to PHP <a href='http://php.net/manual/function.date.php'>date()</a> function.")),
- "ON_CATCHUP_SHOW_NEXT_FEED" => array(__("Automatically show next feed"), __("After marking one as read")),
- "PURGE_OLD_DAYS" => array(__("Purge articles older than"), __("<strong>days</strong> (0 disables)")),
- "PURGE_UNREAD_ARTICLES" => array(__("Purge unread articles")),
- "REVERSE_HEADLINES" => array(__("Reverse headline order (oldest first)")),
- "SHORT_DATE_FORMAT" => array(__("Short date format")),
- "SHOW_CONTENT_PREVIEW" => array(__("Show content preview in headlines")),
- "SORT_HEADLINES_BY_FEED_DATE" => array(__("Sort headlines by feed date"), __("Use feed-specified date to sort headlines instead of local import date.")),
- "SSL_CERT_SERIAL" => array(__("SSL client certificate")),
- "STRIP_IMAGES" => array(__("Do not embed media")),
- "STRIP_UNSAFE_TAGS" => array(__("Strip unsafe tags from articles"), __("Strip all but most common HTML tags when reading articles.")),
- "USER_STYLESHEET" => array(__("Customize stylesheet")),
- "USER_TIMEZONE" => array(__("Time zone")),
- "VFEED_GROUP_BY_FEED" => array(__("Group by feed"), __("Group multiple-feed output by originating feed")),
- "USER_LANGUAGE" => array(__("Language")),
- "USER_CSS_THEME" => array(__("Theme"))
+ 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"), "<strong>" . __("hours") . "</strong>"),
+ 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 <a href='http://php.net/manual/function.date.php'>date()</a> 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"), __("<strong>days</strong> (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")),
];
- $this->pref_blacklist = ["ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES",
- "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT",
- "FEEDS_SORT_BY_UNREAD", "USER_STYLESHEET"];
-
- /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */
-
- $this->profile_blacklist = ["ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS",
- "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",
- "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE",
- "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE",
- "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME"];
+ // hidden in the main prefs UI (use to hide things that have description set above)
+ $this->pref_blacklist = [
+ //
+ ];
}
function changepassword() {
@@ -181,31 +173,33 @@ class Pref_Prefs extends Handler_Protected {
$value = $_POST[$pref_name];
switch ($pref_name) {
- case 'DIGEST_PREFERRED_TIME':
- if (get_pref('DIGEST_PREFERRED_TIME') != $value) {
+ 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 = ?");
+ last_digest_sent = NULL WHERE id = ?");
$sth->execute([$_SESSION['uid']]);
}
break;
- case 'USER_LANGUAGE':
+ case Prefs::USER_LANGUAGE:
if (!$need_reload) $need_reload = $_SESSION["language"] != $value;
break;
- case 'USER_CSS_THEME':
+ case Prefs::USER_CSS_THEME:
if (!$need_reload) $need_reload = get_pref($pref_name) != $value;
break;
- case 'BLACKLISTED_TAGS':
+ case Prefs::BLACKLISTED_TAGS:
$cats = FeedItem_Common::normalize_categories(explode(",", $value));
asort($cats);
$value = implode(", ", $cats);
break;
}
- set_pref($pref_name, $value);
+ if (Prefs::is_valid($pref_name)) {
+ Prefs::set($pref_name, $value, $_SESSION["uid"], $_SESSION["profile"] ?? null);
+ }
}
if ($need_reload) {
@@ -260,17 +254,9 @@ class Pref_Prefs extends Handler_Protected {
}
function resetconfig() {
+ Prefs::reset($_SESSION["uid"], $_SESSION["profile"]);
- $_SESSION["prefs_op_result"] = "reset-to-defaults";
-
- $sth = $this->pdo->prepare("DELETE FROM ttrss_user_prefs
- WHERE (profile = :profile OR (:profile IS NULL AND profile IS NULL))
- AND owner_uid = :uid");
- $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]);
-
- $this->_init_user_prefs($_SESSION["uid"], $_SESSION["profile"]);
-
- echo __("Your preferences are now set to default values.");
+ print "PREFS_NEED_RELOAD";
}
private function index_auth_personal() {
@@ -568,35 +554,18 @@ class Pref_Prefs extends Handler_Protected {
if ($profile) {
print_notice(__("Some preferences are only available in default profile."));
- $this->_init_user_prefs($_SESSION["uid"], $profile);
- } else {
- $this->_init_user_prefs($_SESSION["uid"]);
}
$prefs_available = [];
-
- $sth = $this->pdo->prepare("SELECT DISTINCT
- ttrss_user_prefs.pref_name,value,type_name,
- ttrss_prefs_sections.order_id,
- def_value,section_id
- FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
- WHERE type_id = ttrss_prefs_types.id AND
- (profile = :profile OR (:profile IS NULL AND profile IS NULL)) AND
- section_id = ttrss_prefs_sections.id AND
- ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
- owner_uid = :uid
- ORDER BY ttrss_prefs_sections.order_id,pref_name");
- $sth->execute([":uid" => $_SESSION['uid'], ":profile" => $profile]);
-
$listed_boolean_prefs = [];
- while ($line = $sth->fetch()) {
+ foreach (Prefs::get_all($_SESSION["uid"], $profile) as $line) {
if (in_array($line["pref_name"], $this->pref_blacklist)) {
continue;
}
- if ($profile && in_array($line["pref_name"], $this->profile_blacklist)) {
+ if ($profile && in_array($line["pref_name"], Prefs::_PROFILE_BLACKLIST)) {
continue;
}
@@ -607,7 +576,7 @@ class Pref_Prefs extends Handler_Protected {
continue;
$prefs_available[$pref_name] = [
- 'type_name' => $line["type_name"],
+ 'type_hint' => $line['type_hint'],
'value' => $line['value'],
'help_text' => $this->_get_help_text($pref_name),
'short_desc' => $short_desc
@@ -640,7 +609,7 @@ class Pref_Prefs extends Handler_Protected {
print "</label>";
$value = $item['value'];
- $type_name = $item['type_name'];
+ $type_hint = $item['type_hint'];
if ($pref_name == "USER_LANGUAGE") {
print \Controls\select_hash($pref_name, $value, get_translations(),
@@ -701,7 +670,7 @@ class Pref_Prefs extends Handler_Protected {
print \Controls\select_tag($pref_name, $value, Pref_Feeds::get_ts_languages());
- } else if ($type_name == "bool") {
+ } else if ($type_hint == Config::T_BOOL) {
array_push($listed_boolean_prefs, $pref_name);
@@ -726,7 +695,7 @@ class Pref_Prefs extends Handler_Protected {
$attributes = ["required" => true];
}
- if ($type_name == 'integer')
+ if ($type_hint == Config::T_INT)
print \Controls\number_spinner_tag($pref_name, $value, $attributes);
else
print \Controls\input_tag($pref_name, $value, "text", $attributes);
@@ -757,7 +726,7 @@ class Pref_Prefs extends Handler_Protected {
$item['help_text'] .= ". " . T_sprintf("Current server time: %s", date("H:i"));
} else {
- $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
+ $regexp = ($type_hint == Config::T_INT) ? 'regexp="^\d*$"' : '';
print "<input dojoType=\"dijit.form.ValidationTextBox\" $regexp name=\"$pref_name\" value=\"$value\">";
}
@@ -863,7 +832,7 @@ class Pref_Prefs extends Handler_Protected {
private function index_plugins_user() {
$system_enabled = array_map("trim", explode(",", (string)Config::get(Config::PLUGINS)));
- $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS")));
+ $user_enabled = array_map("trim", explode(",", get_pref(Prefs::_ENABLED_PLUGINS)));
$tmppluginhost = new PluginHost();
$tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true);
@@ -1164,7 +1133,7 @@ class Pref_Prefs extends Handler_Protected {
else
$plugins = "";
- set_pref("_ENABLED_PLUGINS", $plugins);
+ set_pref(Prefs::_ENABLED_PLUGINS, $plugins);
}
function clearplugindata() {
@@ -1174,7 +1143,7 @@ class Pref_Prefs extends Handler_Protected {
}
function customizeCSS() {
- $value = get_pref("USER_STYLESHEET");
+ $value = get_pref(Prefs::USER_STYLESHEET);
$value = str_replace("<br/>", "\n", $value);
print json_encode(["value" => $value]);
@@ -1219,14 +1188,6 @@ class Pref_Prefs extends Handler_Protected {
$sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles WHERE
title = ? AND owner_uid = ?");
$sth->execute([$title, $_SESSION['uid']]);
-
- if ($row = $sth->fetch()) {
- $profile_id = $row['id'];
-
- if ($profile_id) {
- Pref_Prefs::_init_user_prefs($_SESSION["uid"], $profile_id);
- }
- }
}
$this->pdo->commit();
@@ -1367,57 +1328,4 @@ class Pref_Prefs extends Handler_Protected {
$this->appPasswordList();
}
-
- static function _init_user_prefs($uid, $profile = false) {
-
- if (get_schema_version() < 63) $profile_qpart = "";
-
- $pdo = Db::pdo();
- $in_nested_tr = false;
-
- try {
- $pdo->beginTransaction();
- } catch (Exception $e) {
- $in_nested_tr = true;
- }
-
- $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs");
-
- if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
-
- $u_sth = $pdo->prepare("SELECT pref_name
- FROM ttrss_user_prefs WHERE owner_uid = :uid AND
- (profile = :profile OR (:profile IS NULL AND profile IS NULL))");
- $u_sth->execute([':uid' => $uid, ':profile' => $profile]);
-
- $active_prefs = array();
-
- while ($line = $u_sth->fetch()) {
- array_push($active_prefs, $line["pref_name"]);
- }
-
- while ($line = $sth->fetch()) {
- if (array_search($line["pref_name"], $active_prefs) === false) {
-// print "adding " . $line["pref_name"] . "<br>";
-
- if (get_schema_version() < 63) {
- $i_sth = $pdo->prepare("INSERT INTO ttrss_user_prefs
- (owner_uid,pref_name,value) VALUES
- (?, ?, ?)");
- $i_sth->execute([$uid, $line["pref_name"], $line["def_value"]]);
-
- } else {
- $i_sth = $pdo->prepare("INSERT INTO ttrss_user_prefs
- (owner_uid,pref_name,value, profile) VALUES
- (?, ?, ?, ?)");
- $i_sth->execute([$uid, $line["pref_name"], $line["def_value"], $profile]);
- }
-
- }
- }
-
- if (!$in_nested_tr) $pdo->commit();
-
- }
-
}
diff --git a/classes/pref/system.php b/classes/pref/system.php
index 67f7133c6..85635e753 100644
--- a/classes/pref/system.php
+++ b/classes/pref/system.php
@@ -129,7 +129,7 @@ class Pref_System extends Handler_Administrative {
?>
<tr>
<td class='errno'>
- <?= Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")" ?>
+ <?= Logger::ERROR_NAMES[$line["errno"]] . " (" . $line["errno"] . ")" ?>
</td>
<td class='filename'><?= $line["filename"] . ":" . $line["lineno"] ?></td>
<td class='errstr'><?= $line["errstr"] . "\n" . $line["context"] ?></td>