version 1.196.4.13, 2013/08/29 19:42:58
|
version 1.217, 2016/01/27 00:24:09
|
Line 36 use strict;
|
Line 36 use strict;
|
use LONCAPA; |
use LONCAPA; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::File; |
use Apache::File; |
use Crypt::DES; |
|
use DynaLoader; # for Crypt::DES version |
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
Line 45 use Apache::lonnet;
|
Line 43 use Apache::lonnet;
|
use LONCAPA::lonauthcgi(); |
use LONCAPA::lonauthcgi(); |
use LONCAPA(); |
use LONCAPA(); |
|
|
# |
|
# Write lonnet::passwd to do the call below. |
|
# Use: |
|
# my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver); |
|
# |
|
################################################## |
|
# password associated functions # |
|
################################################## |
|
sub des_keys { |
|
# Make a new key for DES encryption. |
|
# Each key has two parts which are returned separately. |
|
# Please note: Each key must be passed through the &hex function |
|
# before it is output to the web browser. The hex versions cannot |
|
# be used to decrypt. |
|
my @hexstr=('0','1','2','3','4','5','6','7', |
|
'8','9','a','b','c','d','e','f'); |
|
my $lkey=''; |
|
for (0..7) { |
|
$lkey.=$hexstr[rand(15)]; |
|
} |
|
my $ukey=''; |
|
for (0..7) { |
|
$ukey.=$hexstr[rand(15)]; |
|
} |
|
return ($lkey,$ukey); |
|
} |
|
|
|
sub des_decrypt { |
|
my ($key,$cyphertext) = @_; |
|
my $keybin=pack("H16",$key); |
|
my $cypher; |
|
if ($Crypt::DES::VERSION>=2.03) { |
|
$cypher=new Crypt::DES $keybin; |
|
} else { |
|
$cypher=new DES $keybin; |
|
} |
|
my $plaintext= |
|
$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16)))); |
|
$plaintext.= |
|
$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16)))); |
|
$plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) ); |
|
return $plaintext; |
|
} |
|
|
|
################################################################ |
################################################################ |
# Handler subroutines # |
# Handler subroutines # |
################################################################ |
################################################################ |
Line 211 sub texenginechanger {
|
Line 165 sub texenginechanger {
|
'tth' => 'tth (TeX to HTML)', |
'tth' => 'tth (TeX to HTML)', |
#'ttm' => 'TeX to MathML', |
#'ttm' => 'TeX to MathML', |
'jsMath' => 'jsMath', |
'jsMath' => 'jsMath', |
'MathJax' => 'MathJax', |
'MathJax' => 'MathJax', |
'mimetex' => 'mimetex (Convert to Images)', |
'mimetex' => 'mimetex (Convert to Images)', |
'raw' => 'Raw (Screen Reader)' |
'raw' => 'Raw (Screen Reader)' |
); |
); |
Line 229 sub texenginechanger {
|
Line 183 sub texenginechanger {
|
'change' => 'Save', |
'change' => 'Save', |
'exmpl' => 'Examples', |
'exmpl' => 'Examples', |
'mathjax' => 'MathJax:', |
'mathjax' => 'MathJax:', |
|
'mathjaxinfo' => 'MathJax provides rendered equations whose source code can be extracted in TeX and MathML formats by right clicking the equation.', |
'jsmath' => 'jsMath:', |
'jsmath' => 'jsMath:', |
'tth' => 'tth (TeX to HTML):', |
'tth' => 'tth (TeX to HTML):', |
'mimetex' => 'mimetex (Convert to Images):', |
'mimetex' => 'mimetex (Convert to Images):', |
Line 265 $lt{'exmpl'}
|
Line 220 $lt{'exmpl'}
|
|
|
<h3>$lt{'mathjax'}</h3> |
<h3>$lt{'mathjax'}</h3> |
</script> |
</script> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=MathJax" width="400" height="120"></iframe> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=MathJax" width="400" height="150"></iframe> |
</p> |
</p> |
<p> |
<p> |
MathJax provides rendered equations whose source code can be extracted in TeX and MathML formats by right clicking the equation. |
$lt{'mathjaxinfo'} |
</p> |
</p> |
|
|
<h3>$lt{'jsmath'}</h3> |
<h3>$lt{'jsmath'}</h3> |
Line 280 if (jsMath.nofonts == 1) {
|
Line 235 if (jsMath.nofonts == 1) {
|
} |
} |
|
|
</script> |
</script> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=jsMath" width="400" height="120"></iframe> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=jsMath" width="400" height="150"></iframe> |
</p> |
</p> |
|
|
<h3>$lt{'mimetex'}</h3> |
<h3>$lt{'mimetex'}</h3> |
<p> |
<p> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=mimetex" width="400" height="100"></iframe> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=mimetex" width="400" height="150"></iframe> |
</p> |
</p> |
|
|
<h3>$lt{'tth'}</h3> |
<h3>$lt{'tth'}</h3> |
<p> |
<p> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=tth" width="400" height="220"></iframe> |
<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=tth" width="400" height="150"></iframe> |
</p> |
</p> |
ENDLSCREEN |
ENDLSCREEN |
if ($env{'environment.texengine'} ne 'jsMath') { |
if ($env{'environment.texengine'} ne 'jsMath') { |
Line 354 sub rolesprefchanger {
|
Line 309 sub rolesprefchanger {
|
my $hotlist_n=$userenv{'recentrolesn'}; |
my $hotlist_n=$userenv{'recentrolesn'}; |
my ($checkedon,$checkedoff); |
my ($checkedon,$checkedoff); |
if ($hotlist_flag) { |
if ($hotlist_flag) { |
$checkedon = 'checked="checked"'; |
$checkedon = 'checked="checked"'; |
} else { |
} else { |
$checkedoff = 'checked="checked"'; |
$checkedoff = 'checked="checked"'; |
} |
} |
Line 437 $options.'
|
Line 392 $options.'
|
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::end_pick_box().' |
&Apache::lonhtmlcommon::end_pick_box().' |
</div>'); |
</div>'); |
if ($roles_check_list) { |
if ($roles_check_list) { |
$r->print('<div class="LC_left_float"> |
$r->print('<div class="LC_left_float"> |
<h4>'.&mt('Freeze Roles').'</h4> |
<h4>'.&mt('Freeze Roles').'</h4> |
<p>'.&mt('The table below can be used to [_1]freeze[_2] '.$lc_role.'s in the Hotlist.','<q>','</q>').'<br />'. |
<p>'.&mt('The table below can be used to [_1]freeze[_2] '.$lc_role.'s in the Hotlist.','<q>','</q>').'<br />'. |
Line 834 sub lockwarning {
|
Line 789 sub lockwarning {
|
my $textbottom=&mt('Changing roles or logging out may result in data corruption.'); |
my $textbottom=&mt('Changing roles or logging out may result in data corruption.'); |
my ($num,%which)=&Apache::lonnet::get_locks(); |
my ($num,%which)=&Apache::lonnet::get_locks(); |
my $which=''; |
my $which=''; |
foreach my $id (keys %which) { |
foreach my $id (keys(%which)) { |
$which.='<li>'.$which{$id}.'</li>'; |
$which.='<li>'.$which{$id}.'</li>'; |
} |
} |
my $change=&mt('Override'); |
my $change=&mt('Override'); |
Line 1211 sub colorschanger {
|
Line 1166 sub colorschanger {
|
foreach my $item (sort(keys(%colortypes))) { |
foreach my $item (sort(keys(%colortypes))) { |
my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); |
my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); |
$chtable.=&Apache::loncommon::start_data_table_row(). |
$chtable.=&Apache::loncommon::start_data_table_row(). |
'<td>'.$colortypes{$item}.'<td><input name="'.$item. |
'<td>'.$colortypes{$item}.'<td><input name="'.$item. |
'" class="colorchooser" size="10" value="'.$curcol. |
'" class="colorchooser" size="10" value="'.$curcol. |
'" /></td>'. |
'" /></td>'. |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
my $end_data_table = &Apache::loncommon::end_data_table(); |
my $end_data_table = &Apache::loncommon::end_data_table(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
Line 1226 sub colorschanger {
|
Line 1181 sub colorschanger {
|
' . $colorchooser . ' |
' . $colorchooser . ' |
</script> |
</script> |
'); |
'); |
|
|
$r->print(<<ENDCOL); |
$r->print(<<ENDCOL); |
|
|
<form name="parmform" action=""> |
<form name="parmform" action=""> |
Line 1265 sub verify_and_change_colors {
|
Line 1219 sub verify_and_change_colors {
|
); |
); |
|
|
my $message=''; |
my $message=''; |
foreach my $item (keys %colortypes) { |
foreach my $item (keys(%colortypes)) { |
my $color=$env{'form.'.$item}; |
my $color=$env{'form.'.$item}; |
if (!($color =~ /^#/)) { |
if (!($color =~ /^#/)) { |
$color = '#' . $color; |
$color = '#' . $color; |
} |
} |
my $entry='color.'.$function.'.'.$item; |
my $entry='color.'.$function.'.'.$item; |
if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) { |
if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) { |
&Apache::lonnet::put('environment',{$entry => $color}); |
&Apache::lonnet::put('environment',{$entry => $color}); |
Line 1308 sub passwordchanger {
|
Line 1262 sub passwordchanger {
|
$r->print(Apache::loncommon::start_page('Personal Data')); |
$r->print(Apache::loncommon::start_page('Personal Data')); |
$r->print(Apache::lonhtmlcommon::breadcrumbs('Change Password')); |
$r->print(Apache::lonhtmlcommon::breadcrumbs('Change Password')); |
} |
} |
|
my ($blocked,$blocktext) = |
|
&Apache::loncommon::blocking_status('passwd'); |
|
if ($blocked) { |
|
$r->print('<p class="LC_warning">'.$blocktext.'</p>'); |
|
return; |
|
} |
if ((!defined($caller)) || ($caller eq 'preferences')) { |
if ((!defined($caller)) || ($caller eq 'preferences')) { |
$user = $env{'user.name'}; |
$user = $env{'user.name'}; |
$domain = $env{'user.domain'}; |
$domain = $env{'user.domain'}; |
Line 1320 sub passwordchanger {
|
Line 1280 sub passwordchanger {
|
$r->print( |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&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.' |
.&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.' |
,'<a href="/adm/resetpw">','</a>') |
,'<a href="/adm/resetpw">','</a>') |
.'</p>' |
.'</p>' |
); |
); |
return; |
return; |
Line 1341 sub passwordchanger {
|
Line 1301 sub passwordchanger {
|
} |
} |
} else { |
} else { |
$r->print( |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&mt('Sorry, the URL generated when you requested reset of' |
.&mt('Sorry, the URL generated when you requested reset of' |
.' your password contained incomplete information.') |
.' your password contained incomplete information.') |
.'</p>' |
.'</p>' |
); |
); |
return; |
return; |
Line 1364 sub passwordchanger {
|
Line 1324 sub passwordchanger {
|
return if ($currentauth !~ /^(unix|internal):/); |
return if ($currentauth !~ /^(unix|internal):/); |
# |
# |
# Generate keys |
# Generate keys |
my ($lkey_cpass ,$ukey_cpass ) = &des_keys(); |
my ($lkey_cpass ,$ukey_cpass ) = &Apache::loncommon::des_keys(); |
my ($lkey_npass1,$ukey_npass1) = &des_keys(); |
my ($lkey_npass1,$ukey_npass1) = &Apache::loncommon::des_keys(); |
my ($lkey_npass2,$ukey_npass2) = &des_keys(); |
my ($lkey_npass2,$ukey_npass2) = &Apache::loncommon::des_keys(); |
# Store the keys in the log files |
# Store the keys in the log files |
my $lonhost = $r->dir_config('lonHostID'); |
my $lonhost = $r->dir_config('lonHostID'); |
my $logtoken=Apache::lonnet::reply('tmpput:' |
my $logtoken=Apache::lonnet::reply('tmpput:' |
Line 1536 sub server_form {
|
Line 1496 sub server_form {
|
sub verify_and_change_password { |
sub verify_and_change_password { |
my ($r,$caller,$mailtoken) = @_; |
my ($r,$caller,$mailtoken) = @_; |
my ($user,$domain,$homeserver); |
my ($user,$domain,$homeserver); |
|
my ($blocked,$blocktext) = |
|
&Apache::loncommon::blocking_status('passwd'); |
|
if ($blocked) { |
|
$r->print('<p class="LC_warning">'.$blocktext.'</p>'); |
|
return; |
|
} |
if ($caller eq 'reset_by_email') { |
if ($caller eq 'reset_by_email') { |
$user = $env{'form.uname'}; |
$user = $env{'form.uname'}; |
$domain = $env{'form.udom'}; |
$domain = $env{'form.udom'}; |
Line 1605 ENDERROR
|
Line 1571 ENDERROR
|
} |
} |
my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo); |
my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo); |
# |
# |
$currentpass = &des_decrypt($ckey ,$currentpass); |
$currentpass = &Apache::loncommon::des_decrypt($ckey ,$currentpass); |
$newpass1 = &des_decrypt($n1key,$newpass1); |
$newpass1 = &Apache::loncommon::des_decrypt($n1key,$newpass1); |
$newpass2 = &des_decrypt($n2key,$newpass2); |
$newpass2 = &Apache::loncommon::des_decrypt($n2key,$newpass2); |
# |
# |
if ($caller eq 'reset_by_email') { |
if ($caller eq 'reset_by_email') { |
my %data = &Apache::lonnet::tmpget($mailtoken); |
my %data = &Apache::lonnet::tmpget($mailtoken); |
Line 1922 sub verify_and_change_coursepage {
|
Line 1888 sub verify_and_change_coursepage {
|
&print_main_menu($r,$message); |
&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(<<ENDSCREEN); |
|
<form name="prefs" action="/adm/preferences" method="post"> |
|
<input type="hidden" name="action" value="change_authoring_settings" /> |
|
$text<br /> |
|
<label><input type="checkbox" name="cmoff"$constchecked />$cmoff</label><br /> |
|
<input type="submit" value="$change" /> |
|
</form> |
|
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]','<i>'.&mt('Deactivate CodeMirror in Authoring Space').'</i>','<tt>'.$status.'</tt>')); |
|
$message=&Apache::loncommon::confirmwrapper($message); |
|
&print_main_menu($r,$message); |
|
} |
|
} |
|
|
sub lockednameschanger { |
sub lockednameschanger { |
my $r = shift; |
my $r = shift; |
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
Line 2126 push(@{ $menu[0]->{items} }, {
|
Line 2144 push(@{ $menu[0]->{items} }, {
|
linktitle => 'Change your password.', |
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()) { |
if (&can_toggle_namelocking()) { |
push(@{ $menu[0]->{items} }, { |
push(@{ $menu[0]->{items} }, { |
Line 2182 push(@{ $menu[4]->{items} }, {
|
Line 2181 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()) { |
if (&can_toggle_debug()) { |
push(@{ $menu[4]->{items} }, { |
push(@{ $menu[4]->{items} }, { |
linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'), |
linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'), |
Line 2226 sub handler {
|
Line 2237 sub handler {
|
} else { |
} else { |
$brlink ='/adm/preferences'; |
$brlink ='/adm/preferences'; |
$brtxt = 'Set User 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 |
Apache::lonhtmlcommon::add_breadcrumb |
({href => $brlink, |
({href => $brlink, |
Line 2290 sub handler {
|
Line 2301 sub handler {
|
&coursedisplaychanger($r); |
&coursedisplaychanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_coursepage'){ |
}elsif($env{'form.action'} eq 'verify_and_change_coursepage'){ |
&verify_and_change_coursepage($r); |
&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'){ |
}elsif($env{'form.action'} eq 'debugtoggle'){ |
if (&can_toggle_debug()) { |
if (&can_toggle_debug()) { |
&toggle_debug(); |
&toggle_debug(); |