Diff for /loncom/interface/lonpreferences.pm between versions 1.57 and 1.73

version 1.57, 2005/02/28 19:08:11 version 1.73, 2006/01/06 19:05:30
Line 40  use DynaLoader; # for Crypt::DES version Line 40  use DynaLoader; # for Crypt::DES version
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::lonnet;
   
 #  #
 # Write lonnet::passwd to do the call below.  # Write lonnet::passwd to do the call below.
Line 109  sub wysiwygchanger { Line 110  sub wysiwygchanger {
 <form name="server" action="/adm/preferences" method="post">  <form name="server" 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 118  ENDLSCREEN Line 119  ENDLSCREEN
   
 sub verify_and_change_wysiwyg {  sub verify_and_change_wysiwyg {
     my $r = shift;      my $r = shift;
     my $newsetting=$ENV{'form.wysiwyg'};      my $newsetting=$env{'form.wysiwyg'};
     &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});      &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
     &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting);      &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting);
     $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');      $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');
Line 129  sub verify_and_change_wysiwyg { Line 130  sub verify_and_change_wysiwyg {
 ################################################################  ################################################################
 sub languagechanger {  sub languagechanger {
     my $r = shift;      my $r = shift;
     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      my %userenv = &Apache::lonnet::get
         ('environment',['languages']);          ('environment',['languages']);
     my $language=$userenv{'languages'};      my $language=$userenv{'languages'};
Line 156  ENDLSCREEN Line 157  ENDLSCREEN
   
 sub verify_and_change_languages {  sub verify_and_change_languages {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $env{'user.domain'};
 # Screenname  # Screenname
     my $newlanguage  = $ENV{'form.language'};      my $newlanguage  = $env{'form.language'};
     $newlanguage=~s/[^\-\w]//g;      $newlanguage=~s/[^\-\w]//g;
     my $message='';      my $message='';
     if ($newlanguage) {      if ($newlanguage) {
Line 172  sub verify_and_change_languages { Line 173  sub verify_and_change_languages {
         $message='Reset preferred language';          $message='Reset preferred language';
     }      }
     $r->print(<<ENDVCSCREEN);      $r->print(<<ENDVCSCREEN);
 </p>  
 $message  $message
 ENDVCSCREEN  ENDVCSCREEN
 }  }
Line 182  ENDVCSCREEN Line 182  ENDVCSCREEN
 ################################################################  ################################################################
 sub texenginechanger {  sub texenginechanger {
     my $r = shift;      my $r = shift;
     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',['texengine']);      my %userenv = &Apache::lonnet::get('environment',['texengine']);
     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);
   <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 243  ENDLSCREEN Line 244  ENDLSCREEN
   
 sub verify_and_change_texengine {  sub verify_and_change_texengine {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $env{'user.domain'};
 # Screenname  # Screenname
     my $newtexengine  = $ENV{'form.texengine'};      my $newtexengine  = $env{'form.texengine'};
     $newtexengine=~s/[^\-\w]//g;      $newtexengine=~s/[^\-\w]//g;
     if ($newtexengine eq 'ttm') {      if ($newtexengine eq 'ttm') {
  &Apache::lonnet::appenv('browser.mathml' => 1);   &Apache::lonnet::appenv('browser.mathml' => 1);
     } else {      } else {
  if ($ENV{'environment.texengine'} eq 'ttm') {   if ($env{'environment.texengine'} eq 'ttm') {
     &Apache::lonnet::appenv('browser.mathml' => 0);      &Apache::lonnet::appenv('browser.mathml' => 0);
  }   }
     }      }
Line 268  sub verify_and_change_texengine { Line 269  sub verify_and_change_texengine {
   
   
     $r->print(<<ENDVCSCREEN);      $r->print(<<ENDVCSCREEN);
 </p>  
 $message  $message
 ENDVCSCREEN  ENDVCSCREEN
 }  }
Line 278  ENDVCSCREEN Line 278  ENDVCSCREEN
 ################################################################  ################################################################
 sub rolesprefchanger {  sub rolesprefchanger {
     my $r = shift;      my $r = shift;
     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      my %userenv = &Apache::lonnet::get
         ('environment',['recentroles','recentrolesn']);          ('environment',['recentroles','recentrolesn']);
     my $hotlist_flag=$userenv{'recentroles'};      my $hotlist_flag=$userenv{'recentroles'};
Line 320  ENDSCREEN Line 320  ENDSCREEN
   
 sub verify_and_change_rolespref {  sub verify_and_change_rolespref {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $env{'user.domain'};
 # Recent Roles Hotlist Flag  # Recent Roles Hotlist Flag
     my $hotlist_flag  = $ENV{'form.recentroles'};      my $hotlist_flag  = $env{'form.recentroles'};
     my $hotlist_n  = $ENV{'form.recentrolesn'};      my $hotlist_n  = $env{'form.recentrolesn'};
     my $message='';      my $message='';
     if ($hotlist_flag) {      if ($hotlist_flag) {
         &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});          &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
Line 344  sub verify_and_change_rolespref { Line 344  sub verify_and_change_rolespref {
     }      }
   
     $r->print(<<ENDRPSCREEN);      $r->print(<<ENDRPSCREEN);
 </p>  
 $message  $message
 ENDRPSCREEN  ENDRPSCREEN
 }  }
Line 356  ENDRPSCREEN Line 355  ENDRPSCREEN
 ################################################################  ################################################################
 sub screennamechanger {  sub screennamechanger {
     my $r = shift;      my $r = shift;
     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      my %userenv = &Apache::lonnet::get
         ('environment',['screenname','nickname']);          ('environment',['screenname','nickname']);
     my $screenname=$userenv{'screenname'};      my $screenname=$userenv{'screenname'};
Line 376  ENDSCREEN Line 375  ENDSCREEN
   
 sub verify_and_change_screenname {  sub verify_and_change_screenname {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $env{'user.domain'};
 # Screenname  # Screenname
     my $newscreen  = $ENV{'form.screenname'};      my $newscreen  = $env{'form.screenname'};
     $newscreen=~s/[^ \w]//g;      $newscreen=~s/[^ \w]//g;
     my $message='';      my $message='';
     if ($newscreen) {      if ($newscreen) {
Line 393  sub verify_and_change_screenname { Line 392  sub verify_and_change_screenname {
     }      }
 # Nickname  # Nickname
     $message.='<br />';      $message.='<br />';
     $newscreen  = $ENV{'form.nickname'};      $newscreen  = $env{'form.nickname'};
     $newscreen=~s/[^ \w]//g;      $newscreen=~s/[^ \w]//g;
     if ($newscreen) {      if ($newscreen) {
         &Apache::lonnet::put('environment',{'nickname' => $newscreen});          &Apache::lonnet::put('environment',{'nickname' => $newscreen});
Line 404  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);
 </p>  
 $message  $message
 ENDVCSCREEN  ENDVCSCREEN
 }  }
Line 417  ENDVCSCREEN Line 415  ENDVCSCREEN
   
 sub msgforwardchanger {  sub msgforwardchanger {
     my $r = shift;      my $r = shift;
     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',['msgforward','notification','critnotification']);      my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification']);
     my $msgforward=$userenv{'msgforward'};      my $msgforward=$userenv{'msgforward'};
     my $notification=$userenv{'notification'};      my $notification=$userenv{'notification'};
Line 447  ENDMSG Line 445  ENDMSG
   
 sub verify_and_change_msgforward {  sub verify_and_change_msgforward {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $env{'user.domain'};
     my $newscreen  = '';      my $newscreen  = '';
     my $message='';      my $message='';
     foreach (split(/\,/,$ENV{'form.msgforward'})) {      foreach (split(/\,/,$env{'form.msgforward'})) {
  my ($msuser,$msdomain)=split(/[\@\:]/,$_);   my ($msuser,$msdomain)=split(/[\@\:]/,$_);
         $msuser=~s/\W//g;          $msuser=~s/\W//g;
         $msdomain=~s/\W//g;          $msdomain=~s/\W//g;
Line 473  sub verify_and_change_msgforward { Line 471  sub verify_and_change_msgforward {
         &Apache::lonnet::delenv('environment\.msgforward');          &Apache::lonnet::delenv('environment\.msgforward');
         $message.='Reset message forwarding<br />';          $message.='Reset message forwarding<br />';
     }      }
     my $notification=$ENV{'form.notification'};      my $notification=$env{'form.notification'};
     $notification=~s/\s//gs;      $notification=~s/\s//gs;
     if ($notification) {      if ($notification) {
         &Apache::lonnet::put('environment',{'notification' => $notification});          &Apache::lonnet::put('environment',{'notification' => $notification});
Line 484  sub verify_and_change_msgforward { Line 482  sub verify_and_change_msgforward {
         &Apache::lonnet::delenv('environment\.notification');          &Apache::lonnet::delenv('environment\.notification');
         $message.='Reset message notification<br />';          $message.='Reset message notification<br />';
     }      }
     my $critnotification=$ENV{'form.critnotification'};      my $critnotification=$env{'form.critnotification'};
     $critnotification=~s/\s//gs;      $critnotification=~s/\s//gs;
     if ($critnotification) {      if ($critnotification) {
         &Apache::lonnet::put('environment',{'critnotification' => $critnotification});          &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
Line 496  sub verify_and_change_msgforward { Line 494  sub verify_and_change_msgforward {
         $message.='Reset critical message notification<br />';          $message.='Reset critical message notification<br />';
     }      }
     $r->print(<<ENDVCMSG);      $r->print(<<ENDVCMSG);
 </p>  
 $message  $message
 ENDVCMSG  ENDVCMSG
 }  }
Line 509  sub colorschanger { Line 506  sub colorschanger {
     my $r = shift;      my $r = shift;
 # figure out colors  # figure out colors
     my $function='student';      my $function='student';
     if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {      if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
  $function='coordinator';   $function='coordinator';
     }      }
     if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {      if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
  $function='admin';   $function='admin';
     }      }
     if (($ENV{'request.role'}=~/^(au|ca)/) ||      if (($env{'request.role'}=~/^(au|ca)/) ||
  ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {   ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
  $function='author';   $function='author';
     }      }
Line 585  sub verify_and_change_colors { Line 582  sub verify_and_change_colors {
     my $r = shift;      my $r = shift;
 # figure out colors  # figure out colors
     my $function='student';      my $function='student';
     if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {      if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
  $function='coordinator';   $function='coordinator';
     }      }
     if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {      if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
  $function='admin';   $function='admin';
     }      }
     if (($ENV{'request.role'}=~/^(au|ca)/) ||      if (($env{'request.role'}=~/^(au|ca)/) ||
  ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {   ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
  $function='author';   $function='author';
     }      }
Line 606  sub verify_and_change_colors { Line 603  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};
         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});
     &Apache::lonnet::appenv('environment.'.$entry => $color);      &Apache::lonnet::appenv('environment.'.$entry => $color);
     $message.='Set '.$colortypes{$item}.' to '.$color.'<br />';      $message.='Set '.$colortypes{$item}.' to '.$color.'<br />';
Line 619  sub verify_and_change_colors { Line 616  sub verify_and_change_colors {
  }   }
     }      }
     $r->print(<<ENDVCCOL);      $r->print(<<ENDVCCOL);
 </p>  
 $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" />
Line 636  sub passwordchanger { Line 632  sub passwordchanger {
     my $r = shift;      my $r = shift;
     my $errormessage = shift;      my $errormessage = shift;
     $errormessage = ($errormessage || '');      $errormessage = ($errormessage || '');
     my $user       = $ENV{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $env{'user.domain'};
     my $homeserver = $ENV{'user.home'};      my $homeserver = $env{'user.home'};
     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);      my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
     # 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):/);
Line 738  ENDFORM Line 734  ENDFORM
   
 sub verify_and_change_password {  sub verify_and_change_password {
     my $r = shift;      my $r = shift;
     my $user       = $ENV{'user.name'};      my $user       = $env{'user.name'};
     my $domain     = $ENV{'user.domain'};      my $domain     = $env{'user.domain'};
     my $homeserver = $ENV{'user.home'};      my $homeserver = $env{'user.home'};
     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);      my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
     # 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):/);
Line 753  $html Line 749  $html
 </head>  </head>
 ENDHEADER  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'};
     my $logtoken    = $ENV{'form.logtoken'};      my $logtoken    = $env{'form.logtoken'};
     # Check for empty data       # Check for empty data 
     unless (defined($currentpass) &&       unless (defined($currentpass) && 
     defined($newpass1)    &&       defined($newpass1)    && 
Line 841  ENDERROR Line 837  ENDERROR
 ################################################################  ################################################################
 sub discussionchanger {  sub discussionchanger {
     my $r = shift;      my $r = shift;
     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      my %userenv = &Apache::lonnet::get
         ('environment',['discdisplay','discmarkread']);          ('environment',['discdisplay','discmarkread']);
     my $discdisp = 'allposts';      my $discdisp = 'allposts';
Line 864  sub discussionchanger { Line 860  sub discussionchanger {
   
     my $function = &Apache::loncommon::get_users_function();      my $function = &Apache::loncommon::get_users_function();
     my $color = &Apache::loncommon::designparm($function.'.tabbg',      my $color = &Apache::loncommon::designparm($function.'.tabbg',
                                                     $ENV{'user.domain'});                                                      $env{'user.domain'});
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'pref' => 'Display Preference',          'pref' => 'Display Preference',
         'curr' => 'Current setting ',          'curr' => 'Current setting ',
Line 946  END Line 942  END
                                                                                                                                                                                                                                   
 sub verify_and_change_discussion {  sub verify_and_change_discussion {
     my $r = shift;      my $r = shift;
     my $user     = $ENV{'user.name'};      my $user     = $env{'user.name'};
     my $domain   = $ENV{'user.domain'};      my $domain   = $env{'user.domain'};
     my $message='';      my $message='';
     if (defined($ENV{'form.discdisp'}) ) {      if (defined($env{'form.discdisp'}) ) {
         my $newdisp  = $ENV{'form.newdisp'};          my $newdisp  = $env{'form.newdisp'};
         if ($newdisp eq 'unread') {          if ($newdisp eq 'unread') {
             $message .='In discussions: only new posts will be displayed.<br/>';              $message .='In discussions: only new posts will be displayed.<br/>';
             &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});              &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
Line 961  sub verify_and_change_discussion { Line 957  sub verify_and_change_discussion {
             &Apache::lonnet::delenv('environment\.discdisplay');              &Apache::lonnet::delenv('environment\.discdisplay');
         }          }
     }      }
     if (defined($ENV{'form.discmark'}) ) {      if (defined($env{'form.discmark'}) ) {
         my $newmark = $ENV{'form.newmark'};          my $newmark = $env{'form.newmark'};
         if ($newmark eq 'ondisp') {          if ($newmark eq 'ondisp') {
            $message.='In discussions: new posts will be cease to be identified as "new" after display.<br/>';             $message.='In discussions: new posts will be cease to be identified as "new" after display.<br/>';
             &Apache::lonnet::put('environment',{'discmarkread' => $newmark});              &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
Line 974  sub verify_and_change_discussion { Line 970  sub verify_and_change_discussion {
         }          }
     }      }
     $r->print(<<ENDVCSCREEN);      $r->print(<<ENDVCSCREEN);
 </p>  
 $message  $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="server" 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 988  ENDVCSCREEN Line 1062  ENDVCSCREEN
 ################################################################  ################################################################
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     my $user = $ENV{'user.name'};      my $user = $env{'user.name'};
     my $domain = $ENV{'user.domain'};      my $domain = $env{'user.domain'};
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     # Some pages contain DES keys and should not be cached.      # Some pages contain DES keys and should not be cached.
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
Line 997  sub handler { Line 1071  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 1058  sub handler { Line 1132  sub handler {
                       printmenu => 'yes',                        printmenu => 'yes',
                       subroutine => \&verify_and_change_msgforward }));                        subroutine => \&verify_and_change_msgforward }));
     my $aboutmeaction=      my $aboutmeaction=
         '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';          '/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
     push (@Options,{ action => 'none',       push (@Options,{ action => 'none', 
                      linktext =>                       linktext =>
                          q{Edit the 'About Me' Personal Information Screen},                           q{Edit the 'About Me' Personal Information Screen},
Line 1159  sub handler { Line 1233  sub handler {
                             text => 'Change Math Preferences'},                              text => 'Change Math Preferences'},
                       printmenu => 'yes',                        printmenu => 'yes',
                       }));                        }));
       if ($env{'user.adv'}) {
           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'} =~ /^(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,
Line 1178  ENDHEADER Line 1267  ENDHEADER
     my $help = undef;      my $help = undef;
     my $printmenu = 'yes';      my $printmenu = 'yes';
     foreach my $option (@Options) {      foreach my $option (@Options) {
         if ($option->{'action'} eq $ENV{'form.action'}) {          if ($option->{'action'} eq $env{'form.action'}) {
             $call = $option->{'subroutine'};              $call = $option->{'subroutine'};
             $printmenu = $option->{'printmenu'};              $printmenu = $option->{'printmenu'};
             if (exists($option->{'breadcrumb'})) {              if (exists($option->{'breadcrumb'})) {
Line 1194  ENDHEADER Line 1283  ENDHEADER
     if (defined($call)) {      if (defined($call)) {
         $call->($r);          $call->($r);
     }      }
     if (($printmenu eq 'yes') && (!$ENV{'form.returnurl'})) {      if (($printmenu eq 'yes') && (!$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)$/                           /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/
             ) {              ) {
             push (@Options,({ action => 'debugtoggle',              push (@Options,({ action => 'debugtoggle',
                               linktext => 'Toggle Debug Messages',                                linktext => 'Toggle Debug Messages',
                               text => 'Current Debug status is -'.                                text => 'Current Debug status is -'.
                                   $ENV{'user.debug'}.'-.',                                    $env{'user.debug'}.'-.',
                               href => '/adm/preferences',                                href => '/adm/preferences',
                               printmenu => 'yes',                                printmenu => 'yes',
                               subroutine => \&toggle_debug,                                subroutine => \&toggle_debug,
Line 1234  ENDHEADER Line 1323  ENDHEADER
         }          }
         $optionlist .= '</table>';          $optionlist .= '</table>';
         $r->print($optionlist);          $r->print($optionlist);
     } elsif ($ENV{'form.returnurl'}) {      } elsif ($env{'form.returnurl'}) {
  $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::endbodytag().'</html>');
Line 1243  ENDHEADER Line 1332  ENDHEADER
 }  }
   
 sub toggle_debug {  sub toggle_debug {
     if ($ENV{'user.debug'}) {      if ($env{'user.debug'}) {
         &Apache::lonnet::delenv('user\.debug');          &Apache::lonnet::delenv('user\.debug');
     } else {      } else {
         &Apache::lonnet::appenv('user.debug' => 1);          &Apache::lonnet::appenv('user.debug' => 1);

Removed from v.1.57  
changed lines
  Added in v.1.73


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