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);
31 # set the version for version checking
37 Koha::Borrower::Files - Module for managing borrower files
42 my ( $class, %args ) = @_;
43 my $self = bless( {}, $class );
45 $self->{'borrowernumber'} = $args{'borrowernumber'};
52 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
53 my $files_hashref = $bf->GetFilesInfo
60 my $dbh = C4::Context->dbh;
69 WHERE borrowernumber = ?
70 ORDER BY file_name, date_uploaded
72 my $sth = $dbh->prepare($query);
73 $sth->execute( $self->{'borrowernumber'} );
74 return $sth->fetchall_arrayref( {} );
78 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
79 $bh->AddFile( name => $filename, type => $mimetype, description => $description, content => $content );
83 my ( $self, %args ) = @_;
85 my $name = $args{'name'};
86 my $type = $args{'type'};
87 my $description = $args{'description'};
88 my $content = $args{'content'};
90 return unless ( $name && $content );
92 my $dbh = C4::Context->dbh;
94 INSERT INTO borrower_files ( borrowernumber, file_name, file_type, file_description, file_content )
97 my $sth = $dbh->prepare($query);
98 $sth->execute( $self->{'borrowernumber'},
99 $name, $type, $description, $content );
103 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
104 my $file = $bh->GetFile( file_id => $file_id );
108 my ( $self, %args ) = @_;
110 my $file_id = $args{'id'};
112 my $dbh = C4::Context->dbh;
114 SELECT * FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
116 my $sth = $dbh->prepare($query);
117 $sth->execute( $file_id, $self->{'borrowernumber'} );
118 return $sth->fetchrow_hashref();
122 my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
123 $bh->DelFile( file_id => $file_id );
127 my ( $self, %args ) = @_;
129 my $file_id = $args{'id'};
131 my $dbh = C4::Context->dbh;
133 DELETE FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
135 my $sth = $dbh->prepare($query);
136 $sth->execute( $file_id, $self->{'borrowernumber'} );
146 Kyle M Hall <kyle.m.hall@gmail.com>