--- loncom/interface/lonpreferences.pm 2004/05/11 10:42:41 1.42 +++ loncom/interface/lonpreferences.pm 2004/05/25 22:00:21 1.43 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.42 2004/05/11 10:42:41 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.43 2004/05/25 22:00:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -634,48 +634,134 @@ sub discussionchanger { my $user = $ENV{'user.name'}; my $domain = $ENV{'user.domain'}; my %userenv = &Apache::lonnet::get - ('environment',['discdisplay']); - my $discdisplay=$userenv{'discdisplay'}; - my $discchange = 'unread'; - my $alllong = &mt('all posts'); - my $unreadlong = &mt('only unread posts'); - my $discbutton = $unreadlong; - my $currdisc = $alllong; - if ($discdisplay eq 'unread') { - $discchange = 'allposts'; - $discbutton = $alllong; - $currdisc = $unreadlong; + ('environment',['discdisplay','discmarkread']); + my $discdisp = 'allposts'; + my $discmark = 'onmark'; + + if (defined($userenv{'discdisplay'})) { + unless ($userenv{'discdisplay'} eq '') { + $discdisp = $userenv{'discdisplay'}; + } } - $r->print(< 'Display Preference', + 'curr' => 'Current setting ', + 'actn' => 'Action', + 'sdpf' => 'Set display preferences for discussion posts for both bulletin boards and individual resources in all your courses.', + 'prca' => 'Preferences can be set that determine', + 'whpo' => 'Which posts are displayed when you display a bulletin board or resource, and', + 'unwh' => 'Under what circumstances posts are identfied as "New"', + 'allposts' => 'All posts', + 'unread' => 'New posts only', + 'ondisp' => 'Once displayed', + 'onmark' => 'Once marked as read', + 'disa' => 'Posts displayed?', + 'npmr' => 'New posts cease to be identified as "New"?', + 'thde' => 'The preferences you set here can be overridden within each individual discussion.', + 'chgt' => 'Change to ' + ); + my $dispchange = $lt{'unread'}; + my $markchange = $lt{'ondisp'}; + my $currdisp = $lt{'allposts'}; + my $currmark = $lt{'onmark'}; + + if ($discdisp eq 'unread') { + $dispchange = $lt{'allposts'}; + $currdisp = $lt{'unread'}; + $newdisp = 'allposts'; + } + + if ($discmark eq 'ondisp') { + $markchange = $lt{'onmark'}; + $currmark = $lt{'ondisp'}; + $newmark = 'onmark'; + } + + $r->print(<<"END");

-ENDLSCREEN - $r->print( -&mt('You can set a display preference for discussion posts for both bulletin boards and individual resources in all your courses.').'
'. -&mt('This default preference can be overridden within each individual discussion.').'

'. -&mt('Your discussion post display preference is currently set to display').' '.$currdisc. -'.

' - ); +$lt{'sdpf'}
$lt{'prca'}
  1. $lt{'whpo'}
  2. $lt{'unwh'}
+
+
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + +
$lt{'pref'}$lt{'curr'}$lt{'actn'}?
$lt{'disa'}$lt{$discdisp} $lt{'chgt'} "$dispchange"
$lt{'npmr'}$lt{$discmark} $lt{'chgt'} "$markchange"
+
+
+
+
+ +
+
+Note: $lt{'thde'} + +END } sub verify_and_change_discussion { my $r = shift; - my $user = $ENV{'user.name'}; - my $domain = $ENV{'user.domain'}; -# Discussion - my $discdisplay = $ENV{'form.discdisplay'}; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; my $message=''; - if ($discdisplay eq 'unread') { - &Apache::lonnet::put('environment',{'discdisplay' => $discdisplay}); - &Apache::lonnet::appenv('environment.discdisplay' => $discdisplay); - $message='Discussions set to display only unread posts'; - } else { - &Apache::lonnet::del('environment',['discdisplay']); - &Apache::lonnet::delenv('environment\.discdisplay'); - $message='Discussions set to display all posts'; + if (defined($ENV{'form.discdisp'}) ) { + my $newdisp = $ENV{'form.newdisp'}; + if ($newdisp eq 'unread') { + $message .='In discussions: only new posts will be displayed.
'; + &Apache::lonnet::put('environment',{'discdisplay' => $newdisp}); + &Apache::lonnet::appenv('environment.discdisplay' => $newdisp); + } else { + $message .= 'In discussions: all posts will be displayed.
'; + &Apache::lonnet::del('environment',['discdisplay']); + &Apache::lonnet::delenv('environment\.discdisplay'); + } + } + if (defined($ENV{'form.discmark'}) ) { + my $newmark = $ENV{'form.newmark'}; + if ($newmark eq 'ondisp') { + $message.='In discussions: new posts will be cease to be identified as "new" after display.
'; + &Apache::lonnet::put('environment',{'discmarkread' => $newmark}); + &Apache::lonnet::appenv('environment.discmarkread' => $newmark); + } else { + $message.='In discussions: posts will be identified as "new" until marked as read by the reader.
'; + &Apache::lonnet::del('environment',['discmarkread']); + &Apache::lonnet::delenv('environment\.discmarkread'); + } } $r->print(< @@ -804,13 +890,13 @@ sub handler { href => '/adm/preferences', breadcrumb => { href => '/adm/preferences?action=changediscussions', - text => 'Change Discussions'}, + text => 'Change Discussion Preferences'}, subroutine => \&discussionchanger, }, { action => 'verify_and_change_discussion', breadcrumb => { href => '/adm/preferences?action=changediscussions', - text => 'Change Discussions'}, + text => 'Change Discussion Preferences'}, printmenu => 'yes', subroutine => \&verify_and_change_discussion, } ));