Diff for /loncom/interface/lonpreferences.pm between versions 1.60 and 1.78

version 1.60, 2005/06/06 02:29:46 version 1.78, 2006/03/21 21:06:35
Line 98  sub wysiwygchanger { Line 98  sub wysiwygchanger {
     my $r = shift;      my $r = shift;
     my %userenv = &Apache::lonnet::get      my %userenv = &Apache::lonnet::get
         ('environment',['wysiwygeditor']);          ('environment',['wysiwygeditor']);
       my $onselect='checked="checked"';
     my $offselect='';      my $offselect='';
     my $onselect='checked="1"';      if ($userenv{'wysiwygeditor'} eq 'on') {
     if ($userenv{'wysiwygeditor'}) {  
  $onselect='';   $onselect='';
  $offselect='checked="1"';   $offselect='checked="checked"';
     }      }
     my $switchoff=&mt('Disable WYSIWYG editor');      my $switchoff=&mt('Disable WYSIWYG editor');
     my $switchon=&mt('Enable WYSIWYG editor');      my $switchon=&mt('Enable WYSIWYG editor');
     $r->print(<<ENDLSCREEN);      $r->print(<<ENDLSCREEN);
 <form name="server" action="/adm/preferences" method="post">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="set_wysiwyg" />  <input type="hidden" name="action" value="set_wysiwyg" />
 <br />  <br />
 <input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff<br />  <label><input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff</label><br />
 <input type="radio" name="wysiwyg" value="on" $offselect /> $switchon  <label><input type="radio" name="wysiwyg" value="on" $offselect /> $switchon</label>
 ENDLSCREEN  ENDLSCREEN
     $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');      $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
 }  }
Line 147  sub languagechanger { Line 147  sub languagechanger {
     my $selectionbox=&Apache::loncommon::select_form($language,'language',      my $selectionbox=&Apache::loncommon::select_form($language,'language',
      %langchoices);       %langchoices);
     $r->print(<<ENDLSCREEN);      $r->print(<<ENDLSCREEN);
 <form name="server" action="/adm/preferences" method="post">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_languages" />  <input type="hidden" name="action" value="verify_and_change_languages" />
 <br />$pref: $selectionbox  <br />$pref: $selectionbox
 ENDLSCREEN  ENDLSCREEN
Line 188  sub texenginechanger { Line 188  sub texenginechanger {
     my $texengine=$userenv{'texengine'};      my $texengine=$userenv{'texengine'};
   
     my $pref=&mt('Preferred method to display Math');      my $pref=&mt('Preferred method to display Math');
     my %mathchoices=('' => 'No Preference',      my %mathchoices=('' => 'Default',
      'tth' => 'TeX to HTML',       'tth' => 'TeX to HTML',
      'ttm' => 'TeX to MathML',       #'ttm' => 'TeX to MathML',
      'jsMath' => 'jsMath',       'jsMath' => 'jsMath',
      'mimetex' => 'Convert to Images'       'mimetex' => 'Convert to Images'
                      );                       );
     my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',      my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
      %mathchoices);       %mathchoices);
     my $mathexample='$$\int\left(\frac{a+b}{c^6*d}\right)$$';      my $jsMath_start=&Apache::lontexconvert::jsMath_header();
     my $jsMath_example=&Apache::lontexconvert::jsMath_converted(\$mathexample);  
     $mathexample='$$\int\left(\frac{a+b}{c^6*d}\right)$$';  
     my $tth_example=&Apache::lontexconvert::tth_converted(\$mathexample);  
     $mathexample='$$\int\left(\frac{a+b}{c^6*d}\right)$$';  
     my $mimetex_example=&Apache::lontexconvert::mimetex_converted(\$mathexample);  
     my $change=&mt('Change');      my $change=&mt('Change');
     $r->print(<<ENDLSCREEN);      $r->print(<<ENDLSCREEN);
 <form name="server" action="/adm/preferences" method="post">  <br />
   
   <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_texengine" />  <input type="hidden" name="action" value="verify_and_change_texengine" />
 <p>$pref: $selectionbox</p>  <p>$pref: $selectionbox</p>
 <p><input type="submit" value="$change" /></p>  <p><input type="submit" value="$change" /></p>
 </form>  </form>
 Examples:  Examples:
 <p> TeX to HTML <br /> $tth_example</p>  <p> TeX to HTML <br /> 
 <script type="text/javascript">function NoFontMessage () { }</script>  <iframe src="/res/adm/pages/math_example.tex?buttons=no&mode=tth" width="400" hieght="200"></iframe>
 <script src="/adm/jsMath/jsMath.js"></script>  </p>
 <p>jsMath <br />   <p>jsMath <br /> 
   $jsMath_start
 <script type="text/javascript">  <script type="text/javascript">
 if (jsMath.nofonts == 1) {  if (jsMath.nofonts == 1) {
     document.writeln      document.writeln
Line 231  if (jsMath.nofonts == 1) { Line 228  if (jsMath.nofonts == 1) {
  +'</font></small></div></center>');   +'</font></small></div></center>');
 }  }
 </script>  </script>
   <iframe src="/res/adm/pages/math_example.tex?buttons=no&mode=jsMath" width="400" hieght="200"></iframe>
   
 $jsMath_example</p>  </p>
 <p> Convert to Images <br /> $mimetex_example</p>  <p> Convert to Images <br />
   <br />
   <iframe src="/res/adm/pages/math_example.tex?buttons=no&mode=mimetex" width="400" hieght="200"></iframe>
   </p>
 ENDLSCREEN  ENDLSCREEN
     if ($env{'environment.texengine'} ne 'jsMath') {      if ($env{'environment.texengine'} ne 'jsMath') {
  $r->print('<script type="text/javascript">jsMath.Process()</script>');   $r->print('<script type="text/javascript">jsMath.Process()</script>');
Line 303  visited and places a table of these at t Line 304  visited and places a table of these at t
 People with very few roles should leave this feature disabled.  People with very few roles should leave this feature disabled.
 </p>  </p>
   
 <form name="server" action="/adm/preferences" method="post">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_rolespref" />  <input type="hidden" name="action" value="verify_and_change_rolespref" />
 <br />Enable Recent Roles Hotlist:  <br />Enable Recent Roles Hotlist:
 <input type="checkbox" $checked name="recentroles" value="true" />  <input type="checkbox" $checked name="recentroles" value="true" />
Line 361  sub screennamechanger { Line 362  sub screennamechanger {
     my $screenname=$userenv{'screenname'};      my $screenname=$userenv{'screenname'};
     my $nickname=$userenv{'nickname'};      my $nickname=$userenv{'nickname'};
     $r->print(<<ENDSCREEN);      $r->print(<<ENDSCREEN);
 <form name="server" action="/adm/preferences" method="post">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_screenname" />  <input type="hidden" name="action" value="verify_and_change_screenname" />
 <br />New screenname (shown if you post anonymously):  <br />New screenname (shown if you post anonymously):
 <input type="text" size="20" value="$screenname" name="screenname" />  <input type="text" size="20" value="$screenname" name="screenname" />
Line 402  sub verify_and_change_screenname { Line 403  sub verify_and_change_screenname {
         &Apache::lonnet::delenv('environment\.nickname');          &Apache::lonnet::delenv('environment\.nickname');
         $message.='Reset nickname';          $message.='Reset nickname';
     }      }
       &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain);
     $r->print(<<ENDVCSCREEN);      $r->print(<<ENDVCSCREEN);
 $message  $message
 ENDVCSCREEN  ENDVCSCREEN
Line 429  sub msgforwardchanger { Line 430  sub msgforwardchanger {
   
     $r->print(<<ENDMSG);      $r->print(<<ENDMSG);
 $forwardingHelp <br />  $forwardingHelp <br />
 <form name="server" action="/adm/preferences" method="post">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_msgforward" />  <input type="hidden" name="action" value="verify_and_change_msgforward" />
 New Forwarding Address(es) (<tt>user:domain,user:domain,...</tt>):  New Forwarding Address(es) (<tt>user:domain,user:domain,...</tt>):
 <input type="text" size="40" value="$msgforward" name="msgforward" /><hr />  <input type="text" size="40" value="$msgforward" name="msgforward" /><hr />
Line 549  sub colorschanger { Line 550  sub colorschanger {
         pclose();          pclose();
         if (document.parmform.pres_marker.value!='') {          if (document.parmform.pres_marker.value!='') {
             if (document.parmform.pres_type.value!='') {              if (document.parmform.pres_type.value!='') {
                 eval('document.server.'+                  eval('document.prefs.'+
                      document.parmform.pres_marker.value+                       document.parmform.pres_marker.value+
      '.value=document.parmform.pres_value.value;');       '.value=document.parmform.pres_value.value;');
     }      }
Line 566  sub colorschanger { Line 567  sub colorschanger {
 <input type="hidden" name="pres_type" />  <input type="hidden" name="pres_type" />
 <input type="hidden" name="pres_value" />  <input type="hidden" name="pres_value" />
 </form>  </form>
 <form name="server" action="/adm/preferences" method="post">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_colors" />  <input type="hidden" name="action" value="verify_and_change_colors" />
 <table border="2">  <table border="2">
 $chtable  $chtable
Line 616  sub verify_and_change_colors { Line 617  sub verify_and_change_colors {
     }      }
     $r->print(<<ENDVCCOL);      $r->print(<<ENDVCCOL);
 $message  $message
 <form name="client" action="/adm/preferences" method="post">  <form name="client" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="changecolors" />  <input type="hidden" name="action" value="changecolors" />
 </form>  </form>
 ENDVCCOL  ENDVCCOL
Line 658  sub passwordchanger { Line 659  sub passwordchanger {
     $lkey_npass2= hex($lkey_npass2);      $lkey_npass2= hex($lkey_npass2);
     # Output javascript to deal with passwords      # Output javascript to deal with passwords
     # Output DES javascript      # Output DES javascript
     my $html=&Apache::lonxml::xmlbegin();  
     $r->print($html."<head>");  
     {      {
  my $include = $r->dir_config('lonIncludes');   my $include = $r->dir_config('lonIncludes');
  my $jsh=Apache::File->new($include."/londes.js");   my $jsh=Apache::File->new($include."/londes.js");
Line 699  $errormessage Line 698  $errormessage
      ensure that unencrypted passwords will not be sent out by a       ensure that unencrypted passwords will not be sent out by a
      crappy browser -->       crappy browser -->
   
 <form name="pserver" action="/adm/preferences" method="post">  <form name="pserver" action="/adm/preferences" method="POST">
 <input type="hidden" name="logtoken"    value="$logtoken" />  <input type="hidden" name="logtoken"    value="$logtoken" />
 <input type="hidden" name="action"      value="verify_and_change_pass" />  <input type="hidden" name="action"      value="verify_and_change_pass" />
 <input type="hidden" name="currentpass" value="" />  <input type="hidden" name="currentpass" value="" />
Line 740  sub verify_and_change_password { Line 739  sub verify_and_change_password {
     # Check for authentication types that allow changing of the password.      # Check for authentication types that allow changing of the password.
     return if ($currentauth !~ /^(unix|internal):/);      return if ($currentauth !~ /^(unix|internal):/);
     #      #
     my $html=&Apache::lonxml::xmlbegin();  
     $r->print(<<ENDHEADER);  
 $html  
 <head>  
 <title>LON-CAPA Preferences:  Change password for $user</title>  
 </head>  
 ENDHEADER  
     #  
     my $currentpass = $env{'form.currentpass'};       my $currentpass = $env{'form.currentpass'}; 
     my $newpass1    = $env{'form.newpass_1'};       my $newpass1    = $env{'form.newpass_1'}; 
     my $newpass2    = $env{'form.newpass_2'};      my $newpass2    = $env{'form.newpass_2'};
Line 772  password decryption.  Please log out and Line 763  password decryption.  Please log out and
 </p>  </p>
 ENDERROR  ENDERROR
         # Probably should log an error here          # Probably should log an error here
         return;          return 1;
     }      }
     my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);      my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
     #       # 
Line 785  ENDERROR Line 776  ENDERROR
  '<font color="#ff0000">ERROR:</font>'.   '<font color="#ff0000">ERROR:</font>'.
  'The new passwords you entered do not match.  '.   'The new passwords you entered do not match.  '.
  'Please try again.');   'Please try again.');
  return;   return 1;
     }      }
     if (length($newpass1) < 7) {      if (length($newpass1) < 7) {
  &passwordchanger($r,   &passwordchanger($r,
  '<font color="#ff0000">ERROR:</font>'.   '<font color="#ff0000">ERROR:</font>'.
  'Passwords must be a minimum of 7 characters long.  '.   'Passwords must be a minimum of 7 characters long.  '.
  'Please try again.');   'Please try again.');
  return;   return 1;
     }      }
     #      #
     # Check for bad characters      # Check for bad characters
Line 827  ENDTEXT Line 818  ENDTEXT
 <h2><font color="#ff0000">The password for $user was not changed</font></h2>  <h2><font color="#ff0000">The password for $user was not changed</font></h2>
 Please make sure your old password was entered correctly.  Please make sure your old password was entered correctly.
 ENDERROR  ENDERROR
           return 1;
     }      }
     return;      return;
 }  }
Line 895  sub discussionchanger { Line 887  sub discussionchanger {
     }      }
           
     $r->print(<<"END");      $r->print(<<"END");
 <form name="server" action="/adm/preferences" method="post">  <form name="prefs" action="/adm/preferences" method="POST">
 <input type="hidden" name="action" value="verify_and_change_discussion" />  <input type="hidden" name="action" value="verify_and_change_discussion" />
 <br />  <br />
 $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>   $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol> 
Line 973  $message Line 965  $message
 ENDVCSCREEN  ENDVCSCREEN
 }  }
   
   ################################################################
   # Subroutines for page display on course access (Course Coordinators)
   ################################################################
   sub coursedisplaychanger {
       my $r = shift;
       my $user       = $env{'user.name'};
       my $domain     = $env{'user.domain'};
       my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
       my $currvalue = 'whatsnew';
       my $firstselect = '';
       my $whatsnewselect = 'checked="checked"';
       if (exists($userenv{'course_init_display'})) {
           if ($userenv{'course_init_display'} eq 'firstres') {
               $currvalue = 'firstres';
               $firstselect = 'checked="checked"';
       $whatsnewselect = '';
           }
       }
       my %pagenames = (
                          firstres => 'First resource',
                          whatsnew => "What's new page",
                       );
       my $whatsnew_off=&mt('Display the [_1] in the course.','<b>first resource</b>');
       my $whatsnew_on=&mt('Display the "[_1]" page - a summary of items in the course which require attention.',"<b>What's New</b>");
   
       $r->print('<br /><b>'.&mt('Set the default page to be displayed when you select a course role').'</b>&nbsp;'.&mt('(Currently: [_1])',$pagenames{$currvalue}).'<br />'.&mt('The global user preference you set for your courses can be overridden in an individual course by setting a course specific setting via the "[_1]" page in the course',"<i>What's New</i>").'<br /><br />');
       $r->print(<<ENDLSCREEN);
   <form name="prefs" action="/adm/preferences" method="POST">
   <input type="hidden" name="action" value="verify_and_change_coursepage" />
   <br />
   <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br />
   <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
   ENDLSCREEN
       $r->print('<br /><br /><input type="submit" value="'.&mt('Change').'" />
   </form>');
   }
   
   sub verify_and_change_coursepage {
       my $r = shift;
       my $message='';
       my %lt = &Apache::lonlocal::texthash(
           'defs' => 'Default now set',
           'when' => 'when you select a course role from the roles screen',
           'ywbt' => 'you will be taken to the start of the course.',
           'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
           'gtts' => 'Go to the start of the course',
           'dasp' => "Display the What's New page listing course action items", 
       );
       my $newdisp  = $env{'form.newdisp'};
       $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
       if ($newdisp eq 'firstres') {
           $message .= $lt{'ywbt'}.'<br/>';
           &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
           &Apache::lonnet::appenv('environment.course_init_display' => $newdisp);
       } else {
           $message .= $lt{'apwb'}.'<br/>';
           &Apache::lonnet::del('environment',['course_init_display']);
           &Apache::lonnet::delenv('environment\.course_init_display');
       }
       my $refpage = $env{'form.refpage'};
       if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
           if ($newdisp eq 'firstres') {
               my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
               my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; 
               my ($furl,$ferr)=
                   &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
               $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';
           } else {
               $message .= '<br /><font size="+1"><a href="/adm/whatsnew?refpage='.
                           $refpage.'">'.$lt{'dasp'}.'</a></font>';
           }
       }
       $r->print(<<ENDVCSCREEN);
   $message
   <br /><br />
   ENDVCSCREEN
   }
   
   
 ######################################################  ######################################################
 #            other handler subroutines               #  #            other handler subroutines               #
 ######################################################  ######################################################
Line 991  sub handler { Line 1062  sub handler {
     return OK if $r->header_only;      return OK if $r->header_only;
     #      #
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['action','wysiwyg','returnurl']);                                     ['action','wysiwyg','returnurl','refpage']);
     #      #
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
Line 1016  sub handler { Line 1087  sub handler {
                           breadcrumb =>                             breadcrumb => 
                               { href =>'/adm/preferences?action=changepass',                                { href =>'/adm/preferences?action=changepass',
                                 text => 'Change Password'},                                  text => 'Change Password'},
                           printmenu => 'yes',                            printmenu => 'not_on_error',
                           }));                            }));
     }      }
     push (@Options,({ action   => 'changescreenname',      push (@Options,({ action   => 'changescreenname',
Line 1153  sub handler { Line 1224  sub handler {
                             text => 'Change Math Preferences'},                              text => 'Change Math Preferences'},
                       printmenu => 'yes',                        printmenu => 'yes',
                       }));                        }));
       if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
    || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
       .$env{'request.course.sec'})) {
           push (@Options,({ action => 'changecourseinit',
                             linktext => 'Change Course Initialization Preference',
                             href => '/adm/preferences',
                             subroutine => \&coursedisplaychanger,
                             breadcrumb =>
                                 { href => '/adm/preferences?action=changecourseinit',
                                   text => 'Change Course Init. Pref.'},
                             },
                           { action => 'verify_and_change_coursepage',
                             breadcrumb =>
                             { href => '/adm/preferences?action=changecourseinit',                               text => 'Change Course Initialization Preference'},
                           printmenu => 'yes',
                           subroutine => \&verify_and_change_coursepage,
                          }));
       }
   
       if ($env{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle|raeburn)$/) {
     if ($env{'user.name'} =~ /^(megan|albertel|fox|foxr|koretemey|korte|hallmat3|turtle)$/) {  
         push (@Options,({ action => 'debugtoggle',          push (@Options,({ action => 'debugtoggle',
                           printmenu => 'yes',                            printmenu => 'yes',
                           subroutine => \&toggle_debug,                            subroutine => \&toggle_debug,
                           }));                            }));
     }      }
     my $html=&Apache::lonxml::xmlbegin();  
     $r->print(<<ENDHEADER);      $r->print(&Apache::loncommon::start_page('Change Preferences'));
 $html  
 <head>  
 <title>LON-CAPA Preferences</title>  
 </head>  
 ENDHEADER  
     my $call = undef;      my $call = undef;
     my $help = undef;      my $help = undef;
     my $printmenu = 'yes';      my $printmenu = 'yes';
Line 1182  ENDHEADER Line 1266  ENDHEADER
     $help=$option->{'help'};      $help=$option->{'help'};
         }          }
     }      }
     $r->print(&Apache::loncommon::bodytag('Change Preferences'));  
     $r->print(&Apache::lonhtmlcommon::breadcrumbs      $r->print(&Apache::lonhtmlcommon::breadcrumbs
               (undef,'Change Preferences',$help));                (undef,'Change Preferences',$help));
       my $error;
     if (defined($call)) {      if (defined($call)) {
         $call->($r);          $error = $call->($r);
     }      }
     if (($printmenu eq 'yes') && (!$env{'form.returnurl'})) {      if ( ( ($printmenu eq 'yes')
      || ($printmenu eq 'not_on_error' && !$error) )
    && (!$env{'form.returnurl'})) {
         my $optionlist = '<table cellpadding="5">';          my $optionlist = '<table cellpadding="5">';
         if ($env{'user.name'} =~           if ($env{'user.name'} =~ 
                          /^(megan|albertel|kortemey|fox|foxr|korte|hallmat3|turtle)$/                           /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/
             ) {              ) {
             push (@Options,({ action => 'debugtoggle',              push (@Options,({ action => 'debugtoggle',
                               linktext => 'Toggle Debug Messages',                                linktext => 'Toggle Debug Messages',
Line 1232  ENDHEADER Line 1318  ENDHEADER
  $r->print('<br /><a href="'.$env{'form.returnurl'}.'"><font size="+1">'.   $r->print('<br /><a href="'.$env{'form.returnurl'}.'"><font size="+1">'.
   &mt('Return').'</font></a>');    &mt('Return').'</font></a>');
     }      }
     $r->print(&Apache::loncommon::endbodytag().'</html>');      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
 }  }
   

Removed from v.1.60  
changed lines
  Added in v.1.78


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>