1 package Koha::Borrower::Files;
3 # Copyright 2012 Kyle M Hall
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
31 # set the version for version checking
39 my $debug = C4::Context->preference("DebugLevel");
44 Koha::Borrower::Files - Module for managing borrower files
49 my ( $class, %args ) = @_;
50 my $self = bless( {}, $class );
52 $self->{'borrowernumber'} = $args{'borrowernumber'};
59 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
60 my $files_hashref = $bf->GetFilesInfo
67 my $dbh = C4::Context->dbh;
76 WHERE borrowernumber = ?
77 ORDER BY file_name, date_uploaded
79 my $sth = $dbh->prepare($query);
80 $sth->execute( $self->{'borrowernumber'} );
81 return $sth->fetchall_arrayref( {} );
85 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
86 $bh->AddFile( name => $filename, type => $mimetype, description => $description, content => $content );
90 my ( $self, %args ) = @_;
92 my $name = $args{'name'};
93 my $type = $args{'type'};
94 my $description = $args{'description'};
95 my $content = $args{'content'};
97 return unless ( $name && $content );
99 my $dbh = C4::Context->dbh;
101 INSERT INTO borrower_files ( borrowernumber, file_name, file_type, file_description, file_content )
104 my $sth = $dbh->prepare($query);
105 $sth->execute( $self->{'borrowernumber'},
106 $name, $type, $description, $content );
110 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
111 my $file = $bh->GetFile( file_id => $file_id );
115 my ( $self, %args ) = @_;
117 my $file_id = $args{'id'};
119 my $dbh = C4::Context->dbh;
121 SELECT * FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
123 my $sth = $dbh->prepare($query);
124 $sth->execute( $file_id, $self->{'borrowernumber'} );
125 return $sth->fetchrow_hashref();
129 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
130 $bh->DelFile( file_id => $file_id );
134 my ( $self, %args ) = @_;
136 my $file_id = $args{'id'};
138 my $dbh = C4::Context->dbh;
140 DELETE FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
142 my $sth = $dbh->prepare($query);
143 $sth->execute( $file_id, $self->{'borrowernumber'} );
153 Kyle M Hall <kyle.m.hall@gmail.com>