[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha koha-tmpl/intranet-tmpl/default/en/include... [rel_2_2]
From: |
paul poulain |
Subject: |
[Koha-cvs] koha koha-tmpl/intranet-tmpl/default/en/include... [rel_2_2] |
Date: |
Thu, 10 Aug 2006 12:39:38 +0000 |
CVSROOT: /cvsroot/koha
Module name: koha
Branch: rel_2_2
Changes by: paul poulain <tipaul> 06/08/10 12:39:38
Modified files:
koha-tmpl/intranet-tmpl/default/en/includes: menus.inc
Added files:
import : picture-upload.pl
koha-tmpl/intranet-tmpl/npl/en/import: picture-upload.tmpl
Log message:
adding a member picture upload in parameters section.
this script is a contribution of Michael Hafen, and is marked as
"experimental". However, it seems to work correctly, there may just be some
directory (write permission) problems.
PS : NPL template untested but provided by michael
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/import/picture-upload.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/default/en/includes/menus.inc?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.5&r2=1.1.2.6
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/npl/en/import/picture-upload.tmpl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.2.1
Patches:
Index: koha-tmpl/intranet-tmpl/default/en/includes/menus.inc
===================================================================
RCS file:
/cvsroot/koha/koha/koha-tmpl/intranet-tmpl/default/en/includes/menus.inc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -b -r1.1.2.5 -r1.1.2.6
--- koha-tmpl/intranet-tmpl/default/en/includes/menus.inc 31 Jul 2006
13:28:18 -0000 1.1.2.5
+++ koha-tmpl/intranet-tmpl/default/en/includes/menus.inc 10 Aug 2006
12:39:38 -0000 1.1.2.6
@@ -134,6 +134,7 @@
<TMPL_IF name="CAN_user_tools">
<hr>
+ <a href="/cgi-bin/koha/import/picture-upload.pl" title="Import
members pictures" class="submenu parameters" onMouseOver="CancelTimeOut(TID)"
onMouseOut="TID=setTimeout('SetOff(7)',Mduration)">Import members pictures in
pictures directory</a>
<a href="/cgi-bin/koha/export/marc.pl" title="Exporting in MARC
format" class="submenu parameters" onMouseOver="CancelTimeOut(TID)"
onMouseOut="TID=setTimeout('SetOff(7)',Mduration)">MARC biblio export</a>
<a href="/cgi-bin/koha/import/breeding.pl" title="The reservoir
is a table where imported MARC records are stored. A MARC record is stored in
the reservoir as long as you have no item. When you type the ISBN or title of a
biblio, it's searched for in the reservoir. If it is found, the biblio is added
to Koha active table" class="submenu parameters"
onMouseOver="CancelTimeOut(TID)"
onMouseOut="TID=setTimeout('SetOff(7)',Mduration)">Upload MARC records in
reservoir</a>
<a href="/cgi-bin/koha/barcodes/barcodes.pl" title="the barcode
generator deals with generating barcodes for items you acquire" class="submenu
parameters" onMouseOver="CancelTimeOut(TID)"
onMouseOut="TID=setTimeout('SetOff(7)',Mduration)">Generate barcodes</a>
Index: import/picture-upload.pl
===================================================================
RCS file: import/picture-upload.pl
diff -N import/picture-upload.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ import/picture-upload.pl 10 Aug 2006 12:39:38 -0000 1.1.2.1
@@ -0,0 +1,113 @@
+#!/usr/bin/perl
+
+use File::Temp;
+use File::Copy;
+use CGI;
+use C4::Context;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+
+#my $destdir =
"/usr/local/koha/intranet/htdocs/intranet-tmpl/images/patronpictures";
+#my $uploadfile = shift @ARGV;
+my $input = new CGI;
+my $destdir = C4::Context->config('intrahtdocs') . "/patronimages";
+
+warn "DEST : $destdir";
+my ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "import/picture-upload.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {management => 1,
tools => 1},
+ debug => 0,
+ });
+
+my $uploadfilename = $input->param( 'uploadfile' );
+my $uploadfile = $input->upload( 'uploadfile' );
+my ( $total, $handled, @counts );
+
+if ( $uploadfile ) {
+ my $dirname = File::Temp::tempdir( CLEANUP => 1);
+ my ( $tfh, $tempfile ) = File::Temp::tempfile( SUFFIX => '.zip', UNLINK =>
1 );
+ my ( @directories, %errors );
+
+ $errors{'NOTZIP'} = 1 unless ( $uploadfilename =~ /\.zip$/i );
+ $errors{'NOWRITETEMP'} = 1 unless ( -w "$dirname" );
+ $errors{'NOWRITEDEST'} = 1 unless ( -w "$destdir" );
+ $errors{'EMPTYUPLOAD'} = 1 unless ( length( $uploadfile ) > 0 );
+
+ if ( %errors ) {
+ $template->param( ERRORS => [ \%errors ] );
+ } else {
+ while ( <$uploadfile> ) {
+ print $tfh $_;
+ }
+
+ close $tfh;
+
+ `unzip $tempfile -d $dirname`;
+
+ push @directories, "$dirname";
+ foreach $recursive_dir ( @directories ) {
+ opendir $dir, $recursive_dir;
+ while ( my $entry = readdir $dir ) {
+ push @directories, "$recursive_dir/$entry" if ( -d
"$recursive_dir/$entry" and $entry !~ /^\./ );
+ }
+ closedir $dir;
+ }
+
+ foreach my $dir ( @directories ) {
+ $handled += handle_dir( $dir );
+ }
+
+ $total = scalar @directories;
+
+ $template->param(
+ TOTAL => $total,
+ HANDLED => $handled,
+ COUNTS => address@hidden,
+ );
+ }
+}
+
+output_html_with_http_headers $input, $cookie, $template->output;
+
+
+sub handle_dir {
+ my ( $dir ) = @_;
+ my ( %count );
+ $count{filenames} = ();
+
+ return 0 unless ( -r "$dir/IDLINK.TXT" or -r "$dir/DATALINK.TXT" );
+
+ my $file = ( -r "$dir/IDLINK.TXT" ) ? "$dir/IDLINK.TXT" :
"$dir/DATALINK.TXT";
+
+ open $fh, $file or { print "Openning $dir/$filename failed!\n" and return
0 };
+
+ while (my $line = <$fh>) {
+ chomp $line;
+
+ my ( $filename, $cardnumber );
+
+ my $delim = ($line =~ /\t/) ? "\t" : ",";
+
+ ($cardnumber, $filename) = split $delim, $line;
+ $cardnumber =~ s/[\"\r\n]//g; # remove offensive characters
+ $filename =~ s/[\"\r\n]//g;
+
+ if ($cardnumber && $filename) {
+ my $result = move ( "$dir/$filename", "$destdir/$cardnumber.jpg" );
+ if ( $result ) {
+ $count{count}++;
+ push @{ $count{filenames} }, { source => $filename, dest =>
$cardnumber .".jpg" };
+ }
+ }
+ }
+ $count{source} = $dir;
+ $count{dest} = $destdir;
+ push @counts, \%count;
+
+ close $fh;
+
+ return 1;
+}
Index: koha-tmpl/intranet-tmpl/npl/en/import/picture-upload.tmpl
===================================================================
RCS file: koha-tmpl/intranet-tmpl/npl/en/import/picture-upload.tmpl
diff -N koha-tmpl/intranet-tmpl/npl/en/import/picture-upload.tmpl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ koha-tmpl/intranet-tmpl/npl/en/import/picture-upload.tmpl 10 Aug 2006
12:39:38 -0000 1.1.2.1
@@ -0,0 +1,63 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->Koha -- Cataloging: Copy
Import<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!-- TMPL_INCLUDE NAME="masthead.inc" -->
+<!-- TMPL_INCLUDE NAME="intranet-nav.inc" -->
+
+<div id="main">
+<h1>Patron Pictures Import System</h1>
+
+<!-- TMPL_IF name="total" -->
+ <ul class="data">
+ <li>Unpacking completed</li>
+ </ul>
+<!--
+<!-- TMPL_VAR NAME="total" --> Scanned
+<!-- TMPL_VAR NAME="handled" --> Processed
+<!-- TMPL_LOOP name="counts" -->
+ <!-- TMPL_VAR name="count" --> Images moved from <!-- TMPL_VAR
name="source" --> to <!-- TMPL_VAR name="dest" -->
+ <!-- TMPL_LOOP name="filenames" -->
+ <!-- TMPL_VAR name="source" --> To <!-- TMPL_VAR name="dest" -->
+ <!-- /TMPL_LOOP -->
+<!-- /TMPL_LOOP -->
+ -->
+<!-- TMPL_ELSE -->
+
+<!-- TMPL_IF name="errors" -->
+ <!-- TMPL_LOOP name="errors" -->
+ <ul class="error">
+ <!-- TMPL_IF name="NOTZIP" -->
+ <li>The upload file does not appear to be a zip file. The
extention is not '.zip'.</li>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="NOWRITETEMP" -->
+ <li>This script is not able to create/write to the necessary
temporary directory.</li>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="NOWRITEDEST" -->
+ <li>This script is not able to write to the patronpictures
holding directory.</li>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="EMPTYUPLOAD" -->
+ <li>The upload file appears to be empty.</li>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+<!-- /TMPL_IF -->
+
+<form method="post" action="/cgi-bin/koha/import/picture-upload.pl"
enctype="multipart/form-data">
+<div class="data">
+<ul>
+ <li>Select a file to unpack on the server. Each .jpg file contained
therein will be copied to the appropriate place on the server for patron
pictures.</li>
+ <li>You can include multiple picture packs in the .zip file in seperate
directories.</li>
+ <li>There should be a DATALINK.TXT or IDLINK.TXT file for each picture
pack that has the cardnumber of the patron and the file containing that patrons
picture. One patron per line seperated by either ,'s or tabs. Quotes around
the fields are ignored.</li>
+</ul>
+<table>
+ <tr>
+ <th><label for="uploadfile">Select the .zip file to unpack:
</label></th>
+ <td>
+ <input type="file" id="uploadfile" name="uploadfile"
/><br />
+ </td>
+ </tr>
+</table>
+</div>
+ <input type="submit" value="Unpack" class="submit" />
+</form>
+
+<!-- /TMPL_IF -->
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha koha-tmpl/intranet-tmpl/default/en/include... [rel_2_2],
paul poulain <=