View | Details | Raw Unified | Return to bug 6815
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (-1 / +1 lines)
Lines 167-173 Link Here
167
                <input id="webcam_op" name="op" type="hidden" value="Upload" />
167
                <input id="webcam_op" name="op" type="hidden" value="Upload" />
168
            </form>
168
            </form>
169
            <div class="modal-footer">
169
            <div class="modal-footer">
170
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
170
                <button id="cancel_capture" type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
171
            </div>
171
            </div>
172
        </div>
172
        </div>
173
    </div>
173
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js (-3 / +3 lines)
Lines 54-60 function initializeCamera( camera_form ){ Link Here
54
        var download_anchor = document.getElementById('download');
54
        var download_anchor = document.getElementById('download');
55
        download_anchor.href = canvas.toDataURL('image/jpeg');
55
        download_anchor.href = canvas.toDataURL('image/jpeg');
56
        download_anchor.download = "patron-photo.jpg";
56
        download_anchor.download = "patron-photo.jpg";
57
        download_anchor.click();
58
        // gather form data for AJAX POST
57
        // gather form data for AJAX POST
59
        var data = new FormData();
58
        var data = new FormData();
60
        data.append("uploadfiletext", download_anchor.href );
59
        data.append("uploadfiletext", download_anchor.href );
Lines 72-78 function initializeCamera( camera_form ){ Link Here
72
            contentType: false,
71
            contentType: false,
73
            processData: false
72
            processData: false
74
        }).done(function() {
73
        }).done(function() {
75
74
            var cancel_button = document.getElementById('cancel_capture');
75
            cancel_button.click();
76
        });
76
        });
77
    });
77
    });
78
}
78
}
Lines 110-113 $(document).ready(function(){ Link Here
110
            });
110
            });
111
    });
111
    });
112
112
113
})
113
})
(-)a/tools/picture-upload.pl (-16 / +35 lines)
Lines 25-30 use File::Temp; Link Here
25
use File::Copy;
25
use File::Copy;
26
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
27
use GD;
27
use GD;
28
use MIME::Base64;
28
use C4::Context;
29
use C4::Context;
29
use C4::Auth;
30
use C4::Auth;
30
use C4::Output;
31
use C4::Output;
Lines 43-60 unless (C4::Context->preference('patronimages')) { Link Here
43
    exit;
44
    exit;
44
}
45
}
45
46
46
my ($template, $loggedinuser, $cookie)
47
my ($template, $loggedinuser, $cookie) = get_template_and_user(
47
    = get_template_and_user({template_name => "tools/picture-upload.tt",
48
    {
48
					query => $input,
49
        template_name => "tools/picture-upload.tt",
49
					type => "intranet",
50
        query => $input,
50
					authnotrequired => 0,
51
        type => "intranet",
51
					flagsrequired => { tools => 'batch_upload_patron_images'},
52
        authnotrequired => 0,
52
					debug => 0,
53
        flagsrequired => { tools => 'batch_upload_patron_images'},
53
					});
54
        debug => 0,
55
    }
56
);
54
57
55
our $filetype      = $input->param('filetype') || '';
58
our $filetype      = $input->param('filetype') || '';
56
my $cardnumber     = $input->param('cardnumber');
59
my $cardnumber     = $input->param('cardnumber');
57
our $uploadfilename = $input->param('uploadfile') || '';
60
our $uploadfilename = $input->param('uploadfile') || $input->param('uploadfilename') || '';
61
my $uploadfiletext = $input->param('uploadfiletext') || '';
58
my $uploadfile     = $input->upload('uploadfile');
62
my $uploadfile     = $input->upload('uploadfile');
59
my $borrowernumber = $input->param('borrowernumber');
63
my $borrowernumber = $input->param('borrowernumber');
60
my $op             = $input->param('op') || '';
64
my $op             = $input->param('op') || '';
Lines 87-93 our @counts = (); Link Here
87
our %errors = ();
91
our %errors = ();
88
92
89
# Case is important in these operational values as the template must use case to be visually pleasing!
93
# Case is important in these operational values as the template must use case to be visually pleasing!
90
if ( ( $op eq 'Upload' ) && $uploadfile ) {
94
if ( ( $op eq 'Upload' ) && ($uploadfile || $uploadfiletext) ) {
91
95
92
    output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )
96
    output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )
93
        unless Koha::Token->new->check_csrf({
97
        unless Koha::Token->new->check_csrf({
Lines 106-123 if ( ( $op eq 'Upload' ) && $uploadfile ) { Link Here
106
    $debug and warn "tempfile = $tempfile";
110
    $debug and warn "tempfile = $tempfile";
107
    my ( @directories, $results );
111
    my ( @directories, $results );
108
112
109
    $errors{'NOTZIP'} = 1
110
      if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i );
111
    $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname );
113
    $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname );
112
    $errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 );
114
    if ( length($uploadfiletext) == 0 ) {
115
        $errors{'NOTZIP'} = 1
116
          if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i );
117
        $errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 );
118
    }
113
119
114
    if (%errors) {
120
    if (%errors) {
115
        $template->param( ERRORS => [ \%errors ] );
121
        $template->param( ERRORS => [ \%errors ] );
116
        output_html_with_http_headers $input, $cookie, $template->output;
122
        output_html_with_http_headers $input, $cookie, $template->output;
117
        exit;
123
        exit;
118
    }
124
    }
119
    while (<$uploadfile>) {
125
120
        print $tfh $_;
126
    if ( length($uploadfiletext) == 0 ) {
127
        while (<$uploadfile>) {
128
            print $tfh $_;
129
        }
130
    } else {
131
        if ( $uploadfiletext =~ /data:image\/jpeg;base64,(.*)/ ) {
132
            my $encoded_picture = $1;
133
            my $decoded_picture = decode_base64($encoded_picture);
134
            print $tfh $decoded_picture;
135
        } else {
136
            $errors{'BADPICTUREDATA'} = 1;
137
            $template->param( ERRORS => [ \%errors ] );
138
            output_html_with_http_headers $input, $cookie, $template->output;
139
            exit;
140
        }
121
    }
141
    }
122
    close $tfh;
142
    close $tfh;
123
    if ( $filetype eq 'zip' ) {
143
    if ( $filetype eq 'zip' ) {
124
- 

Return to bug 6815