--- loncom/interface/lonpreferences.pm 2005/02/25 05:54:01 1.54
+++ loncom/interface/lonpreferences.pm 2013/06/07 16:07:46 1.205
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.54 2005/02/25 05:54:01 albertel Exp $
+# $Id: lonpreferences.pm,v 1.205 2013/06/07 16:07:46 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@
package Apache::lonpreferences;
use strict;
+use LONCAPA;
use Apache::Constants qw(:common);
use Apache::File;
use Crypt::DES;
@@ -40,6 +41,9 @@ 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.
@@ -95,33 +99,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);
+ }
}
@@ -342,149 +555,631 @@ 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):
-
- 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 .= '
'.
+ &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
}
@@ -570,61 +1250,114 @@ 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) {
- my $color=$ENV{'form.'.$item};
+ my $color=$env{'form.'.$item};
+ if (!($color =~ /^#/)) {
+ $color = '#' . $color;
+ }
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.' ';
+ &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(<
-$message
-
-
-
-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.'
+ ,'','')
+ .'
",
+ $caller,$mailtoken);
+ return 1;
+ }
+ } else {
+ $user = $env{'user.name'};
+ $domain = $env{'user.domain'};
+ $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
+ if ($currentauth !~ /^(unix|internal):/) {
+ if ($caller eq 'reset_by_email') {
+ &passwordchanger($r,"
\n".
+ &mt("Authentication type for this user can not be changed by this mechanism").
+ "\n
",
+ $caller,$mailtoken);
+ return 1;
+ } else {
+ return;
+ }
+ }
#
- 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) &&
defined($newpass2) ){
- &passwordchanger($r,"
\nERROR".
- "Password data was blank.\n
");
+ &passwordchanger($r,"
\n".
+ &mt("One or more password fields were blank").
+ "\n
",$caller,$mailtoken);
return;
}
# Get the keys
@@ -756,34 +1589,55 @@ ENDHEADER
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
- return;
+ return 1;
}
my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
#
$currentpass = &des_decrypt($ckey ,$currentpass);
$newpass1 = &des_decrypt($n1key,$newpass1);
$newpass2 = &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.');
- return;
+ ''.
+ &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.');
- return;
+ ''.
+ &mt('Passwords must be a minimum of 7 characters long.').' '.
+ &mt('Please try again.').'',$caller,$mailtoken);
+ return 1;
}
#
# Check for bad characters
@@ -793,31 +1647,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
+ 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;
}
@@ -827,8 +1696,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';
@@ -840,7 +1714,7 @@ sub discussionchanger {
}
}
if (defined($userenv{'discmarkread'})) {
- unless ($userenv{'discdisplay'} eq '') {
+ unless ($userenv{'discmarkread'} eq '') {
$discmark = $userenv{'discmarkread'};
}
}
@@ -850,21 +1724,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 '
);
@@ -884,85 +1758,426 @@ 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 be 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.",'','')
+ .'
+');
+}
+
+sub verify_and_change_coursepage {
+ my $r = shift;
+ my $message='';
+ my %lt = &Apache::lonlocal::texthash(
+ 'defs' => 'Default now set',
+ 'when' => 'when you select a course role from the roles screen',
+ '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",
+ );
+ my $newdisp = $env{'form.newdisp'};
+ $message = ''.$lt{'defs'}.': '.$lt{'when'}.', ';
+ if ($newdisp eq 'firstres') {
+ $message .= $lt{'ywbt'}.' ';
+ &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
+ &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
+ } else {
+ $message .= $lt{'apwb'}.' ';
+ &Apache::lonnet::del('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'})) {
+ if ($newdisp eq 'firstres') {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my ($furl,$ferr)=
+ &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
+ $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 .= '