--- loncom/interface/lonpreferences.pm 2009/09/08 22:17:02 1.170
+++ loncom/interface/lonpreferences.pm 2010/06/19 23:28:12 1.190
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.170 2009/09/08 22:17:02 bisitz Exp $
+# $Id: lonpreferences.pm,v 1.190 2010/06/19 23:28:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,6 +42,7 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonnet;
+use LONCAPA::lonauthcgi();
use LONCAPA();
#
@@ -116,7 +117,7 @@ sub wysiwygchanger {
my $switchon=&mt('Enable WYSIWYG editor');
my $warning='';
if ($env{'user.adv'}) {
- $warning.="
".&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."
";
+ $warning.='
'.&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."
";
}
$r->print(<
@@ -165,8 +166,12 @@ sub languagechanger {
= &Apache::loncommon::plainlanguagedescription($_);
}
}
- my $selectionbox=&Apache::loncommon::select_form($language,'language',
- %langchoices);
+ %langchoices = &Apache::lonlocal::texthash(%langchoices);
+ my $selectionbox=
+ &Apache::loncommon::select_form(
+ $language,
+ 'language',
+ \%langchoices);
$r->print(<
@@ -187,7 +192,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');
@@ -205,9 +215,9 @@ sub texenginechanger {
my $r = shift;
Apache::lonhtmlcommon::add_breadcrumb(
{ href => '/adm/preferences?action=changetexenginepref',
- text => 'Change How Math Equations Are Displayed'});
+ text => 'Math display settings'});
$r->print(Apache::loncommon::start_page('Content Display Settings'));
- $r->print(Apache::lonhtmlcommon::breadcrumbs('Change How Math Equations Are Displayed'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Math display settings'));
my $user = $env{'user.name'};
my $domain = $env{'user.domain'};
my %userenv = &Apache::lonnet::get('environment',['texengine']);
@@ -220,12 +230,16 @@ sub texenginechanger {
'mimetex' => 'mimetex (Convert to Images)',
'raw' => 'Raw (Screen Reader)'
);
- my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
- %mathchoices);
+ %mathchoices = &Apache::lonlocal::texthash(%mathchoices);
+ my $selectionbox=
+ &Apache::loncommon::select_form(
+ $texengine,
+ 'texengine',
+ \%mathchoices);
my $jsMath_start=&Apache::lontexconvert::jsMath_header();
my %lt=&Apache::lonlocal::texthash(
- 'headline' => 'Change Math Preferences',
- 'preftxt' => 'Preferred method to display Math',
+ 'headline' => 'Change how math is displayed',
+ 'preftxt' => 'Preferred method to display math',
'change' => 'Save',
'exmpl' => 'Examples',
'jsmath' => 'jsMath:',
@@ -280,7 +294,7 @@ if (jsMath.nofonts == 1) {
$lt{'tth'}
-
+
ENDLSCREEN
if ($env{'environment.texengine'} ne 'jsMath') {
@@ -392,13 +406,20 @@ sub rolesprefchanger {
-ENDSCREEN
-}
-
-sub verify_and_change_icons {
- my $r = shift;
- my $user = $env{'user.name'};
- my $domain = $env{'user.domain'};
- my $newicons = $env{'form.menumode'};
-
- &Apache::lonnet::put('environment',{'icons' => $newicons});
- &Apache::lonnet::appenv({'environment.icons' => $newicons});
- my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Menu Display').'',''.$newicons.''));
- $message=&Apache::loncommon::confirmwrapper($message);
- &print_main_menu($r, $message);
-}
-
-################################################################
# Clicker Subroutines #
################################################################
@@ -778,11 +741,11 @@ sub msgforwardchanger {
all => 'All',
crit => 'Critical only',
reg => 'Non-critical only',
- foad => 'Forwarding Address(es)',
- noti => 'Notification E-mail Address(es)',
+ foad => 'Forward to account(s)',
+ fwdm => 'Forward messages to other account(s) in LON-CAPA',
+ noti => 'E-mail notification of LON-CAPA messages',
foad_exmpl => 'e.g. userA:domain1,userB:domain2,...',
- mnot => 'E-mail Address(es) which should be notified about new LON-CAPA messages',
- # old: 'Message Notification Email Address(es)',
+ mnot => 'E-mail address(es) which should be notified about new LON-CAPA messages',
mnot_exmpl => 'e.g. joe@doe.com',
chg => 'Save',
email => 'The e-mail address entered in row ',
@@ -792,9 +755,9 @@ sub msgforwardchanger {
);
Apache::lonhtmlcommon::add_breadcrumb(
{ href => '/adm/preferences?action=changemsgforward',
- text => 'Change Message Forwarding/Notification'});
- $r->print(Apache::loncommon::start_page('Message Management'));
- $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Message Forwarding/Notification'));
+ text => 'Messages & Notifications'});
+ $r->print(Apache::loncommon::start_page('Messages & Notifications'));
+ $r->print(Apache::lonhtmlcommon::breadcrumbs('Messages & Notifications'));
my $forwardingHelp = &Apache::loncommon::help_open_topic("Prefs_Forwarding");
my $notificationHelp = &Apache::loncommon::help_open_topic("Prefs_Notification");
my $criticalMessageHelp = &Apache::loncommon::help_open_topic("Course_Critical_Message");
@@ -860,11 +823,12 @@ $validatescript
$r->print(<$lt{'foad'} $forwardingHelp
+
$lt{'fwdm'} $forwardingHelp
+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);
+ }
+ } 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);
+ }
+}
+
+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 print_main_menu {
@@ -1846,25 +1910,6 @@ my @menu=
},
]
},
- { categorytitle=>'Page Display Settings',
- items =>[
- { linktext => 'Color Scheme',
- url => '/adm/preferences?action=changecolors',
- permission => 'F',
- #help => 'Change_Colors',
- icon => 'preferences-desktop-theme.png',
- linktitle => 'Change LON-CAPA default colors.'
- },
- { linktext => 'Menu Display',
- url => '/adm/preferences?action=changeicons',
- permission => 'F',
- #help => '',
- icon => 'preferences-system-windows.png',
- linktitle => 'Change whether the menus are displayed with buttons, icons or icons and text.'
- }
-
- ]
- },
{ categorytitle=>'Content Display Settings',
items =>[
{ linktext => 'Language',
@@ -1874,30 +1919,34 @@ my @menu=
icon => 'preferences-desktop-locale.png',
linktitle => 'Choose the default language for this user.'
},
- { linktext => 'WYSIWYG Editor',
- url => '/adm/preferences?action=changewysiwyg',
- permission => 'F',
- #help => '',
- icon => 'edit-select-all.png',
- linktitle => 'Enable or disable the WYSIWYG-Editor.'
- },
{ linktext => $role.' Page',
url => '/adm/preferences?action=changerolespref',
permission => 'F',
#help => '',
- icon => 'sctr.png',
+ icon => 'role_hotlist.png',
linktitle => 'Configure the roles hotlist.'
},
- { linktext => 'Display of Scientific Equations',
+ { linktext => 'Math display settings',
url => '/adm/preferences?action=changetexenginepref',
permission => 'F',
#help => '',
- icon => 'stat.png',
- linktitle => 'Change how Scientific Equations are displayed.'
+ icon => 'dismath.png',
+ linktitle => 'Change how math is displayed.'
},
]
},
- { categorytitle=>'Message Management',
+ { categorytitle=>'Page Display Settings',
+ items =>[
+ { linktext => 'Color Scheme',
+ url => '/adm/preferences?action=changecolors',
+ permission => 'F',
+ #help => 'Change_Colors',
+ icon => 'preferences-desktop-theme.png',
+ linktitle => 'Change LON-CAPA default colors.'
+ },
+ ]
+ },
+ { categorytitle=>'Messages & Notifications',
items =>[
{ linktext => 'Messages & Notifications',
url => '/adm/preferences?action=changemsgforward',
@@ -1938,25 +1987,18 @@ push(@{ $menu[0]->{items} }, {
linktitle => 'Change your password.',
});
}
- if ($env{'environment.remote'} eq 'off') {
-push(@{ $menu[1]->{items} }, {
- linktext => 'Launch Remote Control',
- url => '/adm/remote?url=/adm/preferences&action=launch',
- permission => 'F',
- #help => '',
- icon => 'network-wireless.png',
- linktitle => 'Launch the remote control for LON-CAPA.',
- });
- }else{
-push(@{ $menu[1]->{items} }, {
- linktext => 'Collapse Remote Control',
- url => '/adm/remote?url=/adm/preferences&action=collapse',
- permission => 'F',
- #help => '',
- icon => 'network-wireless.png',
- linktitle => 'Collapse the remote control for LON-CAPA.',
- });
+
+ if (&can_toggle_namelocking()) {
+ push(@{ $menu[0]->{items} }, {
+ linktext => 'Automatic name changes',
+ url => '/adm/preferences?action=changelockednames',
+ permission => 'F',
+ #help => '',
+ icon => 'system-lock-screen.png',
+ linktitle => 'Allow/disallow propagation of name changes from institutional directory service',
+ });
}
+
my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']);
if (keys(%author_roles) > 0) {
push(@{ $menu[4]->{items} }, {
@@ -1977,21 +2019,21 @@ push(@{ $menu[4]->{items} }, {
url => '/adm/preferences?action=changecourseinit',
permission => 'F',
#help => '',
- icon => 'edit-copy.png',
+ icon => 'course_ini.png',
linktitle => 'Set the default page to be displayed when you select a course role.',
});
}
- if ($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/) {
+ if (&can_toggle_debug()) {
push(@{ $menu[4]->{items} }, {
- linktext => 'Toggle Debug Messages (Current:'.$env{'user.debug'}.')',
+ linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'),
url => '/adm/preferences?action=debugtoggle',
permission => 'F',
#help => '',
icon => 'blog.png',
linktitle => 'Toggle Debug Messages.',
});
- }
+ }
$r->print(&Apache::loncommon::start_page('My Space'));
$r->print(Apache::lonhtmlcommon::breadcrumbs('Change Preferences'));
@@ -2062,10 +2104,6 @@ sub handler {
&texenginechanger($r);
}elsif($env{'form.action'} eq 'verify_and_change_texengine'){
&verify_and_change_texengine($r);
- }elsif($env{'form.action'} eq 'changeicons'){
- &iconchanger($r);
- }elsif($env{'form.action'} eq 'verify_and_change_icons'){
- &verify_and_change_icons($r);
}elsif($env{'form.action'} eq 'changeclicker'){
&clickerchanger($r);
}elsif($env{'form.action'} eq 'verify_and_change_clicker'){
@@ -2083,8 +2121,14 @@ sub handler {
}elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
&verify_and_change_coursepage($r);
}elsif($env{'form.action'} eq 'debugtoggle'){
- &toggle_debug();
+ if (&can_toggle_debug()) {
+ &toggle_debug();
+ }
&print_main_menu($r);
+ } elsif ($env{'form.action'} eq 'changelockednames') {
+ &lockednameschanger($r);
+ } elsif ($env{'form.action'} eq 'verify_and_change_lockednames') {
+ &verify_and_change_lockednames($r);
}
# Properly end the HTML page of all preference pages
@@ -2106,5 +2150,63 @@ sub toggle_debug {
}
}
+sub can_toggle_debug {
+ my $can_toggle = 0;
+ my $page = 'toggledebug';
+ if (&LONCAPA::lonauthcgi::can_view($page)) {
+ $can_toggle = 1;
+ } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) {
+ $can_toggle = 1;
+ }
+ return $can_toggle;
+}
+
+sub can_toggle_namelocking {
+ my $lockablenames;
+ 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');
+ }
+ my %updateable = &updateable_userinfo($domconfig{'autoupdate'},\@inststatuses);
+ if ($updateable{'lastname'} || $updateable{'firstname'} ||
+ $updateable{'middlename'}) {
+ if (ref($domconfig{'autoupdate'}{'lockablenames'}) eq 'ARRAY') {
+ unless (@inststatuses) {
+ @inststatuses = ('default');
+ }
+ foreach my $status (@inststatuses) {
+ if (grep(/^\Q$status\E$/,@{$domconfig{'autoupdate'}{'lockablenames'}})) {
+ $lockablenames = 1;
+ last;
+ }
+ }
+ }
+ }
+ }
+ }
+ return $lockablenames;
+}
+
+sub updateable_userinfo {
+ my ($autoupdate,$inststatuses) = @_;
+ my %updateable;
+ return %updateable unless ((ref($autoupdate) eq 'HASH') &&
+ (ref($inststatuses) eq 'ARRAY'));
+ if (ref($autoupdate->{'fields'}) eq 'HASH') {
+ foreach my $status (@{$inststatuses}) {
+ if (ref($autoupdate->{'fields'}{$status}) eq 'ARRAY') {
+ foreach my $field (@{$autoupdate->{'fields'}{$status}}) {
+ $updateable{$field} = 1;
+ }
+ }
+ }
+ }
+ return %updateable;
+}
+
1;
__END__