--- loncom/interface/lonpreferences.pm 2005/02/26 05:37:23 1.56
+++ loncom/interface/lonpreferences.pm 2024/02/28 06:28:07 1.196.4.28.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.56 2005/02/26 05:37:23 albertel Exp $
+# $Id: lonpreferences.pm,v 1.196.4.28.2.2 2024/02/28 06:28:07 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,63 +27,19 @@
#
# This package uses the "londes.js" javascript code.
#
-# TODOs that have to be completed:
-# interface with lonnet to change the password
package Apache::lonpreferences;
use strict;
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;
-
-#
-# 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 Apache::lonnet;
+use LONCAPA::lonauthcgi();
+use LONCAPA();
+use DateTime::TimeZone();
################################################################
# Handler subroutines #
@@ -95,33 +51,46 @@ 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.")."
";
+ }
$r->print(<
+');
+}
+
+sub rolespref_get_role_text {
+# Get a line of text for each role
+ my ($roles) = @_;
+ my %roletext = ();
+
+ foreach my $item (@$roles) {
+# get course information
+ my ($role,$rest) = split(/\./, $item);
+ my $trole = "";
+ $trole = &Apache::lonnet::plaintext($role);
+ my ($tdomain,$other,$tsection)= split(/\//,Apache::lonnet::declutter($rest));
+ my $tother = '-';
+ if ($role =~ /^(cc|st|in|ta|ep|cr)/ ) {
+ my %newhash=&Apache::lonnet::coursedescription($tdomain."_".$other);
+ $tother = " - ".$newhash{'description'};
+ } elsif ($role =~ /dc/) {
+ $tother = "";
+ } else {
+ $tother = " - $other";
+ }
+
+ my $section="";
+ if ($tsection) {
+ $section = " - Section/Group: $tsection";
+ }
+ $roletext{$item} = $tdomain." - ".$trole.$tother.$section;
+ }
+ return %roletext;
}
sub verify_and_change_rolespref {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ my $role = ($env{'user.adv'} ? 'Role' : 'Course');
+ 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 $message='';
+ my $hotlist_flag = $env{'form.recentroles'};
+ my $hotlist_n = $env{'form.recentrolesn'};
+ my $message='';
if ($hotlist_flag) {
&Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
- &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag);
- $message='Recent Roles Hotlist is Enabled';
+ &Apache::lonnet::appenv({'environment.recentroles' => $hotlist_flag});
+ $message=&Apache::lonhtmlcommon::confirm_success(&mt('Recent '.$role.'s Hotlist is Enabled.')." ".&mt('Display [_1] Most Recent '.$role.'s.',$hotlist_n));
} else {
&Apache::lonnet::del('environment',['recentroles']);
- &Apache::lonnet::delenv('environment\.recentroles');
- $message='Recent Roles Hotlist is Disabled';
+ &Apache::lonnet::delenv('environment.recentroles');
+ $message=&Apache::lonhtmlcommon::confirm_success(&mt('Recent '.$role.'s Hotlist is Disabled'));
}
if ($hotlist_n) {
&Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
- &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n);
- if ($hotlist_flag) {
- $message.=" Display $hotlist_n Most Recent Roles\n";
+ &Apache::lonnet::appenv({'environment.recentrolesn' => $hotlist_n});
+ }
+
+# Get list of froze roles and list of recent roles
+ my @freeze_list = &Apache::loncommon::get_env_multiple('form.freezeroles');
+ my %freeze = ();
+ my %roletext = ();
+
+ foreach my $key (@freeze_list) {
+ $freeze{$key}='1';
+ }
+
+ my %recent_roles =
+ &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
+ my %frozen_roles =
+ &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
+ my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
+
+# Unset any roles that were previously frozen but aren't in list
+ foreach my $role_key (sort(keys(%recent_roles))) {
+ if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) {
+ $message .= " ".&Apache::lonhtmlcommon::confirm_success(&mt('Unfreezing '.$role.': [_1]',''.$role_text{$role_key}.''));
+ &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0);
}
}
- $r->print(<
-$message
-ENDRPSCREEN
+# Freeze selected roles
+ foreach my $role_key (@freeze_list) {
+ if (!$frozen_roles{$role_key}) {
+ $message .= " ".
+ &Apache::lonhtmlcommon::confirm_success(&mt('Freezing '.$role.': [_1]',''.$role_text{$role_key}.''));
+ &Apache::lonhtmlcommon::store_recent('roles',
+ $role_key,' ',1);
+ }
+ }
+ $message=&Apache::loncommon::confirmwrapper($message);
+ if ($env{'form.returnurl'} eq '/adm/roles') {
+ return $message;
+ } else {
+ &print_main_menu($r, $message);
+ }
}
-
################################################################
# Anonymous Discussion Name Change Subroutines #
################################################################
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):
-
- New nickname (shown if you post non-anonymously):
-
-
-
-ENDSCREEN
+ Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=changescreenname',
+ text => 'Change Screen Name'});
+ $r->print(Apache::loncommon::start_page('Personal Data'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Screen Name'));
+ $r->print('
'
+ .&mt('Change the name that is displayed in your posts.')
+ .'
'
+ );
+ $r->print('
'
+ .''
+ .&Apache::lonhtmlcommon::start_pick_box()
+ .&Apache::lonhtmlcommon::row_title(&mt('Screenname').' '.&mt('(shown if you post anonymously)'))
+ .''
+ .&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(&mt('Nickname').' '.&mt('(shown if you post non-anonymously)'))
+ .''
+ .&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title()
+ .''
+ .&Apache::lonhtmlcommon::row_closure(1)
+ .&Apache::lonhtmlcommon::end_pick_box()
+ .'
'
+ );
}
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) {
&Apache::lonnet::put('environment',{'screenname' => $newscreen});
- &Apache::lonnet::appenv('environment.screenname' => $newscreen);
- $message='Set new screenname to '.$newscreen;
+ &Apache::lonnet::appenv({'environment.screenname' => $newscreen});
+ $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Screenname').'','"'.$newscreen.'"'));
} else {
&Apache::lonnet::del('environment',['screenname']);
- &Apache::lonnet::delenv('environment\.screenname');
- $message='Reset screenname';
+ &Apache::lonnet::delenv('environment.screenname');
+ $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]',''.&mt('Screenname').''));
}
# Nickname
$message.=' ';
- $newscreen = $ENV{'form.nickname'};
+ $newscreen = $env{'form.nickname'};
$newscreen=~s/[^ \w]//g;
if ($newscreen) {
&Apache::lonnet::put('environment',{'nickname' => $newscreen});
- &Apache::lonnet::appenv('environment.nickname' => $newscreen);
- $message.='Set new nickname to '.$newscreen;
+ &Apache::lonnet::appenv({'environment.nickname' => $newscreen});
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Nickname').'','"'.$newscreen.'"'));
} else {
&Apache::lonnet::del('environment',['nickname']);
- &Apache::lonnet::delenv('environment\.nickname');
- $message.='Reset nickname';
+ &Apache::lonnet::delenv('environment.nickname');
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]',''.&mt('Nickname').''));
}
+ &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain);
+ $message=&Apache::loncommon::confirmwrapper($message);
+ &print_main_menu($r, $message);
+}
- $r->print(<
-$message
-ENDVCSCREEN
+################################################################
+# Icon Subroutines #
+################################################################
+sub iconchanger {
+ my $r = shift;
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=changeicons',
+ text => 'Change Menu Display'});
+ $r->print(Apache::loncommon::start_page('Page Display Settings'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Menu Display'));
+
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
+ my %userenv = &Apache::lonnet::get('environment',['icons']);
+ my $iconic='checked="checked"';
+ my ($classic,$onlyicon,$iconic_preview,$iconsonly_preview);
+ if ($userenv{'icons'} eq 'classic') {
+ $iconic='';
+ $classic='
'.
+ &mt('Your current selection: "Use buttons and text" is deprecated - it is recommended that you change this to "Use icons and text".').'
';
+ }
+ if ($userenv{'icons'} eq 'iconsonly') {
+ $onlyicon='checked="checked"';
+ $iconic='';
+ }
+ my $change=&mt('Save');
+ my %lt = &icon_options();
+ my ($inlinetools,$toolsorder) = &icon_previews();
+ if ((ref($inlinetools) eq 'HASH') && (ref($toolsorder) eq 'ARRAY')) {
+ foreach my $tool (@{$toolsorder}) {
+ my ($command,$row,$col,$img,$top,$bot,$act,$desc) =
+ split(/\&/,$inlinetools->{$tool});
+ $iconic_preview .= '
'
+ .&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.'
+ ,'','')
+ .'
+
ENDERROR
+ &passwordchanger($r,$errormessage,$caller,$mailtoken,$timelimit,$extrafields);
+ if ($caller eq 'reset_by_email') {
+ return 'badchars';
+ } else {
+ return;
+ }
}
#
# 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);
+ if (ref($ended)) {
+ $$ended = 1;
+ }
+ }
} 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
+ if ($caller eq 'reset_by_email') {
+ if (!$result) {
+ return 'error';
+ } else {
+ return $result;
+ }
+ } else {
+ my $feedback;
+ if ($result eq 'prioruse') {
+ $feedback = &mt('Please enter a password that you have not used recently.');
+ } else {
+ $feedback = &mt('Please make sure your old password was entered correctly.');
+ }
+ $message = &Apache::lonhtmlcommon::confirm_success(
+ &mt("The password for user [_1] was not changed.",''.$user.'').' '.$feedback,1);
+ $message=&Apache::loncommon::confirmwrapper($message);
+ &print_main_menu($r, $message);
+ if (ref($ended)) {
+ $$ended = 1;
+ }
+ }
}
return;
}
@@ -838,8 +1809,13 @@ ENDERROR
################################################################
sub discussionchanger {
my $r = shift;
- my $user = $ENV{'user.name'};
- my $domain = $ENV{'user.domain'};
+ 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
('environment',['discdisplay','discmarkread']);
my $discdisp = 'allposts';
@@ -851,7 +1827,7 @@ sub discussionchanger {
}
}
if (defined($userenv{'discmarkread'})) {
- unless ($userenv{'discdisplay'} eq '') {
+ unless ($userenv{'discmarkread'} eq '') {
$discmark = $userenv{'discmarkread'};
}
}
@@ -861,21 +1837,21 @@ 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 ',
'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 '
);
@@ -895,85 +1871,834 @@ 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 {
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. ';
+ $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 (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(<
-$message
-ENDVCSCREEN
+ $message=&Apache::loncommon::confirmwrapper($message);
+ &print_main_menu($r, $message);
+}
+
+################################################################
+# Subroutines for page display on course access (Course Coordinators)
+################################################################
+sub coursedisplaychanger {
+ my $r = shift;
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/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']);
+ 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 = &Apache::lonlocal::texthash(
+ firstres => 'First resource',
+ whatsnew => "What's New Page",
+ );
+ 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]What's New Page[_2] in the course.",'','')
+ .'
';
+ $message .= &Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($result,1));
+ } elsif (@delete) {
+ $result = &mt('Set use of domain default for').':
'.
+ join('
', map { $titles{$_} } @delete).'
';
+ $message .= &Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($result));
+ }
+ if (@unchanged) {
+ $result = &mt('No changes made for').':
'.
+ join('
', map { $titles{$_} } @unchanged).'
';
+ $message .= &Apache::loncommon::confirmwrapper(&Apache::lonhtmlcommon::confirm_success($result));
+ }
+ }
+ if ($env{'form.returnurl'}) {
+ &do_redirect($r,$env{'form.returnurl'},$message);
+ } else {
+ &print_main_menu($r,$message);
+ }
+ }
+}
+
+sub authoring_settings_text {
+ return &Apache::lonlocal::texthash(
+ 'auss' => 'Authoring Space Settings',
+ 'used' => 'Use domain default',
+ 'usyo' => 'Use your own user-specific setting',
+ 'curd' => 'Current domain default is',
+ 'ousv' => 'Own user-specific value',
+ 'save' => 'Save',
+ 'yes' => 'Deactivated',
+ 'no' => 'Activated',
+ );
+}
+
+sub authoring_settings_titles {
+ return &Apache::lonlocal::texthash(
+ 'nocodemirror' => 'CodeMirror for EditXML editor',
+ 'copyright' => 'Default Copyright/Distribution in new metadata file',
+ 'sourceavail' => 'Default Source Available in new metadata file',
+ );
+}
+
+sub lockednameschanger {
+ my $r = shift;
+ my %userenv = &Apache::lonnet::get('environment',['lockedname']);
+ my $lockedname='';
+ my $ended;
+ 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)) {
+ &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 %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 .= '
'.$longnames{$item}.'
';
+ }
+ }
+ $text .= '
';
+ my $locking=&mt('Disallow automatic updates to name information for your LON-CAPA account');
+ my $change=&mt('Save');
+ $r->print(<
+
+$text
+
+
+
+ENDSCREEN
+ } else {
+ my $message = &mt('Based on your institutional affiliation no name information is automatically updated for your LON-CAPA account.');
+ &print_main_menu($r,$message);
+ $ended = 1;
+ }
+ } else {
+ my $message = &mt('You are not permitted to set a user preference for automatic name updates for your LON-CAPA account.');
+ &print_main_menu($r,$message);
+ $ended = 1;
+ }
+ return $ended;
+}
+
+sub verify_and_change_lockednames {
+ my $r = shift;
+ my $message;
+ if (&can_toggle_namelocking()) {
+ my $newlockedname = $env{'form.lockednames'};
+ $newlockedname =~ s/\D//g;
+ my $currlockedname = $env{'environment.lockedname'};
+ if ($newlockedname ne $currlockedname) {
+ if ($newlockedname) {
+ if (&Apache::lonnet::put('environment',{lockedname => $newlockedname}) eq 'ok') {
+ &Apache::lonnet::appenv({'environment.lockedname' => $newlockedname});
+ }
+ } elsif (&Apache::lonnet::del('environment',['lockedname']) eq 'ok') {
+ &Apache::lonnet::delenv('environment.lockedname');
+ }
+ }
+ my $status='';
+ if ($newlockedname) {
+ $status=&mt('disallowed');
+ } else {
+ $status=&mt('allowed');
+ }
+ $message=&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',''.&mt('Automatic update of first, middle and last names if institutional directory information indicates changes').'',''.$status.''));
+ $message=&Apache::loncommon::confirmwrapper($message);
+ }
+ &print_main_menu($r,$message);
+}
+
+sub timezonechanger {
+ my $r = shift;
+ my $uname = $env{'user.name'};
+ my $udom = $env{'user.domain'};
+ if (&Apache::lonnet::usertools_access($uname,$udom,'timezone')) {
+ my $js = &toggle_options_js();
+ my $js = <<"ENDSCRIPT";
+ my %loaditems = (
+ onload => "javascript:toggleOptions(document.prefs,'settimezone','LC_timezone_selector');",
+ );
+ my $args = { 'add_entries' => \%loaditems };
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/preferences?action=',
+ text => 'Set Your Time Zone'});
+ $r->print(Apache::loncommon::start_page('Set Your Time Zone',$js,$args));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Set Your Time Zone'));
+ my %userenv = &Apache::lonnet::get('environment',['timezone']);
+ my $timezone = $userenv{'timezone'};
+ my %lt = &Apache::lonlocal::texthash(
+ lctz => 'Use Time Zone set by LON-CAPA',
+ owntz => 'Use Time Zone set by you',
+ save => 'Save',
+ );
+ my (%checked,$tzsty);
+ if ($userenv{'timezone'} ne '') {
+ $checked{'owntz'} = ' checked="checked"';
+ $tzsty = 'inline-block';
+ } else {
+ $checked{'lctz'} = ' checked="checked"';
+ $tzsty = 'none';
+ }
+ my $onclick = ' onclick="javascript:toggleOptions(this.form,'."'settimezone','LC_timezone_selector'".');"';
+ my $selector = &Apache::loncommon::select_timezone('timezone',$timezone,undef,1);
+ $r->print(<<"END");
+