--- loncom/interface/lonfeedback.pm 2004/09/21 20:44:16 1.127 +++ loncom/interface/lonfeedback.pm 2004/11/11 22:19:53 1.129 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.127 2004/09/21 20:44:16 albertel Exp $ +# $Id: lonfeedback.pm,v 1.129 2004/11/11 22:19:53 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::loncommon(); use Apache::lontexconvert(); use Apache::lonlocal; # must not have () use Apache::lonhtmlcommon(); +use Apache::lonnavmaps; use HTML::LCParser(); use Apache::lonspeller(); use Cwd; @@ -98,7 +99,7 @@ sub list_discussion { $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|; } } - + $ressymb=&Apache::lonenc::check_encrypt($ressymb); # Get discussion display settings for this discussion my $lastkey = $ressymb.'_lastread'; my $showkey = $ressymb.'_showonlyunread'; @@ -359,7 +360,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/ } |; - $discussion.='
'; + $discussion.='
'; $discussion .='
'. ''; if ($visible>2) { @@ -677,7 +678,7 @@ ENDDISCUSS ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { if ($outputtarget ne 'tex') { $discussion.='
'. + $ressymb.':::" '.$target.'>'. ''. &mt('Post Discussion').'
'; } @@ -2048,6 +2049,7 @@ sub redirect_back { $sectag = ''; } } + $feedurl=&Apache::lonenc::check_encrypt($feedurl); $r->print (< @@ -2085,9 +2087,10 @@ sub no_redirect_back { ENDNOREDIR if ($feedurl!~/^\/adm\/feedback/) { - $r->print(''); + $r->print(''); } - + $feedurl=&Apache::lonenc::check_encrypt($feedurl); $r->print (< @@ -2716,6 +2719,24 @@ sub construct_attachmenturl { } return $newattachmenturl; } + +sub has_discussion { + my $resourcesref = shift; + my $navmap = Apache::lonnavmaps::navmap->new(); + my @allres=$navmap->retrieveResources(); + foreach my $resource (@allres) { + if ($resource->hasDiscussion()) { + my $ressymb; + if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { + $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; + } else { + $ressymb = $resource->symb(); + } + push @{$resourcesref}, $ressymb; + } + } + return; +} sub handler { my $r = shift; @@ -2728,7 +2749,7 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navmaps','navurl','navtime','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']); + ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']); if ($ENV{'form.discsymb'}) { my $symb = $ENV{'form.discsymb'}; my $readkey = $symb.'_read'; @@ -2875,13 +2896,17 @@ END } &print_sortfilter_options($r,$symb,$previous,$feedurl); return OK; - } elsif ($ENV{'form.navmaps'}) { + } elsif ($ENV{'form.navtime'}) { my %discinfo = (); my @resources = (); - if ($ENV{'form.navmaps'} =~ /:/) { - @resources = split/:/,$ENV{'form.navmaps'}; + if (defined($ENV{'form.navmaps'})) { + if ($ENV{'form.navmaps'} =~ /:/) { + @resources = split/:/,$ENV{'form.navmaps'}; + } else { + @resources = ("$ENV{'form.navmaps'}"); + } } else { - @resources = ("$ENV{'form.navmaps'}"); + &has_discussion(\@resources); } my $numitems = @resources; my $feedurl = '/adm/navmaps'; @@ -2890,7 +2915,8 @@ END } my %lt = &Apache::lonlocal::texthash( 'mnpa' => 'Marked "New" posts as read in a total of', - 'robb' => 'resources/bulletin boards.' + 'robb' => 'resources/bulletin boards.', + 'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.' ); foreach (@resources) { # backward compatibility (bulletin boards used to be 'wrapped') @@ -2903,7 +2929,12 @@ END my $lastkey = $ressymb.'_lastread'; $discinfo{$lastkey} = $ENV{'form.navtime'}; } - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + my $textline = "$lt{'mnpa'} $numitems $lt{'robb'}"; + if ($numitems > 0) { + &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + } else { + $textline = "$lt{'twnp'}"; + } &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; $r->print (< -$lt{'mnpa'} $numitems $lt{'robb'} +$textline
Continue