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

(-)a/C4/Auth.pm (-1 / +1 lines)
Lines 648-654 sub checkauth { Link Here
648
                $session->param('surname'),      $session->param('branch'),
648
                $session->param('surname'),      $session->param('branch'),
649
                $session->param('branchname'),   $session->param('flags'),
649
                $session->param('branchname'),   $session->param('flags'),
650
                $session->param('emailaddress'), $session->param('branchprinter'),
650
                $session->param('emailaddress'), $session->param('branchprinter'),
651
                $session->param('persona')
651
                $session->param('persona'),      $type
652
            );
652
            );
653
            C4::Context::set_shelves_userenv('bar',$session->param('barshelves'));
653
            C4::Context::set_shelves_userenv('bar',$session->param('barshelves'));
654
            C4::Context::set_shelves_userenv('pub',$session->param('pubshelves'));
654
            C4::Context::set_shelves_userenv('pub',$session->param('pubshelves'));
(-)a/C4/Branch.pm (-17 / +66 lines)
Lines 42-47 BEGIN { Link Here
42
		&GetCategoryTypes
42
		&GetCategoryTypes
43
		&GetBranchCategories
43
		&GetBranchCategories
44
		&GetBranchesInCategory
44
		&GetBranchesInCategory
45
        &GetCategoriesForBranch
45
		&ModBranchCategoryInfo
46
		&ModBranchCategoryInfo
46
        &GetIndependentGroupModificationRights
47
        &GetIndependentGroupModificationRights
47
		&DelBranch
48
		&DelBranch
Lines 109-114 Create a branch selector with the following code. Link Here
109
110
110
sub GetBranches {
111
sub GetBranches {
111
    my ($onlymine)=@_;
112
    my ($onlymine)=@_;
113
    $onlymine ||= onlymine();
112
    # returns a reference to a hash of references to ALL branches...
114
    # returns a reference to a hash of references to ALL branches...
113
    my %branches;
115
    my %branches;
114
    my $dbh = C4::Context->dbh;
116
    my $dbh = C4::Context->dbh;
Lines 431-436 sub GetBranchesInCategory { Link Here
431
	return( \@branches );
433
	return( \@branches );
432
}
434
}
433
435
436
=head2 GetCategoriesForBranch
437
438
    my @categories = GetCategoriesForBranch({
439
        branchcode   => $branchcode,
440
        categorytype => 'independent_group'
441
    });
442
443
    Called in a list context, returns an array of branch category codes
444
    that branch is part of.
445
446
    Called in a scalar context, returns an array ref.
447
448
=cut
449
450
sub GetCategoriesForBranch {
451
    my ( $params ) = @_;
452
    my $branchcode = $params->{branchcode};
453
    my $categorytype = $params->{categorytype} || '%';
454
455
    carp("Missing branchcode parameter!") unless ( $branchcode );
456
457
    my $sql = q{
458
        SELECT categorycode FROM branchrelations
459
        JOIN branchcategories USING ( categorycode )
460
        WHERE branchcode   = ?
461
          AND categorytype = ?
462
    };
463
464
    my $categories = C4::Context->dbh->selectcol_arrayref( $sql, {}, ( $branchcode, $categorytype ) );
465
466
    return wantarray() ? $categories : @$categories;
467
}
468
434
=head2 GetIndependentGroupModificationRights
469
=head2 GetIndependentGroupModificationRights
435
470
436
    GetIndependentGroupModificationRights(
471
    GetIndependentGroupModificationRights(
Lines 460-466 sub GetBranchesInCategory { Link Here
460
    is useful for "branchcode IN $branchcodes" clauses
495
    is useful for "branchcode IN $branchcodes" clauses
461
    in SQL queries.
496
    in SQL queries.
462
497
463
    $this_branch and $other_branch are equal for efficiency.
498
    Returns 1 if $this_branch and $other_branch are equal for efficiency.
464
499
465
    So you can write:
500
    So you can write:
466
    my @branches = GetIndependentGroupModificationRights();
501
    my @branches = GetIndependentGroupModificationRights();
Lines 472-501 sub GetBranchesInCategory { Link Here
472
sub GetIndependentGroupModificationRights {
507
sub GetIndependentGroupModificationRights {
473
    my ($params) = @_;
508
    my ($params) = @_;
474
509
475
    my $this_branch  = $params->{branch};
510
    my $this_branch  = $params->{branch}    ||= q{};
476
    my $other_branch = $params->{for};
511
    my $other_branch = $params->{for}       ||= q{};
477
    my $stringify    = $params->{stringify};
512
    my $stringify    = $params->{stringify} ||= q{};
478
513
514
    $this_branch ||= $ENV{BRANCHCODE};
479
    $this_branch ||= C4::Context->userenv->{branch};
515
    $this_branch ||= C4::Context->userenv->{branch};
480
516
481
    carp("No branch found!") unless ($this_branch);
517
    unless ($this_branch) {
518
        carp("No branch found!");
519
        return;
520
    }
482
521
483
    return 1 if ( $this_branch eq $other_branch );
522
    return 1 if ( $this_branch eq $other_branch );
484
523
485
    my $sql = q{
524
    my $allow_all = 0;
486
        SELECT DISTINCT(branchcode)
525
    $allow_all = 1 if C4::Context->IsSuperLibrarian();
487
        FROM branchrelations
526
    $allow_all = 1 if C4::Context->userenv->{type} eq 'opac' && !$ENV{BRANCHCODE};
488
        JOIN branchcategories USING ( categorycode )
489
        WHERE categorycode IN (
490
            SELECT categorycode
491
            FROM branchrelations
492
            WHERE branchcode = ?
493
        )
494
        AND branchcategories.categorytype = 'independent_group'
495
    };
496
527
528
    my $sql;
497
    my @params;
529
    my @params;
498
    push( @params, $this_branch );
530
    if ( $allow_all ) {
531
        $sql = q{
532
            SELECT branchcode FROM branches WHERE 1
533
        }
534
    } else {
535
        $sql = q{
536
            SELECT DISTINCT(branchcode)
537
            FROM branchrelations
538
            JOIN branchcategories USING ( categorycode )
539
            WHERE categorycode IN (
540
                SELECT categorycode
541
                FROM branchrelations
542
                WHERE branchcode = ?
543
            )
544
            AND branchcategories.categorytype = 'independent_group'
545
        };
546
        push( @params, $this_branch );
547
    }
499
548
500
    if ($other_branch) {
549
    if ($other_branch) {
501
        $sql .= q{ AND branchcode = ? };
550
        $sql .= q{ AND branchcode = ? };
(-)a/C4/Context.pm (-14 / +22 lines)
Lines 1112-1134 set_userenv is called in Auth.pm Link Here
1112
1112
1113
#'
1113
#'
1114
sub set_userenv {
1114
sub set_userenv {
1115
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona)= @_;
1115
    my (
1116
    my $var=$context->{"activeuser"} || '';
1116
        $usernum,      $userid,        $usercnum,   $userfirstname,
1117
        $usersurname,  $userbranch,    $branchname, $userflags,
1118
        $emailaddress, $branchprinter, $persona,    $type
1119
    ) = @_;
1120
1121
    my $var = $context->{"activeuser"} || '';
1122
1117
    my $cell = {
1123
    my $cell = {
1118
        "number"     => $usernum,
1124
        "number"        => $usernum,
1119
        "id"         => $userid,
1125
        "id"            => $userid,
1120
        "cardnumber" => $usercnum,
1126
        "cardnumber"    => $usercnum,
1121
        "firstname"  => $userfirstname,
1127
        "firstname"     => $userfirstname,
1122
        "surname"    => $usersurname,
1128
        "surname"       => $usersurname,
1123
        #possibly a law problem
1129
        "branch"        => $userbranch,
1124
        "branch"     => $userbranch,
1130
        "branchname"    => $branchname,
1125
        "branchname" => $branchname,
1131
        "flags"         => $userflags,
1126
        "flags"      => $userflags,
1132
        "emailaddress"  => $emailaddress,
1127
        "emailaddress"     => $emailaddress,
1133
        "branchprinter" => $branchprinter,
1128
        "branchprinter"    => $branchprinter,
1134
        "persona"       => $persona,
1129
        "persona"    => $persona,
1135
        "type"          => $type,
1130
    };
1136
    };
1137
1131
    $context->{userenv}->{$var} = $cell;
1138
    $context->{userenv}->{$var} = $cell;
1139
1132
    return $cell;
1140
    return $cell;
1133
}
1141
}
1134
1142
(-)a/C4/Items.pm (-1 / +9 lines)
Lines 1206-1211 If this is set, it is set to C<One Order>. Link Here
1206
1206
1207
sub GetItemsInfo {
1207
sub GetItemsInfo {
1208
    my ( $biblionumber ) = @_;
1208
    my ( $biblionumber ) = @_;
1209
1210
    my $IndependentBranchesRecordsAndItems =
1211
      C4::Context->preference('IndependentBranchesRecordsAndItems')
1212
      && !C4::Context->IsSuperLibrarian();
1213
1209
    my $dbh   = C4::Context->dbh;
1214
    my $dbh   = C4::Context->dbh;
1210
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1215
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1211
    my $query = "
1216
    my $query = "
Lines 1235-1241 sub GetItemsInfo { Link Here
1235
     LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber
1240
     LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber
1236
     LEFT JOIN itemtypes   ON   itemtypes.itemtype         = "
1241
     LEFT JOIN itemtypes   ON   itemtypes.itemtype         = "
1237
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
1242
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
1238
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1243
    $query .= " WHERE items.biblionumber = ? ";
1244
    $query .= " AND items.homebranch IN ( " . GetIndependentGroupModificationRights({ stringify => 1}) . " ) " if ( $IndependentBranchesRecordsAndItems );
1245
    $query .= " ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1246
1239
    my $sth = $dbh->prepare($query);
1247
    my $sth = $dbh->prepare($query);
1240
    $sth->execute($biblionumber);
1248
    $sth->execute($biblionumber);
1241
    my $i = 0;
1249
    my $i = 0;
(-)a/C4/Search.pm (+71 lines)
Lines 36-41 use URI::Escape; Link Here
36
use Business::ISBN;
36
use Business::ISBN;
37
use MARC::Record;
37
use MARC::Record;
38
use MARC::Field;
38
use MARC::Field;
39
use List::MoreUtils qw(none);
39
use utf8;
40
use utf8;
40
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
41
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
41
42
Lines 301-306 sub SimpleSearch { Link Here
301
        $zoom_query->destroy();
302
        $zoom_query->destroy();
302
    }
303
    }
303
304
305
    if ( C4::Context->preference('IndependentBranchesRecordsAndItems') ) {
306
        my @new_results;
307
        my $dbh = C4::Context->dbh();
308
        foreach my $result ( @{$results} ) {
309
            my $marc_record = MARC::Record->new_from_usmarc($result);
310
            my $koha_record = TransformMarcToKoha( $dbh, $marc_record );
311
            my $is_allowed = $koha_record->{branchcode} ? GetIndependentGroupModificationRights( { for => $koha_record->{branchcode} } ) : 1;
312
313
            push( @new_results, $result ) if ( $is_allowed );
314
        }
315
        $results = \@new_results;
316
        $total_hits = scalar( @new_results );
317
    }
318
304
    return ( undef, $results, $total_hits );
319
    return ( undef, $results, $total_hits );
305
}
320
}
306
321
Lines 1574-1579 sub buildQuery { Link Here
1574
        $limit .= "($availability_limit)";
1589
        $limit .= "($availability_limit)";
1575
    }
1590
    }
1576
1591
1592
    if ( C4::Context->preference('IndependentBranchesRecordsAndItems') ) {
1593
        my $search_context = C4::Context->userenv->{type};
1594
        my $IndependentBranchesRecordsAndItems;
1595
        if ( $search_context eq 'opac' ) {
1596
            # For the OPAC, if IndependentBranchesRecordsAndItems is enabled,
1597
            # and BRANCHCODE has been set in the httpd conf,
1598
            # we need to filter the items
1599
            $IndependentBranchesRecordsAndItems = $ENV{BRANCHCODE};
1600
        }
1601
        else {
1602
            # For the intranet, if IndependentBranchesRecordsAndItems is enabled,
1603
            # and the user is not a superlibrarian,
1604
            # we need to filter the items
1605
            $IndependentBranchesRecordsAndItems = !C4::Context->IsSuperLibrarian();
1606
        }
1607
        my @allowed_branches = $IndependentBranchesRecordsAndItems ? GetIndependentGroupModificationRights() : ();
1608
1609
        if ( @allowed_branches ) {
1610
            $limit .= " and " if ( $query || $limit );
1611
            $limit .= "(" . join( " or ", map { "branch:$_" } @allowed_branches ) . ")";
1612
        }
1613
    }
1614
1577
    # Normalize the query and limit strings
1615
    # Normalize the query and limit strings
1578
    # This is flawed , means we can't search anything with : in it
1616
    # This is flawed , means we can't search anything with : in it
1579
    # if user wants to do ccl or cql, start the query with that
1617
    # if user wants to do ccl or cql, start the query with that
Lines 1828-1841 sub searchResults { Link Here
1828
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
1866
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
1829
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
1867
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
1830
1868
1869
        my $IndependentBranchesRecordsAndItems;
1870
        if ( $search_context eq 'opac' ) {
1871
            # For the OPAC, if IndependentBranchesRecordsAndItems is enabled,
1872
            # and BRANCHCODE has been set in the httpd conf,
1873
            # we need to filter the items
1874
            $IndependentBranchesRecordsAndItems =
1875
              C4::Context->preference('IndependentBranchesRecordsAndItems')
1876
              && $ENV{BRANCHCODE};
1877
        }
1878
        else {
1879
            # For the intranet, if IndependentBranchesRecordsAndItems is enabled,
1880
            # and the user is not a superlibrarian,
1881
            # we need to filter the items
1882
            $IndependentBranchesRecordsAndItems =
1883
              C4::Context->preference('IndependentBranchesRecordsAndItems')
1884
              && !C4::Context->IsSuperLibrarian();
1885
        }
1886
        my @allowed_branches = $IndependentBranchesRecordsAndItems ? GetIndependentGroupModificationRights() : undef;
1887
1831
        # loop through every item
1888
        # loop through every item
1889
        my $index = -1;
1832
        foreach my $field (@fields) {
1890
        foreach my $field (@fields) {
1891
            $index++;
1833
            my $item;
1892
            my $item;
1834
1893
1835
            # populate the items hash
1894
            # populate the items hash
1836
            foreach my $code ( keys %subfieldstosearch ) {
1895
            foreach my $code ( keys %subfieldstosearch ) {
1837
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1896
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1838
            }
1897
            }
1898
1899
            # if IndependentBranchesRecordsAndItems is enabled, and this record
1900
            # isn't allowed to be viewed, remove it from the items list and go
1901
            # right to the next item.
1902
            if ( $IndependentBranchesRecordsAndItems ) {
1903
                if ( none { $_ eq $item->{homebranch} } @allowed_branches ) {
1904
                    splice(@fields, $index, 1);
1905
                    $items_count--;
1906
                    next;
1907
                }
1908
            }
1909
1839
            $item->{description} = $itemtypes{ $item->{itype} }{description};
1910
            $item->{description} = $itemtypes{ $item->{itype} }{description};
1840
1911
1841
	        # OPAC hidden items
1912
	        # OPAC hidden items
(-)a/C4/Serials.pm (+4 lines)
Lines 738-743 sub SearchSubscriptions { Link Here
738
        push @where_strs, "subscription.closed = ?";
738
        push @where_strs, "subscription.closed = ?";
739
        push @where_args, "$args->{closed}";
739
        push @where_args, "$args->{closed}";
740
    }
740
    }
741
    if( C4::Context->preference('IndependentBranchesRecordsAndItems') && !C4::Context->IsSuperlibrarian() ) {
742
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
743
        push @where_strs, "subscription.branchcode IN ( $branches )";
744
    }
741
    if(@where_strs){
745
    if(@where_strs){
742
        $query .= " WHERE " . join(" AND ", @where_strs);
746
        $query .= " WHERE " . join(" AND ", @where_strs);
743
    }
747
    }
(-)a/catalogue/search.pl (-17 / +12 lines)
Lines 135-140 Not yet completed... Link Here
135
use strict;            # always use
135
use strict;            # always use
136
#use warnings; FIXME - Bug 2505
136
#use warnings; FIXME - Bug 2505
137
137
138
use List::MoreUtils qw(any);
139
138
## STEP 1. Load things that are used in both search page and
140
## STEP 1. Load things that are used in both search page and
139
# results page and decide which template to load, operations 
141
# results page and decide which template to load, operations 
140
# to perform, etc.
142
# to perform, etc.
Lines 152-157 use URI::Escape; Link Here
152
use POSIX qw(ceil floor);
154
use POSIX qw(ceil floor);
153
use String::Random;
155
use String::Random;
154
use C4::Branch; # GetBranches
156
use C4::Branch; # GetBranches
157
use URI::Escape;
155
158
156
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
159
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
157
# create a new CGI object
160
# create a new CGI object
Lines 181-189 else { Link Here
181
    flagsrequired   => { catalogue => 1 },
184
    flagsrequired   => { catalogue => 1 },
182
    }
185
    }
183
);
186
);
187
184
if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
188
if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
185
    $template->param('UNIMARC' => 1);
189
    $template->param('UNIMARC' => 1);
186
}
190
}
191
187
if (C4::Context->preference("IntranetNumbersPreferPhrase")) {
192
if (C4::Context->preference("IntranetNumbersPreferPhrase")) {
188
    $template->param('numbersphr' => 1);
193
    $template->param('numbersphr' => 1);
189
}
194
}
Lines 228-247 my $branches = GetBranches(); Link Here
228
# Populate branch_loop with all branches sorted by their name.  If
233
# Populate branch_loop with all branches sorted by their name.  If
229
# IndependentBranches is activated, set the default branch to the borrower
234
# IndependentBranches is activated, set the default branch to the borrower
230
# branch, except for superlibrarian who need to search all libraries.
235
# branch, except for superlibrarian who need to search all libraries.
231
my $user = C4::Context->userenv;
236
$template->param(
232
my @branch_loop = map {
237
    branchloop       => GetBranchesLoop(),
233
     {
238
    searchdomainloop => GetBranchCategories( undef, 'searchdomain' ),
234
        value      => $_,
239
);
235
        branchname => $branches->{$_}->{branchname},
236
        selected   => $user->{branch} eq $_ && C4::Branch::onlymine(),
237
     }
238
} sort {
239
    $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
240
} keys %$branches;
241
242
my $categories = GetBranchCategories('searchdomain');
243
244
$template->param(branchloop => \@branch_loop, searchdomainloop => $categories);
245
240
246
# load the Type stuff
241
# load the Type stuff
247
my $itemtypes = GetItemTypes;
242
my $itemtypes = GetItemTypes;
Lines 407-418 if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) { Link Here
407
}
402
}
408
403
409
# an operand can be a single term, a phrase, or a complete ccl query
404
# an operand can be a single term, a phrase, or a complete ccl query
410
my @operands = map uri_unescape($_), $cgi->param('q');
405
my @operands = map { uri_unescape( $_ ) } $cgi->param('q');
411
406
412
# limits are use to limit to results to a pre-defined category such as branch or language
407
# limits are use to limit to results to a pre-defined category such as branch or language
413
my @limits = map uri_unescape($_), $cgi->param('limit');
408
my @limits = map { uri_unescape($_) } $cgi->param('limit');
414
409
415
if($params->{'multibranchlimit'}) {
410
if( $params->{'multibranchlimit'} ) {
416
    my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
411
    my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
417
    push @limits, $multibranch if ($multibranch ne  '()');
412
    push @limits, $multibranch if ($multibranch ne  '()');
418
}
413
}
(-)a/cataloguing/addbooks.pl (-1 / +2 lines)
Lines 98-108 if ($query) { Link Here
98
    foreach my $line (@newresults) {
98
    foreach my $line (@newresults) {
99
        if ( not exists $line->{'size'} ) { $line->{'size'} = "" }
99
        if ( not exists $line->{'size'} ) { $line->{'size'} = "" }
100
    }
100
    }
101
    my $q = $input->param('q');
101
    $template->param(
102
    $template->param(
102
        total          => $total_hits,
103
        total          => $total_hits,
103
        query          => $query,
104
        query          => $query,
104
        resultsloop    => \@newresults,
105
        resultsloop    => \@newresults,
105
        pagination_bar => pagination_bar( "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ),
106
        pagination_bar => pagination_bar( "/cgi-bin/koha/cataloguing/addbooks.pl?q=$q&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ),
106
    );
107
    );
107
}
108
}
108
109
(-)a/cataloguing/additem.pl (-20 / +23 lines)
Lines 677-682 if ( C4::Context->preference('EasyAnalyticalRecords') ) { Link Here
677
    }
677
    }
678
}
678
}
679
679
680
my $IndependentBranches = !C4::Context->IsSuperLibrarian()
681
  && C4::Context->preference('IndependentBranches');
682
my $IndependentBranchesRecordsAndItems = $IndependentBranches
683
  && C4::Context->preference('IndependentBranchesRecordsAndItems');
680
684
681
foreach my $field (@fields) {
685
foreach my $field (@fields) {
682
    next if ( $field->tag() < 10 );
686
    next if ( $field->tag() < 10 );
Lines 700-714 foreach my $field (@fields) { Link Here
700
						|| $subfieldvalue;
704
						|| $subfieldvalue;
701
        }
705
        }
702
706
703
        if (   $field->tag eq $branchtagfield
707
        if (   $IndependentBranches
704
            && $subfieldcode eq $branchtagsubfield
708
            && $field->tag   eq $branchtagfield
705
            && C4::Context->preference("IndependentBranches") )
709
            && $subfieldcode eq $branchtagsubfield )
706
        {
710
        {
711
707
            #verifying rights
712
            #verifying rights
708
            my $userenv = C4::Context->userenv();
709
            unless (
713
            unless (
710
                $userenv->{'flags'} % 2 == 1
714
                GetIndependentGroupModificationRights(
711
                || GetIndependentGroupModificationRights(
712
                    { for => $subfieldvalue }
715
                    { for => $subfieldvalue }
713
                )
716
                )
714
              )
717
              )
Lines 716-739 foreach my $field (@fields) { Link Here
716
                $this_row{'nomod'} = 1;
719
                $this_row{'nomod'} = 1;
717
            }
720
            }
718
        }
721
        }
719
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
720
722
721
	if ( C4::Context->preference('EasyAnalyticalRecords') ) {
723
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
722
	    foreach my $hostitemnumber (@hostitemnumbers){
723
		if ($this_row{itemnumber} eq $hostitemnumber){
724
			$this_row{hostitemflag} = 1;
725
			$this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber);
726
			last;
727
		}
728
	    }
729
724
730
#	    my $countanalytics=GetAnalyticsCount($this_row{itemnumber});
725
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
731
#           if ($countanalytics > 0){
726
            foreach my $hostitemnumber (@hostitemnumbers) {
732
#                $this_row{countanalytics} = $countanalytics;
727
                if ( $this_row{itemnumber} eq $hostitemnumber ) {
733
#           }
728
                    $this_row{hostitemflag} = 1;
734
	}
729
                    $this_row{hostbiblionumber} =
730
                      GetBiblionumberFromItemnumber($hostitemnumber);
731
                    last;
732
                }
733
            }
734
        }
735
735
736
    }
736
    }
737
738
    next if ( $this_row{'nomod'} && $IndependentBranchesRecordsAndItems );
739
737
    if (%this_row) {
740
    if (%this_row) {
738
        push(@big_array, \%this_row);
741
        push(@big_array, \%this_row);
739
    }
742
    }
(-)a/installer/data/mysql/updatedatabase.pl (-12 / +33 lines)
Lines 6941-6958 if ( CheckVersion($DBversion) ) { Link Here
6941
    SetVersion ($DBversion);
6941
    SetVersion ($DBversion);
6942
}
6942
}
6943
6943
6944
$DBversion = "3.11.00.XXX";
6945
if ( CheckVersion($DBversion) ) {
6946
    $dbh->do(q{
6947
        ALTER TABLE branchcategories
6948
        CHANGE categorytype categorytype
6949
          ENUM( 'searchdomain', 'independent_group' )
6950
            NULL DEFAULT NULL
6951
    });
6952
    print "Upgrade to $DBversion done (Remove branch property groups, add independent groups)\n";
6953
    SetVersion ($DBversion);
6954
}
6955
6956
$DBversion = '3.13.00.003';
6944
$DBversion = '3.13.00.003';
6957
if ( CheckVersion($DBversion) ) {
6945
if ( CheckVersion($DBversion) ) {
6958
    $dbh->do("ALTER TABLE serial DROP itemnumber");
6946
    $dbh->do("ALTER TABLE serial DROP itemnumber");
Lines 7148-7153 if ( CheckVersion($DBversion) ) { Link Here
7148
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo')");
7136
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo')");
7149
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo')");
7137
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo')");
7150
    print "Upgrade to $DBversion done (Bug 7639: system preferences to forgive fines on lost items)\n";
7138
    print "Upgrade to $DBversion done (Bug 7639: system preferences to forgive fines on lost items)\n";
7139
    SetVersion($DBversion);
7140
}
7141
7142
$DBversion = "3.13.00.XXX";
7143
if ( CheckVersion($DBversion) ) {
7144
    $dbh->do(q{
7145
        ALTER TABLE branchcategories
7146
        CHANGE categorytype categorytype
7147
          ENUM( 'searchdomain', 'independent_group' )
7148
            NULL DEFAULT NULL
7149
    });
7150
    print "Upgrade to $DBversion done (Remove branch property groups, add independent groups)\n";
7151
    SetVersion ($DBversion);
7152
}
7153
7154
$DBversion = "3.13.00.XXX";
7155
if ( CheckVersion($DBversion) ) {
7156
    $dbh->do("
7157
        INSERT INTO systempreferences (
7158
            variable,
7159
            value,
7160
            options,
7161
            explanation,
7162
            type
7163
        ) VALUES (
7164
            'IndependentBranchesRecordsAndItems',
7165
            '0',
7166
            '',
7167
            'If on, the staff interface search will hide all records that do not contain an item owned by the logged in branch, and hide the items themselves.',
7168
            'YesNo'
7169
        )
7170
    ");
7171
    print "Upgrade to $DBversion done (Bug 10278 - Add ability to hide items and records from search results for Independent Branches)\n";
7151
    SetVersion ($DBversion);
7172
    SetVersion ($DBversion);
7152
}
7173
}
7153
7174
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc (-28 / +36 lines)
Lines 1-33 Link Here
1
<div class="gradient">
1
<div class="gradient">
2
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Catalogue Resident Search Box -->
2
    <h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Catalogue Resident Search Box -->
3
<div id="header_search">
3
    <div id="header_search">
4
4
5
[% INCLUDE 'patron-search-box.inc' %]
5
        [% INCLUDE 'patron-search-box.inc' %]
6
6
7
[% IF ( CAN_user_circulate ) %]
7
        [% IF ( CAN_user_circulate ) %]
8
<div id="checkin_search" class="residentsearch">
8
            <div id="checkin_search" class="residentsearch">
9
    <p class="tip">Scan a barcode to check in:</p>
9
                <p class="tip">Scan a barcode to check in:</p>
10
    <form method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off">
10
                <form method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off">
11
        <input name="barcode" id="ret_barcode" size="40" />
11
                    <input name="barcode" id="ret_barcode" size="40" />
12
        <input value="Submit" class="submit" type="submit" />
12
                    <input value="Submit" class="submit" type="submit" />
13
    </form>
13
                </form>
14
</div>
14
            </div>
15
	[% END %]
15
        [% END %]
16
	[% IF ( CAN_user_catalogue ) %]
16
17
	<div id="catalog_search" class="residentsearch">
17
        [% IF ( CAN_user_catalogue ) %]
18
	<p class="tip">Enter search keywords:</p>
18
            <div id="catalog_search" class="residentsearch">
19
		<form action="/cgi-bin/koha/catalogue/search.pl"  method="get" id="cat-search-block">
19
            <p class="tip">Enter search keywords:</p>
20
			 <input type="text" name="q" id="search-form" size="40" value="" title="Enter the terms you wish to search for." class="form-text" />
20
                <form action="/cgi-bin/koha/catalogue/search.pl"  method="get" id="cat-search-block">
21
				<input type="submit" class="submit" value="Submit" />
21
                    <input type="text" name="q" id="search-form" size="40" value="" title="Enter the terms you wish to search for." class="form-text" />
22
		</form>
22
                    <input type="submit" class="submit" value="Submit" />
23
	</div>
23
                </form>
24
	[% END %]
24
            </div>
25
	
25
        [% END %]
26
			<ul>
26
27
            [% IF ( CAN_user_circulate ) %]<li><a href="#circ_search">Check out</a></li>[% END %]
27
28
    [% IF ( CAN_user_circulate ) %]<li><a href="#checkin_search">Check in</a></li>[% END %]
28
        <ul>
29
            [% IF ( CAN_user_catalogue ) %]<li class="ui-tabs-selected"><a href="#catalog_search">Search the catalog</a></li>[% END %]
29
            [% IF ( CAN_user_circulate ) %]
30
			</ul>	
30
                <li><a href="#circ_search">Check out</a></li>
31
</div><!-- /header_search -->
31
            [% END %]
32
            [% IF ( CAN_user_circulate ) %]
33
                <li><a href="#checkin_search">Check in</a></li>
34
            [% END %]
35
            [% IF ( CAN_user_catalogue ) %]
36
                <li class="ui-tabs-selected"><a href="#catalog_search">Search the catalog</a></li>
37
            [% END %]
38
        </ul>
39
    </div><!-- /header_search -->
32
</div><!-- /gradient -->
40
</div><!-- /gradient -->
33
<!-- End Catalogue Resident Search Box -->
41
<!-- End Catalogue Resident Search Box -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+7 lines)
Lines 70-75 Administration: Link Here
70
                  yes: Prevent
70
                  yes: Prevent
71
                  no: "Don't prevent"
71
                  no: "Don't prevent"
72
            - staff (but not superlibrarians) from modifying objects (holds, items, patrons, etc.) belonging to other libraries.
72
            - staff (but not superlibrarians) from modifying objects (holds, items, patrons, etc.) belonging to other libraries.
73
        -
74
            - pref: IndependentBranchesRecordsAndItems
75
              default: 0
76
              choices:
77
                  yes: Prevent
78
                  no: "Don't prevent"
79
            - staff from seeing items owned by other libraries, and records without any items the library.
73
    CAS Authentication:
80
    CAS Authentication:
74
        -
81
        -
75
            - pref: casAuthentication
82
            - pref: casAuthentication
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (-26 / +33 lines)
Lines 1-3 Link Here
1
[% USE Koha %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Catalog &rsaquo; Advanced search</title>
3
<title>Koha &rsaquo; Catalog &rsaquo; Advanced search</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 229-262 Link Here
229
[% END %]
230
[% END %]
230
231
231
<!-- AVAILABILITY LIMITS -->
232
<!-- AVAILABILITY LIMITS -->
232
    <fieldset id="availability"><legend>Location and availability</legend>
233
<fieldset id="availability"><legend>Location and availability</legend>
233
<fieldset id="currently-avail">
234
    <fieldset id="currently-avail">
234
        <p><label for="available-items">Only items currently available</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
235
            <p><label for="available-items">Only items currently available</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
235
</fieldset>
236
    </fieldset>
236
237
237
<fieldset id="select-libs">
238
    <fieldset id="select-libs">
238
        <p><label for="branchloop">Individual libraries:</label><select name="limit" id="branchloop" onchange='if(this.value != ""){document.getElementById("categoryloop").disabled=true;} else {document.getElementById("categoryloop").disabled=false;}'>
239
            <p>
239
        <option value="">All libraries</option>
240
                <label for="branchloop">Individual libraries:</label>
240
        [% FOREACH branchloo IN branchloop %]
241
                <select name="limit" id="branchloop" onchange='if(this.value != ""){document.getElementById("categoryloop").disabled=true;} else {document.getElementById("categoryloop").disabled=false;}'>
241
        [% IF ( branchloo.selected ) %]
242
                    <option value="">All libraries</option>
242
        <option value="branch:[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
243
                    [% FOREACH branchloo IN branchloop %]
243
        [% ELSE %]
244
                        [% IF ( branchloo.selected ) %]
244
        <option value="branch:[% branchloo.value %]">[% branchloo.branchname %]</option>
245
                            <option value="branch:[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
245
        [% END %]
246
                        [% ELSE %]
246
        [% END %]
247
                            <option value="branch:[% branchloo.value %]">[% branchloo.branchname %]</option>
247
        </select></p>
248
                        [% END %]
248
    <!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
249
                    [% END %]
249
        [% IF ( searchdomainloop ) %]
250
                </select>
250
    <p>OR</p> <!-- should addjs to grey out group pulldown if a library is selected. -->
251
            </p>
251
        <p><label for="categoryloop">Groups of libraries: </label><select name="multibranchlimit" id="categoryloop">
252
252
        <option value=""> -- none -- </option>
253
            [% IF searchdomainloop && !Koha.Preference('IndependentBranchesRecordsAndItems') %]
253
        [% FOREACH searchdomainloo IN searchdomainloop %]
254
                <p>OR</p> <!-- should addjs to grey out group pulldown if a library is selected. -->
254
        <option value="[% searchdomainloo.categorycode %]">[% searchdomainloo.categoryname %]</option>
255
                <p>
255
        [% END %]
256
                    <label for="categoryloop">Groups of libraries: </label>
256
        </select></p>
257
                    <select name="multibranchlimit" id="categoryloop">
257
    [% END %]
258
                        <option value=""> -- none -- </option>
258
</fieldset>
259
                        [% FOREACH searchdomainloo IN searchdomainloop %]
260
                            <option value="[% searchdomainloo.categorycode %]">[% searchdomainloo.categoryname %]</option>
261
                        [% END %]
262
                    </select>
263
                </p>
264
            [% END %]
259
    </fieldset>
265
    </fieldset>
266
</fieldset>
260
<!-- /AVAILABILITY LIMITS -->
267
<!-- /AVAILABILITY LIMITS -->
261
268
262
<!-- RANK LIMITS -->
269
<!-- RANK LIMITS -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt (+2 lines)
Lines 28-34 Link Here
28
    function GetZ3950Terms(fw){
28
    function GetZ3950Terms(fw){
29
        var strQuery="&frameworkcode=" + fw;
29
        var strQuery="&frameworkcode=" + fw;
30
        [% FOREACH z3950_search_param IN z3950_search_params %]
30
        [% FOREACH z3950_search_param IN z3950_search_params %]
31
/*
31
            strQuery += "&" + "[% z3950_search_param.name %]" + "=" + "[% z3950_search_param.encvalue %]";
32
            strQuery += "&" + "[% z3950_search_param.name %]" + "=" + "[% z3950_search_param.encvalue %]";
33
*/
32
        [% END %]
34
        [% END %]
33
        return strQuery;
35
        return strQuery;
34
    }
36
    }
(-)a/opac/opac-search.pl (-1 / +6 lines)
Lines 407-412 if($params->{'multibranchlimit'}) { Link Here
407
    push @limits, $multibranch if ($multibranch ne  '()');
407
    push @limits, $multibranch if ($multibranch ne  '()');
408
}
408
}
409
409
410
if ( C4::Context->preference('IndependentBranchesRecordsAndItems') ) {
411
    my @branches = GetIndependentGroupModificationRights();
412
    my $allowed = '(' . join( " or ", map { "branch: $_ " } @branches ) . ')';
413
    push( @limits, $allowed ) if ( $allowed ne '()' );
414
}
415
410
my $available;
416
my $available;
411
foreach my $limit(@limits) {
417
foreach my $limit(@limits) {
412
    if ($limit =~/available/) {
418
    if ($limit =~/available/) {
413
- 

Return to bug 10278