Bugzilla – Attachment 38518 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: Capture picture from web cam
Bug-6815-Capture-picture-from-web-cam.patch (text/plain), 6.41 KB, created by
Mark Tompsett
on 2015-04-26 00:11:56 UTC
(
hide
)
Description:
Bug 6815: Capture picture from web cam
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-04-26 00:11:56 UTC
Size:
6.41 KB
patch
obsolete
>From 7f19f8fe54b0f663f1786c425c22ad563934fb1a Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Sat, 25 Apr 2015 19:41:12 -0400 >Subject: [PATCH] Bug 6815: Capture picture from web cam > >This enhancement gives the librarian the ability to capture >a photo from a webcam attached to the Koha server. > >It does this by adding a 'Capture' button to the member details >page. This button is only visible if there is likely a webcam. >This is determined by if /dev/video{something} exists. > >This also corrects the functionality of the delete button, which >is broken, because borrowernumber and cardnumber got mixed up. > >This requires the package streamer be installed: > $ sudo apt-get install streamer >Additionally, I had to add www-data to the video group. > $ sudo addgroup www-data video > >TEST PLAN >--------- > 1) Back up DB. > 2) Have a picture file available for uploading. > 3) Find a particular patron > 4) Upload the picture file on hand. > -- should work fine. > 5) Delete the patron picture. > -- fails. > 6) Apply patch. > 7) Delete the patron picture. > -- success > 8) Upload the patron picture again. > -- success > 9) Check for Capture button. > a) plug in it and refresh page > -- capture button should be there. > b) unplug it and refresh page > -- capture button should not be there. > c) plug it back in and refresh >10) Make a strange face, hold it, and click 'Capture' > -- a few seconds later the page should refresh > with your face. >11) Restore DB >12) run koha qa test tools. >--- > .../prog/en/modules/members/moremember.tt | 6 +++--- > members/moremember.pl | 13 +++++++++++- > tools/picture-upload.pl | 24 ++++++++++++++++------ > 3 files changed, 33 insertions(+), 10 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 9536a22..be49b97 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -271,9 +271,9 @@ function validate1(date) { > </li> > </ol> > <fieldset class="action"> >- <input type="submit" value="Upload" class="submit" /> >- <input name="op" type="hidden" value="Upload" /> >- [% IF ( picture ) %]<a id="delpicture" href="/cgi-bin/koha/tools/picture-upload.pl?op=Delete&cardnumber=[% cardnumber %]&borrowernumber=[% borrowernumber %]" class="delete">Delete</a>[% END %] >+ <input type="submit" name="op" id="op" value="Upload" class="submit btn" /> >+ [% IF ( webcam ) %]<input type="submit" name="op" id="op" value="Capture" class="submit btn" /> [% END %] >+ [% IF ( picture ) %]<a id="delpicture" href="/cgi-bin/koha/tools/picture-upload.pl?op=Delete&cardnumber=[% cardnumber %]&borrowernumber=[% borrowernumber %]" class="delete btn">Delete</a>[% END %] > </fieldset> > </fieldset> > </form> >diff --git a/members/moremember.pl b/members/moremember.pl >index a0024cb..8606108 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -50,7 +50,7 @@ use C4::Letters; > use C4::Biblio; > use C4::Branch; # GetBranchName > use C4::Form::MessagingPreferences; >-use List::MoreUtils qw/uniq/; >+use List::MoreUtils qw/uniq none/; > use C4::Members::Attributes qw(GetBorrowerAttributes); > use Koha::Borrower::Debarments qw(GetDebarments IsDebarred); > use Module::Load; >@@ -113,6 +113,17 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > ); > my $borrowernumber = $input->param('borrowernumber'); > >+# Look for something that might be a webcam. >+opendir DIR, "/dev" or die "cannot determine devices on system: $!"; >+my @devices = readdir DIR; >+close DIR; >+if (none { $_ =~ /video/ } @devices) { >+ $template->param( webcam => 0 ); >+} >+else { >+ $template->param( webcam => 1 ); >+} >+ > my ( $od, $issue, $fines ) = GetMemberIssuesAndFines($borrowernumber); > $template->param( issuecount => $issue ); > >diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl >index 3ae4f62..22e9178 100755 >--- a/tools/picture-upload.pl >+++ b/tools/picture-upload.pl >@@ -75,13 +75,17 @@ $debug and warn "Operation requested: $op"; > my ( $total, $handled, @counts, $tempfile, $tfh, %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) || >+ ( $op eq 'Capture' ) ) { > my $dirname = File::Temp::tempdir( CLEANUP => 1 ); > $debug and warn "dirname = $dirname"; > my $filesuffix; > if ( $uploadfilename =~ m/(\..+)$/i ) { > $filesuffix = $1; > } >+ if ( $op eq 'Capture' ) { >+ $filesuffix = '.jpeg'; >+ } > ( $tfh, $tempfile ) = > File::Temp::tempfile( SUFFIX => $filesuffix, UNLINK => 1 ); > $debug and warn "tempfile = $tempfile"; >@@ -90,17 +94,25 @@ if ( ( $op eq 'Upload' ) && $uploadfile ) { > $errors{'NOTZIP'} = 1 > if ( $uploadfilename !~ /\.zip$/i && $filetype =~ m/zip/i ); > $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname ); >- $errors{'EMPTYUPLOAD'} = 1 unless ( length($uploadfile) > 0 ); >+ $errors{'EMPTYUPLOAD'} = 1 unless ( >+ (defined($uploadfile) && length($uploadfile) > 0) || >+ $op eq 'Capture' ); > > if (%errors) { > $template->param( ERRORS => [ \%errors ] ); > output_html_with_http_headers $input, $cookie, $template->output; > exit; > } >- while (<$uploadfile>) { >- print $tfh $_; >+ if ( $op eq 'Upload' ) { >+ while (<$uploadfile>) { >+ print $tfh $_; >+ } >+ close $tfh; >+ } >+ elsif ( $op eq 'Capture' ) { >+ close $tfh; >+ system('/usr/bin/streamer -o ' . $tempfile); > } >- close $tfh; > if ( $filetype eq 'zip' ) { > unless ( system( "unzip", $tempfile, '-d', $dirname ) == 0 ) { > $errors{'UZIPFAIL'} = $uploadfilename; >@@ -157,7 +169,7 @@ elsif ( ( $op eq 'Upload' ) && !$uploadfile ) { > $template->param( filetype => $filetype ); > } > elsif ( $op eq 'Delete' ) { >- my $dberror = RmPatronImage($cardnumber); >+ my $dberror = RmPatronImage($borrowernumber); > $debug and warn "Patron image deleted for $cardnumber"; > warn "Database returned $dberror" if $dberror; > } >-- >1.9.1
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