Bugzilla – Attachment 106790 Details for
Bug 6815
Capture member photo via webcam
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6815: Actually push the taken picture to the DB
Bug-6815-Actually-push-the-taken-picture-to-the-DB.patch (text/plain), 5.66 KB, created by
Christopher Brannon
on 2020-07-12 00:34:44 UTC
(
hide
)
Description:
Bug 6815: Actually push the taken picture to the DB
Filename:
MIME Type:
Creator:
Christopher Brannon
Created:
2020-07-12 00:34:44 UTC
Size:
5.66 KB
patch
obsolete
>From c00fc958b7613021ef843e1a9a725ca4d5762b3d Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Fri, 10 Jul 2020 18:21:37 +0000 >Subject: [PATCH] Bug 6815: Actually push the taken picture to the DB > >Tweak circ-menu, so we can close the modal. >Tweak patron-webcam so it does the push. >Tweak picture-upload, so it decodes rather than tries to receive > the picture. >--- > .../intranet-tmpl/prog/en/includes/circ-menu.inc | 2 +- > .../intranet-tmpl/prog/js/pages/patron-webcam.js | 6 +-- > tools/picture-upload.pl | 50 +++++++++++++++------- > 3 files changed, 39 insertions(+), 19 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc >index 790fae6836..a97085f81a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc >@@ -167,7 +167,7 @@ > <input id="webcam_op" name="op" type="hidden" value="Upload" /> > </form> > <div class="modal-footer"> >- <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> >+ <button id="cancel_capture" type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> > </div> > </div> > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js b/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js >index 3677b84abe..25813020ad 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js >@@ -54,7 +54,6 @@ function initializeCamera( camera_form ){ > var download_anchor = document.getElementById('download'); > download_anchor.href = canvas.toDataURL('image/jpeg'); > download_anchor.download = "patron-photo.jpg"; >- download_anchor.click(); > // gather form data for AJAX POST > var data = new FormData(); > data.append("uploadfiletext", download_anchor.href ); >@@ -72,7 +71,8 @@ function initializeCamera( camera_form ){ > contentType: false, > processData: false > }).done(function() { >- >+ var cancel_button = document.getElementById('cancel_capture'); >+ cancel_button.click(); > }); > }); > } >@@ -110,4 +110,4 @@ $(document).ready(function(){ > }); > }); > >-}) >\ No newline at end of file >+}) >diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl >index c114a86a32..1908d63e24 100755 >--- a/tools/picture-upload.pl >+++ b/tools/picture-upload.pl >@@ -25,6 +25,7 @@ use File::Temp; > use File::Copy; > use CGI qw ( -utf8 ); > use GD; >+use MIME::Base64; > use C4::Context; > use C4::Auth; > use C4::Output; >@@ -43,18 +44,21 @@ unless (C4::Context->preference('patronimages')) { > exit; > } > >-my ($template, $loggedinuser, $cookie) >- = get_template_and_user({template_name => "tools/picture-upload.tt", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => { tools => 'batch_upload_patron_images'}, >- debug => 0, >- }); >+my ($template, $loggedinuser, $cookie) = get_template_and_user( >+ { >+ template_name => "tools/picture-upload.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => 'batch_upload_patron_images'}, >+ debug => 0, >+ } >+); > > our $filetype = $input->param('filetype') || ''; > my $cardnumber = $input->param('cardnumber'); >-our $uploadfilename = $input->param('uploadfile') || ''; >+our $uploadfilename = $input->param('uploadfile') || $input->param('uploadfilename') || ''; >+my $uploadfiletext = $input->param('uploadfiletext') || ''; > my $uploadfile = $input->upload('uploadfile'); > my $borrowernumber = $input->param('borrowernumber'); > my $op = $input->param('op') || ''; >@@ -87,7 +91,7 @@ our @counts = (); > our %errors = (); > > # Case is important in these operational values as the template must use case to be visually pleasing! >-if ( ( $op eq 'Upload' ) && $uploadfile ) { >+if ( ( $op eq 'Upload' ) && ($uploadfile || $uploadfiletext) ) { > > output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) > unless Koha::Token->new->check_csrf({ >@@ -106,18 +110,34 @@ if ( ( $op eq 'Upload' ) && $uploadfile ) { > $debug and warn "tempfile = $tempfile"; > my ( @directories, $results ); > >- $errors{'NOTZIP'} = 1 >- if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i ); > $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname ); >- $errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 ); >+ if ( length($uploadfiletext) == 0 ) { >+ $errors{'NOTZIP'} = 1 >+ if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i ); >+ $errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 ); >+ } > > if (%errors) { > $template->param( ERRORS => [ \%errors ] ); > output_html_with_http_headers $input, $cookie, $template->output; > exit; > } >- while (<$uploadfile>) { >- print $tfh $_; >+ >+ if ( length($uploadfiletext) == 0 ) { >+ while (<$uploadfile>) { >+ print $tfh $_; >+ } >+ } else { >+ if ( $uploadfiletext =~ /data:image\/jpeg;base64,(.*)/ ) { >+ my $encoded_picture = $1; >+ my $decoded_picture = decode_base64($encoded_picture); >+ print $tfh $decoded_picture; >+ } else { >+ $errors{'BADPICTUREDATA'} = 1; >+ $template->param( ERRORS => [ \%errors ] ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+ } > } > close $tfh; > if ( $filetype eq 'zip' ) { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6815
:
22623
|
29613
|
38518
|
91302
|
91303
|
91335
|
99015
|
99016
|
99757
|
106774
|
106775
|
106776
|
106777
|
106782
|
106783
|
106787
|
106788
|
106789
|
106790
|
106791
|
106792
|
106793
|
106794
|
106795
|
106796
|
106797
|
106798
|
106799
|
106800
|
106801
|
106802
|
106803
|
106804
|
106938
|
106939
|
106940
|
131174
|
131554
|
131985
|
131987
|
131988
|
131999
|
132000
|
132001