Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
2 |
# This script lets the users change the passwords by themselves. |
3 |
# |
4 |
# (c) 2005 Universidad ORT Uruguay. |
5 |
# |
6 |
# This file is part of the extensions and enhacments made to koha by Universidad ORT Uruguay |
7 |
# |
8 |
# Koha is free software; you can redistribute it and/or modify it under the |
9 |
# terms of the GNU General Public License as published by the Free Software |
10 |
# Foundation; either version 2 of the License, or (at your option) any later |
11 |
# version. |
12 |
# |
13 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
14 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
15 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License along |
18 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
19 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
21 |
use strict; |
22 |
use warnings; |
23 |
|
24 |
use CGI; |
25 |
|
26 |
use C4::Auth; # checkauth, getborrowernumber. |
27 |
use C4::Context; |
28 |
use Digest::MD5 qw(md5_base64); |
29 |
use C4::Circulation; |
30 |
use C4::Members; |
31 |
use C4::Output; |
32 |
use C4::GnuPG; |
33 |
|
34 |
my $query = new CGI; |
35 |
my $dbh = C4::Context->dbh; |
36 |
|
37 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
38 |
{ |
39 |
template_name => "opac-gnupg.tt", |
40 |
query => $query, |
41 |
type => "opac", |
42 |
authnotrequired => 0, |
43 |
flagsrequired => { borrow => 1 }, |
44 |
debug => 1, |
45 |
} |
46 |
); |
47 |
|
48 |
# get borrower information .... |
49 |
my ( $borr ) = GetMemberDetails( $borrowernumber ); |
50 |
my $patronemail = $borr->{'email'}; |
51 |
# save key if key received |
52 |
if ( $query->param('PublicKey') ) { |
53 |
C4::GnuPG->add_key($query->param('PublicKey'), $patronemail); |
54 |
# $template->param( 'addedkey' => $query->param('PublicKey') ); |
55 |
# $template->param( 'added' => '1' ); |
56 |
} |
57 |
elsif ( $query->param('DeleteKey') ) { |
58 |
C4::GnuPG->del_key($patronemail); |
59 |
} |
60 |
if ( C4::GnuPG->does_exist($patronemail) ) { |
61 |
# TODO: display public key if present |
62 |
my $keythingy = C4::GnuPG->get_key($patronemail); |
63 |
$template->param( 'does_exist' => '1' ); |
64 |
$template->param( 'keythingy' => $keythingy ); |
65 |
} |
66 |
# ask for key |
67 |
#$template->param( 'Ask_data' => '1' ); |
68 |
#$template->param( 'Error_messages' => '1' ); |
69 |
|
70 |
my $gnupgbinary = '/usr/bin/gpg'; |
71 |
if (-e $gnupgbinary) { |
72 |
$template->param( 'gpgbinary' => '1' ); |
73 |
} |
74 |
|
75 |
$template->param( |
76 |
firstname => $borr->{'firstname'}, |
77 |
surname => $borr->{'surname'}, |
78 |
patronemail => $patronemail, |
79 |
gnupgview => 1, |
80 |
); |
81 |
|
82 |
output_html_with_http_headers $query, $cookie, $template->output; |