diff --git a/classes/Digest.php b/classes/Digest.php index 95827b310..6005f5fe4 100644 --- a/classes/Digest.php +++ b/classes/Digest.php @@ -92,7 +92,8 @@ class Digest $tpl->readTemplateFromFile("digest_template_html.txt"); $tpl_t->readTemplateFromFile("digest_template.txt"); - $user_tz_string = get_pref(Prefs::USER_TIMEZONE, $user_id); + $user_tz_string = Prefs::get(Prefs::USER_TIMEZONE, $user_id); + $min_score = Prefs::get(Prefs::DIGEST_MIN_SCORE, $user_id); if ($user_tz_string == 'Automatic') $user_tz_string = 'GMT'; @@ -136,10 +137,10 @@ class Digest AND $interval_qpart AND ttrss_user_entries.owner_uid = :user_id AND unread = true - AND score >= 0 + AND score >= :min_score ORDER BY ttrss_feed_categories.title, ttrss_feeds.title, score DESC, date_updated DESC LIMIT " . (int)$limit); - $sth->execute([':user_id' => $user_id]); + $sth->execute([':user_id' => $user_id, ':min_score' => $min_score]); $headlines_count = 0; $headlines = array(); diff --git a/classes/Pref_Prefs.php b/classes/Pref_Prefs.php index c9eb89631..31c71e004 100644 --- a/classes/Pref_Prefs.php +++ b/classes/Pref_Prefs.php @@ -74,6 +74,7 @@ class Pref_Prefs extends Handler_Protected { Prefs::DIGEST_ENABLE, Prefs::DIGEST_CATCHUP, Prefs::DIGEST_PREFERRED_TIME, + Prefs::DIGEST_MIN_SCORE, ], __('Advanced') => [ Prefs::BLACKLISTED_TAGS, @@ -127,6 +128,7 @@ class Pref_Prefs extends Handler_Protected { 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")), Prefs::CDM_ENABLE_GRID => array(__("Grid view"), __("On wider screens, if always expanded")), + Prefs::DIGEST_MIN_SCORE => array(__("Required score"), __("Include articles with this or above score into digest")), ]; // hidden in the main prefs UI (use to hide things that have description set above) @@ -688,7 +690,7 @@ class Pref_Prefs extends Handler_Protected { } } else if (in_array($pref_name, [Prefs::FRESH_ARTICLE_MAX_AGE, - Prefs::PURGE_OLD_DAYS, Prefs::LONG_DATE_FORMAT, Prefs::SHORT_DATE_FORMAT])) { + Prefs::PURGE_OLD_DAYS, Prefs::LONG_DATE_FORMAT, Prefs::SHORT_DATE_FORMAT, Prefs::DIGEST_MIN_SCORE])) { if ($pref_name == Prefs::PURGE_OLD_DAYS && Config::get(Config::FORCE_ARTICLE_PURGE) != 0) { $attributes = ["disabled" => true, "required" => true]; diff --git a/classes/Prefs.php b/classes/Prefs.php index 6dc8a1342..4426c2117 100644 --- a/classes/Prefs.php +++ b/classes/Prefs.php @@ -61,6 +61,7 @@ class Prefs { const DISABLE_CONDITIONAL_COUNTERS = "DISABLE_CONDITIONAL_COUNTERS"; const WIDESCREEN_MODE = "WIDESCREEN_MODE"; const CDM_ENABLE_GRID = "CDM_ENABLE_GRID"; + const DIGEST_MIN_SCORE = "DIGEST_MIN_SCORE"; private const _DEFAULTS = [ Prefs::PURGE_OLD_DAYS => [ 60, Config::T_INT ], @@ -122,6 +123,7 @@ class Prefs { Prefs::DISABLE_CONDITIONAL_COUNTERS => [ false, Config::T_BOOL ], Prefs::WIDESCREEN_MODE => [ false, Config::T_BOOL ], Prefs::CDM_ENABLE_GRID => [ false, Config::T_BOOL ], + Prefs::DIGEST_MIN_SCORE => [ 0, Config::T_INT ], ]; const _PROFILE_BLACKLIST = [ @@ -138,6 +140,7 @@ class Prefs { //Prefs::SORT_HEADLINES_BY_FEED_DATE, Prefs::SSL_CERT_SERIAL, Prefs::DIGEST_PREFERRED_TIME, + Prefs::DIGEST_MIN_SCORE, Prefs::_PREFS_MIGRATED ]; @@ -247,7 +250,7 @@ class Prefs { /** * @return bool|int|null|string */ - static function get(string $pref_name, int $owner_uid, ?int $profile_id) { + static function get(string $pref_name, int $owner_uid, ?int $profile_id = null) { return self::get_instance()->_get($pref_name, $owner_uid, $profile_id); } diff --git a/include/functions.php b/include/functions.php index 5096e9c65..b1aaf769b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -38,6 +38,8 @@ /** * @return bool|int|null|string + * + * @deprecated by Prefs::get() */ function get_pref(string $pref_name, int $owner_uid = null) { return Prefs::get($pref_name, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null); @@ -45,6 +47,8 @@ /** * @param bool|int|string $value + * + * @deprecated by Prefs::set() */ function set_pref(string $pref_name, $value, int $owner_uid = null, bool $strip_tags = true): bool { return Prefs::set($pref_name, $value, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null, $strip_tags);