--- loncom/interface/lonpreferences.pm 2009/12/02 18:33:27 1.179
+++ loncom/interface/lonpreferences.pm 2011/05/16 00:57:08 1.186.2.6
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.179 2009/12/02 18:33:27 bisitz Exp $
+# $Id: lonpreferences.pm,v 1.186.2.6 2011/05/16 00:57:08 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(<
@@ -166,11 +166,12 @@ sub languagechanger {
= &Apache::loncommon::plainlanguagedescription($_);
}
}
+ %langchoices = &Apache::lonlocal::texthash(%langchoices);
my $selectionbox=
&Apache::loncommon::select_form(
$language,
'language',
- &Apache::lonlocal::texthash(%langchoices));
+ \%langchoices);
$r->print(<
@@ -191,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');
@@ -224,11 +230,12 @@ sub texenginechanger {
'mimetex' => 'mimetex (Convert to Images)',
'raw' => 'Raw (Screen Reader)'
);
+ %mathchoices = &Apache::lonlocal::texthash(%mathchoices);
my $selectionbox=
&Apache::loncommon::select_form(
$texengine,
'texengine',
- &Apache::lonlocal::texthash(%mathchoices));
+ \%mathchoices);
my $jsMath_start=&Apache::lontexconvert::jsMath_header();
my %lt=&Apache::lonlocal::texthash(
'headline' => 'Change how math is displayed',
@@ -399,13 +406,20 @@ sub rolesprefchanger {
ENDSCREEN
@@ -626,14 +650,47 @@ sub verify_and_change_icons {
my $user = $env{'user.name'};
my $domain = $env{'user.domain'};
my $newicons = $env{'form.menumode'};
-
+ my %lt = &icon_options();
+ my $newchoice = $newicons;
+ if ($lt{$newicons}) {
+ $newchoice = $lt{$newicons};
+ }
&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.''));
+ my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Menu Display').'',''.$newchoice.''));
$message=&Apache::loncommon::confirmwrapper($message);
&print_main_menu($r, $message);
}
+sub icon_options {
+ my %lt = &Apache::lonlocal::texthash(
+ iconic => 'Use icons and text',
+ iconsonly => 'Use icons only',
+ );
+ return %lt;
+}
+
+sub icon_previews {
+ my %icon_text = (
+ annotate => 'Notes',
+ bookmark => 'Bookmark',
+ catalog => 'Info',
+ evaluate => 'Evaluate',
+ feedback => 'Communicate',
+ printout => 'Print',
+ );
+ my %inlinetools = (
+ printout => "s&8&3&prt.png&$icon_text{'printout'}&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document",
+ bookmark => "s&9&1&sbkm.png&$icon_text{'bookmark'}&bookmark[_2]&set_bookmark()&Set a bookmark for this resource",
+ evaluate => "s&8&1&eval.png&$icon_text{'evaluate'}&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource",
+ feedback => "s&8&2&fdbk.png&$icon_text{'feedback'}&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource",
+ annotate => "s&9&3&anot.png&$icon_text{'annotate'}&tations[_1]&annotate()&Make notes and annotations about this resource",
+ catalog => "s&6&3&catalog.png&$icon_text{'catalog'}&info[_1]&catalog_info()&Show Metadata",
+ );
+ my @toolsorder = qw(annotate bookmark evaluate feedback printout catalog);
+ return (\%inlinetools,\@toolsorder);
+}
+
################################################################
# Clicker Subroutines #
################################################################
@@ -995,28 +1052,32 @@ sub verify_and_change_msgforward {
my $domain = $env{'user.domain'};
my $newscreen = '';
my $message='';
- foreach (split(/\,/,$env{'form.msgforward'})) {
- my ($msuser,$msdomain)=split(/[\@\:]/,$_);
+ foreach my $recip (split(/\,/,$env{'form.msgforward'})) {
+ my ($msuser,$msdomain);
+ if ($recip =~ /:/) {
+ ($msuser,$msdomain)=split(':',$recip);
+ } else {
+ ($msuser,$msdomain)=split(/\@/,$recip);
+ }
$msuser = &LONCAPA::clean_username($msuser);
$msdomain = &LONCAPA::clean_domain($msdomain);
if (($msuser) && ($msdomain)) {
if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
- $newscreen.=$msuser.':'.$msdomain.',';
- } else {
- $message.= &mt('No such user: ').''.$msuser.':'.$msdomain.' ';
- }
+ $newscreen.=$msuser.':'.$msdomain.',';
+ } else {
+ $message.= &mt('No such user: ').''.$msuser.':'.$msdomain.' ';
+ }
}
}
$newscreen=~s/\,$//;
if ($newscreen) {
&Apache::lonnet::put('environment',{'msgforward' => $newscreen});
&Apache::lonnet::appenv({'environment.msgforward' => $newscreen});
- $message .= &mt('Set message forwarding to ').'"'.$newscreen.'".'
- .' ';
+ $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Set message forwarding to ').'"'.$newscreen.'". ');
} else {
&Apache::lonnet::del('environment',['msgforward']);
&Apache::lonnet::delenv('environment.msgforward');
- $message.= &mt("Set message forwarding to 'off'.").' ';
+ $message.= &Apache::lonhtmlcommon::confirm_success(&mt("Set message forwarding to 'off'.").' ');
}
my $critnotification;
my $notification;
@@ -1052,43 +1113,41 @@ sub verify_and_change_msgforward {
if ($notification) {
&Apache::lonnet::put('environment',{'notification' => $notification});
&Apache::lonnet::appenv({'environment.notification' => $notification});
- $message.=&mt('Set non-critical message notification address(es) to ').'"'.$notification.'". ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set non-critical message notification address(es) to ').'"'.$notification.'". ');
} else {
&Apache::lonnet::del('environment',['notification']);
&Apache::lonnet::delenv('environment.notification');
- $message.=&mt("Set non-critical message notification to 'off'.").' ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set non-critical message notification to 'off'.").' ');
}
if ($critnotification) {
&Apache::lonnet::put('environment',{'critnotification' => $critnotification});
&Apache::lonnet::appenv({'environment.critnotification' => $critnotification});
- $message.=&mt('Set critical message notification address(es) to ').'"'.$critnotification.'". ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set critical message notification address(es) to ').'"'.$critnotification.'". ');
} else {
&Apache::lonnet::del('environment',['critnotification']);
&Apache::lonnet::delenv('environment.critnotification');
- $message.=&mt("Set critical message notification to 'off'.").' ';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set critical message notification to 'off'.").' ');
}
if ($critnotification || $notification) {
if ($notify_with_html) {
&Apache::lonnet::put('environment',{'notifywithhtml' => $notify_with_html});
&Apache::lonnet::appenv({'environment.notifywithhtml' => $notify_with_html});
- $message.=&mt('Set address(es) to receive excerpts with html retained ').'"'.$notify_with_html.'".';
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set address(es) to receive excerpts with html retained ').'"'.$notify_with_html.'".');
} else {
&Apache::lonnet::del('environment',['notifywithhtml']);
&Apache::lonnet::delenv('environment.notifywithhtml');
if ($totaladdresses == 1) {
- $message.=&mt("Set notification address to receive excerpts with html stripped.");
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set notification address to receive excerpts with html stripped."));
} else {
- $message.=&mt("Set all notification addresses to receive excerpts with html stripped.");
+ $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set all notification addresses to receive excerpts with html stripped."));
}
}
} else {
&Apache::lonnet::del('environment',['notifywithhtml']);
&Apache::lonnet::delenv('environment.notifywithhtml');
}
- if ($message) {
- $message .= ' ';
- }
&Apache::loncommon::flush_email_cache($user,$domain);
+ $message=&Apache::loncommon::confirmwrapper($message);
&msgforwardchanger($r,$message);
}
@@ -1578,6 +1637,7 @@ ENDERROR
my $message;
if ($result =~ /^ok$/) {
$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 {
@@ -1820,13 +1880,102 @@ 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'}.'';
}
}
- &print_main_menu($r, &Apache::lonhtmlcommon::confirm_success($message));
+ $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 .= '
'.$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 {
@@ -1862,25 +2011,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',
@@ -1890,29 +2020,40 @@ 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 => 'Math display settings',
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.'
+ },
+ { linktext => 'Menu Display',
+ url => '/adm/preferences?action=changeicons',
+ permission => 'F',
+ #help => '',
+ icon => 'preferences-system-windows.png',
+ linktitle => 'Change whether the menus are displayed with icons or icons and text.'
+ }
+ ]
+ },
{ categorytitle=>'Messages & Notifications',
items =>[
{ linktext => 'Messages & Notifications',
@@ -1926,7 +2067,7 @@ my @menu=
url => '/adm/preferences?action=changediscussions',
permission => 'F',
#help => 'Change_Discussion_Display',
- icon => 'mail-message-new.png',
+ icon => 'chat.png',
linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.'
},
]
@@ -1956,23 +2097,36 @@ push(@{ $menu[0]->{items} }, {
}
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.',
- });
+ 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.',
- });
+ 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} }, {
@@ -1993,7 +2147,7 @@ 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.',
});
@@ -2007,7 +2161,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'));
@@ -2103,6 +2257,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
@@ -2135,5 +2293,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__