--- loncom/interface/lonpreferences.pm 2009/09/10 16:24:47 1.125.4.4
+++ loncom/interface/lonpreferences.pm 2024/03/02 18:47:15 1.244
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.125.4.4 2009/09/10 16:24:47 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.244 2024/03/02 18:47:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,66 +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 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;
+use LONCAPA::lonauthcgi();
use LONCAPA();
-
-#
-# 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 DateTime::TimeZone();
################################################################
# Handler subroutines #
@@ -98,6 +51,12 @@ 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"';
@@ -110,7 +69,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(<
@@ -131,9 +90,7 @@ sub verify_and_change_wysiwyg {
&Apache::lonnet::appenv({'environment.wysiwygeditor' => $newsetting});
my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('WYSIWYG Editor').'',''.&mt($newsetting).''));
$message=&Apache::loncommon::confirmwrapper($message);
- $r->print(< '/adm/preferences?action=changelanguages',
+ text => 'Change Language'});
+ $r->print(Apache::loncommon::start_page('Content Display Settings'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Language'));
+ my %userenv = &Apache::lonnet::get('environment',['languages']);
my $language=$userenv{'languages'};
- my $pref=&mt('Preferred language');
- my %langchoices=('' => 'No language preference');
- foreach (&Apache::loncommon::languageids()) {
- if (&Apache::loncommon::supportedlanguagecode($_)) {
- $langchoices{&Apache::loncommon::supportedlanguagecode($_)}
- = &Apache::loncommon::plainlanguagedescription($_);
- }
- }
- my $selectionbox=&Apache::loncommon::select_form($language,'language',
- %langchoices);
- $r->print(<
-
- $pref: $selectionbox
-ENDLSCREEN
- $r->print(' ');
+ $r->print(
+ ''
+ );
}
@@ -177,7 +128,12 @@ sub verify_and_change_languages {
if ($newlanguage) {
&Apache::lonnet::put('environment',{'languages' => $newlanguage});
&Apache::lonnet::appenv({'environment.languages' => $newlanguage});
- $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Preferred language').'','"'.$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');
@@ -185,9 +141,7 @@ sub verify_and_change_languages {
}
$message=&Apache::loncommon::confirmwrapper($message);
&Apache::loncommon::flush_langs_cache($user,$domain);
- $r->print(< '/adm/preferences?action=changetexenginepref',
+ text => 'Math display settings'});
+ $r->print(Apache::loncommon::start_page('Content Display Settings'));
+ $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']);
my $texengine=$userenv{'texengine'};
+ if (lc($texengine) eq 'jsmath') {
+ $texengine = 'MathJax';
+ }
my %mathchoices=('' => 'Default',
'tth' => 'tth (TeX to HTML)',
#'ttm' => 'TeX to MathML',
- 'jsMath' => 'jsMath',
+ 'MathJax' => 'MathJax',
'mimetex' => 'mimetex (Convert to Images)',
'raw' => 'Raw (Screen Reader)'
);
- my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
- %mathchoices);
- my $jsMath_start=&Apache::lontexconvert::jsMath_header();
+ %mathchoices = &Apache::lonlocal::texthash(%mathchoices);
+ my $selectionbox=
+ &Apache::loncommon::select_form(
+ $texengine,
+ 'texengine',
+ \%mathchoices);
+ my $MathJax_start=&Apache::lontexconvert::MathJax_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:',
+ 'mathjax' => 'MathJax:',
+ 'mathjaxinfo' => 'MathJax provides rendered equations whose source code can be extracted in TeX and MathML formats by right clicking the equation.',
'tth' => 'tth (TeX to HTML):',
'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);
}
######################################################
# password handler subroutines #
######################################################
sub passwordchanger {
- my ($r,$errormessage,$caller,$mailtoken) = @_;
+ my ($r,$errormessage,$caller,$mailtoken,$timelimit,$extrafields) = @_;
# This function is a bit of a mess....
# Passwords are encrypted using londes.js (DES encryption)
$errormessage = ($errormessage || '');
- my ($user,$domain,$currentpass,$defdom);
+ my ($user,$domain,$currentpass,$clientip);
+ $clientip = &Apache::lonnet::get_requestor_ip($r);
+ &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';
}
+ my ($blocked,$blocktext) =
+ &Apache::loncommon::blocking_status('passwd',$clientip);
+ if ($blocked) {
+ $r->print('
'.$blocktext.'
');
+ return;
+ }
} 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 [_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})) {
- if (time - $data{'time'} < 7200) {
- $user = $data{'username'};
- $domain = $data{'domain'};
- $currentpass = $data{'temppasswd'};
- } else {
- $r->print(&mt('Sorry, the token generated when you requested a password reset has expired.').' ');
+ 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;
+ "\n",$caller,$mailtoken,$timelimit,$extrafields);
+ if ($caller eq 'reset_by_email') {
+ return 'missingdata';
+ } else {
+ return;
+ }
}
# Get the keys
my $lonhost = $r->dir_config('lonHostID');
@@ -1450,13 +1705,17 @@ sub verify_and_change_password {
ENDERROR
# Probably should log an error here
- return 1;
+ if ($caller eq 'reset_by_email') {
+ return 'internalerror';
+ } else {
+ return;
+ }
}
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);
@@ -1464,30 +1723,53 @@ ENDERROR
&passwordchanger($r,
''.
&mt('Could not verify current authentication.').' '.
- &mt('Please try again.').'',$caller,$mailtoken);
- return 1;
+ &mt('Please try again.').'',$caller,$mailtoken,$timelimit,$extrafields);
+ return 'emptydata';
}
if ($currentpass ne $data{'temppasswd'}) {
&passwordchanger($r,
''.
&mt('Could not verify current authentication.').' '.
- &mt('Please try again.').'',$caller,$mailtoken);
- return 1;
+ &mt('Please try again.').'',$caller,$mailtoken,$timelimit,$extrafields);
+ return 'missingtemp';
}
- }
+ }
if ($newpass1 ne $newpass2) {
&passwordchanger($r,
- ''.
+ ''.
&mt('The new passwords you entered do not match.').' '.
- &mt('Please try again.').'',$caller,$mailtoken);
- return 1;
+ &mt('Please try again.').'',$caller,$mailtoken,$timelimit,$extrafields);
+ if ($caller eq 'reset_by_email') {
+ return 'mismatch';
+ } else {
+ return;
+ }
}
- if (length($newpass1) < 7) {
- &passwordchanger($r,
- ''.
- &mt('Passwords must be a minimum of 7 characters long.').' '.
- &mt('Please try again.').'',$caller,$mailtoken);
- return 1;
+ if ($currentauth eq 'unix:') {
+ if (length($newpass1) < 7) {
+ &passwordchanger($r,
+ ''.
+ &mt('Passwords must be a minimum of 7 characters long.').' '.
+ &mt('Please try again.').'',$caller,$mailtoken,$timelimit,$extrafields);
+ if ($caller eq 'reset_by_email') {
+ return 'length';
+ } else {
+ return;
+ }
+ }
+ } else {
+ my $warning = &Apache::loncommon::check_passwd_rules($domain,$newpass1);
+ if ($warning) {
+ &passwordchanger($r,''.
+ $warning.
+ &mt('Please try again.').'',
+ $caller,$mailtoken,$timelimit,$extrafields);
+ if ($caller eq 'reset_by_email') {
+ return 'rules';
+ } else {
+ return;
+ }
+ }
}
#
# Check for bad characters
@@ -1497,7 +1779,7 @@ ENDERROR
}
if ($badpassword) {
# I can't figure out how to enter bad characters on my browser.
- my $errormessage =''.
+ my $errormessage =''.
&mt('The password you entered contained illegal characters.').' '.
&mt('Valid characters are').(<<"ENDERROR");
: space and
@@ -1506,8 +1788,12 @@ ENDERROR
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
ENDERROR
- &passwordchanger($r,$errormessage,$caller,$mailtoken);
- return 1;
+ &passwordchanger($r,$errormessage,$caller,$mailtoken,$timelimit,$extrafields);
+ if ($caller eq 'reset_by_email') {
+ return 'badchars';
+ } else {
+ return;
+ }
}
#
# Change the password (finally)
@@ -1516,22 +1802,39 @@ ENDERROR
# Inform the user the password has (not?) been changed
my $message;
if ($result =~ /^ok$/) {
- $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for user [_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 {
- $r->print(&Apache::loncommon::confirmwrapper($message));
+ &print_main_menu($r, $message);
+ if (ref($ended)) {
+ $$ended = 1;
+ }
}
} else {
# error error: run in circles, scream and shout
- $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);
if ($caller eq 'reset_by_email') {
- $r->print($message.' ');
+ if (!$result) {
+ return 'error';
+ } else {
+ return $result;
+ }
} else {
- $r->print(&Apache::loncommon::confirmwrapper($message));
+ 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 1;
}
return;
}
@@ -1541,6 +1844,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
@@ -1572,15 +1880,15 @@ sub discussionchanger {
'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 discussion board or resource, and',
- 'unwh' => 'Under what circumstances posts are identfied as "New"',
+ '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 ',
+ 'chgt' => 'Change to '
);
my $dispchange = $lt{'unread'};
my $markchange = $lt{'ondisp'};
@@ -1598,13 +1906,14 @@ sub discussionchanger {
$currmark = $lt{'ondisp'};
$newmark = 'onmark';
}
-
+
$r->print(<<"END");
$lt{'sdpf'} $lt{'prca'}
$lt{'whpo'}
$lt{'unwh'}
END
+
$r->print('
'.$lt{'thde'}.'
');
$r->print(&Apache::loncommon::start_data_table());
@@ -1631,9 +1940,11 @@ END
END
$r->print(&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table());
- $r->print(' '.
- ''.
- '
');
+
+ $r->print(' '
+ .''
+ .'
'
+ );
}
sub verify_and_change_discussion {
@@ -1644,7 +1955,7 @@ sub verify_and_change_discussion {
if (defined($env{'form.discdisp'}) ) {
my $newdisp = $env{'form.newdisp'};
if ($newdisp eq 'unread') {
- $message .= &Apache::lonhtmlcommon::confirm_success(&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 {
@@ -1656,19 +1967,17 @@ sub verify_and_change_discussion {
if (defined($env{'form.discmark'}) ) {
my $newmark = $env{'form.newmark'};
if ($newmark eq 'ondisp') {
- $message.=&Apache::lonhtmlcommon::confirm_success(&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 cease to be identified as "NEW" after display.')).' ';
&Apache::lonnet::put('environment',{'discmarkread' => $newmark});
&Apache::lonnet::appenv({'environment.discmarkread' => $newmark});
} else {
- $message.=&Apache::lonhtmlcommon::confirm_success(&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 not "NEW".')).' ';
&Apache::lonnet::del('environment',['discmarkread']);
&Apache::lonnet::delenv('environment.discmarkread');
}
}
$message=&Apache::loncommon::confirmwrapper($message);
- $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']);
@@ -1689,19 +2003,21 @@ sub coursedisplaychanger {
$whatsnewselect = '';
}
}
- my %pagenames = (
+ 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] page in the course.",'','').
- '
');
+ $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(<
@@ -1742,18 +2058,670 @@ 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'}.'';
}
}
$message = &Apache::lonhtmlcommon::confirm_success($message);
- $r->print(< '/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) {
+ my ($showdomdefs,$js,$args,@items);
+ my $returnurl = &HTML::Entities::encode($env{'form.returnurl'},'"<>&\'');
+ if (&expanded_authoring_settings()) {
+ @items = ('nocodemirror','copyright','sourceavail');
+ $showdomdefs = 1;
+ $js = &toggle_options_js();
+ my $onload;
+ foreach my $item (@items) {
+ $onload .= "javascript:toggleOptions(document.prefs,'$item','user_$item');"
+ }
+ $args = { 'add_entries' => { 'onload' => $onload } };
+ }
+ $r->print(Apache::loncommon::start_page('Authoring Space Settings',$js,$args));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Authoring Space Settings'));
+ if ($showdomdefs) {
+ my %userenv = &Apache::lonnet::get('environment',\@items);
+ my %domdefs = &Apache::lonnet::get_domain_defaults($domain);
+ my %staticdefaults = (
+ 'nocodemirror' => '0',
+ 'copyright' => 'default',
+ 'sourceavail' => 'closed',
+ );
+ my %lt = &authoring_settings_text();
+ my %titles = &authoring_settings_titles();
+ $r->print("
';
+ $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 expanded_authoring_settings {
+ my $reqdmajor = 2;
+ my $reqdminor = 12;
+ my $loncaparev = &Apache::lonnet::get_server_loncaparev($env{'user.domain'},$env{'user.home'});
+ my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
+ unless (($major eq '' && $minor eq '') ||
+ ($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor))) {
+ return 1;
+ }
+ return;
+}
+
+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 %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");
+