use constants in get_pref()/set_pref()

master
Andrew Dolgov 4 years ago
parent 5aa05c90e1
commit c96172fa04

@ -36,7 +36,7 @@ class API extends Handler {
return false; return false;
} }
if (!empty($_SESSION["uid"]) && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) { if (!empty($_SESSION["uid"]) && $method != "logout" && !get_pref(Prefs::ENABLE_API_ACCESS)) {
$this->_wrap(self::STATUS_ERR, array("error" => self::E_API_DISABLED)); $this->_wrap(self::STATUS_ERR, array("error" => self::E_API_DISABLED));
return false; return false;
} }
@ -69,7 +69,7 @@ class API extends Handler {
if (Config::get(Config::SINGLE_USER_MODE)) $login = "admin"; if (Config::get(Config::SINGLE_USER_MODE)) $login = "admin";
if ($uid = UserHelper::find_user_by_login($login)) { if ($uid = UserHelper::find_user_by_login($login)) {
if (get_pref("ENABLE_API_ACCESS", $uid)) { if (get_pref(Prefs::ENABLE_API_ACCESS, $uid)) {
if (UserHelper::authenticate($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password if (UserHelper::authenticate($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password
$this->_wrap(self::STATUS_OK, array("session_id" => session_id(), $this->_wrap(self::STATUS_OK, array("session_id" => session_id(),
"api_level" => self::API_LEVEL)); "api_level" => self::API_LEVEL));

@ -349,7 +349,7 @@ class Article extends Handler_Protected {
$rv['can_inline'] = isset($_SESSION["uid"]) && $rv['can_inline'] = isset($_SESSION["uid"]) &&
empty($_SESSION["bw_limit"]) && empty($_SESSION["bw_limit"]) &&
!get_pref("STRIP_IMAGES") && !get_pref(Prefs::STRIP_IMAGES) &&
($always_display_enclosures || !preg_match("/<img/i", $article_content)); ($always_display_enclosures || !preg_match("/<img/i", $article_content));
$rv['inline_text_only'] = $hide_images && $rv['can_inline']; $rv['inline_text_only'] = $hide_images && $rv['can_inline'];

@ -21,8 +21,8 @@ class Digest
while ($line = $res->fetch()) { while ($line = $res->fetch()) {
if (get_pref('DIGEST_ENABLE', $line['id'])) { if (get_pref(Prefs::DIGEST_ENABLE, $line['id'])) {
$preferred_ts = strtotime(get_pref('DIGEST_PREFERRED_TIME', $line['id'])); $preferred_ts = strtotime(get_pref(Prefs::DIGEST_PREFERRED_TIME, $line['id']));
// try to send digests within 2 hours of preferred time // try to send digests within 2 hours of preferred time
if ($preferred_ts && time() >= $preferred_ts && if ($preferred_ts && time() >= $preferred_ts &&
@ -31,7 +31,7 @@ class Digest
Debug::log("Sending digest for UID:" . $line['id'] . " - " . $line["email"]); Debug::log("Sending digest for UID:" . $line['id'] . " - " . $line["email"]);
$do_catchup = get_pref('DIGEST_CATCHUP', $line['id']); $do_catchup = get_pref(Prefs::DIGEST_CATCHUP, $line['id']);
global $tz_offset; global $tz_offset;
@ -86,7 +86,7 @@ class Digest
$tpl->readTemplateFromFile("digest_template_html.txt"); $tpl->readTemplateFromFile("digest_template_html.txt");
$tpl_t->readTemplateFromFile("digest_template.txt"); $tpl_t->readTemplateFromFile("digest_template.txt");
$user_tz_string = get_pref('USER_TIMEZONE', $user_id); $user_tz_string = get_pref(Prefs::USER_TIMEZONE, $user_id);
$local_ts = TimeHelper::convert_timestamp(time(), 'UTC', $user_tz_string); $local_ts = TimeHelper::convert_timestamp(time(), 'UTC', $user_tz_string);
$tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts)); $tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
@ -152,7 +152,7 @@ class Digest
$updated = TimeHelper::make_local_datetime($line['last_updated'], false, $updated = TimeHelper::make_local_datetime($line['last_updated'], false,
$user_id); $user_id);
if (get_pref('ENABLE_FEED_CATS', $user_id)) { if (get_pref(Prefs::ENABLE_FEED_CATS, $user_id)) {
$line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title']; $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title'];
} }

@ -108,7 +108,7 @@ class Feeds extends Handler_Protected {
$this->_mark_timestamp("db query"); $this->_mark_timestamp("db query");
$vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $vfeed_group_enabled = get_pref(Prefs::VFEED_GROUP_BY_FEED) &&
!(in_array($feed, self::NEVER_GROUP_FEEDS) && !$cat_view); !(in_array($feed, self::NEVER_GROUP_FEEDS) && !$cat_view);
$result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed $result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed
@ -167,7 +167,7 @@ class Feeds extends Handler_Protected {
++$headlines_count; ++$headlines_count;
if (!get_pref('SHOW_CONTENT_PREVIEW')) { if (!get_pref(Prefs::SHOW_CONTENT_PREVIEW)) {
$line["content_preview"] = ""; $line["content_preview"] = "";
} else { } else {
$line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250); $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
@ -262,12 +262,12 @@ class Feeds extends Handler_Protected {
$this->_mark_timestamp(" note"); $this->_mark_timestamp(" note");
if (!get_pref("CDM_EXPANDED")) { if (!get_pref(Prefs::CDM_EXPANDED)) {
$line["cdm_excerpt"] = "<span class='collapse'> $line["cdm_excerpt"] = "<span class='collapse'>
<i class='material-icons' onclick='return Article.cdmUnsetActive(event)' <i class='material-icons' onclick='return Article.cdmUnsetActive(event)'
title=\"" . __("Collapse article") . "\">remove_circle</i></span>"; title=\"" . __("Collapse article") . "\">remove_circle</i></span>";
if (get_pref('SHOW_CONTENT_PREVIEW')) { if (get_pref(Prefs::SHOW_CONTENT_PREVIEW)) {
$line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>";
} }
} }
@ -459,8 +459,8 @@ class Feeds extends Handler_Protected {
return; return;
} }
set_pref("_DEFAULT_VIEW_MODE", $view_mode); set_pref(Prefs::_DEFAULT_VIEW_MODE, $view_mode);
set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by); set_pref(Prefs::_DEFAULT_VIEW_ORDER_BY, $order_by);
/* bump login timestamp if needed */ /* bump login timestamp if needed */
if (time() - $_SESSION["last_login_update"] > 3600) { if (time() - $_SESSION["last_login_update"] > 3600) {
@ -573,7 +573,7 @@ class Feeds extends Handler_Protected {
"show_language" => Config::get(Config::DB_TYPE) == "pgsql", "show_language" => Config::get(Config::DB_TYPE) == "pgsql",
"show_syntax_help" => count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0, "show_syntax_help" => count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0,
"all_languages" => Pref_Feeds::get_ts_languages(), "all_languages" => Pref_Feeds::get_ts_languages(),
"default_language" => get_pref('DEFAULT_SEARCH_LANGUAGE') "default_language" => get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE)
]); ]);
} }
@ -799,7 +799,7 @@ class Feeds extends Handler_Protected {
if ($feed == -3) { if ($feed == -3) {
$intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE"); $intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE);
if (Config::get(Config::DB_TYPE) == "pgsql") { if (Config::get(Config::DB_TYPE) == "pgsql") {
$match_part = "date_entered > NOW() - INTERVAL '$intl hour' "; $match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
@ -892,7 +892,7 @@ class Feeds extends Handler_Protected {
} else if ($n_feed == -3) { } else if ($n_feed == -3) {
$match_part = "unread = true AND score >= 0"; $match_part = "unread = true AND score >= 0";
$intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid); $intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE, $owner_uid);
if (Config::get(Config::DB_TYPE) == "pgsql") { if (Config::get(Config::DB_TYPE) == "pgsql") {
$match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' "; $match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
@ -1478,7 +1478,7 @@ class Feeds extends Handler_Protected {
} else if ($feed == -3) { // fresh virtual feed } else if ($feed == -3) { // fresh virtual feed
$query_strategy_part = "unread = true AND score >= 0"; $query_strategy_part = "unread = true AND score >= 0";
$intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid); $intl = (int) get_pref(Prefs::FRESH_ARTICLE_MAX_AGE, $owner_uid);
if (Config::get(Config::DB_TYPE) == "pgsql") { if (Config::get(Config::DB_TYPE) == "pgsql") {
$query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' "; $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' ";
@ -1566,7 +1566,7 @@ class Feeds extends Handler_Protected {
if (is_numeric($feed)) { if (is_numeric($feed)) {
// proper override_order applied above // proper override_order applied above
if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) { if ($vfeed_query_part && !$ignore_vfeed_group && get_pref(Prefs::VFEED_GROUP_BY_FEED, $owner_uid)) {
if (!(in_array($feed, self::NEVER_GROUP_BY_DATE) && !$cat_view)) { if (!(in_array($feed, self::NEVER_GROUP_BY_DATE) && !$cat_view)) {
$yyiw_desc = $order_by == "date_reverse" ? "" : "desc"; $yyiw_desc = $order_by == "date_reverse" ? "" : "desc";
@ -2058,7 +2058,7 @@ class Feeds extends Handler_Protected {
if ($search_language) if ($search_language)
$search_language = $pdo->quote(mb_strtolower($search_language)); $search_language = $pdo->quote(mb_strtolower($search_language));
else else
$search_language = $pdo->quote(mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid))); $search_language = $pdo->quote(mb_strtolower(get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE, $owner_uid)));
foreach ($keywords as $k) { foreach ($keywords as $k) {
if (strpos($k, "-") === 0) { if (strpos($k, "-") === 0) {
@ -2166,7 +2166,7 @@ class Feeds extends Handler_Protected {
default: default:
if (strpos($k, "@") === 0) { if (strpos($k, "@") === 0) {
$user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); $user_tz_string = get_pref(Prefs::USER_TIMEZONE, $_SESSION['uid']);
$orig_ts = strtotime(substr($k, 1)); $orig_ts = strtotime(substr($k, 1));
$k = date("Y-m-d", TimeHelper::convert_timestamp($orig_ts, $user_tz_string, 'UTC')); $k = date("Y-m-d", TimeHelper::convert_timestamp($orig_ts, $user_tz_string, 'UTC'));

@ -40,7 +40,7 @@ class Handler_Public extends Handler {
if (!$is_cat && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { if (!$is_cat && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); $user_plugins = get_pref(Prefs::_ENABLED_PLUGINS, $owner_uid);
$tmppluginhost = new PluginHost(); $tmppluginhost = new PluginHost();
$tmppluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL); $tmppluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL);
@ -366,7 +366,7 @@ class Handler_Public extends Handler {
$_POST["password"] = ""; $_POST["password"] = "";
if (get_schema_version() >= 120) { if (get_schema_version() >= 120) {
$_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]); $_SESSION["language"] = get_pref(Prefs::USER_LANGUAGE, $_SESSION["uid"]);
} }
$_SESSION["ref_schema_version"] = get_schema_version(true); $_SESSION["ref_schema_version"] = get_schema_version(true);

@ -122,7 +122,7 @@ class Pref_Feeds extends Handler_Protected {
$root['param'] = 0; $root['param'] = 0;
$root['type'] = 'category'; $root['type'] = 'category';
$enable_cats = get_pref('ENABLE_FEED_CATS'); $enable_cats = get_pref(Prefs::ENABLE_FEED_CATS);
if (clean($_REQUEST['mode'] ?? 0) == 2) { if (clean($_REQUEST['mode'] ?? 0) == 2) {
@ -171,7 +171,7 @@ class Pref_Feeds extends Handler_Protected {
ttrss_labels2 WHERE owner_uid = ? ORDER by caption"); ttrss_labels2 WHERE owner_uid = ? ORDER by caption");
$sth->execute([$_SESSION['uid']]); $sth->execute([$_SESSION['uid']]);
if (get_pref('ENABLE_FEED_CATS')) { if (get_pref(Prefs::ENABLE_FEED_CATS)) {
$cat = $this->feedlist_init_cat(-2); $cat = $this->feedlist_init_cat(-2);
} else { } else {
$cat['items'] = array(); $cat['items'] = array();
@ -527,11 +527,11 @@ class Pref_Feeds extends Handler_Protected {
$row["icon"] = Feeds::_get_icon($feed_id); $row["icon"] = Feeds::_get_icon($feed_id);
$local_update_intervals = $update_intervals; $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) { if (Config::get(Config::FORCE_ARTICLE_PURGE) == 0) {
$local_purge_intervals = $purge_intervals; $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) if ($default_purge_interval > 0)
$local_purge_intervals[0] .= " " . T_nsprintf('(%d day)', '(%d days)', $default_purge_interval, $default_purge_interval); $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([ print json_encode([
"feed" => $row, "feed" => $row,
"cats" => [ "cats" => [
"enabled" => get_pref('ENABLE_FEED_CATS'), "enabled" => get_pref(Prefs::ENABLE_FEED_CATS),
"select" => \Controls\select_feeds_cats("cat_id", $row["cat_id"]), "select" => \Controls\select_feeds_cats("cat_id", $row["cat_id"]),
], ],
"plugin_data" => $plugin_data, "plugin_data" => $plugin_data,
@ -557,7 +557,7 @@ class Pref_Feeds extends Handler_Protected {
], ],
"lang" => [ "lang" => [
"enabled" => Config::get(Config::DB_TYPE) == "pgsql", "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(), "all" => $this::get_ts_languages(),
] ]
]); ]);
@ -576,10 +576,10 @@ class Pref_Feeds extends Handler_Protected {
$feed_ids = clean($_REQUEST["ids"]); $feed_ids = clean($_REQUEST["ids"]);
$local_update_intervals = $update_intervals; $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; $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) if ($default_purge_interval > 0)
$local_purge_intervals[0] .= " " . T_sprintf("(%d days)", $default_purge_interval); $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.TabContainer" style="height : 450px">
<div dojoType="dijit.layout.ContentPane" title="<?= __('General') ?>"> <div dojoType="dijit.layout.ContentPane" title="<?= __('General') ?>">
<section> <section>
<?php if (get_pref('ENABLE_FEED_CATS')) { ?> <?php if (get_pref(Prefs::ENABLE_FEED_CATS)) { ?>
<fieldset> <fieldset>
<label><?= __('Place in category:') ?></label> <label><?= __('Place in category:') ?></label>
<?= \Controls\select_feeds_cats("cat_id", null, ['disabled' => '1']) ?> <?= \Controls\select_feeds_cats("cat_id", null, ['disabled' => '1']) ?>
@ -830,7 +830,7 @@ class Pref_Feeds extends Handler_Protected {
break; break;
case "cat_id": case "cat_id":
if (get_pref('ENABLE_FEED_CATS')) { if (get_pref(Prefs::ENABLE_FEED_CATS)) {
if ($cat_id) { if ($cat_id) {
$qpart = "cat_id = " . $this->pdo->quote($cat_id); $qpart = "cat_id = " . $this->pdo->quote($cat_id);
} else { } else {
@ -946,7 +946,7 @@ class Pref_Feeds extends Handler_Protected {
</div> </div>
</div> </div>
<?php if (get_pref('ENABLE_FEED_CATS')) { ?> <?php if (get_pref(Prefs::ENABLE_FEED_CATS)) { ?>
<div dojoType="fox.form.DropDownButton"> <div dojoType="fox.form.DropDownButton">
<span><?= __('Categories') ?></span> <span><?= __('Categories') ?></span>
<div dojoType="dijit.Menu" style="display: none"> <div dojoType="dijit.Menu" style="display: none">
@ -1237,7 +1237,7 @@ class Pref_Feeds extends Handler_Protected {
function batchSubscribe() { function batchSubscribe() {
print json_encode([ 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") "cat_select" => \Controls\select_feeds_cats("cat")
]); ]);
} }

@ -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; if (!$root_id) $root_id = null;

@ -106,9 +106,15 @@ class Pref_Prefs extends Handler_Protected {
Prefs::USER_CSS_THEME => array(__("Theme")) Prefs::USER_CSS_THEME => array(__("Theme"))
]; ];
$this->pref_blacklist = [Prefs::ALLOW_DUPLICATE_POSTS, Prefs::REVERSE_HEADLINES, // hidden in the main prefs UI
Prefs::SORT_HEADLINES_BY_FEED_DATE, Prefs::DEFAULT_ARTICLE_LIMIT, $this->pref_blacklist = [
Prefs::FEEDS_SORT_BY_UNREAD, Prefs::USER_STYLESHEET]; Prefs::ALLOW_DUPLICATE_POSTS,
Prefs::REVERSE_HEADLINES,
Prefs::SORT_HEADLINES_BY_FEED_DATE,
Prefs::DEFAULT_ARTICLE_LIMIT,
Prefs::FEEDS_SORT_BY_UNREAD,
Prefs::USER_STYLESHEET
];
} }
function changepassword() { function changepassword() {
@ -830,7 +836,7 @@ class Pref_Prefs extends Handler_Protected {
private function index_plugins_user() { private function index_plugins_user() {
$system_enabled = array_map("trim", explode(",", (string)Config::get(Config::PLUGINS))); $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 = new PluginHost();
$tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true);
@ -1131,7 +1137,7 @@ class Pref_Prefs extends Handler_Protected {
else else
$plugins = ""; $plugins = "";
set_pref("_ENABLED_PLUGINS", $plugins); set_pref(Prefs::_ENABLED_PLUGINS, $plugins);
} }
function clearplugindata() { function clearplugindata() {
@ -1141,7 +1147,7 @@ class Pref_Prefs extends Handler_Protected {
} }
function customizeCSS() { function customizeCSS() {
$value = get_pref("USER_STYLESHEET"); $value = get_pref(Prefs::USER_STYLESHEET);
$value = str_replace("<br/>", "\n", $value); $value = str_replace("<br/>", "\n", $value);
print json_encode(["value" => $value]); print json_encode(["value" => $value]);

@ -392,14 +392,14 @@ class RPC extends Handler_Protected {
$params["check_for_updates"] = Config::get(Config::CHECK_FOR_UPDATES); $params["check_for_updates"] = Config::get(Config::CHECK_FOR_UPDATES);
$params["icons_url"] = Config::get(Config::ICONS_URL); $params["icons_url"] = Config::get(Config::ICONS_URL);
$params["cookie_lifetime"] = Config::get(Config::SESSION_COOKIE_LIFETIME); $params["cookie_lifetime"] = Config::get(Config::SESSION_COOKIE_LIFETIME);
$params["default_view_mode"] = get_pref("_DEFAULT_VIEW_MODE"); $params["default_view_mode"] = get_pref(Prefs::_DEFAULT_VIEW_MODE);
$params["default_view_limit"] = (int) get_pref("_DEFAULT_VIEW_LIMIT"); $params["default_view_limit"] = (int) get_pref(Prefs::_DEFAULT_VIEW_LIMIT);
$params["default_view_order_by"] = get_pref("_DEFAULT_VIEW_ORDER_BY"); $params["default_view_order_by"] = get_pref(Prefs::_DEFAULT_VIEW_ORDER_BY);
$params["bw_limit"] = (int) $_SESSION["bw_limit"]; $params["bw_limit"] = (int) $_SESSION["bw_limit"];
$params["is_default_pw"] = Pref_Prefs::isdefaultpassword(); $params["is_default_pw"] = Pref_Prefs::isdefaultpassword();
$params["label_base_index"] = LABEL_BASE_INDEX; $params["label_base_index"] = LABEL_BASE_INDEX;
$theme = get_pref("USER_CSS_THEME"); $theme = get_pref(Prefs::USER_CSS_THEME);
$params["theme"] = theme_exists($theme) ? $theme : ""; $params["theme"] = theme_exists($theme) ? $theme : "";
$params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names()); $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names());
@ -454,7 +454,7 @@ class RPC extends Handler_Protected {
$data["max_feed_id"] = (int) $max_feed_id; $data["max_feed_id"] = (int) $max_feed_id;
$data["num_feeds"] = (int) $num_feeds; $data["num_feeds"] = (int) $num_feeds;
$data['cdm_expanded'] = get_pref('CDM_EXPANDED'); $data['cdm_expanded'] = get_pref(Prefs::CDM_EXPANDED);
$data["labels"] = Labels::get_all($_SESSION["uid"]); $data["labels"] = Labels::get_all($_SESSION["uid"]);
if (Config::get(Config::LOG_DESTINATION) == 'sql' && $_SESSION['access_level'] >= 10) { if (Config::get(Config::LOG_DESTINATION) == 'sql' && $_SESSION['access_level'] >= 10) {

@ -290,7 +290,7 @@ class RSSUtils {
$fetch_url = $row["feed_url"]; $fetch_url = $row["feed_url"];
$pluginhost = new PluginHost(); $pluginhost = new PluginHost();
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); $user_plugins = get_pref(Prefs::_ENABLED_PLUGINS, $owner_uid);
$pluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL); $pluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL);
$pluginhost->load((string)$user_plugins, PluginHost::KIND_USER, $owner_uid); $pluginhost->load((string)$user_plugins, PluginHost::KIND_USER, $owner_uid);
@ -401,7 +401,7 @@ class RSSUtils {
$feed_language = mb_strtolower($row["feed_language"]); $feed_language = mb_strtolower($row["feed_language"]);
if (!$feed_language) if (!$feed_language)
$feed_language = mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid)); $feed_language = mb_strtolower(get_pref(Prefs::DEFAULT_SEARCH_LANGUAGE, $owner_uid));
if (!$feed_language) if (!$feed_language)
$feed_language = 'simple'; $feed_language = 'simple';
@ -415,7 +415,7 @@ class RSSUtils {
$cache_filename = Config::get(Config::CACHE_DIR) . "/feeds/" . sha1($fetch_url) . ".xml"; $cache_filename = Config::get(Config::CACHE_DIR) . "/feeds/" . sha1($fetch_url) . ".xml";
$pluginhost = new PluginHost(); $pluginhost = new PluginHost();
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); $user_plugins = get_pref(Prefs::_ENABLED_PLUGINS, $owner_uid);
$pluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL); $pluginhost->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL);
$pluginhost->load((string)$user_plugins, PluginHost::KIND_USER, $owner_uid); $pluginhost->load((string)$user_plugins, PluginHost::KIND_USER, $owner_uid);
@ -1208,7 +1208,7 @@ class RSSUtils {
$boring_tags = array_map('trim', $boring_tags = array_map('trim',
explode(",", mb_strtolower( explode(",", mb_strtolower(
get_pref('BLACKLISTED_TAGS', $owner_uid)))); get_pref(Prefs::BLACKLISTED_TAGS, $owner_uid))));
$entry_tags = FeedItem_Common::normalize_categories( $entry_tags = FeedItem_Common::normalize_categories(
array_unique( array_unique(

@ -95,7 +95,7 @@ class Sanitizer {
} }
if ($entry->hasAttribute('src') && if ($entry->hasAttribute('src') &&
($owner && get_pref("STRIP_IMAGES", $owner)) || $force_remove_images || ($_SESSION["bw_limit"] ?? false)) { ($owner && get_pref(Prefs::STRIP_IMAGES, $owner)) || $force_remove_images || ($_SESSION["bw_limit"] ?? false)) {
$p = $doc->createElement('p'); $p = $doc->createElement('p');

@ -7,16 +7,16 @@ class TimeHelper {
if ($eta_min && time() + $tz_offset - $timestamp < 3600) { if ($eta_min && time() + $tz_offset - $timestamp < 3600) {
return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp));
} else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) {
$format = get_pref('SHORT_DATE_FORMAT', $owner_uid); $format = get_pref(Prefs::SHORT_DATE_FORMAT, $owner_uid);
if (strpos((strtolower($format)), "a") === false) if (strpos((strtolower($format)), "a") === false)
return date("G:i", $timestamp); return date("G:i", $timestamp);
else else
return date("g:i a", $timestamp); return date("g:i a", $timestamp);
} else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) {
$format = get_pref('SHORT_DATE_FORMAT', $owner_uid); $format = get_pref(Prefs::SHORT_DATE_FORMAT, $owner_uid);
return date($format, $timestamp); return date($format, $timestamp);
} else { } else {
$format = get_pref('LONG_DATE_FORMAT', $owner_uid); $format = get_pref(Prefs::LONG_DATE_FORMAT, $owner_uid);
return date($format, $timestamp); return date($format, $timestamp);
} }
} }
@ -37,7 +37,7 @@ class TimeHelper {
# We store date in UTC internally # We store date in UTC internally
$dt = new DateTime($timestamp, $utc_tz); $dt = new DateTime($timestamp, $utc_tz);
$user_tz_string = get_pref('USER_TIMEZONE', $owner_uid); $user_tz_string = get_pref(Prefs::USER_TIMEZONE, $owner_uid);
if ($user_tz_string != 'Automatic') { if ($user_tz_string != 'Automatic') {
@ -59,9 +59,9 @@ class TimeHelper {
$tz_offset, $owner_uid, $eta_min); $tz_offset, $owner_uid, $eta_min);
} else { } else {
if ($long) if ($long)
$format = get_pref('LONG_DATE_FORMAT', $owner_uid); $format = get_pref(Prefs::LONG_DATE_FORMAT, $owner_uid);
else else
$format = get_pref('SHORT_DATE_FORMAT', $owner_uid); $format = get_pref(Prefs::SHORT_DATE_FORMAT, $owner_uid);
return date($format, $user_timestamp); return date($format, $user_timestamp);
} }

@ -73,7 +73,7 @@ class UserHelper {
if (!$pluginhost) $pluginhost = PluginHost::getInstance(); if (!$pluginhost) $pluginhost = PluginHost::getInstance();
if ($owner_uid && SCHEMA_VERSION >= 100 && empty($_SESSION["safe_mode"])) { if ($owner_uid && SCHEMA_VERSION >= 100 && empty($_SESSION["safe_mode"])) {
$plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); $plugins = get_pref(Prefs::_ENABLED_PLUGINS, $owner_uid);
$pluginhost->load((string)$plugins, PluginHost::KIND_USER, $owner_uid); $pluginhost->load((string)$plugins, PluginHost::KIND_USER, $owner_uid);
@ -125,7 +125,7 @@ class UserHelper {
} }
static function print_user_stylesheet() { static function print_user_stylesheet() {
$value = get_pref('USER_STYLESHEET'); $value = get_pref(Prefs::USER_STYLESHEET);
if ($value) { if ($value) {
print "<style type='text/css' id='user_css_style'>"; print "<style type='text/css' id='user_css_style'>";

@ -128,7 +128,7 @@ function print_feed_multi_select($id, $default_ids = [],
} }
} }
if (get_pref('ENABLE_FEED_CATS')) { if (get_pref(Prefs::ENABLE_FEED_CATS)) {
if (!$root_id) $root_id = null; if (!$root_id) $root_id = null;

@ -140,7 +140,7 @@
} }
if (!empty($_SESSION["uid"]) && get_schema_version() >= 120) { if (!empty($_SESSION["uid"]) && get_schema_version() >= 120) {
$pref_locale = get_pref("USER_LANGUAGE", $_SESSION["uid"]); $pref_locale = get_pref(Prefs::USER_LANGUAGE, $_SESSION["uid"]);
if (!empty($pref_locale) && $pref_locale != 'auto') { if (!empty($pref_locale) && $pref_locale != 'auto') {
$selected_locale = $pref_locale; $selected_locale = $pref_locale;

@ -29,7 +29,7 @@
<meta name="viewport" content="initial-scale=1,width=device-width" /> <meta name="viewport" content="initial-scale=1,width=device-width" />
<?php if ($_SESSION["uid"] && empty($_SESSION["safe_mode"])) { <?php if ($_SESSION["uid"] && empty($_SESSION["safe_mode"])) {
$theme = get_pref("USER_CSS_THEME"); $theme = get_pref(Prefs::USER_CSS_THEME);
if ($theme && theme_exists("$theme")) { if ($theme && theme_exists("$theme")) {
echo stylesheet_tag(get_theme_path($theme), 'theme_css'); echo stylesheet_tag(get_theme_path($theme), 'theme_css');
} }

@ -19,7 +19,7 @@ class Close_Button extends Plugin {
} }
function hook_article_button($line) { function hook_article_button($line) {
if (!get_pref("COMBINED_DISPLAY_MODE")) { if (!get_pref(Prefs::COMBINED_DISPLAY_MODE)) {
return "<i class='material-icons icon-close-article' return "<i class='material-icons icon-close-article'
style='cursor : pointer' onclick='Article.close()' style='cursor : pointer' onclick='Article.close()'
title='".__('Close article')."'>close</i>"; title='".__('Close article')."'>close</i>";

@ -20,7 +20,7 @@
<meta name="viewport" content="initial-scale=1,width=device-width" /> <meta name="viewport" content="initial-scale=1,width=device-width" />
<?php if ($_SESSION["uid"] && empty($_SESSION["safe_mode"])) { <?php if ($_SESSION["uid"] && empty($_SESSION["safe_mode"])) {
$theme = get_pref("USER_CSS_THEME"); $theme = get_pref(Prefs::USER_CSS_THEME);
if ($theme && theme_exists("$theme")) { if ($theme && theme_exists("$theme")) {
echo stylesheet_tag(get_theme_path($theme), 'theme_css'); echo stylesheet_tag(get_theme_path($theme), 'theme_css');
} }

Loading…
Cancel
Save