--- loncom/interface/lonpreferences.pm 2009/04/05 17:18:29 1.150
+++ loncom/interface/lonpreferences.pm 2011/06/23 22:47:56 1.193
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.150 2009/04/05 17:18:29 droeschl Exp $
+# $Id: lonpreferences.pm,v 1.193 2011/06/23 22:47:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,6 +42,7 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonnet;
+use LONCAPA::lonauthcgi();
use LONCAPA();
#
@@ -116,7 +117,7 @@ sub wysiwygchanger {
my $switchon=&mt('Enable WYSIWYG editor');
my $warning='';
if ($env{'user.adv'}) {
- $warning.="
".&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."
";
+ $warning.='
'.&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."
";
}
$r->print(<
@@ -135,9 +136,9 @@ sub verify_and_change_wysiwyg {
my $newsetting=$env{'form.wysiwyg'};
&Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
&Apache::lonnet::appenv({'environment.wysiwygeditor' => $newsetting});
-# $r->print('
');
+ my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('WYSIWYG Editor').'',''.&mt($newsetting).''));
+ $message=&Apache::loncommon::confirmwrapper($message);
+ &print_main_menu($r,$message);
}
################################################################
@@ -165,8 +166,12 @@ sub languagechanger {
= &Apache::loncommon::plainlanguagedescription($_);
}
}
- my $selectionbox=&Apache::loncommon::select_form($language,'language',
- %langchoices);
+ %langchoices = &Apache::lonlocal::texthash(%langchoices);
+ my $selectionbox=
+ &Apache::loncommon::select_form(
+ $language,
+ 'language',
+ \%langchoices);
$r->print(<
@@ -187,17 +192,20 @@ sub verify_and_change_languages {
if ($newlanguage) {
&Apache::lonnet::put('environment',{'languages' => $newlanguage});
&Apache::lonnet::appenv({'environment.languages' => $newlanguage});
- $message=&mt('Set new preferred languages to ').'"'.$newlanguage.'".';
+ $message=&Apache::lonhtmlcommon::confirm_success(
+ &mt('Set [_1] to [_2]',
+ ''.&mt('Preferred language').'',
+ '"'.$newlanguage.'".'))
+ .' '
+ .&mt('The change will become active on the next page.');
} else {
&Apache::lonnet::del('environment',['languages']);
&Apache::lonnet::delenv('environment.languages');
- $message=&mt('Reset preferred language.');
+ $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]',''.&mt('Preferred language').''));
}
+ $message=&Apache::loncommon::confirmwrapper($message);
&Apache::loncommon::flush_langs_cache($user,$domain);
- print_main_menu($r, $message);
-# $r->print(< '/adm/preferences?action=changetexenginepref',
- text => 'Change How Math Equations Are Displayed'});
+ text => 'Math display settings'});
$r->print(Apache::loncommon::start_page('Content Display Settings'));
- $r->print(Apache::lonhtmlcommon::breadcrumbs('Change How Math Equations Are Displayed'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Math display settings'));
my $user = $env{'user.name'};
my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get('environment',['texengine']);
@@ -219,14 +227,19 @@ sub texenginechanger {
'tth' => 'tth (TeX to HTML)',
#'ttm' => 'TeX to MathML',
'jsMath' => 'jsMath',
- 'mimetex' => 'mimetex (Convert to Images)'
+ 'mimetex' => 'mimetex (Convert to Images)',
+ 'raw' => 'Raw (Screen Reader)'
);
- my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
- %mathchoices);
+ %mathchoices = &Apache::lonlocal::texthash(%mathchoices);
+ my $selectionbox=
+ &Apache::loncommon::select_form(
+ $texengine,
+ 'texengine',
+ \%mathchoices);
my $jsMath_start=&Apache::lontexconvert::jsMath_header();
my %lt=&Apache::lonlocal::texthash(
- 'headline' => 'Change Math Preferences',
- 'preftxt' => 'Preferred method to display Math',
+ 'headline' => 'Change how math is displayed',
+ 'preftxt' => 'Preferred method to display math',
'change' => 'Save',
'exmpl' => 'Examples',
'jsmath' => 'jsMath:',
@@ -234,6 +247,21 @@ sub texenginechanger {
'mimetex' => 'mimetex (Convert to Images):',
);
+ my $jsMathWarning='
'
+ .'
'
+ .&mt("It looks like you don't have the TeX math fonts installed.")
+ .'
'
+ .'
'
+ .&mt('The jsMath example on this page may not look right without them. '
+ .'The [_1]jsMath Home Page[_2] has information on how to download the '
+ .'needed fonts. In the meantime, jsMath will do the best it can '
+ .'with the fonts you have, but it may not be pretty and some equations '
+ .'may not be rendered correctly.'
+ ,''
+ ,'')
+ .'
'
+ .'';
+
$r->print(<$lt{'headline'}
-#ENDVCCOL
+ &print_main_menu($r, $message);
}
######################################################
@@ -1211,8 +1287,8 @@ sub passwordchanger {
# This function is a bit of a mess....
# Passwords are encrypted using londes.js (DES encryption)
$errormessage = ($errormessage || '');
- my ($user,$domain,$currentpass,$defdom);
- Apache::lonhtmlcommon::add_breadcrumb(
+ my ($user,$domain,$currentpass);
+ &Apache::lonhtmlcommon::add_breadcrumb(
{ href => '/adm/preferences?action=changepass',
text => 'Change Password'});
unless ($caller eq 'reset_by_email') {
@@ -1226,10 +1302,11 @@ sub passwordchanger {
$caller = 'preferences';
}
} elsif ($caller eq 'reset_by_email') {
- $defdom = $r->dir_config('lonDefDomain');
my %data = &Apache::lonnet::tmpget($mailtoken);
if (keys(%data) == 0) {
- $r->print(&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a new request for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.'));
+ $r->print(&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.'
+ ,'','')
+ );
return;
}
if (defined($data{time})) {
@@ -1245,7 +1322,10 @@ sub passwordchanger {
$r->print(&mt('Sorry, the URL generated when you requested reset of your password contained incomplete information.').' ');
return;
}
- } else {
+ if (&Apache::lonnet::domain($domain) eq '') {
+ $domain = $r->dir_config('lonDefDomain');
+ }
+ } else {
$r->print(&mt('Page requested in unexpected context').' ');
return;
}
@@ -1289,7 +1369,7 @@ $errormessage
crappy browser -->
ENDFORM
$r->print(&server_form($logtoken,$caller,$mailtoken));
- $r->print(&client_form($caller,\%hexkey,$currentpass,$defdom));
+ $r->print(&client_form($caller,\%hexkey,$currentpass,$domain));
#
return;
@@ -1326,6 +1406,8 @@ sub jscript_send {
this.document.client.elements.uname.value;
this.document.pserver.elements.udom.value =
this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value;
+ this.document.pserver.elements.email.value =
+ this.document.client.elements.email.value;
|;
}
$ output .= qq|
@@ -1344,42 +1426,42 @@ sub client_form {
'currentpass' => 'Current Password',
'newpass' => 'New Password',
'confirmpass' => 'Confirm Password',
- 'changepass' => 'Save');
+ 'changepass' => 'Save',
+ );
- my $output = qq|
-
-ENDFORM
+|;
return $output;
}
@@ -1410,6 +1492,7 @@ sub server_form {
+
|;
}
@@ -1554,22 +1637,27 @@ ENDERROR
# Inform the user the password has (not?) been changed
my $message;
if ($result =~ /^ok$/) {
- $message = &mt('The password for [_1] was successfully changed.',$user);
+ $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for user [_1] was successfully changed.',''.$user.''));
+ $message = &Apache::loncommon::confirmwrapper($message);
if ($caller eq 'reset_by_email') {
$r->print($message.' ');
} else {
&print_main_menu($r, $message);
}
-# $r->print("
".&mt('The password for [_1] was successfully changed',$user)."
");
} else {
# error error: run in circles, scream and shout
- $message = &mt("The password for [_1] was not changed.",$user).' '.&mt('Please make sure your old password was entered correctly.');
- unless ($caller eq 'reset_by_email') {
+ if ($caller eq 'reset_by_email') {
+ if (!$result) {
+ return 1;
+ } else {
+ return $result;
+ }
+ } else {
+ $message = &Apache::lonhtmlcommon::confirm_success(
+ &mt("The password for user [_1] was not changed.",''.$user.'').' '.&mt('Please make sure your old password was entered correctly.'),1);
+ $message=&Apache::loncommon::confirmwrapper($message);
&print_main_menu($r, $message);
}
-# $r->print("
".&mt("The password for [_1] was not changed",$user)."
".
-# &mt('Please make sure your old password was entered correctly.'));
- return 1;
}
return;
}
@@ -1582,7 +1670,7 @@ sub discussionchanger {
Apache::lonhtmlcommon::add_breadcrumb(
{ href => '/adm/preferences?action=changediscussions',
text => 'Change Discussion Preferences'});
- $r->print(Apache::loncommon::start_page('Message Management'));
+ $r->print(Apache::loncommon::start_page('Change Discussion Preferences'));
$r->print(Apache::lonhtmlcommon::breadcrumbs('Change Discussion Preferences'));
my $user = $env{'user.name'};
my $domain = $env{'user.domain'};
@@ -1597,7 +1685,7 @@ sub discussionchanger {
}
}
if (defined($userenv{'discmarkread'})) {
- unless ($userenv{'discdisplay'} eq '') {
+ unless ($userenv{'discmarkread'} eq '') {
$discmark = $userenv{'discmarkread'};
}
}
@@ -1641,15 +1729,16 @@ sub discussionchanger {
$currmark = $lt{'ondisp'};
$newmark = 'onmark';
}
-
+
$r->print(<<"END");
@@ -1675,7 +1764,10 @@ END
$r->print(&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table());
- $r->print('
'.&mt('Note').': '.$lt{'thde'}.'');
+ $r->print(' '
+ .''
+ .''
+ );
}
sub verify_and_change_discussion {
@@ -1686,11 +1778,11 @@ sub verify_and_change_discussion {
if (defined($env{'form.discdisp'}) ) {
my $newdisp = $env{'form.newdisp'};
if ($newdisp eq 'unread') {
- $message .=&mt('In discussions: only new posts will be displayed.').' ';
+ $message .=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: only new posts will be displayed.')).' ';
&Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
&Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
} else {
- $message .= &mt('In discussions: all posts will be displayed.').' ';
+ $message .= &Apache::lonhtmlcommon::confirm_success(&mt('In discussions: all posts will be displayed.')).' ';
&Apache::lonnet::del('environment',['discdisplay']);
&Apache::lonnet::delenv('environment.discdisplay');
}
@@ -1698,19 +1790,17 @@ sub verify_and_change_discussion {
if (defined($env{'form.discmark'}) ) {
my $newmark = $env{'form.newmark'};
if ($newmark eq 'ondisp') {
- $message.=&mt('In discussions: new posts will be cease to be identified as "NEW" after display.').' ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('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.=&mt('In discussions: posts will be identified as "NEW" until marked as read by the reader.').' ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('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(< '/adm/preferences?action=changecourseinit',
text => 'Change Course Init. Pref.'});
$r->print(Apache::loncommon::start_page('Change Course Initialization Preference'));
@@ -1791,17 +1881,102 @@ sub verify_and_change_coursepage {
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my ($furl,$ferr)=
&Apache::lonuserstate::readmap($cdom.'/'.$cnum);
- $message .= ' '.$lt{'gtts'}.' '.&mt('now').'';
+ $message .= ' '.$lt{'gtts'}.' '.&mt('now').'';
+ } else {
+ $message .= ' '.$lt{'dasp'}.'';
+ }
+ }
+ $message = &Apache::lonhtmlcommon::confirm_success($message);
+ $message = &Apache::loncommon::confirmwrapper($message);
+ &print_main_menu($r,$message);
+}
+
+sub lockednameschanger {
+ my $r = shift;
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=changelockednames',
+ text => 'Automatic name changes'});
+ $r->print(Apache::loncommon::start_page('Automatic name changes'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Allow/disallow name updates'));
+ my %userenv = &Apache::lonnet::get('environment',['lockedname']);
+ my $lockedname='';
+ if (&can_toggle_namelocking()) {
+ if ($userenv{'lockedname'}) {
+ $lockedname = ' checked="checked"';
+ }
+ my %updateable;
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['autoupdate'],$env{'user.domain'});
+ if (ref($domconfig{'autoupdate'}) eq 'HASH') {
+ if ($domconfig{'autoupdate'}{'run'}) {
+ my @inststatuses = split(':',$env{'environment.inststatus'});
+ unless (@inststatuses) {
+ @inststatuses = ('default');
+ }
+ %updateable = &updateable_userinfo($domconfig{'autoupdate'},\@inststatuses);
+ }
+ }
+ if (keys(%updateable)) {
+ my %longnames = &Apache::lonlocal::texthash (
+ firstname => 'First Name',
+ middlename => 'Middle Name',
+ lastname => 'Last Name',
+ );
+ my $text=&mt('By default, based on your institutional affiliation, your LON-CAPA account can be automatically updated nightly based on directory information from your institution.').' '.&mt('The following may be updated, unless you disallow updates:').
+ '
';
+ foreach my $item ('firstname','middlename','lastname') {
+ if ($updateable{$item}) {
+ $text .= '