Parent Directory
|
Revision Log
Added missing \ for apostrophes after user name.
1 ################################################################################ 2 # WeBWorK Online Homework Delivery System 3 # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 4 # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Options.pm,v 1.17 2004/09/10 21:03:57 sh002i Exp $ 5 # 6 # This program is free software; you can redistribute it and/or modify it under 7 # the terms of either: (a) the GNU General Public License as published by the 8 # Free Software Foundation; either version 2, or (at your option) any later 9 # version, or (b) the "Artistic License" which comes with this package. 10 # 11 # This program is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the 14 # Artistic License for more details. 15 ################################################################################ 16 17 package WeBWorK::ContentGenerator::Options; 18 use base qw(WeBWorK::ContentGenerator); 19 20 =head1 NAME 21 22 WeBWorK::ContentGenerator::Options - Change user options. 23 24 =cut 25 26 use strict; 27 use warnings; 28 use CGI qw(); 29 use WeBWorK::Utils qw(cryptPassword dequote); 30 31 sub body { 32 my ($self) = @_; 33 my $r = $self->r; 34 my $db = $r->db; 35 my $authz = $r->authz; 36 37 my $userID = $r->param("user"); 38 my $User = $db->getUser($userID); 39 die "record not found for user '$userID'." unless defined $User; 40 41 my $eUserID = $r->param('effectiveUser'); 42 my $EUser = $db->getUser($eUserID); # checked 43 die "record not found for effective user '$eUserID'." unless defined $EUser; 44 45 my $changeOptions = $r->param("changeOptions"); 46 my $currP = $r->param("currPassword"); 47 my $newP = $r->param("newPassword"); 48 my $confirmP = $r->param("confirmPassword"); 49 my $newA = $r->param("newAddress"); 50 51 print CGI::start_form(-method=>"POST", -action=>$r->uri); 52 print $self->hidden_authen_fields; 53 54 print CGI::h2("Change Password"); 55 56 my $user_name = $User->first_name . " " . $User->last_name; 57 my $e_user_name = $EUser->first_name . " " . $EUser->last_name; 58 59 if ($changeOptions and ($currP or $newP or $confirmP)) { 60 61 my $Password = eval {$db->getPassword($User->user_id)}; # checked 62 warn "Can't get password record for user '$userID': $@" if $@ or not defined $Password; 63 64 my $EPassword = eval {$db->getPassword($EUser->user_id)}; # checked 65 warn "Can't get password record for effective user '$eUserID': $@" if $@ or not defined $EPassword; 66 67 if (crypt($currP, $Password->password) eq $Password->password) { 68 if ($newP or $confirmP) { 69 if ($newP eq $confirmP) { 70 $EPassword->password(cryptPassword($newP)); 71 eval { $db->putPassword($EPassword) }; 72 if ($@) { 73 print CGI::div({class=>"ResultsWithError"}, 74 CGI::p("Couldn't change $e_user_name\'s password: $@"), 75 ); 76 } else { 77 print CGI::div({class=>"ResultsWithoutError"}, 78 CGI::p("$e_user_name\'s password has been changed."), 79 ); 80 } 81 } else { 82 print CGI::div({class=>"ResultsWithError"}, 83 CGI::p( 84 "The passwords you entered in the ", 85 CGI::b("$e_user_name\'s New Password"), " and ", 86 CGI::b("Confirm $e_user_name\'s New Password"), " fields 87 don't match. Please retype your new password and try 88 again." 89 ), 90 ); 91 } 92 } else { 93 print CGI::div({class=>"ResultsWithError"}, 94 CGI::p("$e_user_name\'s new password cannot be blank."), 95 ); 96 } 97 } else { 98 print CGI::div({class=>"ResultsWithError"}, 99 CGI::p( 100 "The password you entered in the ", CGI::b("$user_name\'s 101 Current Password"), " field does not match your current 102 password. Please retype your current password and try 103 again." 104 ), 105 ); 106 } 107 } 108 109 print CGI::table({class=>"FormLayout"}, 110 CGI::Tr( 111 CGI::td("$user_name\'s Current Password"), 112 CGI::td(CGI::password_field("currPassword")), 113 ), 114 CGI::Tr( 115 CGI::td("$e_user_name\'s New Password"), 116 CGI::td(CGI::password_field("newPassword")), 117 ), 118 CGI::Tr( 119 CGI::td("Confirm $e_user_name\'s New Password"), 120 CGI::td(CGI::password_field("confirmPassword")), 121 ), 122 ); 123 124 print CGI::h2("Change Email Address"); 125 126 if ($changeOptions) { 127 if ($newA) { 128 my $oldA = $EUser->email_address; 129 $EUser->email_address($newA); 130 eval { $db->putUser($EUser) }; 131 if ($@) { 132 $EUser->email_address($oldA); 133 print CGI::div({class=>"ResultsWithError"}, 134 CGI::p("Couldn't change your email address: $@"), 135 ); 136 } else { 137 print CGI::div({class=>"ResultsWithoutError"}, 138 CGI::p("Your email address has been changed."), 139 ); 140 } 141 } 142 } 143 144 print CGI::table({class=>"FormLayout"}, 145 CGI::Tr( 146 CGI::td("$e_user_name\'s Current Address"), 147 CGI::td($EUser->email_address), 148 ), 149 CGI::Tr( 150 CGI::td("$e_user_name\'s New Address"), 151 CGI::td(CGI::textfield("newAddress", $newA)), 152 ), 153 ); 154 155 print CGI::br(); 156 print CGI::submit("changeOptions", "Change User Options"); 157 print CGI::end_form(); 158 159 return ""; 160 } 161 162 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |