--- loncom/interface/lonpreferences.pm 2016/08/10 23:50:07 1.196.4.19 +++ loncom/interface/lonpreferences.pm 2015/02/23 12:36:27 1.216 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.196.4.19 2016/08/10 23:50:07 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.216 2015/02/23 12:36:27 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -160,14 +160,12 @@ sub texenginechanger { my $domain = $env{'user.domain'}; my %userenv = &Apache::lonnet::get('environment',['texengine']); my $texengine=$userenv{'texengine'}; - if (lc($texengine) eq 'jsmath') { - $texengine = 'MathJax'; - } my %mathchoices=('' => 'Default', 'tth' => 'tth (TeX to HTML)', #'ttm' => 'TeX to MathML', - 'MathJax' => 'MathJax', + 'jsMath' => 'jsMath', + 'MathJax' => 'MathJax', 'mimetex' => 'mimetex (Convert to Images)', 'raw' => 'Raw (Screen Reader)' ); @@ -178,17 +176,34 @@ sub texenginechanger { 'texengine', \%mathchoices); my $MathJax_start=&Apache::lontexconvert::MathJax_header(); + my $jsMath_start=&Apache::lontexconvert::jsMath_header(); my %lt=&Apache::lonlocal::texthash( 'headline' => 'Change how math is displayed', 'preftxt' => 'Preferred method to display math', 'change' => 'Save', 'exmpl' => 'Examples', 'mathjax' => 'MathJax:', - 'mathjaxinfo' => 'MathJax provides rendered equations whose source code can be extracted in TeX and MathML formats by right clicking the equation.', + 'mathjaxinfo' => 'MathJax provides rendered equations whose source code can be extracted in TeX and MathML formats by right clicking the equation.', + 'jsmath' => 'jsMath:', 'tth' => 'tth (TeX to HTML):', 'mimetex' => 'mimetex (Convert to Images):', ); + my $jsMathWarning='

' + .'

' + .&mt("It looks like you don't have the TeX math fonts installed.") + .'
' + .'
' + .&mt('The jsMath example on this page may not look right without them. ' + .'The [_1]jsMath Home Page[_2] has information on how to download the ' + .'needed fonts. In the meantime, jsMath will do the best it can ' + .'with the fonts you have, but it may not be pretty and some equations ' + .'may not be rendered correctly.' + ,'' + ,'') + .'
' + .'

'; + $r->print(<$lt{'headline'}
@@ -211,6 +226,18 @@ $lt{'exmpl'} $lt{'mathjaxinfo'}

+

$lt{'jsmath'}

+

+$jsMath_start + + +

+

$lt{'mimetex'}

@@ -221,6 +248,9 @@ $lt{'mathjaxinfo'}

ENDLSCREEN + if ($env{'environment.texengine'} ne 'jsMath') { + $r->print(''); + } } @@ -231,9 +261,6 @@ sub verify_and_change_texengine { # Screenname my $newtexengine = $env{'form.texengine'}; $newtexengine=~s/[^\-\w]//g; - if (lc($newtexengine) eq 'jsmath') { - $newtexengine = 'MathJax'; - } if ($newtexengine eq 'ttm') { &Apache::lonnet::appenv({'browser.mathml' => 1}); } else { @@ -282,7 +309,7 @@ sub rolesprefchanger { my $hotlist_n=$userenv{'recentrolesn'}; my ($checkedon,$checkedoff); if ($hotlist_flag) { - $checkedon = 'checked="checked"'; + $checkedon = 'checked="checked"'; } else { $checkedoff = 'checked="checked"'; } @@ -365,7 +392,7 @@ $options.' &Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::end_pick_box().' '); - if ($roles_check_list) { + if ($roles_check_list) { $r->print('

'.&mt('Freeze Roles').'

'.&mt('The table below can be used to [_1]freeze[_2] '.$lc_role.'s in the Hotlist.','','').'
'. @@ -1139,10 +1166,10 @@ sub colorschanger { foreach my $item (sort(keys(%colortypes))) { my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); $chtable.=&Apache::loncommon::start_data_table_row(). - ''.$colortypes{$item}.''. - &Apache::loncommon::end_data_table_row()."\n"; + ''.$colortypes{$item}.''. + &Apache::loncommon::end_data_table_row()."\n"; } my $end_data_table = &Apache::loncommon::end_data_table(); my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); @@ -1154,7 +1181,6 @@ sub colorschanger { ' . $colorchooser . ' '); - $r->print(< @@ -1195,9 +1221,9 @@ sub verify_and_change_colors { my $message=''; foreach my $item (keys(%colortypes)) { my $color=$env{'form.'.$item}; - if (!($color =~ /^#/)) { - $color = '#' . $color; - } + if (!($color =~ /^#/)) { + $color = '#' . $color; + } my $entry='color.'.$function.'.'.$item; if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) { &Apache::lonnet::put('environment',{$entry => $color}); @@ -1236,12 +1262,6 @@ sub passwordchanger { $r->print(Apache::loncommon::start_page('Personal Data')); $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Password')); } - my ($blocked,$blocktext) = - &Apache::loncommon::blocking_status('passwd'); - if ($blocked) { - $r->print('

'.$blocktext.'

'); - return; - } if ((!defined($caller)) || ($caller eq 'preferences')) { $user = $env{'user.name'}; $domain = $env{'user.domain'}; @@ -1254,7 +1274,7 @@ sub passwordchanger { $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.' - ,'','') + ,'','') .'

' ); return; @@ -1275,9 +1295,9 @@ sub passwordchanger { } } else { $r->print( - '

' - .&mt('Sorry, the URL generated when you requested reset of' - .' your password contained incomplete information.') + '

' + .&mt('Sorry, the URL generated when you requested reset of' + .' your password contained incomplete information.') .'

' ); return; @@ -1348,18 +1368,21 @@ sub jscript_send { uextkey=this.document.client.elements.ukey_cpass.value; lextkey=this.document.client.elements.lkey_cpass.value; initkeys(); - this.document.pserver.elements.currentpass.value = - getCrypted(this.document.client.elements.currentpass.value); + + this.document.pserver.elements.currentpass.value + =crypted(this.document.client.elements.currentpass.value); + uextkey=this.document.client.elements.ukey_npass1.value; lextkey=this.document.client.elements.lkey_npass1.value; initkeys(); this.document.pserver.elements.newpass_1.value - =getCrypted(this.document.client.elements.newpass_1.value); + =crypted(this.document.client.elements.newpass_1.value); + uextkey=this.document.client.elements.ukey_npass2.value; lextkey=this.document.client.elements.lkey_npass2.value; initkeys(); this.document.pserver.elements.newpass_2.value - =getCrypted(this.document.client.elements.newpass_2.value); + =crypted(this.document.client.elements.newpass_2.value); |; if ($caller eq 'reset_by_email') { $output .= qq| @@ -1374,7 +1397,6 @@ sub jscript_send { $ output .= qq| this.document.pserver.submit(); } - |; } @@ -1400,7 +1422,7 @@ sub client_form { .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( '') - .'' + .'' .'' .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( @@ -1410,16 +1432,16 @@ sub client_form { } else { $output .= &Apache::lonhtmlcommon::row_title( '') - .'' + .'' .&Apache::lonhtmlcommon::row_closure(); } $output .= &Apache::lonhtmlcommon::row_title( '') - .'' + .'' .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( '') - .'' + .'' .&Apache::lonhtmlcommon::row_closure(1) .&Apache::lonhtmlcommon::end_pick_box(); $output .= '

' @@ -1468,12 +1490,6 @@ sub server_form { sub verify_and_change_password { my ($r,$caller,$mailtoken) = @_; my ($user,$domain,$homeserver); - my ($blocked,$blocktext) = - &Apache::loncommon::blocking_status('passwd'); - if ($blocked) { - $r->print('

'.$blocktext.'

'); - return; - } if ($caller eq 'reset_by_email') { $user = $env{'form.uname'}; $domain = $env{'form.udom'}; @@ -1860,6 +1876,58 @@ sub verify_and_change_coursepage { &print_main_menu($r,$message); } +sub author_space_settings { + my $r = shift; + &Apache::lonhtmlcommon::add_breadcrumb( + { href => '/adm/preferences?action=authorsettings', + text => 'Authoring Space Settings'}); + my $user = $env{'user.name'}; + my $domain = $env{'user.domain'}; + my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']); + if (keys(%author_roles) > 0) { + $r->print(Apache::loncommon::start_page('Authoring Space Settings')); + $r->print(Apache::lonhtmlcommon::breadcrumbs('Authoring Space Settings')); + my %userenv = &Apache::lonnet::get('environment',['nocodemirror']); + my $constchecked=''; + if ($env{'environment.nocodemirror'}) { + $constchecked=' checked="checked"'; + } + my $text=&mt('By default, CodeMirror an editor with advanced functionality for editing code is activated for authors.'); + my $cmoff=&mt('Deactivate CodeMirror. This can improve performance on slow computers and accessibility.'); + my $change=&mt('Save'); + $r->print(< + + $text
+
+ + +ENDSCREEN + } +} + +sub change_authoring_settings { + my $r = shift; + my $user = $env{'user.name'}; + my $domain = $env{'user.domain'}; + my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']); + if (keys(%author_roles) > 0) { + my %ausettings=('environment.nocodemirror' => ''); + if ($env{'form.cmoff'}) { $ausettings{'environment.nocodemirror'}='yes'; } + &Apache::lonnet::put('environment',\%ausettings); + &Apache::lonnet::appenv({'environment.nocodemirror' => $ausettings{'environment.nocodemirror'}}); + my $status=''; + if ($ausettings{'environment.nocodemirror'} eq 'yes') { + $status=&mt('on'); + } else { + $status=&mt('off'); + } + my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Deactivate CodeMirror in Authoring Space').'',''.$status.'')); + $message=&Apache::loncommon::confirmwrapper($message); + &print_main_menu($r,$message); + } +} + sub lockednameschanger { my $r = shift; &Apache::lonhtmlcommon::add_breadcrumb( @@ -2064,25 +2132,6 @@ 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} }, { @@ -2120,6 +2169,18 @@ push(@{ $menu[4]->{items} }, { }); } + + my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']); + if (keys(%author_roles) > 0) { + push(@{ $menu[4]->{items} }, { + linktext => 'Authoring Space Configuration', + url => '/adm/preferences?action=authorsettings', + permission => 'F', + icon => 'course_ini.png', + linktitle => 'Settings for your authoring space.', + }); + } + if (&can_toggle_debug()) { push(@{ $menu[4]->{items} }, { linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'), @@ -2164,7 +2225,7 @@ sub handler { } else { $brlink ='/adm/preferences'; $brtxt = 'Set User Preferences'; - $brhelp = 'Prefs_About_Me,Prefs_Language,Prefs_Screen_Name_Nickname,Change_Colors,Change_Password,Prefs_Messages,Change_Discussion_Display'; + $brhelp = 'Prefs_About_Me,Prefs_Language,Prefs_Screen_Name_Nickname,Change_Colors,Change_Password,Prefs_Messages,Change_Discussion_Display'; } Apache::lonhtmlcommon::add_breadcrumb ({href => $brlink, @@ -2175,7 +2236,7 @@ sub handler { }elsif($env{'form.action'} eq 'changepass'){ &passwordchanger($r); }elsif($env{'form.action'} eq 'verify_and_change_pass'){ - &verify_and_change_password($r,'preferences'); + &verify_and_change_password($r); }elsif($env{'form.action'} eq 'changescreenname'){ &screennamechanger($r); }elsif($env{'form.action'} eq 'verify_and_change_screenname'){ @@ -2228,6 +2289,10 @@ sub handler { &coursedisplaychanger($r); }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){ &verify_and_change_coursepage($r); + }elsif($env{'form.action'} eq 'authorsettings'){ + &author_space_settings($r); + }elsif($env{'form.action'} eq 'change_authoring_settings'){ + &change_authoring_settings($r); }elsif($env{'form.action'} eq 'debugtoggle'){ if (&can_toggle_debug()) { &toggle_debug();