| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK.pm,v 1.57 2004/06/17 20:10:18 sh002i Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK.pm,v 1.58 2004/06/23 00:37:41 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
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 |
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 |
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. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 187 | $r->param($u->name => "$id $hash"); |
187 | $r->param($u->name => "$id $hash"); |
| 188 | } |
188 | } |
| 189 | |
189 | |
| 190 | my ($db, $authz); |
190 | my ($db, $authz); |
| 191 | |
191 | |
| 192 | if ($displayArgs{courseID}) { |
192 | if ($displayArgs{courseID} and not $ce->{'!'}) { |
| 193 | debug("We got a courseID from the URLPath, now we can do some stuff:\n"); |
193 | debug("We got a courseID from the URLPath, now we can do some stuff:\n"); |
| 194 | debug("...we can create a database object...\n"); |
194 | debug("...we can create a database object...\n"); |
| 195 | $db = new WeBWorK::DB($ce->{dbLayout}); |
195 | $db = new WeBWorK::DB($ce->{dbLayout}); |
| 196 | debug("(here's the DB handle: $db)\n"); |
196 | debug("(here's the DB handle: $db)\n"); |
| 197 | $r->db($db); |
197 | $r->db($db); |
| … | |
… | |
| 222 | my $userID = $r->param("user"); |
222 | my $userID = $r->param("user"); |
| 223 | my $eUserID = $r->param("effectiveUser") || $userID; |
223 | my $eUserID = $r->param("effectiveUser") || $userID; |
| 224 | debug("userID=$userID eUserID=$eUserID\n"); |
224 | debug("userID=$userID eUserID=$eUserID\n"); |
| 225 | my $su_authorized = $authz->hasPermissions($userID, "become_student", $eUserID); |
225 | my $su_authorized = $authz->hasPermissions($userID, "become_student", $eUserID); |
| 226 | if ($su_authorized) { |
226 | if ($su_authorized) { |
| 227 | debug("Ok, looks like you're is allowed to become $eUserID. Whoopie!\n"); |
227 | debug("Ok, looks like you're allowed to become $eUserID. Whoopie!\n"); |
| 228 | } else { |
228 | } else { |
| 229 | debug("Uh oh, you're isn't allowed to become $eUserID. Nice try!\n"); |
229 | debug("Uh oh, you're not allowed to become $eUserID. Nice try!\n"); |
| 230 | $eUserID = $userID; |
230 | $eUserID = $userID; |
| 231 | } |
231 | } |
| 232 | $r->param("effectiveUser" => $eUserID); |
232 | $r->param("effectiveUser" => $eUserID); |
| 233 | } else { |
233 | } else { |
| 234 | debug("Bad news: authentication failed!\n"); |
234 | debug("Bad news: authentication failed!\n"); |
| 235 | $displayModule = AUTHEN_MODULE; |
235 | $displayModule = AUTHEN_MODULE; |
| 236 | debug("set displayModule to $displayModule\n"); |
236 | debug("set displayModule to $displayModule\n"); |
| 237 | } |
237 | } |
|
|
238 | } |
|
|
239 | |
|
|
240 | # if a course ID was given in the URL and resulted in an error (as stored in $!) |
|
|
241 | # it probably means that the course does not exist or was misspelled |
|
|
242 | if ($displayArgs{courseID} and $ce->{'!'}) { |
|
|
243 | debug("Something was wrong with the courseID: \n"); |
|
|
244 | debug("\t\t" . $ce->{'!'} . "\n"); |
|
|
245 | debug("Time to bail!\n"); |
|
|
246 | return DECLINED; |
| 238 | } |
247 | } |
| 239 | |
248 | |
| 240 | debug(("-" x 80) . "\n"); |
249 | debug(("-" x 80) . "\n"); |
| 241 | debug("Finally, we'll load the display module...\n"); |
250 | debug("Finally, we'll load the display module...\n"); |
| 242 | |
251 | |