Diff for /loncom/interface/lonpreferences.pm between versions 1.66 and 1.75

version 1.66, 2005/07/05 15:25:34 version 1.75, 2006/03/15 21:19:10
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',
Line 196  sub texenginechanger { Line 196  sub texenginechanger {
                      );                       );
     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);
   <br />
   
 <form name="server" action="/adm/preferences" method="post">  <form name="server" 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 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 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 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 981  sub coursedisplaychanger { Line 973  sub coursedisplaychanger {
     my $user       = $env{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $env{'user.domain'};      my $domain     = $env{'user.domain'};
     my %userenv = &Apache::lonnet::get('environment',['course_init_display']);      my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
       my $currvalue = 'whatsnew';
     my $firstselect='checked="checked"';      my $firstselect = '';
     my $whatsnewselect='';      my $whatsnewselect = 'checked="checked"';
     if ($userenv{'course_init_display'} ne 'firstres') {      if (exists($userenv{'course_init_display'})) {
         $firstselect='';          if ($userenv{'course_init_display'} eq 'firstres') {
         $whatsnewselect='checked="checked"';              $currvalue = 'firstres';
               $firstselect = 'checked="checked"';
       $whatsnewselect = '';
           }
     }      }
     my $whatsnew_off=&mt('Display the first resource in the course.');      my %pagenames = (
     my $whatsnew_on=&mt('Display a summary of items in the course which require action from the course coordinator.');                         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 page to be displayed when you select the role of Course Coordinator').':</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);      $r->print(<<ENDLSCREEN);
 <form name="server" action="/adm/preferences" method="post">  <form name="server" action="/adm/preferences" method="post">
 <input type="hidden" name="action" value="verify_and_change_coursepage" />  <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="firstres" $firstselect /> $whatsnew_off</label><br />
 <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label>  <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
 ENDLSCREEN  ENDLSCREEN
     $r->print('<br /><input type="submit" value="'.&mt('Change').'" />      $r->print('<br /><br /><input type="submit" value="'.&mt('Change').'" />
 </form>');  </form>');
 }  }
   
Line 1006  sub verify_and_change_coursepage { Line 1006  sub verify_and_change_coursepage {
     my $r = shift;      my $r = shift;
     my $message='';      my $message='';
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'when' => 'Whenever you select the Course Coordinator role from the roles screen',          '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.',          '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.',          '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',          'gtts' => 'Go to the start of the course',
         'dasp' => 'Display a summary page listing course action items',           'dasp' => "Display the What's New page listing course action items", 
     );      );
     my $newdisp  = $env{'form.newdisp'};      my $newdisp  = $env{'form.newdisp'};
       $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
     if ($newdisp eq 'firstres') {      if ($newdisp eq 'firstres') {
         $message .= $lt{'when'}.', '.$lt{'ywbt'}.'<br/>';          $message .= $lt{'ywbt'}.'<br/>';
         &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});          &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
         &Apache::lonnet::appenv('environment.course_init_display' => $newdisp);          &Apache::lonnet::appenv('environment.course_init_display' => $newdisp);
     } else {      } else {
         $message .= $lt{'when'}.', '.$lt{'apwb'}.'<br/>';          $message .= $lt{'apwb'}.'<br/>';
         &Apache::lonnet::del('environment',['course_init_display']);          &Apache::lonnet::del('environment',['course_init_display']);
         &Apache::lonnet::delenv('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 (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
         if ($newdisp eq 'firstres') {          if ($newdisp eq 'firstres') {
             my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};              my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
Line 1030  sub verify_and_change_coursepage { Line 1033  sub verify_and_change_coursepage {
                 &Apache::lonuserstate::readmap($cdom.'/'.$cnum);                  &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
             $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';              $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';
         } else {          } else {
             $message .= '<br /><font size="+1"><a href="/adm/whatsnew">'.$lt{'dasp'}.'</a></font>';              $message .= '<br /><font size="+1"><a href="/adm/whatsnew?refpage='.
                           $refpage.'">'.$lt{'dasp'}.'</a></font>';
         }          }
     }      }
     $r->print(<<ENDVCSCREEN);      $r->print(<<ENDVCSCREEN);
Line 1058  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 1083  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 1220  sub handler { Line 1224  sub handler {
                             text => 'Change Math Preferences'},                              text => 'Change Math Preferences'},
                       printmenu => 'yes',                        printmenu => 'yes',
                       }));                        }));
     if($env{'request.role'} =~ /^cc\.\//) {      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',          push (@Options,({ action => 'changecourseinit',
                           linktext => 'Change Course Initialization Preference',                            linktext => 'Change Course Initialization Preference',
                           href => '/adm/preferences',                            href => '/adm/preferences',
Line 1267  ENDHEADER Line 1273  ENDHEADER
     $r->print(&Apache::loncommon::bodytag('Change Preferences'));      $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'} =~ 
                          /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/                           /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/

Removed from v.1.66  
changed lines
  Added in v.1.75


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