';
@@ -210,6 +211,52 @@ sub add_blog_entry_link {
}
+sub blocking_blogdisplay {
+ my ($uname,$udom,$html,$filterfeedname) = @_;
+ my $user = &Apache::loncommon::plainname($uname,$udom);
+ if ($html) {
+ $user = &Apache::loncommon::aboutmewrapper($user,$uname,$udom);
+ } else {
+ $user = $user.' ('.$uname.':'.$udom.')';
+ }
+ my %setters;
+ my ($blocked,$output,$blockcause);
+ my ($startblock,$endblock) =
+ &Apache::loncommon::blockcheck(\%setters,'blogs');
+ if ($startblock && $endblock) {
+ $blockcause = 'user';
+ } else {
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
+ ($startblock,$endblock) =
+ &Apache::loncommon::blockcheck(\%setters,'blogs',
+ $uname,$udom);
+ $blockcause = 'blogowner';
+ }
+ }
+ if ($startblock && $endblock) {
+ $blocked = 1;
+ my $showstart = &Apache::lonlocal::locallocaltime($startblock);
+ my $showend = &Apache::lonlocal::locallocaltime($endblock);
+ $output = &mt('Blogs belonging to [_1] are unavailable from [_2] to [_3].',$user,$showstart,$showend);
+ if ($html) {$output.=' ';}
+ if ($blockcause eq 'user') {
+ $output .= &mt('This is because you are a student in one or more courses in which communication is being blocked.');
+ if ($html) {
+ $output .= ' '.
+ &Apache::loncommon::build_block_table($startblock,
+ $endblock,\%setters);
+ }
+ } else {
+ $output .= &mt('This is because the blog owner is a student in one or more courses in which communication is being blocked.');
+ }
+ if (!$html) {
+ my $id = &get_new_feed_id();
+ $output = ''.$output."".$id.$filterfeedname.'_'.$udom.'_'.$uname.'';
+ }
+ }
+ return ($blocked,$output);
+}
+
sub handler {
my ($r) = @_;
@@ -240,6 +287,10 @@ sub handler {
my $filterfeedname=&filterfeedname($filename);
my $feedname=&feedname($filename);
my ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
+ my ($blocked,$blocktext);
+ if (!&Apache::lonnet::is_course($udom,$uname)) {
+ ($blocked,$blocktext) = &blocking_blogdisplay($uname,$udom,$html,$filterfeedname);
+ }
if ($html) {
my $title = $displayfeedname?$displayfeedname
:"Available RSS Feeds and Blogs";
@@ -249,8 +300,9 @@ sub handler {
$env{'form.register'}}).
&changed_js());
} else { # render RSS
+ my $server = &Apache::lonnet::absolute_url();
$r->print("\n".
- "\nhttp://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.
+ "\n".''.$server.'/public/'.$udom.'/'.$uname.'/'.
$filterfeedname.'_rss.html'.
"\n".
&mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').
@@ -260,7 +312,7 @@ sub handler {
my $newid = &get_new_feed_id();
# Is this user for real?
my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
- if ($html) {
+ if ($html && !$blocked) {
# Any new feeds or renaming of feeds?
if ($edit) {
# Hide a feed?
@@ -289,10 +341,13 @@ sub handler {
}
if ($homeserver eq 'no_host') {
$r->print(($html?'
':'').&mt('No feed available').($html?'
':''));
+ } elsif ($blocked) {
+ $r->print($blocktext);
+ $r->print(($html?&Apache::loncommon::end_page():''."\n"));
} else { # is indeed a user
# Course or user?
my $name='';
- if ($uname=~/^\d/) {
+ if (&Apache::lonnet::is_course($udom,$uname)) {
my %cenv=&Apache::lonnet::dump('environment',$udom,$uname);
$name=$cenv{'description'};
} else {
@@ -349,6 +404,8 @@ sub handler {
}
} #done storing
+# Render private items?
+ my $viewpubliconly=1;
$r->print("\n".
($html?'
':'').
&mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
@@ -357,11 +414,9 @@ sub handler {
&mt('Name of this Feed').
': ':'').'
':'
'));
-# Render private items?
- my $viewpubliconly=1;
if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
$viewpubliconly=0;
- }
+ }
# Get feed items
my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
foreach my $entry (sort(keys(%newsfeed)),$newid.'_status') {