--- loncom/interface/lonpreferences.pm 2005/02/25 06:48:00 1.55
+++ loncom/interface/lonpreferences.pm 2006/04/10 18:59:30 1.80
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.55 2005/02/25 06:48:00 albertel Exp $
+# $Id: lonpreferences.pm,v 1.80 2006/04/10 18:59:30 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,6 +40,7 @@ use DynaLoader; # for Crypt::DES version
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
+use Apache::lonnet;
#
# Write lonnet::passwd to do the call below.
@@ -97,20 +98,20 @@ sub wysiwygchanger {
my $r = shift;
my %userenv = &Apache::lonnet::get
('environment',['wysiwygeditor']);
+ my $onselect='checked="checked"';
my $offselect='';
- my $onselect='checked="1"';
- if ($userenv{'wysiwygeditor'}) {
+ if ($userenv{'wysiwygeditor'} eq 'on') {
$onselect='';
- $offselect='checked="1"';
+ $offselect='checked="checked"';
}
my $switchoff=&mt('Disable WYSIWYG editor');
my $switchon=&mt('Enable WYSIWYG editor');
$r->print(<
+
+
Convert to Images
+
+
+
ENDLSCREEN
- if ($ENV{'environment.texengine'} ne 'jsMath') {
+ if ($env{'environment.texengine'} ne 'jsMath') {
$r->print('');
}
}
@@ -240,11 +244,18 @@ ENDLSCREEN
sub verify_and_change_texengine {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
# Screenname
- my $newtexengine = $ENV{'form.texengine'};
+ my $newtexengine = $env{'form.texengine'};
$newtexengine=~s/[^\-\w]//g;
+ if ($newtexengine eq 'ttm') {
+ &Apache::lonnet::appenv('browser.mathml' => 1);
+ } else {
+ if ($env{'environment.texengine'} eq 'ttm') {
+ &Apache::lonnet::appenv('browser.mathml' => 0);
+ }
+ }
my $message='';
if ($newtexengine) {
&Apache::lonnet::put('environment',{'texengine' => $newtexengine});
@@ -255,8 +266,9 @@ sub verify_and_change_texengine {
&Apache::lonnet::delenv('environment\.texengine');
$message='Reset preferred math display.';
}
+
+
$r->print(<
$message
ENDVCSCREEN
}
@@ -266,8 +278,8 @@ ENDVCSCREEN
################################################################
sub rolesprefchanger {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get
('environment',['recentroles','recentrolesn']);
my $hotlist_flag=$userenv{'recentroles'};
@@ -292,7 +304,7 @@ visited and places a table of these at t
People with very few roles should leave this feature disabled.
-
+
Enable Recent Roles Hotlist:
@@ -308,11 +320,11 @@ ENDSCREEN
sub verify_and_change_rolespref {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
# Recent Roles Hotlist Flag
- my $hotlist_flag = $ENV{'form.recentroles'};
- my $hotlist_n = $ENV{'form.recentrolesn'};
+ my $hotlist_flag = $env{'form.recentroles'};
+ my $hotlist_n = $env{'form.recentrolesn'};
my $message='';
if ($hotlist_flag) {
&Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
@@ -332,7 +344,6 @@ sub verify_and_change_rolespref {
}
$r->print(<
$message
ENDRPSCREEN
}
@@ -344,14 +355,14 @@ ENDRPSCREEN
################################################################
sub screennamechanger {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get
('environment',['screenname','nickname']);
my $screenname=$userenv{'screenname'};
my $nickname=$userenv{'nickname'};
$r->print(<
+
New screenname (shown if you post anonymously):
@@ -364,10 +375,10 @@ ENDSCREEN
sub verify_and_change_screenname {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
# Screenname
- my $newscreen = $ENV{'form.screenname'};
+ my $newscreen = $env{'form.screenname'};
$newscreen=~s/[^ \w]//g;
my $message='';
if ($newscreen) {
@@ -381,7 +392,7 @@ sub verify_and_change_screenname {
}
# Nickname
$message.=' ';
- $newscreen = $ENV{'form.nickname'};
+ $newscreen = $env{'form.nickname'};
$newscreen=~s/[^ \w]//g;
if ($newscreen) {
&Apache::lonnet::put('environment',{'nickname' => $newscreen});
@@ -392,9 +403,8 @@ sub verify_and_change_screenname {
&Apache::lonnet::delenv('environment\.nickname');
$message.='Reset nickname';
}
-
+ &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain);
$r->print(<
$message
ENDVCSCREEN
}
@@ -405,8 +415,8 @@ ENDVCSCREEN
sub msgforwardchanger {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification']);
my $msgforward=$userenv{'msgforward'};
my $notification=$userenv{'notification'};
@@ -420,7 +430,7 @@ sub msgforwardchanger {
$r->print(<
-
+
New Forwarding Address(es) (user:domain,user:domain,...):
@@ -435,11 +445,11 @@ ENDMSG
sub verify_and_change_msgforward {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
my $newscreen = '';
my $message='';
- foreach (split(/\,/,$ENV{'form.msgforward'})) {
+ foreach (split(/\,/,$env{'form.msgforward'})) {
my ($msuser,$msdomain)=split(/[\@\:]/,$_);
$msuser=~s/\W//g;
$msdomain=~s/\W//g;
@@ -461,7 +471,7 @@ sub verify_and_change_msgforward {
&Apache::lonnet::delenv('environment\.msgforward');
$message.='Reset message forwarding ';
}
- my $notification=$ENV{'form.notification'};
+ my $notification=$env{'form.notification'};
$notification=~s/\s//gs;
if ($notification) {
&Apache::lonnet::put('environment',{'notification' => $notification});
@@ -472,7 +482,7 @@ sub verify_and_change_msgforward {
&Apache::lonnet::delenv('environment\.notification');
$message.='Reset message notification ';
}
- my $critnotification=$ENV{'form.critnotification'};
+ my $critnotification=$env{'form.critnotification'};
$critnotification=~s/\s//gs;
if ($critnotification) {
&Apache::lonnet::put('environment',{'critnotification' => $critnotification});
@@ -484,7 +494,6 @@ sub verify_and_change_msgforward {
$message.='Reset critical message notification ';
}
$r->print(<
$message
ENDVCMSG
}
@@ -496,17 +505,7 @@ ENDVCMSG
sub colorschanger {
my $r = shift;
# figure out colors
- my $function='student';
- if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
- $function='coordinator';
- }
- if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
- $function='admin';
- }
- if (($ENV{'request.role'}=~/^(au|ca)/) ||
- ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
- $function='author';
- }
+ my $function=&Apache::loncommon::get_users_function();
my $domain=&Apache::loncommon::determinedomain();
my %colortypes=('pgbg' => 'Page Background',
'tabbg' => 'Header Background',
@@ -541,7 +540,7 @@ sub colorschanger {
pclose();
if (document.parmform.pres_marker.value!='') {
if (document.parmform.pres_type.value!='') {
- eval('document.server.'+
+ eval('document.prefs.'+
document.parmform.pres_marker.value+
'.value=document.parmform.pres_value.value;');
}
@@ -558,7 +557,7 @@ sub colorschanger {
-
+
$chtable
@@ -572,17 +571,7 @@ ENDCOL
sub verify_and_change_colors {
my $r = shift;
# figure out colors
- my $function='student';
- if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
- $function='coordinator';
- }
- if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
- $function='admin';
- }
- if (($ENV{'request.role'}=~/^(au|ca)/) ||
- ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
- $function='author';
- }
+ my $function=&Apache::loncommon::get_users_function();
my $domain=&Apache::loncommon::determinedomain();
my %colortypes=('pgbg' => 'Page Background',
'tabbg' => 'Header Background',
@@ -594,9 +583,9 @@ sub verify_and_change_colors {
my $message='';
foreach my $item (keys %colortypes) {
- my $color=$ENV{'form.'.$item};
+ my $color=$env{'form.'.$item};
my $entry='color.'.$function.'.'.$item;
- if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$ENV{'form.resetall'})) {
+ if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
&Apache::lonnet::put('environment',{$entry => $color});
&Apache::lonnet::appenv('environment.'.$entry => $color);
$message.='Set '.$colortypes{$item}.' to '.$color.' ';
@@ -607,9 +596,8 @@ sub verify_and_change_colors {
}
}
$r->print(<
$message
-
+
ENDVCCOL
@@ -624,9 +612,9 @@ sub passwordchanger {
my $r = shift;
my $errormessage = shift;
$errormessage = ($errormessage || '');
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
- my $homeserver = $ENV{'user.home'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
+ my $homeserver = $env{'user.home'};
my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
# Check for authentication types that allow changing of the password.
return if ($currentauth !~ /^(unix|internal):/);
@@ -651,8 +639,6 @@ sub passwordchanger {
$lkey_npass2= hex($lkey_npass2);
# Output javascript to deal with passwords
# Output DES javascript
- my $html=&Apache::lonxml::xmlbegin();
- $r->print($html."");
{
my $include = $r->dir_config('lonIncludes');
my $jsh=Apache::File->new($include."/londes.js");
@@ -692,7 +678,7 @@ $errormessage
ensure that unencrypted passwords will not be sent out by a
crappy browser -->
-
+
@@ -726,25 +712,17 @@ ENDFORM
sub verify_and_change_password {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
- my $homeserver = $ENV{'user.home'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
+ my $homeserver = $env{'user.home'};
my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
# Check for authentication types that allow changing of the password.
return if ($currentauth !~ /^(unix|internal):/);
#
- my $html=&Apache::lonxml::xmlbegin();
- $r->print(<
-LON-CAPA Preferences: Change password for $user
-
-ENDHEADER
- #
- my $currentpass = $ENV{'form.currentpass'};
- my $newpass1 = $ENV{'form.newpass_1'};
- my $newpass2 = $ENV{'form.newpass_2'};
- my $logtoken = $ENV{'form.logtoken'};
+ my $currentpass = $env{'form.currentpass'};
+ my $newpass1 = $env{'form.newpass_1'};
+ my $newpass2 = $env{'form.newpass_2'};
+ my $logtoken = $env{'form.logtoken'};
# Check for empty data
unless (defined($currentpass) &&
defined($newpass1) &&
@@ -765,7 +743,7 @@ password decryption. Please log out and
ENDERROR
# Probably should log an error here
- return;
+ return 1;
}
my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
#
@@ -778,14 +756,14 @@ ENDERROR
'ERROR:'.
'The new passwords you entered do not match. '.
'Please try again.');
- return;
+ return 1;
}
if (length($newpass1) < 7) {
&passwordchanger($r,
'ERROR:'.
'Passwords must be a minimum of 7 characters long. '.
'Please try again.');
- return;
+ return 1;
}
#
# Check for bad characters
@@ -820,6 +798,7 @@ ENDTEXT
The password for $user was not changed
Please make sure your old password was entered correctly.
ENDERROR
+ return 1;
}
return;
}
@@ -829,8 +808,8 @@ ENDERROR
################################################################
sub discussionchanger {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get
('environment',['discdisplay','discmarkread']);
my $discdisp = 'allposts';
@@ -852,7 +831,7 @@ sub discussionchanger {
my $function = &Apache::loncommon::get_users_function();
my $color = &Apache::loncommon::designparm($function.'.tabbg',
- $ENV{'user.domain'});
+ $env{'user.domain'});
my %lt = &Apache::lonlocal::texthash(
'pref' => 'Display Preference',
'curr' => 'Current setting ',
@@ -888,7 +867,7 @@ sub discussionchanger {
}
$r->print(<<"END");
-
+
$lt{'sdpf'} $lt{'prca'}
$lt{'whpo'}
$lt{'unwh'}
@@ -934,11 +913,11 @@ END
sub verify_and_change_discussion {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
my $message='';
- if (defined($ENV{'form.discdisp'}) ) {
- my $newdisp = $ENV{'form.newdisp'};
+ 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});
@@ -949,8 +928,8 @@ sub verify_and_change_discussion {
&Apache::lonnet::delenv('environment\.discdisplay');
}
}
- if (defined($ENV{'form.discmark'}) ) {
- my $newmark = $ENV{'form.newmark'};
+ 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});
@@ -962,11 +941,89 @@ sub verify_and_change_discussion {
}
}
$r->print(<
$message
ENDVCSCREEN
}
+################################################################
+# Subroutines for page display on course access (Course Coordinators)
+################################################################
+sub coursedisplaychanger {
+ my $r = shift;
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
+ my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
+ my $currvalue = 'whatsnew';
+ my $firstselect = '';
+ my $whatsnewselect = 'checked="checked"';
+ if (exists($userenv{'course_init_display'})) {
+ if ($userenv{'course_init_display'} eq 'firstres') {
+ $currvalue = 'firstres';
+ $firstselect = 'checked="checked"';
+ $whatsnewselect = '';
+ }
+ }
+ my %pagenames = (
+ firstres => 'First resource',
+ whatsnew => "What's new page",
+ );
+ my $whatsnew_off=&mt('Display the [_1] in the course.','first resource');
+ my $whatsnew_on=&mt('Display the "[_1]" page - a summary of items in the course which require attention.',"What's New");
+
+ $r->print(' '.&mt('Set the default page to be displayed when you select a course role').' '.&mt('(Currently: [_1])',$pagenames{$currvalue}).' '.&mt('The global user preference you set for your courses can be overridden in an individual course by setting a course specific setting via the "[_1]" page in the course',"What's New").'