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

(-)a/C4/Auth.pm (-1 / +1 lines)
Lines 679-685 sub checkauth { Link Here
679
                $session->param('surname'),      $session->param('branch'),
679
                $session->param('surname'),      $session->param('branch'),
680
                $session->param('branchname'),   $session->param('flags'),
680
                $session->param('branchname'),   $session->param('flags'),
681
                $session->param('emailaddress'), $session->param('branchprinter'),
681
                $session->param('emailaddress'), $session->param('branchprinter'),
682
                $session->param('persona')
682
                $session->param('persona'),      $type
683
            );
683
            );
684
            C4::Context::set_shelves_userenv('bar',$session->param('barshelves'));
684
            C4::Context::set_shelves_userenv('bar',$session->param('barshelves'));
685
            C4::Context::set_shelves_userenv('pub',$session->param('pubshelves'));
685
            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 1111-1133 set_userenv is called in Auth.pm Link Here
1111
1111
1112
#'
1112
#'
1113
sub set_userenv {
1113
sub set_userenv {
1114
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $persona)= @_;
1114
    my (
1115
    my $var=$context->{"activeuser"} || '';
1115
        $usernum,      $userid,        $usercnum,   $userfirstname,
1116
        $usersurname,  $userbranch,    $branchname, $userflags,
1117
        $emailaddress, $branchprinter, $persona,    $type
1118
    ) = @_;
1119
1120
    my $var = $context->{"activeuser"} || '';
1121
1116
    my $cell = {
1122
    my $cell = {
1117
        "number"     => $usernum,
1123
        "number"        => $usernum,
1118
        "id"         => $userid,
1124
        "id"            => $userid,
1119
        "cardnumber" => $usercnum,
1125
        "cardnumber"    => $usercnum,
1120
        "firstname"  => $userfirstname,
1126
        "firstname"     => $userfirstname,
1121
        "surname"    => $usersurname,
1127
        "surname"       => $usersurname,
1122
        #possibly a law problem
1128
        "branch"        => $userbranch,
1123
        "branch"     => $userbranch,
1129
        "branchname"    => $branchname,
1124
        "branchname" => $branchname,
1130
        "flags"         => $userflags,
1125
        "flags"      => $userflags,
1131
        "emailaddress"  => $emailaddress,
1126
        "emailaddress"     => $emailaddress,
1132
        "branchprinter" => $branchprinter,
1127
        "branchprinter"    => $branchprinter,
1133
        "persona"       => $persona,
1128
        "persona"    => $persona,
1134
        "type"          => $type,
1129
    };
1135
    };
1136
1130
    $context->{userenv}->{$var} = $cell;
1137
    $context->{userenv}->{$var} = $cell;
1138
1131
    return $cell;
1139
    return $cell;
1132
}
1140
}
1133
1141
(-)a/C4/Items.pm (-1 / +9 lines)
Lines 1228-1233 If this is set, it is set to C<One Order>. Link Here
1228
1228
1229
sub GetItemsInfo {
1229
sub GetItemsInfo {
1230
    my ( $biblionumber ) = @_;
1230
    my ( $biblionumber ) = @_;
1231
1232
    my $IndependentBranchesRecordsAndItems =
1233
      C4::Context->preference('IndependentBranchesRecordsAndItems')
1234
      && !C4::Context->IsSuperLibrarian();
1235
1231
    my $dbh   = C4::Context->dbh;
1236
    my $dbh   = C4::Context->dbh;
1232
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1237
    # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
1233
    my $query = "
1238
    my $query = "
Lines 1257-1263 sub GetItemsInfo { Link Here
1257
     LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber
1262
     LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber
1258
     LEFT JOIN itemtypes   ON   itemtypes.itemtype         = "
1263
     LEFT JOIN itemtypes   ON   itemtypes.itemtype         = "
1259
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
1264
     . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
1260
    $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1265
    $query .= " WHERE items.biblionumber = ? ";
1266
    $query .= " AND items.homebranch IN ( " . GetIndependentGroupModificationRights({ stringify => 1}) . " ) " if ( $IndependentBranchesRecordsAndItems );
1267
    $query .= " ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1268
1261
    my $sth = $dbh->prepare($query);
1269
    my $sth = $dbh->prepare($query);
1262
    $sth->execute($biblionumber);
1270
    $sth->execute($biblionumber);
1263
    my $i = 0;
1271
    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 1578-1583 sub buildQuery { Link Here
1578
        $limit .= "($availability_limit)";
1593
        $limit .= "($availability_limit)";
1579
    }
1594
    }
1580
1595
1596
    if ( C4::Context->preference('IndependentBranchesRecordsAndItems') ) {
1597
        my $search_context = C4::Context->userenv->{type};
1598
        my $IndependentBranchesRecordsAndItems;
1599
        if ( $search_context eq 'opac' ) {
1600
            # For the OPAC, if IndependentBranchesRecordsAndItems is enabled,
1601
            # and BRANCHCODE has been set in the httpd conf,
1602
            # we need to filter the items
1603
            $IndependentBranchesRecordsAndItems = $ENV{BRANCHCODE};
1604
        }
1605
        else {
1606
            # For the intranet, if IndependentBranchesRecordsAndItems is enabled,
1607
            # and the user is not a superlibrarian,
1608
            # we need to filter the items
1609
            $IndependentBranchesRecordsAndItems = !C4::Context->IsSuperLibrarian();
1610
        }
1611
        my @allowed_branches = $IndependentBranchesRecordsAndItems ? GetIndependentGroupModificationRights() : ();
1612
1613
        if ( @allowed_branches ) {
1614
            $limit .= " and " if ( $query || $limit );
1615
            $limit .= "(" . join( " or ", map { "branch:$_" } @allowed_branches ) . ")";
1616
        }
1617
    }
1618
1581
    # Normalize the query and limit strings
1619
    # Normalize the query and limit strings
1582
    # This is flawed , means we can't search anything with : in it
1620
    # This is flawed , means we can't search anything with : in it
1583
    # if user wants to do ccl or cql, start the query with that
1621
    # if user wants to do ccl or cql, start the query with that
Lines 1839-1852 sub searchResults { Link Here
1839
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
1877
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
1840
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
1878
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
1841
1879
1880
        my $IndependentBranchesRecordsAndItems;
1881
        if ( $search_context eq 'opac' ) {
1882
            # For the OPAC, if IndependentBranchesRecordsAndItems is enabled,
1883
            # and BRANCHCODE has been set in the httpd conf,
1884
            # we need to filter the items
1885
            $IndependentBranchesRecordsAndItems =
1886
              C4::Context->preference('IndependentBranchesRecordsAndItems')
1887
              && $ENV{BRANCHCODE};
1888
        }
1889
        else {
1890
            # For the intranet, if IndependentBranchesRecordsAndItems is enabled,
1891
            # and the user is not a superlibrarian,
1892
            # we need to filter the items
1893
            $IndependentBranchesRecordsAndItems =
1894
              C4::Context->preference('IndependentBranchesRecordsAndItems')
1895
              && !C4::Context->IsSuperLibrarian();
1896
        }
1897
        my @allowed_branches = $IndependentBranchesRecordsAndItems ? GetIndependentGroupModificationRights() : undef;
1898
1842
        # loop through every item
1899
        # loop through every item
1900
        my $index = -1;
1843
        foreach my $field (@fields) {
1901
        foreach my $field (@fields) {
1902
            $index++;
1844
            my $item;
1903
            my $item;
1845
1904
1846
            # populate the items hash
1905
            # populate the items hash
1847
            foreach my $code ( keys %subfieldstosearch ) {
1906
            foreach my $code ( keys %subfieldstosearch ) {
1848
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1907
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
1849
            }
1908
            }
1909
1910
            # if IndependentBranchesRecordsAndItems is enabled, and this record
1911
            # isn't allowed to be viewed, remove it from the items list and go
1912
            # right to the next item.
1913
            if ( $IndependentBranchesRecordsAndItems ) {
1914
                if ( none { $_ eq $item->{homebranch} } @allowed_branches ) {
1915
                    splice(@fields, $index, 1);
1916
                    $items_count--;
1917
                    next;
1918
                }
1919
            }
1920
1850
            $item->{description} = $itemtypes{ $item->{itype} }{description};
1921
            $item->{description} = $itemtypes{ $item->{itype} }{description};
1851
1922
1852
	        # OPAC hidden items
1923
	        # OPAC hidden items
(-)a/C4/Serials.pm (+4 lines)
Lines 777-782 sub SearchSubscriptions { Link Here
777
        push @where_strs, "subscription.closed = ?";
777
        push @where_strs, "subscription.closed = ?";
778
        push @where_args, "$args->{closed}";
778
        push @where_args, "$args->{closed}";
779
    }
779
    }
780
    if( C4::Context->preference('IndependentBranchesRecordsAndItems') && !C4::Context->IsSuperlibrarian() ) {
781
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
782
        push @where_strs, "subscription.branchcode IN ( $branches )";
783
    }
780
    if(@where_strs){
784
    if(@where_strs){
781
        $query .= " WHERE " . join(" AND ", @where_strs);
785
        $query .= " WHERE " . join(" AND ", @where_strs);
782
    }
786
    }
(-)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 672-677 if ( C4::Context->preference('EasyAnalyticalRecords') ) { Link Here
672
    }
672
    }
673
}
673
}
674
674
675
my $IndependentBranches = !C4::Context->IsSuperLibrarian()
676
  && C4::Context->preference('IndependentBranches');
677
my $IndependentBranchesRecordsAndItems = $IndependentBranches
678
  && C4::Context->preference('IndependentBranchesRecordsAndItems');
675
679
676
foreach my $field (@fields) {
680
foreach my $field (@fields) {
677
    next if ( $field->tag() < 10 );
681
    next if ( $field->tag() < 10 );
Lines 695-709 foreach my $field (@fields) { Link Here
695
						|| $subfieldvalue;
699
						|| $subfieldvalue;
696
        }
700
        }
697
701
698
        if (   $field->tag eq $branchtagfield
702
        if (   $IndependentBranches
699
            && $subfieldcode eq $branchtagsubfield
703
            && $field->tag   eq $branchtagfield
700
            && C4::Context->preference("IndependentBranches") )
704
            && $subfieldcode eq $branchtagsubfield )
701
        {
705
        {
706
702
            #verifying rights
707
            #verifying rights
703
            my $userenv = C4::Context->userenv();
704
            unless (
708
            unless (
705
                $userenv->{'flags'} % 2 == 1
709
                GetIndependentGroupModificationRights(
706
                || GetIndependentGroupModificationRights(
707
                    { for => $subfieldvalue }
710
                    { for => $subfieldvalue }
708
                )
711
                )
709
              )
712
              )
Lines 711-734 foreach my $field (@fields) { Link Here
711
                $this_row{'nomod'} = 1;
714
                $this_row{'nomod'} = 1;
712
            }
715
            }
713
        }
716
        }
714
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
715
717
716
	if ( C4::Context->preference('EasyAnalyticalRecords') ) {
718
        $this_row{itemnumber} = $subfieldvalue if ($field->tag() eq $itemtagfield && $subfieldcode eq $itemtagsubfield);
717
	    foreach my $hostitemnumber (@hostitemnumbers){
718
		if ($this_row{itemnumber} eq $hostitemnumber){
719
			$this_row{hostitemflag} = 1;
720
			$this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber);
721
			last;
722
		}
723
	    }
724
719
725
#	    my $countanalytics=GetAnalyticsCount($this_row{itemnumber});
720
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
726
#           if ($countanalytics > 0){
721
            foreach my $hostitemnumber (@hostitemnumbers) {
727
#                $this_row{countanalytics} = $countanalytics;
722
                if ( $this_row{itemnumber} eq $hostitemnumber ) {
728
#           }
723
                    $this_row{hostitemflag} = 1;
729
	}
724
                    $this_row{hostbiblionumber} =
725
                      GetBiblionumberFromItemnumber($hostitemnumber);
726
                    last;
727
                }
728
            }
729
        }
730
730
731
    }
731
    }
732
733
    next if ( $this_row{'nomod'} && $IndependentBranchesRecordsAndItems );
734
732
    if (%this_row) {
735
    if (%this_row) {
733
        push(@big_array, \%this_row);
736
        push(@big_array, \%this_row);
734
    }
737
    }
(-)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