--- loncom/interface/lonpreferences.pm 2010/02/04 10:42:02 1.183
+++ loncom/interface/lonpreferences.pm 2010/04/14 13:58:11 1.188
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.183 2010/02/04 10:42:02 bisitz Exp $
+# $Id: lonpreferences.pm,v 1.188 2010/04/14 13:58:11 wenzelju Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -117,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(<
@@ -589,60 +589,6 @@ sub verify_and_change_screenname {
}
################################################################
-# Icon Subroutines #
-################################################################
-sub iconchanger {
- my $r = shift;
- &Apache::lonhtmlcommon::add_breadcrumb(
- { href => '/adm/preferences?action=changeicons',
- text => 'Change Main Menu'});
- $r->print(Apache::loncommon::start_page('Page Display Settings'));
- $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Main Menu'));
-
- my $user = $env{'user.name'};
- my $domain = $env{'user.domain'};
- my %userenv = &Apache::lonnet::get
- ('environment',['icons']);
- my $iconic='checked="checked"';
- my $classic='';
- my $onlyicon='';
- if ($userenv{'icons'} eq 'classic') {
- $classic='checked="checked"';
- $iconic='';
- }
- if ($userenv{'icons'} eq 'iconsonly') {
- $onlyicon='checked="checked"';
- $iconic='';
- }
- my $useicons=&mt('Use icons and text');
- my $usebuttons=&mt('Use buttons and text');
- my $useicononly=&mt('Use icons only');
- my $change=&mt('Save');
- $r->print(<
-
-
-
-
-
-
-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 #
################################################################
@@ -1842,6 +1788,93 @@ sub verify_and_change_coursepage {
&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 .= '
'.$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);
+ }
+ } 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 {
my ($r, $message) = @_;
# Determine current authentication method
@@ -1875,25 +1908,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',
@@ -1903,13 +1917,6 @@ 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',
@@ -1921,11 +1928,22 @@ my @menu=
url => '/adm/preferences?action=changetexenginepref',
permission => 'F',
#help => '',
- icon => 'stat.png',
+ icon => 'dismath.png',
linktitle => 'Change how math is displayed.'
},
]
},
+ { 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',
@@ -1967,25 +1985,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 => 'remotecontrol.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 => 'remotecontrol.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} }, {
@@ -2020,7 +2031,7 @@ push(@{ $menu[4]->{items} }, {
icon => 'blog.png',
linktitle => 'Toggle Debug Messages.',
});
- }
+ }
$r->print(&Apache::loncommon::start_page('My Space'));
$r->print(Apache::lonhtmlcommon::breadcrumbs('Change Preferences'));
@@ -2091,10 +2102,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'){
@@ -2116,6 +2123,10 @@ sub handler {
&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
@@ -2148,5 +2159,52 @@ sub can_toggle_debug {
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__