[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm lonpreferences.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Tue, 11 May 2004 10:42:41 -0000
raeburn Tue May 11 06:42:41 2004 EDT
Modified files:
/loncom/interface lonpreferences.pm lonfeedback.pm
Log:
Set a default display setting for discussions (show only unread/ show all). Default will be overridden by a discussion-specific setting.
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.41 loncom/interface/lonpreferences.pm:1.42
--- loncom/interface/lonpreferences.pm:1.41 Fri Mar 26 15:29:35 2004
+++ loncom/interface/lonpreferences.pm Tue May 11 06:42:41 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.41 2004/03/26 20:29:35 www Exp $
+# $Id: lonpreferences.pm,v 1.42 2004/05/11 10:42:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -626,6 +626,63 @@
return;
}
+################################################################
+# discussion display subroutines
+################################################################
+sub discussionchanger {
+ my $r = shift;
+ 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;
+ }
+ $r->print(<<ENDLSCREEN);
+<form name="server" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="verify_and_change_discussion" />
+<br />
+ENDLSCREEN
+ $r->print(
+&mt('You can set a display preference for discussion posts for both bulletin boards and individual resources in all your courses.').'<br/>'.
+&mt('This default preference can be overridden within each individual discussion.').'<br/><br />'.
+&mt('Your discussion post display preference is currently set to display').' '.$currdisc.
+'.<br /><br /><input type="hidden" name="discdisplay" value="'.
+$discchange.'" /><input type="submit" value="'.
+&mt('Change to display').' '.$discbutton.'" /></form>'
+ );
+}
+
+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 $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';
+ }
+ $r->print(<<ENDVCSCREEN);
+</p>
+$message
+ENDVCSCREEN
+}
+
######################################################
# other handler subroutines #
######################################################
@@ -742,6 +799,22 @@
printmenu => 'yes',
subroutine=>\&verify_and_change_languages, }
));
+ push (@Options,({ action => 'changediscussions',
+ linktext => 'Change Discussion Display Preferences',
+ href => '/adm/preferences',
+ breadcrumb =>
+ { href => '/adm/preferences?action=changediscussions',
+ text => 'Change Discussions'},
+ subroutine => \&discussionchanger,
+ },
+ { action => 'verify_and_change_discussion',
+ breadcrumb =>
+ { href => '/adm/preferences?action=changediscussions',
+ text => 'Change Discussions'},
+ printmenu => 'yes',
+ subroutine => \&verify_and_change_discussion, }
+ ));
+
if ($ENV{'user.name'} =~ /^(albertel|koretemey|korte|hallmat3|turtle)$/) {
push (@Options,({ action => 'debugtoggle',
printmenu => 'yes',
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.82 loncom/interface/lonfeedback.pm:1.83
--- loncom/interface/lonfeedback.pm:1.82 Fri May 7 08:03:53 2004
+++ loncom/interface/lonfeedback.pm Tue May 11 06:42:41 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.82 2004/05/07 12:03:53 albertel Exp $
+# $Id: lonfeedback.pm,v 1.83 2004/05/11 10:42:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -84,6 +84,14 @@
$prevread = $dischash{$lastkey};
}
+# Get discussion display default setting for user
+ my %userenv = &Apache::lonnet::get('environment',['discdisplay'],$ENV{'user.domain'},$ENV{'user.name'});
+ my $discdisplay=$userenv{'discdisplay'};
+ if ($discdisplay eq 'unread') {
+ $showonlyunread = 1;
+ }
+
+# Override user's default if user specified display setting for this discussion
if (defined($dischash{$showkey})) {
$showonlyunread = $dischash{$showkey};
}