X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=opac%2Fopac-sendshelf.pl;h=3f9b719987d799f35a962af67b0f5698b7298f94;hb=6a9323ab343c4bb6ffbcf9a69d48947822f691db;hp=1f9498924a4b772f7bfe28fc0164152a9ccb0acc;hpb=a066cae6c575ddadb6fe3eb9553acef987ae82d0;p=koha_fer diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index 1f9498924a..3f9b719987 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -13,15 +13,16 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; use warnings; use CGI; -use Encode qw(encode); +use Encode qw(decode encode); +use Carp; use Mail::Sendmail; use MIME::QuotedPrint; @@ -40,7 +41,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( template_name => "opac-sendshelfform.tmpl", query => $query, type => "opac", - authnotrequired => 1, + authnotrequired => 0, flagsrequired => { borrow => 1 }, } ); @@ -50,6 +51,8 @@ my $email = $query->param('email'); my $dbh = C4::Context->dbh; +if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) { + if ( $email ) { my $email_from = C4::Context->preference('KohaAdminEmailAddress'); my $comment = $query->param('comment'); @@ -78,27 +81,35 @@ if ( $email ) { # retrieve biblios from shelf foreach my $biblio (@$items) { my $biblionumber = $biblio->{biblionumber}; - + my $fw = GetFrameworkCode($biblionumber); my $dat = GetBiblioData($biblionumber); my $record = GetMarcBiblio($biblionumber); my $marcnotesarray = GetMarcNotes( $record, $marcflavour ); my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); + my $subtitle = GetRecordValue('subtitle', $record, $fw); - my @items = &GetItemsInfo( $biblionumber, 'opac' ); + my @items = GetItemsInfo( $biblionumber ); + $dat->{ISBN} = GetMarcISBN($record, $marcflavour); $dat->{MARCNOTES} = $marcnotesarray; $dat->{MARCSUBJCTS} = $marcsubjctsarray; $dat->{MARCAUTHORS} = $marcauthorsarray; $dat->{'biblionumber'} = $biblionumber; $dat->{ITEM_RESULTS} = \@items; + $dat->{subtitle} = $subtitle; + $dat->{HASAUTHORS} = $dat->{'author'} || @$marcauthorsarray; $iso2709 .= $record->as_usmarc(); push( @results, $dat ); } - my $user = GetMember(borrowernumber => $borrowernumber); + my $user = GetMember(borrowernumber => $borrowernumber); + + if (C4::Context->preference('OPACBaseURL')){ + $template2->param( OPACBaseURL => C4::Context->preference('OPACBaseURL') ); + } $template2->param( BIBLIO_RESULTS => \@results, @@ -114,22 +125,29 @@ if ( $email ) { my $body; # Analysing information and getting mail properties - if ( $template_res =~ /\n(.*)\n/s ) { - $mail{'subject'} = $1; + if ( $template_res =~ /(.*)/s ) { + $mail{subject} = $1; + $mail{subject} =~ s|\n?(.*)\n?|$1|; } else { $mail{'subject'} = "no subject"; } my $email_header = ""; - if ( $template_res =~ /
\n(.*)\n/s ) { + if ( $template_res =~ /
(.*)/s ) { $email_header = $1; + $email_header =~ s|\n?(.*)\n?|$1|; } - my $email_file = "basket.txt"; - if ( $template_res =~ /\n(.*)\n/s ) { + my $email_file = "list.txt"; + if ( $template_res =~ /(.*)/s ) { $email_file = $1; + $email_file =~ s|\n?(.*)\n?|$1|; } - if ( $template_res =~ /\n(.*)\n/s ) { $body = encode_qp($1); } + if ( $template_res =~ /(.*)/s ) { + $body = $1; + $body =~ s|\n?(.*)\n?|$1|; + $body = encode("UTF-8", encode_qp($body)); + } my $boundary = "====" . time() . "===="; @@ -141,15 +159,16 @@ if ( $email ) { $mail{body} = <param( error => 1 ); } @@ -176,3 +195,10 @@ END_OF_BODY ); output_html_with_http_headers $query, $cookie, $template->output; } + +} else { + $template->param( invalidlist => 1, + url => "/cgi-bin/koha/opac-sendshelf.pl", + ); + output_html_with_http_headers $query, $cookie, $template->output; +}