@@ -, +, @@ --- C4/Auth.pm | 11 ++- C4/Branch.pm | 68 ++++++++++++-------- admin/branches.pl | 3 + installer/data/mysql/kohastructure.sql | 4 +- installer/data/mysql/updatedatabase.pl | 10 +++ .../prog/en/modules/admin/branches.tt | 8 ++ koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc | 28 ++++++++- koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 27 ++++++++- 8 files changed, 126 insertions(+), 33 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -383,6 +383,8 @@ sub get_template_and_user { my $opac_name = ''; if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){ $opac_name = $1; # opac_search_limit is a branch, so we use it. + } elsif ( $in->{'query'}->param('multibranchlimit') ) { + $opac_name = $in->{'query'}->param('multibranchlimit'); } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) { $opac_name = C4::Context->userenv->{'branch'}; } @@ -391,13 +393,14 @@ sub get_template_and_user { AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), AuthorisedValueImages => C4::Context->preference("AuthorisedValueImages"), BranchesLoop => GetBranchesLoop($opac_name), - CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, + BranchCategoriesLoop => GetBranchCategories( undef, undef, 1, $opac_name ), + CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, LibraryName => "" . C4::Context->preference("LibraryName"), LibraryNameTitle => "" . $LibraryNameTitle, LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"", OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), - OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), + OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), OPACItemHolds => C4::Context->preference("OPACItemHolds"), OPACShelfBrowser => "". C4::Context->preference("OPACShelfBrowser"), OpacShowRecentComments => C4::Context->preference("OpacShowRecentComments"), @@ -408,7 +411,7 @@ sub get_template_and_user { OpacAuthorities => C4::Context->preference("OpacAuthorities"), OPACBaseURL => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} . ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"), - opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, + opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, opac_search_limit => $opac_search_limit, opac_limit_override => $opac_limit_override, OpacBrowser => C4::Context->preference("OpacBrowser"), @@ -422,7 +425,7 @@ sub get_template_and_user { OpacNavRight => "" . C4::Context->preference("OpacNavRight"), OpacNavBottom => "" . C4::Context->preference("OpacNavBottom"), OpacPasswordChange => C4::Context->preference("OpacPasswordChange"), - OPACPatronDetails => C4::Context->preference("OPACPatronDetails"), + OPACPatronDetails => C4::Context->preference("OPACPatronDetails"), OPACPrivacy => C4::Context->preference("OPACPrivacy"), OPACFinesTab => C4::Context->preference("OPACFinesTab"), OpacTopissue => C4::Context->preference("OpacTopissue"), --- a/C4/Branch.pm +++ a/C4/Branch.pm @@ -328,7 +328,7 @@ sub GetBranchCategory { =head2 GetBranchCategories - my $categories = GetBranchCategories($branchcode,$categorytype); + my $categories = GetBranchCategories($branchcode,$categorytype,$show_in_pulldown,$selected_in_pulldown); Returns a list ref of anon hashrefs with keys eq columns of branchcategories table, i.e. categorycode, categorydescription, categorytype, categoryname. @@ -338,27 +338,43 @@ $branchcode is a member of , and to $categorytype. =cut sub GetBranchCategories { - my ($branchcode,$categorytype) = @_; - my $dbh = C4::Context->dbh(); - my $query = "SELECT c.* FROM branchcategories c"; - my (@where, @bind); - if($branchcode) { - $query .= ",branchrelations r, branches b "; - push @where, "c.categorycode=r.categorycode and r.branchcode=? "; - push @bind , $branchcode; - } - if ($categorytype) { - push @where, " c.categorytype=? "; - push @bind, $categorytype; - } - $query .= " where " . join(" and ", @where) if(@where); - $query .= " order by categorytype,c.categorycode"; - my $sth=$dbh->prepare( $query); - $sth->execute(@bind); - - my $branchcats = $sth->fetchall_arrayref({}); - $sth->finish(); - return( $branchcats ); + my ( $branchcode, $categorytype, $show_in_pulldown, $selected_in_pulldown ) = @_; + my $dbh = C4::Context->dbh(); + + my $query = "SELECT c.* FROM branchcategories c"; + my ( @where, @bind ); + + if( $branchcode ) { + $query .= ",branchrelations r, branches b "; + push @where, "c.categorycode = r.categorycode AND r.branchcode = ? "; + push @bind , $branchcode; + } + + if ( $categorytype ) { + push @where, " c.categorytype = ? "; + push @bind, $categorytype; + } + + if ( defined( $show_in_pulldown ) ) { + push( @where, " c.show_in_pulldown = ? " ); + push( @bind, $show_in_pulldown ); + } + + $query .= " WHERE " . join(" AND ", @where) if(@where); + $query .= " ORDER BY categorytype,c.categorycode"; + my $sth=$dbh->prepare( $query); + $sth->execute(@bind); + + my $branchcats = $sth->fetchall_arrayref({}); + $sth->finish(); + + if ( $selected_in_pulldown ) { + foreach my $bc ( @$branchcats ) { + $bc->{'selected'} = 1 if ( $bc->{'categorycode'} eq $selected_in_pulldown ); + } + } + + return( $branchcats ); } =head2 GetCategoryTypes @@ -506,14 +522,14 @@ sub ModBranchCategoryInfo { my $dbh = C4::Context->dbh; if ($data->{'add'}){ # we are doing an insert - my $sth = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype) VALUES (?,?,?,?)"); - $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} ); + my $sth = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype,show_in_pulldown) VALUES (?,?,?,?,?)"); + $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'} ); $sth->finish(); } else { # modifying - my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=? WHERE categorycode=?"); - $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},uc( $data->{'categorycode'} ) ); + my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=?,show_in_pulldown=? WHERE categorycode=?"); + $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) ); $sth->finish(); } } --- a/admin/branches.pl +++ a/admin/branches.pl @@ -168,6 +168,8 @@ elsif ( $op eq 'addcategory_validate' ) { $template->param( else => 1 ); # confirm settings change... my $params = $input->Vars; + $params->{'show_in_pulldown'} = ( $params->{'show_in_pulldown'} eq 'on' ) ? 1 : 0; + unless ( $params->{'categorycode'} && $params->{'categoryname'} ) { default("MESSAGE4",$template); } @@ -294,6 +296,7 @@ sub editcatform { categorycode => $data->{'categorycode'}, categoryname => $data->{'categoryname'}, codedescription => $data->{'codedescription'}, + show_in_pulldown => $data->{'show_in_pulldown'}, ); } for my $ctype (GetCategoryTypes()) { --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -340,7 +340,9 @@ CREATE TABLE `branchcategories` ( -- information related to library/branch group `categoryname` varchar(32), -- name of the library/branch group `codedescription` mediumtext, -- longer description of the library/branch group `categorytype` varchar(16), -- says whether this is a search group or a properties group - PRIMARY KEY (`categorycode`) + `show_in_pulldown` tinyint(1) NOT NULL DEFAULT '0', -- says this group should be in the opac libararies pulldown if it is enabled + PRIMARY KEY (`categorycode`), + KEY `show_in_pulldown` (`show_in_pulldown`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6339,6 +6339,16 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.11.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(q{ + ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0', + ADD INDEX ( show_in_pulldown ) + }); + print "Upgrade to $DBversion done (Bug 9167: Update the virtualshelves.sortfield column with 'copyrightdate' if needed)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -346,6 +346,14 @@ tinyMCE.init({ [% END %] +
  • + + [% IF ( show_in_pulldown ) %] + + [% ELSE %] + + [% END %] +
  • --- a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc +++ a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc @@ -156,13 +156,39 @@ [% ELSE %]
    [% END %] - [% FOREACH BranchesLoo IN BranchesLoop %] [% IF ( BranchesLoo.selected ) %] [% ELSE %][% END %] [% END %] + [% IF BranchCategoriesLoop %] + + [% FOREACH bc IN BranchCategoriesLoop %] + [% IF ( bc.selected ) %] + + [% ELSE %] + + [% END %] + [% END %] + [% END %] + [% IF BranchCategoriesLoop %] + + [% END %]
    [% ELSE %] [% IF ( opac_limit_override ) %] --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -77,13 +77,38 @@
    [% END %] [% IF ( OpacAddMastheadLibraryPulldown ) %] - [% FOREACH BranchesLoo IN BranchesLoop %] [% IF ( BranchesLoo.selected ) %] [% ELSE %][% END %] [% END %] + [% IF BranchCategoriesLoop %] + + [% FOREACH bc IN BranchCategoriesLoop %] + [% IF ( bc.selected ) %] + + [% ELSE %] + + [% END %] + [% END %] + [% END %] + [% IF BranchCategoriesLoop %] + + [% END %] [% ELSE %] [% IF ( opac_limit_override ) %] [% IF ( opac_search_limit ) %] --