Lines 22-27
use Modern::Perl;
Link Here
|
22 |
use base qw( Template::Plugin ); |
22 |
use base qw( Template::Plugin ); |
23 |
|
23 |
|
24 |
use C4::Context; |
24 |
use C4::Context; |
|
|
25 |
use Koha::Token; |
25 |
use Koha; |
26 |
use Koha; |
26 |
|
27 |
|
27 |
=head1 NAME |
28 |
=head1 NAME |
Lines 48-55
is necessary.
Link Here
|
48 |
|
49 |
|
49 |
=head2 Class Methods |
50 |
=head2 Class Methods |
50 |
|
51 |
|
|
|
52 |
=head3 new |
53 |
|
54 |
This new method allows us to store the context which gives us |
55 |
access to the template vars already set. In particular this gives |
56 |
us access to the template vars set by C4::Auth::get_template_and_user |
57 |
|
51 |
=cut |
58 |
=cut |
52 |
|
59 |
|
|
|
60 |
sub new { |
61 |
my ( $class, $context ) = @_; |
62 |
bless { |
63 |
_CONTEXT => $context, |
64 |
}, $class; |
65 |
} |
66 |
|
67 |
|
53 |
sub Preference { |
68 |
sub Preference { |
54 |
my ( $self, $pref ) = @_; |
69 |
my ( $self, $pref ) = @_; |
55 |
return C4::Context->preference( $pref ); |
70 |
return C4::Context->preference( $pref ); |
Lines 84-87
sub Version {
Link Here
|
84 |
}; |
99 |
}; |
85 |
} |
100 |
} |
86 |
|
101 |
|
|
|
102 |
=head3 GenerateCSRF |
103 |
|
104 |
Generate a new CSRF token. |
105 |
|
106 |
=cut |
107 |
|
108 |
sub GenerateCSRF { |
109 |
my ( $self ) = @_; |
110 |
my $session_id = $self->{_CONTEXT}->stash->{sessionID}; |
111 |
return Koha::Token->new->generate_csrf({ session_id => scalar $session_id }); |
112 |
} |
113 |
|
87 |
1; |
114 |
1; |