--- loncom/interface/lonpreferences.pm 2016/09/16 22:00:55 1.196.4.21
+++ loncom/interface/lonpreferences.pm 2013/07/15 16:13:21 1.207
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.196.4.21 2016/09/16 22:00:55 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.207 2013/07/15 16:13:21 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,8 @@ use strict;
use LONCAPA;
use Apache::Constants qw(:common);
use Apache::File;
+use Crypt::DES;
+use DynaLoader; # for Crypt::DES version
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
@@ -43,6 +45,50 @@ use Apache::lonnet;
use LONCAPA::lonauthcgi();
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 #
################################################################
@@ -160,14 +206,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 +222,33 @@ 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.',
+ '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'}
-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(
@@ -2116,25 +2125,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} }, {
@@ -2172,18 +2162,6 @@ push(@{ $menu[4]->{items} }, {
});
}
-
- my %author_coauthor_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
- if (keys(%author_coauthor_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)'),
@@ -2228,7 +2206,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,
@@ -2239,7 +2217,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'){
@@ -2292,10 +2270,6 @@ 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();