diff options
author | Bharat Mediratta <bharat@menalto.com> | 2012-03-29 13:06:44 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2012-03-29 13:06:44 -0700 |
commit | 7d66ab2e949bc915f108737f08cac2f9057ef729 (patch) | |
tree | 682970fdbb6d8eb1116695ad49cdfb62abd5e74f /modules/comment/helpers | |
parent | 60286bfba3939974088dcdc8935525f571eaa0eb (diff) |
Improve comment RSS feed visibility, initially added by Thomas E. Horner in
fc942aacda07346fa9af04853659eaeac1e766d3.
Change some variable names, refactor out visibility checking code, actually
check visibility at generation time instead of just suppressing the UI,
update module.info
Fixes #1829.
Diffstat (limited to 'modules/comment/helpers')
-rw-r--r-- | modules/comment/helpers/comment_installer.php | 2 | ||||
-rw-r--r-- | modules/comment/helpers/comment_rss.php | 20 |
2 files changed, 14 insertions, 8 deletions
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index e8d5e82c..a64064f6 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -78,7 +78,7 @@ class comment_installer { } if ($version == 4) { - module::set_var("comment", "rss_available", "both"); + module::set_var("comment", "rss_visible", "all"); module::set_version("comment", $version = 5); } } diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 919aac95..cfee4727 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -19,17 +19,23 @@ */ class comment_rss_Core { - static function available_feeds($item, $tag) { - $avail = module::get_var("comment", "rss_available"); - if($avail == "none") { - return array(); + static function feed_visible($feed_id) { + $visible = module::get_var("comment", "rss_visible"); + if (!in_array($feed_id, array("newest", "per_item"))) { + return false; } - if($avail == "both" || $avail == "newest") { + return ($visible == "all" || $visible == $feed_id); + } + + static function available_feeds($item, $tag) { + $feeds = array(); + + if (comment_rss::feed_visible("newest")) { $feeds["comment/newest"] = t("All new comments"); } - if ($item && ($avail == "both" || $avail == "onitem")) { + if ($item && comment_rss::feed_visible("per_item")) { $feeds["comment/item/$item->id"] = t("Comments on %title", array("title" => html::purify($item->title))); } @@ -37,7 +43,7 @@ class comment_rss_Core { } static function feed($feed_id, $offset, $limit, $id) { - if ($feed_id != "newest" && $feed_id != "item") { + if (!comment_rss::feed_visible($feed_id)) { return; } |