| … | |
… | |
| 16 | use Apache::Constants qw(:common); |
16 | use Apache::Constants qw(:common); |
| 17 | use CGI qw(); |
17 | use CGI qw(); |
| 18 | use URI::Escape; |
18 | use URI::Escape; |
| 19 | use WeBWorK::DB; |
19 | use WeBWorK::DB; |
| 20 | use WeBWorK::Utils qw(readFile); |
20 | use WeBWorK::Utils qw(readFile); |
|
|
21 | use WeBWorK::Authz; |
| 21 | |
22 | |
| 22 | ################################################################################ |
23 | ################################################################################ |
| 23 | # This is a very unruly file, so I'm going to use very large comments to divide |
24 | # This is a very unruly file, so I'm going to use very large comments to divide |
| 24 | # it into logical sections. |
25 | # it into logical sections. |
| 25 | ################################################################################ |
26 | ################################################################################ |
| … | |
… | |
| 38 | my $class = ref($invocant) || $invocant; |
39 | my $class = ref($invocant) || $invocant; |
| 39 | my $self = { |
40 | my $self = { |
| 40 | r => $r, |
41 | r => $r, |
| 41 | ce => $ce, |
42 | ce => $ce, |
| 42 | db => $db, |
43 | db => $db, |
|
|
44 | authz => WeBWorK::Authz->new($r, $ce, $db) |
| 43 | }; |
45 | }; |
| 44 | bless $self, $class; |
46 | bless $self, $class; |
| 45 | return $self; |
47 | return $self; |
| 46 | } |
48 | } |
| 47 | |
49 | |
| … | |
… | |
| 123 | $ifstack[-1] = not $ifstack[-1]; |
125 | $ifstack[-1] = not $ifstack[-1]; |
| 124 | } elsif ($function eq "endif" and @ifstack > 1) { |
126 | } elsif ($function eq "endif" and @ifstack > 1) { |
| 125 | pop @ifstack; |
127 | pop @ifstack; |
| 126 | } elsif ($ifstack[-1]) { |
128 | } elsif ($ifstack[-1]) { |
| 127 | if ($self->can($function)) { |
129 | if ($self->can($function)) { |
| 128 | print $self->$function(@_, {@args}); |
130 | my $result = $self->$function(@_, {@args}); |
|
|
131 | unless (defined $result) { |
|
|
132 | warn "Template escape $function returned an undefined value."; |
|
|
133 | } |
|
|
134 | print $result; |
| 129 | } |
135 | } |
| 130 | } |
136 | } |
| 131 | } |
137 | } |
| 132 | |
138 | |
| 133 | if ($ifstack[-1]) { |
139 | if ($ifstack[-1]) { |
| … | |
… | |
| 456 | CGI::a({-href=>$help}, "Help"). CGI::br(). |
462 | CGI::a({-href=>$help}, "Help"). CGI::br(). |
| 457 | CGI::a({-href=>$logout}, "Log Out"). CGI::br() |
463 | CGI::a({-href=>$logout}, "Log Out"). CGI::br() |
| 458 | ; |
464 | ; |
| 459 | } |
465 | } |
| 460 | |
466 | |
|
|
467 | sub submiterror { |
|
|
468 | warn "submiterror\n"; |
|
|
469 | my ($self) = @_; |
|
|
470 | if (exists $self->{submitError}) { |
|
|
471 | warn "returning ".$self->{submitError}."\n"; |
|
|
472 | return $self->{submitError}; |
|
|
473 | } else { |
|
|
474 | warn "returning \"\"\n"; |
|
|
475 | return ""; |
|
|
476 | } |
|
|
477 | } |
|
|
478 | |
| 461 | # &if_can will return 1 if the current object->can("do $_[1]") |
479 | # &if_can will return 1 if the current object->can("do $_[1]") |
| 462 | sub if_can ($$) { |
480 | sub if_can ($$) { |
| 463 | my ($self, $arg) = (@_); |
481 | my ($self, $arg) = (@_); |
| 464 | |
482 | |
| 465 | if ($self->can("$arg")) { |
483 | if ($self->can("$arg")) { |
| … | |
… | |
| 474 | my ($self, $arg) = (@_); |
492 | my ($self, $arg) = (@_); |
| 475 | |
493 | |
| 476 | return $arg; |
494 | return $arg; |
| 477 | } |
495 | } |
| 478 | |
496 | |
|
|
497 | sub if_submiterror($$) { |
|
|
498 | warn "if_submiterror\n"; |
|
|
499 | my ($self, $arg) = @_; |
|
|
500 | if (exists $self->{submitError}) { |
|
|
501 | warn "returning $arg\n"; |
|
|
502 | return $arg; |
|
|
503 | } else { |
|
|
504 | warn "returning ".!$arg."\n"; |
|
|
505 | return !$arg; |
|
|
506 | } |
|
|
507 | } |
|
|
508 | |
| 479 | 1; |
509 | 1; |
| 480 | |
510 | |
| 481 | __END__ |
511 | __END__ |
| 482 | |
512 | |
| 483 | =head1 AUTHOR |
513 | =head1 AUTHOR |