--- loncom/interface/lonfeedback.pm 2004/11/15 22:17:51 1.136 +++ loncom/interface/lonfeedback.pm 2004/11/19 19:43:05 1.142 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.136 2004/11/15 22:17:51 albertel Exp $ +# $Id: lonfeedback.pm,v 1.142 2004/11/19 19:43:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -74,7 +74,7 @@ sub list_discussion { if($ENV{'form.export'}) { $outputtarget = 'export'; } - } + } if (not &discussion_visible($status)) { return ''; } my @bgcols = ("#cccccc","#eeeeee"); my $discussiononly=0; @@ -106,7 +106,7 @@ sub list_discussion { my $userpickkey = $ressymb.'_userpick'; my $toggkey = $ressymb.'_readtoggle'; my $readkey = $ressymb.'_read'; - + $ressymb=$encsymb; my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'}); my %discinfo = (); my $showonlyunread = 0; @@ -132,7 +132,6 @@ sub list_discussion { $prevread = $dischash{$lastkey}; } } - &Apache::lonnet::logthis("\n last read r symb ".$lastkey); # Get information about students and non-students in course for filtering display of posts my %roleshash = (); @@ -360,17 +359,17 @@ imscp_v1p1.xsd http://www.imsglobal.org/ ''; if ($visible>2) { $discussion.=''; if ($newpostsflag) { if (!$markondisp) { - $discussion .=''; } @@ -639,38 +638,38 @@ to course faculty
Title: 

ENDDISCUSS - if ($ENV{'form.origpage'}) { - $discussion.=''."\n"; - foreach (@currnewattach) { - $discussion.=''."\n"; - } - } - $discussion.="\n"; - if ($outputtarget ne 'tex') { - $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode); - if (@currnewattach > 0) { - $newattachmsg .= 'New attachments
'; - if (@currnewattach > 1) { - $newattachmsg .= '
    '; - foreach my $item (@currnewattach) { - $item =~ m#.*/([^/]+)$#; - $newattachmsg .= '
  1. '.$1.'
  2. '."\n"; + if ($ENV{'form.origpage'}) { + $discussion.=''."\n"; + foreach (@currnewattach) { + $discussion.=''."\n"; + } + } + $discussion.="\n"; + if ($outputtarget ne 'tex') { + $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode); + if (@currnewattach > 0) { + $newattachmsg .= 'New attachments
    '; + if (@currnewattach > 1) { + $newattachmsg .= '
      '; + foreach my $item (@currnewattach) { + $item =~ m#.*/([^/]+)$#; + $newattachmsg .= '
    1. '.$1.'
    2. '."\n"; + } + $newattachmsg .= '
    '."\n"; + } else { + $currnewattach[0] =~ m#.*/([^/]+)$#; + $newattachmsg .= ''.$1.'
    '."\n"; } - $newattachmsg .= '
'."\n"; - } else { - $currnewattach[0] =~ m#.*/([^/]+)$#; - $newattachmsg .= ''.$1.'
'."\n"; } - } - $discussion.=$newattachmsg; - $discussion.=&generate_preview_button(); - } + $discussion.=$newattachmsg; + $discussion.=&generate_preview_button(); + } } - } else { - if (&discussion_open($status) && - &Apache::lonnet::allowed('pch', - $ENV{'request.course.id'}. - ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { + } else { + if (&discussion_open($status) && + &Apache::lonnet::allowed('pch', + $ENV{'request.course.id'}. + ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { if ($outputtarget ne 'tex') { $discussion.='
'. - '  '. - '   -   '.&mt('Mark NEW posts no longer new').'  '; + $discussion .=''.&mt('Mark NEW posts no longer new').'  '; } else { $discussion .= ' 
'. @@ -966,7 +965,7 @@ sub build_posting_display { } else { $rolematch .= ':'.$sectionpick; $skiptest = 0; - } + } } if ($statusfilter) { if ($statusfilter eq 'all') { @@ -980,7 +979,6 @@ sub build_posting_display { $$shown{$idx} = 1; } else { foreach my $role (@{$$roleinfo{$poster}}) { - &Apache::lonnet::logthis("\n rolematch $rolematch\nrole $role"); if ($role =~ m/^$rolematch$/) { $$shown{$idx} = 1; last; @@ -1657,6 +1655,7 @@ $lt{'sdpf'}
$lt{'prca'}
  1. $l


+ @@ -1678,6 +1677,7 @@ sub print_sortfilter_options { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + &Apache::lonenc::check_encrypt(\$symb); my @sections = (); my $section_sel = ''; my $numsections = 0; @@ -1814,15 +1814,14 @@ END sub print_showposters { my ($r,$symb,$previous,$feedurl,$sortposts) = @_; -# backward compatibility (bulletin boards used to be 'wrapped') - my $ressymb=&wrap_symb($symb); + &Apache::lonenc::check_encrypt(\$symb); my $crs='/'.$ENV{'request.course.id'}; if ($ENV{'request.course.sec'}) { $crs.='_'.$ENV{'request.course.sec'}; } $crs=~s/\_/\//g; my $seeid=&Apache::lonnet::allowed('rin',$crs); - my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'}, + my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); my %namesort = (); @@ -2090,7 +2089,7 @@ ENDNOREDIRTWO } sub screen_header { - my ($feedurl) = @_; + my ($feedurl,$symb) = @_; my $msgoptions=''; my $discussoptions=''; unless (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) { @@ -2116,7 +2115,7 @@ sub screen_header { } } if ($ENV{'request.course.id'}) { - if (&discussion_open() && + if (&discussion_open(undef,$symb) && &Apache::lonnet::allowed('pch', $ENV{'request.course.id'}. ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) { @@ -2126,7 +2125,7 @@ sub screen_header { $discussoptions.='
'. &mt('Anonymous contribution to course discussion of resource'). ' ('.&mt('name only visible to course faculty').')'; - } + } } if ($msgoptions) { $msgoptions='

'.&mt('Sending Messages').'

'.$msgoptions; } if ($discussoptions) { @@ -2444,6 +2443,7 @@ sub modify_attachments { if ($idx) { &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold); } + &Apache::lonenc::check_encrypt(\$symb); $r->print(< @@ -2737,7 +2737,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','navtime','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']); + ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']); if ($ENV{'form.discsymb'}) { my ($symb,$feedurl) = &get_feedurl_and_clean_symb($ENV{'form.discsymb'}); my $readkey = $symb.'_read'; @@ -2824,8 +2824,8 @@ END $ENV{'form.rolefilter'},$ENV{'form.statusfilter'}, $ENV{'form.secpick'}); return OK; - } elsif ($ENV{'form.sortfilter'}) { - my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.sortfilter'}); + } elsif ($ENV{'form.cmd'} eq 'sortfilter') { + my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'}); &print_sortfilter_options($r,$symb,$ENV{'form.previous'},$feedurl); return OK; } elsif ($ENV{'form.navtime'}) { @@ -2896,77 +2896,39 @@ ENDREDIR } elsif ($ENV{'form.markondisp'} || $ENV{'form.markonread'} || $ENV{'form.allposts'} || $ENV{'form.onlyunread'} || $ENV{'form.onlyunmark'} || $ENV{'form.toggoff'} || - $ENV{'form.toggon'} ) { - my $feedurl; - if ( ($ENV{'form.toggoff'}) || ($ENV{'form.toggon'}) ) { + $ENV{'form.toggon'} || $ENV{'form.markread'}) { + my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'}); + my %discinfo; # ------------------------ Modify setting for read/unread toggle for each post - my $symb=$ENV{'form.toggoff'}?$ENV{'form.toggoff'}:$ENV{'form.toggon'}; - ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb); - my %discinfo; - $discinfo{$symb.'_readtoggle'}=1; - if ($ENV{'form.toggoff'}) { $discinfo{$symb.'_readtoggle'}=0; } - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss', - \%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); - } - if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) { + if ($ENV{'form.toggoff'}) { $discinfo{$symb.'_readtoggle'}=0; } + if ($ENV{'form.toggon'}) { $discinfo{$symb.'_readtoggle'}=1; } # --------- Modify setting for identification of 'NEW' posts in this discussion - my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'}; - ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb); - my %discinfo; - my $lastkey = $symb.'_lastread'; - my $ondispkey = $symb.'_markondisp'; - if ($ENV{'form.markondisp'}) { - $discinfo{$lastkey} = time; - $discinfo{$ondispkey} = 1; - } elsif ($ENV{'form.markonread'}) { - if ( $ENV{'form.previous'} > 0 ) { - $discinfo{$lastkey} = $ENV{'form.previous'}; - } - $discinfo{$ondispkey} = 0; - } - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss', - \%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + if ($ENV{'form.markondisp'}) { + $discinfo{$symb.'_lastread'} = time; + $discinfo{$symb.'_markondisp'} = 1; + } + if ($ENV{'form.markonread'}) { + if ( $ENV{'form.previous'} > 0 ) { + $discinfo{$symb.'_lastread'} = $ENV{'form.previous'}; + } + $discinfo{$symb.'_markondisp'} = 0; } - if ($ENV{'form.allposts'} || $ENV{'form.onlyunread'} || - $ENV{'form.onlyunmark'}) { # --------------------------------- Modify display setting for this discussion - my $symb; - if ($ENV{'form.allposts'}) { - $symb = $ENV{'form.allposts'}; - } elsif ($ENV{'form.onlyunread'}) { - $symb = $ENV{'form.onlyunread'}; - } else { - $symb = $ENV{'form.onlyunmark'}; - } - ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb); - my %discinfo; - if ($ENV{'form.allposts'}) { - $discinfo{$symb.'_showonlyunread'} = 0; - $discinfo{$symb.'_showonlyunmark'} = 0; - } elsif ($ENV{'form.onlyunread'}) { - $discinfo{$symb.'_showonlyunread'} = 1; - } else { - $discinfo{$symb.'_showonlyunmark'} = 1; - } - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss', - \%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); + if ($ENV{'form.allposts'}) { + $discinfo{$symb.'_showonlyunread'} = 0; + $discinfo{$symb.'_showonlyunmark'} = 0; } + if ($ENV{'form.onlyunread'}) { $discinfo{$symb.'_showonlyunread'} = 1; } + if ($ENV{'form.onlyunmark'}) { $discinfo{$symb.'_showonlyunmark'} = 1; } +# ----------------------------------------------------- Mark new posts not NEW + if ($ENV{'form.markread'}) { $discinfo{$symb.'_lastread'} = time; } + &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss', + \%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); my $previous=$ENV{'form.previous'}; if ($ENV{'form.markondisp'}) { $previous=undef; } &redirect_back($r,$feedurl,&mt('Changed display status').'
', '0','0','',$previous); return OK; - } elsif ($ENV{'form.markread'}) { -# ----------------------------------------------------- Mark new posts not NEW - my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.markread'}); - &Apache::lonnet::logthis("\n last read w symb ".$symb); - my %discinfo; - $discinfo{$symb.'_lastread'} = time; - &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss', - \%discinfo,$ENV{'user.domain'},$ENV{'user.name'}); - &redirect_back($r,$feedurl,&mt('Changed reading status').'
', - '0','0'); - return OK; } elsif (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) { # ----------------------------------------------------------------- Hide/unhide my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'}; @@ -3007,18 +2969,15 @@ ENDREDIR &redirect_back($r,$feedurl,&mt('Changed discussion status').'
', '0','0','',$ENV{'form.previous'}); return OK; - } elsif (($ENV{'form.threadedon'}) || ($ENV{'form.threadedoff'})) { - my $symb; - if ($ENV{'form.threadedon'}) { - $symb=$ENV{'form.threadedon'}; + } elsif ($ENV{'form.cmd'}=~/^(threadedoff|threadedon)$/) { + my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'}); + if ($ENV{'form.cmd'} eq 'threadedon') { &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'}); &Apache::lonnet::appenv('environment.threadeddiscussion' => 'on'); } else { - $symb=$ENV{'form.threadedoff'}; &Apache::lonnet::del('environment',['threadeddiscussion']); &Apache::lonnet::delenv('environment\.threadeddiscussion'); } - my ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb); &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'
', '0','0','',$ENV{'form.previous'}); return OK; @@ -3051,7 +3010,7 @@ ENDREDIR unless (length($ENV{'form.addnewattach'})>131072) { my $subdir = 'feedback/'.$ENV{'form.timestamp'}; my $newattachment=&Apache::lonnet::userfileupload('addnewattach',undef,$subdir); - push @currnewattach, $newattachment; + push @currnewattach, $newattachment; } } my $attachmenturls; @@ -3143,7 +3102,7 @@ ENDREDIR unless ($ENV{'form.sendit'}) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - my $options=&screen_header($feedurl); + my $options=&screen_header($feedurl,$symb); if ($options) { &mail_screen($r,$feedurl,$options); } else {