[system] / trunk / webwork2 / lib / WeBWorK / ContentGenerator / Options.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Options.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 667 Revision 720
24 my $r = $self->{r}; 24 my $r = $self->{r};
25 my $ce = $self->{courseEnvironment}; 25 my $ce = $self->{courseEnvironment};
26 26
27 $self->{cldb} = WeBWorK::DB::Classlist->new($ce); 27 $self->{cldb} = WeBWorK::DB::Classlist->new($ce);
28 $self->{authdb} = WeBWorK::DB::Auth->new($ce); 28 $self->{authdb} = WeBWorK::DB::Auth->new($ce);
29 $self->{user} = $self->{cldb}->getUser($r->param('user')); 29 $self->{effectiveUser} = $self->{cldb}->getUser($r->param('effectiveUser'));
30} 30}
31 31
32sub path { 32sub path {
33 my ($self, $args) = @_; 33 my ($self, $args) = @_;
34 34
43} 43}
44 44
45sub title { 45sub title {
46 my $self = shift; 46 my $self = shift;
47 47
48 return "User Options for " . $self->{user}->first_name 48 return "User Options for " . $self->{effectiveUser}->first_name
49 . " " . $self->{user}->last_name; 49 . " " . $self->{effectiveUser}->last_name;
50} 50}
51 51
52sub body { 52sub body {
53 my $self = shift; 53 my $self = shift;
54 my $r = $self->{r}; 54 my $r = $self->{r};
55 my $user = $self->{user}; 55 my $effectiveUser = $self->{effectiveUser};
56 56
57 my $changeOptions = $r->param("changeOptions"); 57 my $changeOptions = $r->param("changeOptions");
58 my $newP = $r->param("newPassword"); 58 my $newP = $r->param("newPassword");
59 my $confirmP = $r->param("confirmPassword"); 59 my $confirmP = $r->param("confirmPassword");
60 my $newA = $r->param("newAddress"); 60 my $newA = $r->param("newAddress");
65 print CGI::h2("Change Password"); 65 print CGI::h2("Change Password");
66 if ($changeOptions) { 66 if ($changeOptions) {
67 if ($newP or $confirmP) { 67 if ($newP or $confirmP) {
68 if ($newP eq $confirmP) { 68 if ($newP eq $confirmP) {
69 # possibly do some format checking? 69 # possibly do some format checking?
70 eval { $self->{authdb}->setPassword($user->id, $newP) }; 70 eval { $self->{authdb}->setPassword($effectiveUser->id, $newP) };
71 if ($@) { 71 if ($@) {
72 print CGI::p("Couldn't change your 72 print CGI::p("Couldn't change your
73 password: $@"); 73 password: $@");
74 } else { 74 } else {
75 print CGI::p("Your password has been 75 print CGI::p("Your password has been
96 print CGI::h2("Change Email Address"); 96 print CGI::h2("Change Email Address");
97 if ($changeOptions) { 97 if ($changeOptions) {
98 if ($newA or $confirmA) { 98 if ($newA or $confirmA) {
99 if ($newA eq $confirmA) { 99 if ($newA eq $confirmA) {
100 # possibly do some format checking? 100 # possibly do some format checking?
101 my $oldA = $user->email_address; 101 my $oldA = $effectiveUser->email_address;
102 $user->email_address($newA); 102 $effectiveUser->email_address($newA);
103 eval { $self->{cldb}->setUser($user) }; 103 eval { $self->{cldb}->setUser($effectiveUser) };
104 if ($@) { 104 if ($@) {
105 $user->email_address($oldA); 105 $effectiveUser->email_address($oldA);
106 print CGI::p("Couldn't change your 106 print CGI::p("Couldn't change your
107 email address: $@"); 107 email address: $@");
108 } else { 108 } else {
109 print CGI::p("Your email address has 109 print CGI::p("Your email address has
110 been changed."); 110 been changed.");
119 } 119 }
120 } 120 }
121 print CGI::table( 121 print CGI::table(
122 CGI::Tr( 122 CGI::Tr(
123 CGI::td("Current Address"), 123 CGI::td("Current Address"),
124 CGI::td($user->email_address), 124 CGI::td($effectiveUser->email_address),
125 ), 125 ),
126 CGI::Tr( 126 CGI::Tr(
127 CGI::td("New Address"), 127 CGI::td("New Address"),
128 CGI::td(CGI::textfield("newAddress", $newA)), 128 CGI::td(CGI::textfield("newAddress", $newA)),
129 ), 129 ),

Legend:
Removed from v.667  
changed lines
  Added in v.720

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9