]> git.mjollnir.org Git - moodle.git/commitdiff
Elimintate duplicated code and simplify some logic. Ironically, do it twice in two...
authortjhunt <tjhunt>
Tue, 24 Jul 2007 10:39:10 +0000 (10:39 +0000)
committertjhunt <tjhunt>
Tue, 24 Jul 2007 10:39:10 +0000 (10:39 +0000)
mod/forum/index.php

index 20b2846e9c633d1afef112781a63e662e4fbefc4..9eaaccb329481914c24fd586ce6545b1315a421a 100644 (file)
                 $discussionlink = "<a class=\"dimmed\" href=\"view.php?f=$forum->id\">".$count."</a>";
             }
 
-            //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) {
                         }
                     }
                 }
-                $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;
         }
     }
 
                     $discussionlink = "<a class=\"dimmed\" href=\"view.php?f=$forum->id\">".$count."</a>";
                 }
 
-                //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) {
                             $sublink = "<a title=\"$subtitle\" href=\"subscribe.php?id=$forum->id\">$subscribed</a>";
                         }
                     }
-
-                    $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;
             }
         }
     }