';
@@ -200,16 +201,62 @@ sub add_blog_entry_link {
my ($id,$uname,$udom,$filename,$title,$description,$url,$status,$encurl,$enctype,$linktext)=@_;
return "".$linktext.'';
}
+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,15 +287,22 @@ sub handler {
my $filterfeedname=&filterfeedname($filename);
my $feedname=&feedname($filename);
my ($displayfeedname,$displayoption)=&displayfeedname($filename,$uname,$udom);
+ my ($blocked,$blocktext);
+ if ($uname !~ /^$match_courseid$/) {
+ ($blocked,$blocktext) = &blocking_blogdisplay($uname,$udom,$html,$filterfeedname);
+ }
if ($html) {
- $r->print(&Apache::loncommon::start_page(($displayfeedname?$displayfeedname:&mt("Available RSS Feeds and Blogs")),undef,
+ my $title = $displayfeedname?$displayfeedname
+ :"Available RSS Feeds and Blogs";
+ $r->print(&Apache::loncommon::start_page($title,undef,
{'domain' => $udom,
'force_register' =>
$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').
@@ -258,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?
@@ -287,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 ($uname =~ /^$match_courseid$/) {
my %cenv=&Apache::lonnet::dump('environment',$udom,$uname);
$name=$cenv{'description'};
} else {
@@ -337,7 +394,7 @@ sub handler {
&editentry($id,$uname,$udom,$feedname,
$env{'form.'.$id.'_title'},
$env{'form.'.$id.'_description'},
- $env{'form.'.$id.'_url'},
+ $env{'form.'.$id.'_link'},
$env{'form.'.$id.'_status'},
$env{'form.'.$id.'_enclosureurl'},
$env{'form.'.$id.'_enclosuretype'},
@@ -347,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).
@@ -355,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') {
@@ -400,12 +457,16 @@ ENDEDIT
} else { # not in edit mode, just displaying
if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
if ($newsfeed{$id.'_status'} eq 'hidden') { next; }
+ my $link = $newsfeed{$id.'_link'};
+ if ($link =~ m|^/| ) {
+ $link = "http://".$ENV{'HTTP_HOST'}.$link;
+ }
$r->print("\n".($html?"\n
":"\n").$newsfeed{$id.'_title'}.
($html?" \n":"\n").
$newsfeed{$id.'_description'}.
($html?" \n".&mt('Read more')." \n"):"\n"));
# Enclosure? Get stats
if ($newsfeed{$id.'_enclosureurl'}) {