From f4646b44c1cf92633882a2d25ccc1cc467af818d Mon Sep 17 00:00:00 2001 From: stronk7 Date: Tue, 5 Oct 2004 23:21:38 +0000 Subject: [PATCH] Now RSS links ae showed properly in SITE course when user isn't logged. Solve a problem with if($USER) under PHP5. --- mod/forum/index.php | 98 +++++++++++++++++++++++++++--------------- mod/forum/view.php | 30 +++++++------ mod/glossary/index.php | 12 ++++-- mod/glossary/view.php | 7 ++- 4 files changed, 97 insertions(+), 50 deletions(-) diff --git a/mod/forum/index.php b/mod/forum/index.php index c194b43a0b..b015f4c1c9 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -45,12 +45,13 @@ $generaltable->head = array ($strforum, $strdescription, $strdiscussions); $generaltable->align = array ("left", "left", "center"); - if ($can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin() or $course->id == SITEID)) { + if ($can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin())) { $generaltable->head[] = $strsubscribed; $generaltable->align[] = "center"; } - if ($show_rss = ($can_subscribe && isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && + if ($show_rss = (($can_subscribe || $course->id == SITEID) && + isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds)) { $generaltable->head[] = $strrss; $generaltable->align[] = "center"; @@ -135,6 +136,26 @@ $forumlink = "id\">$forum->name"; } + //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",$forum->name); + } else { + $tooltiptext = get_string("rsssubscriberssposts","forum",$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); + } + } + if ($can_subscribe) { if (forum_is_forcesubscribed($forum->id)) { $sublink = get_string("yes"); @@ -153,26 +174,20 @@ $sublink = "id\">$subscribed"; } } - //If this forum has RSS activated, calculate it - if ($show_rss) { - $rsslink = ''; - if ($forum->rsstype and $forum->rssarticles) { - //Calculate the tolltip text - if ($forum->rsstype == 1) { - $tooltiptext = get_string("rsssubscriberssdiscussions","forum",$forum->name); - } else { - $tooltiptext = get_string("rsssubscriberssposts","forum",$forum->name); - } - //Get html code for RSS link - $rsslink = rss_get_link($course->id, $USER->id, "forum", $forum->id, $tooltiptext); - } + //Depending of rsslink + if (!empty($rsslink)) { //Save data - $generaltable->data[] = array ($forumlink, "$forum->intro", "$count", $sublink,$rsslink); + $generaltable->data[] = array ($forumlink, "$forum->intro", "$count", $sublink, $rsslink); } else { $generaltable->data[] = array ($forumlink, "$forum->intro", "$count", $sublink); } } else { - $generaltable->data[] = array ($forumlink, "$forum->intro", "$count"); + //Depending of rsslink + if (!empty($rsslink)) { + $generaltable->data[] = array ($forumlink, "$forum->intro", "$count", $rsslink); + } else { + $generaltable->data[] = array ($forumlink, "$forum->intro", "$count"); + } } } } @@ -182,12 +197,13 @@ $learningtable->head = array ($strforum, $strdescription, $strdiscussions); $learningtable->align = array ("left", "left", "center"); - if ($can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin() or $course->id == SITEID)) { + if ($can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin())) { $learningtable->head[] = $strsubscribed; $learningtable->align[] = "center"; } - if ($show_rss = ($can_subscribe && isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && + if ($show_rss = (($can_subscribe || $course->id == SITEID) && + isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds)) { $learningtable->head[] = $strrss; $learningtable->align[] = "center"; @@ -233,6 +249,26 @@ $forumlink = "id\">$forum->name"; } + //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",$forum->name); + } else { + $tooltiptext = get_string("rsssubscriberssposts","forum",$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); + } + } + if ($can_subscribe) { if (forum_is_forcesubscribed($forum->id)) { $sublink = get_string("yes"); @@ -253,26 +289,20 @@ $sublink = "id\">$subscribed"; } } - //If this forum has RSS activated, calculate it - if ($show_rss) { - $rsslink = ''; - if ($forum->rsstype and $forum->rssarticles) { - //Calculate the tolltip text - if ($forum->rsstype == 1) { - $tooltiptext = get_string("rsssubscriberssdiscussions","forum",$forum->name); - } else { - $tooltiptext = get_string("rsssubscriberssposts","forum",$forum->name); - } - //Get html code for RSS link - $rsslink = rss_get_link($course->id, $USER->id, "forum", $forum->id, $tooltiptext); - } + //Depending of rsslink + if (!empty($rsslink)) { //Save data - $learningtable->data[] = array ($printsection,$forumlink, "$forum->intro", "$count", $sublink,$rsslink); + $learningtable->data[] = array ($printsection,$forumlink, "$forum->intro", "$count", $sublink, $rsslink); } else { $learningtable->data[] = array ($printsection,$forumlink, "$forum->intro", "$count", $sublink); } } else { - $learningtable->data[] = array ($printsection, $forumlink, "$forum->intro", "$count"); + //Depending of rsslink + if (!empty($rsslink)) { + $learningtable->data[] = array ($printsection, $forumlink, "$forum->intro", "$count", $rsslink); + } else { + $learningtable->data[] = array ($printsection, $forumlink, "$forum->intro", "$count"); + } } } } diff --git a/mod/forum/view.php b/mod/forum/view.php index 125b1e4b49..03aa680bc3 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -115,7 +115,7 @@ } - if ($USER) { + if (!empty($USER->id)) { echo ''; $SESSION->fromdiscussion = "$FULLME"; if (forum_is_forcesubscribed($forum->id)) { @@ -158,18 +158,24 @@ echo "id\">$subtext"; } - //If rss are activated at site and forum level and this forum has rss defined, show link - if (isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && - $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds && $forum->rsstype and $forum->rssarticles) { - echo "
"; - if ($forum->rsstype == 1) { - $tooltiptext = get_string("rsssubscriberssdiscussions","forum",$forum->name); - } else { - $tooltiptext = get_string("rsssubscriberssposts","forum",$forum->name); - } - rss_print_link($course->id, $USER->id, "forum", $forum->id, $tooltiptext); - } + echo ''; + } + //If rss are activated at site and forum level and this forum has rss defined, show link + if (isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && + $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds && $forum->rsstype and $forum->rssarticles) { + echo ''; + if ($forum->rsstype == 1) { + $tooltiptext = get_string("rsssubscriberssdiscussions","forum",$forum->name); + } else { + $tooltiptext = get_string("rsssubscriberssposts","forum",$forum->name); + } + if (empty($USER->id)) { + $userid = 0; + } else { + $userid = $USER->id; + } + rss_print_link($course->id, $userid, "forum", $forum->id, $tooltiptext); echo ''; } diff --git a/mod/glossary/index.php b/mod/glossary/index.php index bc0a32d7e0..ab61d3756d 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -55,9 +55,10 @@ $table->align = array ("LEFT", "CENTER"); } - $can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin() or $course->id == SITEID); + $can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin()); - if ($show_rss = ($can_subscribe && isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) && + if ($show_rss = (($can_subscribe || $course->id == SITEID) && + isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds)) { $table->head[] = $strrss; $table->align[] = "CENTER"; @@ -92,8 +93,13 @@ if ($glossary->rsstype and $glossary->rssarticles) { //Calculate the tolltip text $tooltiptext = get_string("rsssubscriberss","glossary",$glossary->name); + if (empty($USER->id)) { + $userid = 0; + } else { + $userid = $USER->id; + } //Get html code for RSS link - $rsslink = rss_get_link($course->id, $USER->id, "glossary", $glossary->id, $tooltiptext); + $rsslink = rss_get_link($course->id, $userid, "glossary", $glossary->id, $tooltiptext); } } diff --git a/mod/glossary/view.php b/mod/glossary/view.php index d1b1c72eca..783f8848e3 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -233,7 +233,12 @@ $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds && $glossary->rsstype && $glossary->rssarticles) { echo '
'; $tooltiptext = get_string("rsssubscriberss","glossary",$glossary->name); - rss_print_link($course->id, $USER->id, "glossary", $glossary->id, $tooltiptext); + if (empty($USER->id)) { + $userid = 0; + } else { + $userid = $USER->id; + } + rss_print_link($course->id, $userid, "glossary", $glossary->id, $tooltiptext); echo '
'; } -- 2.39.5