1 package Koha::Patron::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>.
34 Koha::Patron::Files - Module for managing patron files
43 my ( $class, %args ) = @_;
44 my $self = bless( {}, $class );
46 $self->{'borrowernumber'} = $args{'borrowernumber'};
53 my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
54 my $files_hashref = $bf->GetFilesInfo
61 my $dbh = C4::Context->dbh;
70 WHERE borrowernumber = ?
71 ORDER BY file_name, date_uploaded
73 my $sth = $dbh->prepare($query);
74 $sth->execute( $self->{'borrowernumber'} );
75 return $sth->fetchall_arrayref( {} );
80 my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
81 $bh->AddFile( name => $filename, type => $mimetype,
82 description => $description, content => $content );
87 my ( $self, %args ) = @_;
89 my $name = $args{'name'};
90 my $type = $args{'type'};
91 my $description = $args{'description'};
92 my $content = $args{'content'};
94 return unless ( $name && $content );
96 my $dbh = C4::Context->dbh;
98 INSERT INTO borrower_files ( borrowernumber, file_name, file_type, file_description, file_content )
101 my $sth = $dbh->prepare($query);
102 $sth->execute( $self->{'borrowernumber'},
103 $name, $type, $description, $content );
108 my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
109 my $file = $bh->GetFile( file_id => $file_id );
114 my ( $self, %args ) = @_;
116 my $file_id = $args{'id'};
118 my $dbh = C4::Context->dbh;
120 SELECT * FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
122 my $sth = $dbh->prepare($query);
123 $sth->execute( $file_id, $self->{'borrowernumber'} );
124 return $sth->fetchrow_hashref();
129 my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
130 $bh->DelFile( file_id => $file_id );
135 my ( $self, %args ) = @_;
137 my $file_id = $args{'id'};
139 my $dbh = C4::Context->dbh;
141 DELETE FROM borrower_files WHERE file_id = ? AND borrowernumber = ?
143 my $sth = $dbh->prepare($query);
144 $sth->execute( $file_id, $self->{'borrowernumber'} );
154 Kyle M Hall <kyle.m.hall@gmail.com>