Diff for /loncom/interface/lonpreferences.pm between versions 1.4 and 1.11

version 1.4, 2002/02/19 21:50:40 version 1.11, 2002/08/27 13:23:01
Line 99  sub des_decrypt { Line 99  sub des_decrypt {
 #                       Handler subroutines                    #  #                       Handler subroutines                    #
 ################################################################  ################################################################
   
   ################################################################
   #         Anonymous Discussion Name Change Subroutines         #
   ################################################################
   sub screennamechanger {
       my $r = shift;
       my $user       = $ENV{'user.name'};
       my $domain     = $ENV{'user.domain'};
       my %userenv = &Apache::lonnet::get('environment',['screenname']);
       my $screenname=$userenv{'screenname'};
       my $bodytag=&Apache::loncommon::bodytag(
                                            'Change Your Anonymous Screen Name');
       $r->print(<<ENDSCREEN);
   <html>
   $bodytag
   
   <form name="server" action="/adm/preferences" method="post">
   <input type="hidden" name="action" value="verify_and_change_screenname" />
   New screenname:
   <input type="text" size="20" value="$screenname" name="screenname" />
   <input type="submit" value="Change" />
   </form>
   </body>
   </html>
   ENDSCREEN
   }
   
   sub verify_and_change_screenname {
       my $r = shift;
       my $user       = $ENV{'user.name'};
       my $domain     = $ENV{'user.domain'};
       my $newscreen  = $ENV{'form.screenname'};
       $newscreen=~s/\W//g;
       my $message='';
       if ($newscreen) {
           &Apache::lonnet::put('environment',{'screenname' => $newscreen});
           &Apache::lonnet::appenv('environment.screenname' => $newscreen);
           $message='Set new screenname to '.$newscreen;
       } else {
           &Apache::lonnet::del('environment',['screenname']);
           &Apache::lonnet::delenv('environment\.screenname');
           $message='Reset screenname';
       }
       my $bodytag=&Apache::loncommon::bodytag(
                                            'Change Your Anonymous Screen Name');
       $r->print(<<ENDVCSCREEN);
   <html>
   $bodytag
   </p>
   $message
   </body></html>
   ENDVCSCREEN
   }
   
 ######################################################  ######################################################
 #            password handler subroutines            #  #            password handler subroutines            #
 ######################################################  ######################################################
Line 135  sub passwordchanger { Line 188  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
       $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");
  $r->print(<$jsh>);   $r->print(<$jsh>);
     }      }
       my $bodytag=&Apache::loncommon::bodytag('Change Password','',
                                            'onLoad="init();"');
     $r->print(<<ENDFORM);      $r->print(<<ENDFORM);
   </head>
 <body bgcolor="#FFFFFF" onLoad="init();">  $bodytag
   
 <script language="JavaScript">  <script language="JavaScript">
   
Line 170  sub passwordchanger { Line 226  sub passwordchanger {
     }      }
   
 </script>  </script>
 <h1>Preferences for $user</h1>  
 <h3>$user is a member of domain $domain</h3>  
 $errormessage  $errormessage
 <p>  
 Change password for $user  
 </p>  
 <p>  <p>
 <!-- We seperate the forms into 'server' and 'client' in order to  <!-- We seperate the forms into 'server' and 'client' in order to
      ensure that unencrypted passwords will not be sent out by a       ensure that unencrypted passwords will not be sent out by a
Line 300  ENDERROR Line 352  ENDERROR
     # Inform the user the password has (not?) been changed      # Inform the user the password has (not?) been changed
     if ($result =~ /^ok$/) {      if ($result =~ /^ok$/) {
  $r->print(<<"ENDTEXT");   $r->print(<<"ENDTEXT");
 <h2>Password for $user was successfully changed</h2>  <h2>The password for $user was successfully changed</h2>
 ENDTEXT  ENDTEXT
     } else {      } else {
  # error error: run in circles, scream and shout   # error error: run in circles, scream and shout
         $r->print(<<ENDERROR);          $r->print(<<ENDERROR);
 <h2><font color="#ff0000">Password for $user was not changed</font></h2>  <h2><font color="#ff0000">The password for $user was not changed</font></h2>
 There was an internal error when attempting to change your password.  Please make sure your old password was entered correctly.
 Please contact your instructor or the domain coordinator.  
 ENDERROR  ENDERROR
     }      }
     return;      return;
Line 317  ENDERROR Line 368  ENDERROR
 #            other handler subroutines               #  #            other handler subroutines               #
 ######################################################  ######################################################
   
   
 ################################################################  ################################################################
 #                          Main handler                        #  #                          Main handler                        #
 ################################################################  ################################################################
Line 330  sub handler { Line 380  sub handler {
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
     # Spit out the header      #
     if ($ENV{'form.action'} eq 'changepass') {      if ($ENV{'form.action'} eq 'changepass') {
  &passwordchanger($r);   &passwordchanger($r);
     } elsif ($ENV{'form.action'} eq 'verify_and_change_pass') {      } elsif ($ENV{'form.action'} eq 'verify_and_change_pass') {
  &verify_and_change_password($r);   &verify_and_change_password($r);
       } elsif ($ENV{'form.action'} eq 'changescreenname') {
           &screennamechanger($r);
       } elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') {
           &verify_and_change_screenname($r);
     } else {      } else {
  $r->print(<<ENDHEADER);   $r->print(<<ENDHEADER);
 <html>  <html>
 <head>  <head>
 <title>LON-CAPA Preferences</title>  <title>LON-CAPA Preferences</title>
 </head>  </head>
 <body bgcolor="#FFFFFF" >  
 <h1>Preferences for $user</h1>  
 <h3>$user is a member of domain $domain</h3>  
 ENDHEADER  ENDHEADER
           $r->print(&Apache::loncommon::bodytag('Change Your Preferences'));
  # Determine current authentication method   # Determine current authentication method
  my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);   my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
  if ($currentauth =~ /^(unix|internal):/) {   if ($currentauth =~ /^(unix|internal):/) {
Line 354  ENDHEADER Line 406  ENDHEADER
 <input type="submit" value="Change password">  <input type="submit" value="Change password">
 </form>  </form>
 ENDPASSWORDFORM  ENDPASSWORDFORM
   # Change screen name
       $r->print(<<ENDSCREENNAMEFORM);
   <form name="client" action="/adm/preferences" method="post">
   <input type="hidden" name="action" value="changescreenname">
   <input type="submit" value="Change anonymous discussion screen name">
   </form>
   ENDSCREENNAMEFORM
   # The "about me" page
               my $aboutmeaction=
           '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
       $r->print(<<ENDABOUTME);
   <form name="client" action="$aboutmeaction" method="post">
   <input type="hidden" name="action" value="changescreenname">
   <input type="submit" value="Edit the 'About Me' Personal Information Screen">
   </form>
   ENDABOUTME
             # Other preference setting code should be added here              # Other preference setting code should be added here
  }   }
     }      }

Removed from v.1.4  
changed lines
  Added in v.1.11


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