--- loncom/interface/lonpreferences.pm 2010/09/19 14:22:40 1.179.2.4
+++ loncom/interface/lonpreferences.pm 2010/05/27 15:52:35 1.186.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.179.2.4 2010/09/19 14:22:40 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.186.2.1 2010/05/27 15:52:35 raeburn 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(<
@@ -191,7 +191,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');
@@ -399,13 +404,20 @@ sub rolesprefchanger {
+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 {
@@ -1850,27 +1945,38 @@ if (&Apache::lonnet::usertools_access($u
}
my @menu=
({ categorytitle=>'Personal Data',
- items =>[]
- },
- { categorytitle=>'Page Display Settings',
items =>[
- { linktext => 'Color Scheme',
- url => '/adm/preferences?action=changecolors',
+ { linktext => 'Personal Information Page',
+ url => $aboutmeurl,
+ permission => $permissions{'aboutme'},
+ #help => 'Prefs_About_Me',
+ icon => 'system-users.png',
+ linktitle => 'Edit information about yourself that should be displayed on your public profile.'
+ },
+ { linktext => 'Screen Name',
+ url => '/adm/preferences?action=changescreenname',
permission => 'F',
- #help => 'Change_Colors',
- icon => 'preferences-desktop-theme.png',
- linktitle => 'Change LON-CAPA default colors.'
+ #help => 'Prefs_Screen_Name_Nickname',
+ icon => 'preferences-desktop-font.png',
+ linktitle => 'Change the name that is displayed in your posts.'
},
]
},
{ categorytitle=>'Content Display Settings',
items =>[
- { linktext => 'WYSIWYG Editor',
- url => '/adm/preferences?action=changewysiwyg',
+ { linktext => 'Language',
+ url => '/adm/preferences?action=changelanguages',
+ permission => 'F',
+ #help => 'Prefs_Language',
+ icon => 'preferences-desktop-locale.png',
+ linktitle => 'Choose the default language for this user.'
+ },
+ { linktext => $role.' Page',
+ url => '/adm/preferences?action=changerolespref',
permission => 'F',
#help => '',
- icon => 'edit-select-all.png',
- linktitle => 'Enable or disable the WYSIWYG-Editor.'
+ icon => 'sctr.png',
+ linktitle => 'Configure the roles hotlist.'
},
{ linktext => 'Math display settings',
url => '/adm/preferences?action=changetexenginepref',
@@ -1881,6 +1987,25 @@ 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=>'Messages & Notifications',
items =>[
{ linktext => 'Messages & Notifications',
@@ -1890,36 +2015,28 @@ my @menu=
icon => 'mail-reply-all.png',
linktitle => 'Change messageforwarding or notifications settings.'
},
+ { linktext => 'Discussion Display',
+ url => '/adm/preferences?action=changediscussions',
+ permission => 'F',
+ #help => 'Change_Discussion_Display',
+ icon => 'mail-message-new.png',
+ linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.'
+ },
]
},
{ categorytitle=>'Other',
- items =>[]
+ items =>[
+ { linktext => 'Register Response Devices ("Clickers")',
+ url => '/adm/preferences?action=changeclicker',
+ permission => 'F',
+ #help => '',
+ icon => 'network-workgroup.png',
+ linktitle => 'Register your clicker.'
+ },
+ ]
},
);
- if (&Apache::lonnet::usertools_access($env{'user.name'},
- $env{'user.domain'},'aboutme')) {
- push(@{ $menu[0]->{items} },
- { linktext => 'Personal Information Page',
- url => $aboutmeurl,
- permission => $permissions{'aboutme'},
- #help => 'Prefs_About_Me',
- icon => 'system-users.png',
- linktitle => 'Edit information about yourself that should be displayed on your public profile.'
- });
- }
-
- unless ($env{'user.domain'} eq 'gcitest') {
- push(@{ $menu[0]->{items} },
- { linktext => 'Screen Name',
- url => '/adm/preferences?action=changescreenname',
- permission => 'F',
- #help => 'Prefs_Screen_Name_Nickname',
- icon => 'preferences-desktop-font.png',
- linktitle => 'Change the name that is displayed in your posts.'
- });
- }
-
if ($currentauth =~ /^(unix|internal):/) {
push(@{ $menu[0]->{items} }, {
linktext => 'Password',
@@ -1930,27 +2047,36 @@ 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.',
+ });
+ }
- unless ((&Apache::loncommon::needs_gci_custom()) || ($env{'user.domain'} eq 'gcitest')) {
- push(@{ $menu[1]->{items} },
- { 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.'
- });
- }
-
- unless ($env{'user.domain'} eq 'gcitest') {
- push(@{ $menu[3]->{items} },
- { linktext => 'Discussion Display',
- url => '/adm/preferences?action=changediscussions',
- permission => 'F',
- #help => 'Change_Discussion_Display',
- icon => 'mail-message-new.png',
- linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.'
- });
+
+ 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']);
@@ -1965,10 +2091,9 @@ push(@{ $menu[4]->{items} }, {
});
}
- unless ((&Apache::loncommon::needs_gci_custom()) || ($env{'user.domain'} eq 'gcitest')) {
- if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
- || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
- .$env{'request.course.sec'})) {
+ if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
+ .$env{'request.course.sec'})) {
push(@{ $menu[4]->{items} }, {
linktext => 'Course Initialization',
url => '/adm/preferences?action=changecourseinit',
@@ -1978,7 +2103,6 @@ push(@{ $menu[4]->{items} }, {
linktitle => 'Set the default page to be displayed when you select a course role.',
});
- }
}
if (&can_toggle_debug()) {
push(@{ $menu[4]->{items} }, {
@@ -2085,6 +2209,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
@@ -2117,5 +2245,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__