From 49b53f26e021b4a170c15ca0ae0d3d415b61f3c4 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 24 Jul 2007 10:39:10 +0000 Subject: [PATCH] Elimintate duplicated code and simplify some logic. Ironically, do it twice in two separate places, becuase there is some more large-scale code duplication in this file that I am not even going to attempt to fix. --- mod/forum/index.php | 115 ++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 73 deletions(-) diff --git a/mod/forum/index.php b/mod/forum/index.php index 20b2846e9c..9eaaccb329 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -216,24 +216,10 @@ $discussionlink = "id\">".$count.""; } - //If this forum has RSS activated, calculate it - $rsslink = ''; - if ($show_rss) { - if ($forum->rsstype and $forum->rssarticles) { - //Calculate the tolltip text - if ($forum->rsstype == 1) { - $tooltiptext = get_string("rsssubscriberssdiscussions","forum",format_string($forum->name)); - } else { - $tooltiptext = get_string("rsssubscriberssposts","forum",format_string($forum->name)); - } - if (empty($USER->id)) { - $userid = 0; - } else { - $userid = $USER->id; - } - //Get html code for RSS link - $rsslink = rss_get_link($course->id, $userid, "forum", $forum->id, $tooltiptext); - } + $row = array ($forumlink, $forum->intro, $discussionlink); + if ($usetracking) { + $row[] = $unreadlink; + $row[] = $trackedlink; // Tracking. } if ($can_subscribe) { @@ -259,27 +245,27 @@ } } } - $row = array ($forumlink, $forum->intro, $discussionlink); - if ($usetracking) { - $row[] = $unreadlink; - $row[] = $trackedlink; // Tracking. - } $row[] = $sublink; - if ($show_rss) { - $row[] = $rsslink; - } - $generaltable->data[] = $row; - } else { - $row = array ($forumlink, $forum->intro, $discussionlink); - if ($usetracking) { - $row[] = $unreadlink; - $row[] = $trackedlink; // Tracking. + } + + //If this forum has RSS activated, calculate it + if ($show_rss and $forum->rsstype and $forum->rssarticles) { + //Calculate the tolltip text + if ($forum->rsstype == 1) { + $tooltiptext = get_string("rsssubscriberssdiscussions","forum",format_string($forum->name)); + } else { + $tooltiptext = get_string("rsssubscriberssposts","forum",format_string($forum->name)); } - if ($show_rss) { - $row[] = $rsslink; + if (empty($USER->id)) { + $userid = 0; + } else { + $userid = $USER->id; } - $generaltable->data[] = $row; + //Get html code for RSS link + $row[] = rss_get_link($course->id, $userid, "forum", $forum->id, $tooltiptext); } + + $generaltable->data[] = $row; } } @@ -381,24 +367,10 @@ $discussionlink = "id\">".$count.""; } - //If this forum has RSS activated, calculate it - $rsslink = ''; - if ($show_rss) { - if ($forum->rsstype and $forum->rssarticles) { - //Calculate the tolltip text - if ($forum->rsstype == 1) { - $tooltiptext = get_string("rsssubscriberssdiscussions","forum",format_string($forum->name)); - } else { - $tooltiptext = get_string("rsssubscriberssposts","forum",format_string($forum->name)); - } - if (empty($USER->id)) { - $userid = 0; - } else { - $userid = $USER->id; - } - //Get html code for RSS link - $rsslink = rss_get_link($course->id, $userid, "forum", $forum->id, $tooltiptext); - } + $row = array ($printsection, $forumlink, $forum->intro, $discussionlink); + if ($usetracking) { + $row[] = $unreadlink; + $row[] = $trackedlink; // Tracking. } if ($can_subscribe) { @@ -422,29 +394,26 @@ $sublink = "id\">$subscribed"; } } - - $row = array ($printsection, $forumlink, $forum->intro, $discussionlink); - if ($usetracking) { - $row[] = $unreadlink; - $row[] = $trackedlink; // Tracking. - } - $row[] = $sublink; - if ($show_rss) { - $row[] = $rsslink; - } - $learningtable->data[] = $row; - - } else { - $row = array ($printsection, $forumlink, $forum->intro, $discussionlink); - if ($usetracking) { - $row[] = $unreadlink; - $row[] = $trackedlink; // Tracking. + } + + //If this forum has RSS activated, calculate it + if ($show_rss and $forum->rsstype and $forum->rssarticles) { + //Calculate the tolltip text + if ($forum->rsstype == 1) { + $tooltiptext = get_string("rsssubscriberssdiscussions","forum",format_string($forum->name)); + } else { + $tooltiptext = get_string("rsssubscriberssposts","forum",format_string($forum->name)); } - if ($show_rss) { - $row[] = $rsslink; + if (empty($USER->id)) { + $userid = 0; + } else { + $userid = $USER->id; } - $learningtable->data[] = $row; + //Get html code for RSS link + $row[] = rss_get_link($course->id, $userid, "forum", $forum->id, $tooltiptext); } + + $learningtable->data[] = $row; } } } -- 2.39.5