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);
30 # set the version for version checking
36 Koha::Borrower::Files - Module for managing borrower files
45 my ( $class, %args ) = @_;
46 my $self = bless( {}, $class );
48 $self->{'borrowernumber'} = $args{'borrowernumber'};
55 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
56 my $files_hashref = $bf->GetFilesInfo
63 my $dbh = C4::Context->dbh;
72 WHERE borrowernumber = ?
73 ORDER BY file_name, date_uploaded
75 my $sth = $dbh->prepare($query);
76 $sth->execute( $self->{'borrowernumber'} );
77 return $sth->fetchall_arrayref( {} );
82 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
83 $bh->AddFile( name => $filename, type => $mimetype,
84 description => $description, content => $content );
89 my ( $self, %args ) = @_;
91 my $name = $args{'name'};
92 my $type = $args{'type'};
93 my $description = $args{'description'};
94 my $content = $args{'content'};
96 return unless ( $name && $content );
98 my $dbh = C4::Context->dbh;
100 INSERT INTO borrower_files ( borrowernumber, file_name, file_type, file_description, file_content )
103 my $sth = $dbh->prepare($query);
104 $sth->execute( $self->{'borrowernumber'},
105 $name, $type, $description, $content );
110 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
111 my $file = $bh->GetFile( file_id => $file_id );
116 my ( $self, %args ) = @_;
118 my $file_id = $args{'id'};
120 my $dbh = C4::Context->dbh;
122 SELECT * FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
124 my $sth = $dbh->prepare($query);
125 $sth->execute( $file_id, $self->{'borrowernumber'} );
126 return $sth->fetchrow_hashref();
131 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
132 $bh->DelFile( file_id => $file_id );
137 my ( $self, %args ) = @_;
139 my $file_id = $args{'id'};
141 my $dbh = C4::Context->dbh;
143 DELETE FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
145 my $sth = $dbh->prepare($query);
146 $sth->execute( $file_id, $self->{'borrowernumber'} );
156 Kyle M Hall <kyle.m.hall@gmail.com>