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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use vars
qw($VERSION);
31 # set the version for version checking
37 Koha::Borrower::Files - Module for managing borrower files
46 my ( $class, %args ) = @_;
47 my $self = bless( {}, $class );
49 $self->{'borrowernumber'} = $args{'borrowernumber'};
56 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
57 my $files_hashref = $bf->GetFilesInfo
64 my $dbh = C4::Context->dbh;
73 WHERE borrowernumber = ?
74 ORDER BY file_name, date_uploaded
76 my $sth = $dbh->prepare($query);
77 $sth->execute( $self->{'borrowernumber'} );
78 return $sth->fetchall_arrayref( {} );
83 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
84 $bh->AddFile( name => $filename, type => $mimetype,
85 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 );
111 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
112 my $file = $bh->GetFile( file_id => $file_id );
117 my ( $self, %args ) = @_;
119 my $file_id = $args{'id'};
121 my $dbh = C4::Context->dbh;
123 SELECT * FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
125 my $sth = $dbh->prepare($query);
126 $sth->execute( $file_id, $self->{'borrowernumber'} );
127 return $sth->fetchrow_hashref();
132 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
133 $bh->DelFile( file_id => $file_id );
138 my ( $self, %args ) = @_;
140 my $file_id = $args{'id'};
142 my $dbh = C4::Context->dbh;
144 DELETE FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
146 my $sth = $dbh->prepare($query);
147 $sth->execute( $file_id, $self->{'borrowernumber'} );
157 Kyle M Hall <kyle.m.hall@gmail.com>