--- loncom/interface/lonpreferences.pm 2006/03/15 22:11:04 1.76
+++ loncom/interface/lonpreferences.pm 2015/02/23 12:36:27 1.216
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.76 2006/03/15 22:11:04 albertel Exp $
+# $Id: lonpreferences.pm,v 1.216 2015/02/23 12:36:27 droeschl Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,58 +33,15 @@
package Apache::lonpreferences;
use strict;
+use LONCAPA;
use Apache::Constants qw(:common);
use Apache::File;
-use Crypt::DES;
-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.
-# Use:
-# my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver);
-#
-##################################################
-# password associated functions #
-##################################################
-sub des_keys {
- # Make a new key for DES encryption.
- # Each key has two parts which are returned separately.
- # Please note: Each key must be passed through the &hex function
- # before it is output to the web browser. The hex versions cannot
- # be used to decrypt.
- my @hexstr=('0','1','2','3','4','5','6','7',
- '8','9','a','b','c','d','e','f');
- my $lkey='';
- for (0..7) {
- $lkey.=$hexstr[rand(15)];
- }
- my $ukey='';
- for (0..7) {
- $ukey.=$hexstr[rand(15)];
- }
- return ($lkey,$ukey);
-}
-
-sub des_decrypt {
- my ($key,$cyphertext) = @_;
- my $keybin=pack("H16",$key);
- my $cypher;
- if ($Crypt::DES::VERSION>=2.03) {
- $cypher=new Crypt::DES $keybin;
- } else {
- $cypher=new DES $keybin;
- }
- my $plaintext=
- $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16))));
- $plaintext.=
- $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16))));
- $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
- return $plaintext;
-}
+use LONCAPA::lonauthcgi();
+use LONCAPA();
################################################################
# Handler subroutines #
@@ -96,24 +53,35 @@ sub des_decrypt {
sub wysiwygchanger {
my $r = shift;
+ Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=changewysiwyg',
+ text => 'Change WYSIWYG Preferences'});
+ $r->print(Apache::loncommon::start_page('Content Display Settings'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Change WYSIWYG Preferences'));
+
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');
+ 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.")."
'.
+ &Apache::loncommon::end_data_table_row()."\n";
}
+ my $end_data_table = &Apache::loncommon::end_data_table();
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
+ my $savebutton = &mt('Save');
+ my $resetbutton = &mt('Reset All');
+ my $resetbuttondesc = &mt('Reset All Colors to Default');
+ my $colorchooser=&Apache::lonhtmlcommon::color_picker();
+ $r->print('
+');
$r->print(<
-
- function pclose() {
- parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
- "height=350,width=350,scrollbars=no,menubar=no");
- parmwin.close();
- }
-
- $pjump_def
-
- function psub() {
- pclose();
- if (document.parmform.pres_marker.value!='') {
- if (document.parmform.pres_type.value!='') {
- eval('document.server.'+
- document.parmform.pres_marker.value+
- '.value=document.parmform.pres_value.value;');
- }
- } else {
- document.parmform.pres_value.value='';
- document.parmform.pres_marker.value='';
- }
- }
-
-
-
+
-
+
-
+$start_data_table
$chtable
+$end_data_table
-
-
+
+
+
+
ENDCOL
}
@@ -581,68 +1205,122 @@ 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',
- 'sidebg'=> 'Header Border',
- 'font' => 'Font',
- 'link' => 'Un-Visited Link',
- 'vlink' => 'Visited Link',
- 'alink' => 'Active Link');
+ my %colortypes=&Apache::lonlocal::texthash(
+ 'pgbg' => 'Page Background Color',
+ 'tabbg' => 'Header Background Color',
+ 'sidebg' => 'Header Border Color',
+ 'font' => 'Font Color',
+ 'fontmenu' => 'Font Menu Color',
+ 'link' => 'Un-Visited Link Color',
+ 'vlink' => 'Visited Link Color',
+ 'alink' => 'Active Link Color',
+ );
my $message='';
- foreach my $item (keys %colortypes) {
+ foreach my $item (keys(%colortypes)) {
my $color=$env{'form.'.$item};
+ if (!($color =~ /^#/)) {
+ $color = '#' . $color;
+ }
my $entry='color.'.$function.'.'.$item;
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.' ';
+ &Apache::lonnet::appenv({'environment.'.$entry => $color});
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.$colortypes{$item}.'','"'.$color.'"'))
+ .' ';
} else {
&Apache::lonnet::del('environment',[$entry]);
- &Apache::lonnet::delenv('environment\.'.$entry);
- $message.='Reset '.$colortypes{$item}.' ';
+ &Apache::lonnet::delenv('environment.'.$entry);
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]',''.$colortypes{$item}.''))
+ .' ';
}
}
- $r->print(<
-
-
-ENDVCCOL
+ $message=&Apache::loncommon::confirmwrapper($message);
+
+ my $now = time;
+ &Apache::lonnet::put('environment',{'color.timestamp' => $now});
+ &Apache::lonnet::appenv({'environment.color.timestamp' => $now});
+
+ &print_main_menu($r, $message);
}
######################################################
# password handler subroutines #
######################################################
sub passwordchanger {
+ my ($r,$errormessage,$caller,$mailtoken) = @_;
# This function is a bit of a mess....
# Passwords are encrypted using londes.js (DES encryption)
- 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,$domain,$currentpass);
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=changepass',
+ text => 'Change Password'});
+ unless ($caller eq 'reset_by_email') {
+ $r->print(Apache::loncommon::start_page('Personal Data'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Password'));
+ }
+ if ((!defined($caller)) || ($caller eq 'preferences')) {
+ $user = $env{'user.name'};
+ $domain = $env{'user.domain'};
+ if (!defined($caller)) {
+ $caller = 'preferences';
+ }
+ } elsif ($caller eq 'reset_by_email') {
+ 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 [_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.'
+ ,'','')
+ .'
\n".
+ &mt("One or more password fields were blank").
+ "\n
",$caller,$mailtoken);
return;
}
# Get the keys
@@ -756,10 +1544,14 @@ sub verify_and_change_password {
my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
# I do not a have a better idea about how to handle this
+ my $tryagain_text = &mt('Please log out and try again.');
+ if ($caller eq 'reset_by_email') {
+ $tryagain_text = &mt('Please try again later.');
+ }
+ my $unable=&mt("Unable to retrieve saved token for password decryption");
$r->print(<
-ERROR: Unable to retrieve stored token for
-password decryption. Please log out and try again.
+$unable. $tryagain_text
ENDERROR
# Probably should log an error here
@@ -767,22 +1559,39 @@ ENDERROR
}
my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
#
- $currentpass = &des_decrypt($ckey ,$currentpass);
- $newpass1 = &des_decrypt($n1key,$newpass1);
- $newpass2 = &des_decrypt($n2key,$newpass2);
- #
+ $currentpass = &Apache::loncommon::des_decrypt($ckey ,$currentpass);
+ $newpass1 = &Apache::loncommon::des_decrypt($n1key,$newpass1);
+ $newpass2 = &Apache::loncommon::des_decrypt($n2key,$newpass2);
+ #
+ if ($caller eq 'reset_by_email') {
+ my %data = &Apache::lonnet::tmpget($mailtoken);
+ if (keys(%data) == 0) {
+ &passwordchanger($r,
+ ''.
+ &mt('Could not verify current authentication.').' '.
+ &mt('Please try again.').'',$caller,$mailtoken);
+ return 1;
+ }
+ if ($currentpass ne $data{'temppasswd'}) {
+ &passwordchanger($r,
+ ''.
+ &mt('Could not verify current authentication.').' '.
+ &mt('Please try again.').'',$caller,$mailtoken);
+ return 1;
+ }
+ }
if ($newpass1 ne $newpass2) {
&passwordchanger($r,
- 'ERROR:'.
- 'The new passwords you entered do not match. '.
- 'Please try again.');
+ ''.
+ &mt('The new passwords you entered do not match.').' '.
+ &mt('Please try again.').'',$caller,$mailtoken);
return 1;
}
if (length($newpass1) < 7) {
&passwordchanger($r,
- 'ERROR:'.
- 'Passwords must be a minimum of 7 characters long. '.
- 'Please try again.');
+ ''.
+ &mt('Passwords must be a minimum of 7 characters long.').' '.
+ &mt('Please try again.').'',$caller,$mailtoken);
return 1;
}
#
@@ -793,32 +1602,46 @@ ENDERROR
}
if ($badpassword) {
# I can't figure out how to enter bad characters on my browser.
- &passwordchanger($r,<ERROR:
-The password you entered contained illegal characters.
-Valid characters are: space and
+ my $errormessage =''.
+ &mt('The password you entered contained illegal characters.').' '.
+ &mt('Valid characters are').(<<"ENDERROR");
+: space and
+
ENDERROR
+ &passwordchanger($r,$errormessage,$caller,$mailtoken);
+ return 1;
}
#
# Change the password (finally)
my $result = &Apache::lonnet::changepass
- ($user,$domain,$currentpass,$newpass1,$homeserver);
+ ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
# Inform the user the password has (not?) been changed
+ my $message;
if ($result =~ /^ok$/) {
- $r->print(<<"ENDTEXT");
-
The password for $user was successfully changed
-ENDTEXT
+ $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);
+ }
} else {
# error error: run in circles, scream and shout
- $r->print(<The password for $user was not changed
-Please make sure your old password was entered correctly.
-ENDERROR
- return 1;
+ 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);
+ }
}
return;
}
@@ -828,6 +1651,11 @@ ENDERROR
################################################################
sub discussionchanger {
my $r = shift;
+ Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=changediscussions',
+ text => 'Change Discussion Preferences'});
+ $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'};
my %userenv = &Apache::lonnet::get
@@ -841,7 +1669,7 @@ sub discussionchanger {
}
}
if (defined($userenv{'discmarkread'})) {
- unless ($userenv{'discdisplay'} eq '') {
+ unless ($userenv{'discmarkread'} eq '') {
$discmark = $userenv{'discmarkread'};
}
}
@@ -856,16 +1684,16 @@ sub discussionchanger {
'pref' => '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.',
+ 'sdpf' => 'Set display preferences for discussion posts for both discussion 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"',
+ 'whpo' => 'Which posts are displayed when you display a discussion board or resource, and',
+ 'unwh' => 'Under what circumstances posts are identified as "NEW"',
'allposts' => 'All posts',
'unread' => 'New posts only',
'ondisp' => 'Once displayed',
- 'onmark' => 'Once marked as read',
+ 'onmark' => 'Once marked not NEW',
'disa' => 'Posts displayed?',
- 'npmr' => 'New posts cease to be identified as "New"?',
+ '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 '
);
@@ -885,50 +1713,45 @@ sub discussionchanger {
$currmark = $lt{'ondisp'};
$newmark = 'onmark';
}
-
+
$r->print(<<"END");
-
END
+ $r->print(&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table());
+
+ $r->print(' '
+ .''
+ .''
+ );
}
sub verify_and_change_discussion {
@@ -939,30 +1762,29 @@ sub verify_and_change_discussion {
if (defined($env{'form.discdisp'}) ) {
my $newdisp = $env{'form.newdisp'};
if ($newdisp eq 'unread') {
- $message .='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);
+ &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
} else {
- $message .= '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');
+ &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. ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: new posts will cease to be identified as "NEW" after display.')).' ';
&Apache::lonnet::put('environment',{'discmarkread' => $newmark});
- &Apache::lonnet::appenv('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. ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: posts will be identified as "NEW" until marked as not "NEW".')).' ';
&Apache::lonnet::del('environment',['discmarkread']);
- &Apache::lonnet::delenv('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'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Course Init. Pref.'));
my $user = $env{'user.name'};
my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
@@ -983,22 +1810,29 @@ sub coursedisplaychanger {
$whatsnewselect = '';
}
}
- my %pagenames = (
+ my %pagenames = &Apache::lonlocal::texthash(
firstres => 'First resource',
- whatsnew => "What's new page",
+ 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");
+ my $whatsnew_off=&mt('Display the [_1]first resource[_2] in the course.','','');
+ my $whatsnew_on=&mt("Display the [_1]What's New Page[_2] - a summary of items in the course which require attention.",'','');
- $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").'
');
+ $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]What's New Page[_2] in the course.",'','')
+ .'
'
+ );
$r->print(<
+
ENDLSCREEN
- $r->print('
+ $r->print('
');
}
@@ -1011,18 +1845,18 @@ sub verify_and_change_coursepage {
'ywbt' => 'you will be taken to the start of the course.',
'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
'gtts' => 'Go to the start of the course',
- 'dasp' => "Display the What's New page listing course action items",
+ 'dasp' => "Display the What's New Page",
);
my $newdisp = $env{'form.newdisp'};
$message = ''.$lt{'defs'}.': '.$lt{'when'}.', ';
if ($newdisp eq 'firstres') {
- $message .= $lt{'ywbt'}.' ';
+ $message .= $lt{'ywbt'}.' ';
&Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
- &Apache::lonnet::appenv('environment.course_init_display' => $newdisp);
+ &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
} else {
- $message .= $lt{'apwb'}.' ';
+ $message .= $lt{'apwb'}.' ';
&Apache::lonnet::del('environment',['course_init_display']);
- &Apache::lonnet::delenv('environment\.course_init_display');
+ &Apache::lonnet::delenv('environment.course_init_display');
}
my $refpage = $env{'form.refpage'};
if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
@@ -1031,18 +1865,339 @@ 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 .= ' '.$lt{'dasp'}.'';
}
}
- $r->print(<
-ENDVCSCREEN
+ $message = &Apache::lonhtmlcommon::confirm_success($message);
+ $message = &Apache::loncommon::confirmwrapper($message);
+ &print_main_menu($r,$message);
+}
+
+sub author_space_settings {
+ my $r = shift;
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=authorsettings',
+ text => 'Authoring Space Settings'});
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
+ my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
+ if (keys(%author_roles) > 0) {
+ $r->print(Apache::loncommon::start_page('Authoring Space Settings'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Authoring Space Settings'));
+ my %userenv = &Apache::lonnet::get('environment',['nocodemirror']);
+ my $constchecked='';
+ if ($env{'environment.nocodemirror'}) {
+ $constchecked=' checked="checked"';
+ }
+ my $text=&mt('By default, CodeMirror an editor with advanced functionality for editing code is activated for authors.');
+ my $cmoff=&mt('Deactivate CodeMirror. This can improve performance on slow computers and accessibility.');
+ my $change=&mt('Save');
+ $r->print(<
+
+ $text
+
+
+
+ENDSCREEN
+ }
+}
+
+sub change_authoring_settings {
+ my $r = shift;
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
+ my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
+ if (keys(%author_roles) > 0) {
+ my %ausettings=('environment.nocodemirror' => '');
+ if ($env{'form.cmoff'}) { $ausettings{'environment.nocodemirror'}='yes'; }
+ &Apache::lonnet::put('environment',\%ausettings);
+ &Apache::lonnet::appenv({'environment.nocodemirror' => $ausettings{'environment.nocodemirror'}});
+ my $status='';
+ if ($ausettings{'environment.nocodemirror'} eq 'yes') {
+ $status=&mt('on');
+ } else {
+ $status=&mt('off');
+ }
+ my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Deactivate CodeMirror in Authoring Space').'',''.$status.''));
+ $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 .= '