View | Details | Raw Unified | Return to bug 14385
Collapse All | Expand All

(-)a/opac/opac-ISBDdetail.pl (-39 / +40 lines)
Lines 58-63 use Koha::RecordProcessor; Link Here
58
58
59
59
60
my $query = CGI->new();
60
my $query = CGI->new();
61
62
my $biblionumber = $query->param('biblionumber');
63
if ( ! $biblionumber ) {
64
    print $query->redirect('/cgi-bin/koha/errors/404.pl');
65
    exit;
66
}
67
$biblionumber = int($biblionumber);
68
69
#open template
61
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
70
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62
    {
71
    {
63
        template_name   => "opac-ISBDdetail.tt",
72
        template_name   => "opac-ISBDdetail.tt",
Lines 68-118 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
68
    }
77
    }
69
);
78
);
70
79
71
my $biblionumber = $query->param('biblionumber');
80
my $borcat = q{};
72
$biblionumber = int($biblionumber);
81
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
73
82
    # we need to fetch the borrower info here, so we can pass the category
74
# get biblionumbers stored in the cart
83
    my $borrower = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
75
if(my $cart_list = $query->cookie("bib_list")){
84
    $borcat = $borrower ? $borrower->categorycode : $borcat;
76
    my @cart_list = split(/\//, $cart_list);
77
    if ( grep {$_ eq $biblionumber} @cart_list) {
78
        $template->param( incart => 1 );
79
    }
80
}
81
82
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
83
84
my $marcflavour      = C4::Context->preference("marcflavour");
85
86
my @items = GetItemsInfo($biblionumber);
87
if (scalar @items >= 1) {
88
    my $borrowernumber;
89
    my $borcat;
90
    if (C4::Context->userenv) {
91
        $borrowernumber = C4::Context->userenv->{'number'};
92
    }
93
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
94
95
        # we need to fetch the borrower info here, so we can pass the category
96
        my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
97
        $borcat = $borrower ? $borrower->categorycode : q{};
98
    }
99
100
    my @hiddenitems = GetHiddenItemnumbers( { items => \@items, borcat => $borcat });
101
102
    if (scalar @hiddenitems == scalar @items ) {
103
        print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
104
        exit;
105
    }
106
}
85
}
107
86
108
my $record = GetMarcBiblio({
87
my $record = GetMarcBiblio({
109
    biblionumber => $biblionumber,
88
    biblionumber => $biblionumber,
110
    embed_items  => 1 });
89
    embed_items  => 1,
90
    opac         => 1,
91
    borcat       => $borcat });
111
if ( ! $record ) {
92
if ( ! $record ) {
112
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
93
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
113
    exit;
94
    exit;
114
}
95
}
115
my $framework = GetFrameworkCode( $biblionumber );
96
97
my @all_items = GetItemsInfo($biblionumber);
98
my $framework = &GetFrameworkCode( $biblionumber );
99
my ($tag_itemnumber, $subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
100
my @nonhiddenitems = $record->field($tag_itemnumber);
101
if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
102
    print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
103
    exit;
104
}
105
116
my $record_processor = Koha::RecordProcessor->new({
106
my $record_processor = Koha::RecordProcessor->new({
117
    filters => 'ViewPolicy',
107
    filters => 'ViewPolicy',
118
    options => {
108
    options => {
Lines 122-127 my $record_processor = Koha::RecordProcessor->new({ Link Here
122
});
112
});
123
$record_processor->process($record);
113
$record_processor->process($record);
124
114
115
# get biblionumbers stored in the cart
116
if(my $cart_list = $query->cookie("bib_list")){
117
    my @cart_list = split(/\//, $cart_list);
118
    if ( grep {$_ eq $biblionumber} @cart_list) {
119
        $template->param( incart => 1 );
120
    }
121
}
122
123
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
124
125
my $marcflavour      = C4::Context->preference("marcflavour");
126
125
# some useful variables for enhanced content;
127
# some useful variables for enhanced content;
126
# in each case, we're grabbing the first value we find in
128
# in each case, we're grabbing the first value we find in
127
# the record and normalizing it
129
# the record and normalizing it
Lines 143-149 $template->param( Link Here
143
145
144
#coping with subscriptions
146
#coping with subscriptions
145
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
147
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
146
my $dbh = C4::Context->dbh;
147
my $dat                 = TransformMarcToKoha( $record );
148
my $dat                 = TransformMarcToKoha( $record );
148
149
149
my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
150
my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
Lines 179-185 my $res = GetISBDView({ Link Here
179
180
180
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
181
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
181
my $patron = Koha::Patrons->find( $loggedinuser );
182
my $patron = Koha::Patrons->find( $loggedinuser );
182
for my $itm (@items) {
183
for my $itm (@all_items) {
183
    $norequests = 0
184
    $norequests = 0
184
      if $norequests
185
      if $norequests
185
        && !$itm->{'withdrawn'}
186
        && !$itm->{'withdrawn'}
(-)a/opac/opac-MARCdetail.pl (-49 / +39 lines)
Lines 61-110 use Koha::Biblios; Link Here
61
use Koha::Patrons;
61
use Koha::Patrons;
62
use Koha::RecordProcessor;
62
use Koha::RecordProcessor;
63
63
64
my $query = new CGI;
64
my $query = CGI->new();
65
66
my $dbh = C4::Context->dbh;
67
65
68
my $biblionumber = $query->param('biblionumber');
66
my $biblionumber = $query->param('biblionumber');
69
if ( ! $biblionumber ) {
67
if ( ! $biblionumber ) {
70
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
68
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
71
    exit;
69
    exit;
72
}
70
}
71
$biblionumber = int($biblionumber);
72
73
# open template
74
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
75
    {
76
        template_name   => "opac-MARCdetail.tt",
77
        query           => $query,
78
        type            => "opac",
79
        authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
80
        debug           => 1,
81
    }
82
);
83
84
my $borcat = q{};
85
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
86
    # we need to fetch the borrower info here, so we can pass the category
87
    my $borrower = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
88
    $borcat = $borrower ? $borrower->categorycode : $borcat;
89
}
73
90
74
my $record = GetMarcBiblio({
91
my $record = GetMarcBiblio({
75
    biblionumber => $biblionumber,
92
    biblionumber => $biblionumber,
76
    embed_items  => 1 });
93
    embed_items  => 1,
94
    opac         => 1,
95
    borcat       => $borcat });
77
if ( ! $record ) {
96
if ( ! $record ) {
78
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
97
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
79
    exit;
98
    exit;
80
}
99
}
81
100
82
my @all_items = GetItemsInfo($biblionumber);
101
my @all_items = GetItemsInfo($biblionumber);
83
my @items2hide;
84
if (scalar @all_items >= 1) {
85
    my $borrowernumber;
86
    my $borcat;
87
    if (C4::Context->userenv) {
88
        $borrowernumber = C4::Context->userenv->{'number'};
89
    }
90
    if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
91
92
        # we need to fetch the borrower info here, so we can pass the category
93
        my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } );
94
        $borcat = $borrower ? $borrower->categorycode : q{};
95
    }
96
    push @items2hide, GetHiddenItemnumbers({ items => \@all_items, borcat => $borcat });
97
98
    if (scalar @items2hide == scalar @all_items ) {
99
        print $query->redirect("/cgi-bin/koha/errors/404.pl");
100
        exit;
101
    }
102
}
103
104
my $framework = &GetFrameworkCode( $biblionumber );
102
my $framework = &GetFrameworkCode( $biblionumber );
105
my $tagslib = &GetMarcStructure( 0, $framework );
106
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
103
my ($tag_itemnumber,$subtag_itemnumber) = &GetMarcFromKohaField('items.itemnumber',$framework);
107
my $biblio = Koha::Biblios->find( $biblionumber );
104
my @nonhiddenitems = $record->field($tag_itemnumber);
105
if (scalar @all_items >= 1 && scalar @nonhiddenitems == 0) {
106
    print $query->redirect("/cgi-bin/koha/errors/404.pl");
107
    exit;
108
}
108
109
109
my $record_processor = Koha::RecordProcessor->new({
110
my $record_processor = Koha::RecordProcessor->new({
110
    filters => 'ViewPolicy',
111
    filters => 'ViewPolicy',
Lines 115-137 my $record_processor = Koha::RecordProcessor->new({ Link Here
115
});
116
});
116
$record_processor->process($record);
117
$record_processor->process($record);
117
118
118
# open template
119
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
120
    {
121
        template_name   => "opac-MARCdetail.tt",
122
        query           => $query,
123
        type            => "opac",
124
        authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
125
        debug           => 1,
126
    }
127
);
128
129
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework);
130
$template->param(
131
    bibliotitle => $biblio->title,
132
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible.
133
     $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8;   # except -8;
134
135
# get biblionumbers stored in the cart
119
# get biblionumbers stored in the cart
136
if(my $cart_list = $query->cookie("bib_list")){
120
if(my $cart_list = $query->cookie("bib_list")){
137
    my @cart_list = split(/\//, $cart_list);
121
    my @cart_list = split(/\//, $cart_list);
Lines 140-145 if(my $cart_list = $query->cookie("bib_list")){ Link Here
140
    }
124
    }
141
}
125
}
142
126
127
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
128
129
my $biblio = Koha::Biblios->find( $biblionumber );
130
my $tagslib = &GetMarcStructure( 0, $framework );
131
my ($bt_tag,$bt_subtag) = GetMarcFromKohaField('biblio.title',$framework);
132
$template->param(
133
    bibliotitle => $biblio->title,
134
) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible.
135
     $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8;   # except -8;
136
143
my $allow_onshelf_holds;
137
my $allow_onshelf_holds;
144
my $patron = Koha::Patrons->find( $loggedinuser );
138
my $patron = Koha::Patrons->find( $loggedinuser );
145
for my $itm (@all_items) {
139
for my $itm (@all_items) {
Lines 148-154 for my $itm (@all_items) { Link Here
148
}
142
}
149
143
150
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
144
$template->param( 'AllowOnShelfHolds' => $allow_onshelf_holds );
151
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
152
145
153
# adding the $RequestOnOpac param
146
# adding the $RequestOnOpac param
154
my $RequestOnOpac;
147
my $RequestOnOpac;
Lines 278-283 for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) { Link Here
278
# loop through each tag
271
# loop through each tag
279
# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
272
# warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
280
# then construct template.
273
# then construct template.
274
# $record has already had all the item fields filtered above.
281
my @fields = $record->fields();
275
my @fields = $record->fields();
282
my %witness
276
my %witness
283
  ; #---- stores the list of subfields used at least once, with the "meaning" of the code
277
  ; #---- stores the list of subfields used at least once, with the "meaning" of the code
Lines 285-293 my @item_subfield_codes; Link Here
285
my @item_loop;
279
my @item_loop;
286
foreach my $field (@fields) {
280
foreach my $field (@fields) {
287
    next if ( $field->tag() < 10 );
281
    next if ( $field->tag() < 10 );
288
    next if ( ( $field->tag() eq $tag_itemnumber ) &&
289
              ( any { $field->subfield($subtag_itemnumber) eq $_ }
290
                   @items2hide) );
291
    my @subf = $field->subfields;
282
    my @subf = $field->subfields;
292
    my $item;
283
    my $item;
293
284
294
- 

Return to bug 14385