Bugzilla – Attachment 57101 Details for
Bug 16735
Replace existing library search groups functionality with the new hierarchical groups system
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16735 - Replace existing library search groups functionality with the new hierarchical groups system
Bug-16735---Replace-existing-library-search-groups.patch (text/plain), 38.02 KB, created by
Kyle M Hall (khall)
on 2016-11-02 13:41:51 UTC
(
hide
)
Description:
Bug 16735 - Replace existing library search groups functionality with the new hierarchical groups system
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-11-02 13:41:51 UTC
Size:
38.02 KB
patch
obsolete
>From 33dab7219827a19a5ff6abd6e05394d1ea411223 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 22 Jun 2016 17:10:23 +0000 >Subject: [PATCH] Bug 16735 - Replace existing library search groups > functionality with the new hierarchical groups system > >Test Plan: >1) Apply this patch set >2) Note your existing search groups have been ported over to the new > __SEARCH_GROUPS__ group if you had any >3) Create the group __SEARCH_GROUPS__ if one does not already exist >4) Add some first level subgroups to this group, add libraries to those groups >5) Search the library group searching in the intranet and opac >6) Note you get the same results as pre-patch >--- > C4/Auth.pm | 6 +- > Koha/Library.pm | 19 --- > Koha/Library/Group.pm | 34 ++++-- > Koha/Library/Groups.pm | 23 ++++ > admin/branches.pl | 85 +------------ > catalogue/search.pl | 16 ++- > installer/data/mysql/updatedatabase.pl | 38 ++++++ > .../intranet-tmpl/prog/en/includes/admin-menu.inc | 2 +- > .../prog/en/modules/admin/admin-home.tt | 6 +- > .../prog/en/modules/admin/branches.tt | 136 +-------------------- > .../prog/en/modules/catalogue/advsearch.tt | 20 +-- > .../opac-tmpl/bootstrap/en/includes/masthead.inc | 26 ++-- > .../bootstrap/en/modules/opac-advsearch.tt | 6 +- > opac/opac-search.pl | 10 +- > t/db_dependent/Koha/Libraries.t | 37 +----- > t/db_dependent/RotatingCollections.t | 1 - > 16 files changed, 144 insertions(+), 321 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 6b7dc66..1037a0d 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -33,8 +33,8 @@ use C4::Search::History; > use Koha; > use Koha::Caches; > use Koha::AuthUtils qw(get_script_name hash_password); >+use Koha::Library::Groups; > use Koha::Libraries; >-use Koha::LibraryCategories; > use Koha::Patrons; > use POSIX qw/strftime/; > use List::MoreUtils qw/ any /; >@@ -509,11 +509,11 @@ sub get_template_and_user { > $opac_name = C4::Context->userenv->{'branch'}; > } > >- my $library_categories = Koha::LibraryCategories->search({categorytype => 'searchdomain', show_in_pulldown => 1}, { order_by => ['categorytype', 'categorycode']}); >+ my $search_groups = Koha::Library::Groups->get_search_groups(); > $template->param( > OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"), > AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), >- BranchCategoriesLoop => $library_categories, >+ LibrarySearchGroups => $search_groups, > opac_name => $opac_name, > LibraryName => "" . C4::Context->preference("LibraryName"), > LibraryNameTitle => "" . $LibraryNameTitle, >diff --git a/Koha/Library.pm b/Koha/Library.pm >index 44088ea..786f457 100644 >--- a/Koha/Library.pm >+++ b/Koha/Library.pm >@@ -35,25 +35,6 @@ Koha::Library - Koha Library Object class > > =cut > >-sub get_categories { >- my ( $self, $params ) = @_; >- # TODO This should return Koha::LibraryCategories >- return $self->{_result}->categorycodes( $params ); >-} >- >-sub update_categories { >- my ( $self, $categories ) = @_; >- $self->_result->delete_related( 'branchrelations' ); >- $self->add_to_categories( $categories ); >-} >- >-sub add_to_categories { >- my ( $self, $categories ) = @_; >- for my $category ( @$categories ) { >- $self->_result->add_to_categorycodes( $category->_result ); >- } >-} >- > =head3 type > > =cut >diff --git a/Koha/Library/Group.pm b/Koha/Library/Group.pm >index cd53899..ea3c33c 100644 >--- a/Koha/Library/Group.pm >+++ b/Koha/Library/Group.pm >@@ -59,7 +59,7 @@ sub children { > my $children = > Koha::Library::Groups->search( { parent_id => $self->id }, { order_by => [ 'title', 'branchcode' ] } ); > >- return $children; >+ return wantarray ? $children->as_list : $children; > } > > =head3 library >@@ -80,16 +80,22 @@ sub library { > return $self->{_library}; > } > >-=head3 libraries_not_direct_children >+=head3 libraries > >-my @libraries = $group->libraries_not_direct_children(); >+my @libraries = $group->libraries( { [invert => 1] } ); > >-Returns the libraries *not* set as direct children of this group >+Returns the libraries set as direct children of this group. >+ >+If invert param is true, the returned list will be libraries >+that are *not* direct children of this group. > > =cut > >-sub libraries_not_direct_children { >- my ($self) = @_; >+sub libraries { >+ my ($self, $params) = @_; >+ my $invert = $params->{invert}; >+ >+ my $in_or_not = $invert ? '-not_in' : '-in'; > > my @children = Koha::Library::Groups->search( > { >@@ -103,7 +109,7 @@ sub libraries_not_direct_children { > > return Koha::Libraries->search( > { >- branchcode => { -not_in => \@branchcodes } >+ branchcode => { $in_or_not => \@branchcodes } > }, > { > order_by => 'branchname' >@@ -111,6 +117,20 @@ sub libraries_not_direct_children { > ); > } > >+=head3 libraries_not_direct_children >+ >+my @libraries = $group->libraries_not_direct_children(); >+ >+Returns the libraries *not* set as direct children of this group >+ >+=cut >+ >+sub libraries_not_direct_children { >+ my ($self) = @_; >+ >+ return $self->libraries( { invert => 1 } ); >+} >+ > =head3 store > > =cut >diff --git a/Koha/Library/Groups.pm b/Koha/Library/Groups.pm >index 9b1356a..d3cb72a 100644 >--- a/Koha/Library/Groups.pm >+++ b/Koha/Library/Groups.pm >@@ -45,6 +45,29 @@ sub get_root_groups { > return $self->search( { parent_id => undef }, { order_by => 'title' } ); > } > >+=head3 my @search_groups = $self->get_search_groups({[interface => 'staff' || 'opac']})) >+ >+Returns search groups for the specified interface. >+Defaults to OPAC if no interface is specified. >+ >+=cut >+ >+sub get_search_groups { >+ my ( $self, $params ) = @_; >+ my $interface = $params->{interface} || q{}; >+ >+ my $title = $interface eq 'staff' ? '__SEARCH_GROUPS__' : '__SEARCH_GROUPS_OPAC__'; >+ >+ my ($search_groups_root) = >+ $self->search( { parent_id => undef, title => $title } ); >+ >+ return unless $search_groups_root; >+ >+ my $children = $search_groups_root->children(); >+ >+ return wantarray ? $children->as_list : $children; >+} >+ > =head3 type > > =cut >diff --git a/admin/branches.pl b/admin/branches.pl >index abe3e5a..cdc4a7b 100755 >--- a/admin/branches.pl >+++ b/admin/branches.pl >@@ -27,7 +27,6 @@ use C4::Koha; > use Koha::Patrons; > use Koha::Items; > use Koha::Libraries; >-use Koha::LibraryCategories; > > my $input = new CGI; > my $branchcode = $input->param('branchcode'); >@@ -53,8 +52,6 @@ if ( $op eq 'add_form' ) { > > $template->param( > library => $library, >- categories => [ Koha::LibraryCategories->search( {}, { order_by => [ 'categorytype', 'categoryname' ] } ) ], >- $library ? ( selected_categorycodes => [ map { $_->categorycode } $library->get_categories ] ) : (), > ); > } elsif ( $op eq 'add_validate' ) { > my @fields = qw( >@@ -79,18 +76,11 @@ if ( $op eq 'add_form' ) { > ); > my $is_a_modif = $input->param('is_a_modif'); > >- my @categories; >- for my $category ( Koha::LibraryCategories->search ) { >- push @categories, $category >- if $input->param( "selected_categorycode_" . $category->categorycode ); >- } > if ($is_a_modif) { > my $library = Koha::Libraries->find($branchcode); > for my $field (@fields) { > $library->$field( scalar $input->param($field) ); > } >- $library->update_categories( \@categories ); >- > eval { $library->store; }; > if ($@) { > push @messages, { type => 'alert', code => 'error_on_update' }; >@@ -105,7 +95,6 @@ if ( $op eq 'add_form' ) { > } > ); > eval { $library->store; }; >- $library->add_to_categories( \@categories ); > if ($@) { > push @messages, { type => 'alert', code => 'error_on_insert' }; > } else { >@@ -152,85 +141,13 @@ if ( $op eq 'add_form' ) { > push @messages, { type => 'message', code => 'success_on_delete' }; > } > $op = 'list'; >-} elsif ( $op eq 'add_form_category' ) { >- my $category; >- if ($categorycode) { >- $category = Koha::LibraryCategories->find($categorycode); >- } >- $template->param( category => $category, ); >-} elsif ( $op eq 'add_validate_category' ) { >- my $is_a_modif = $input->param('is_a_modif'); >- my @fields = qw( >- categoryname >- codedescription >- categorytype >- ); >- if ($is_a_modif) { >- my $category = Koha::LibraryCategories->find($categorycode); >- for my $field (@fields) { >- $category->$field( scalar $input->param($field) ); >- } >- $category->show_in_pulldown( scalar $input->param('show_in_pulldown') eq 'on' ); >- eval { $category->store; }; >- if ($@) { >- push @messages, { type => 'alert', code => 'error_on_update_category' }; >- } else { >- push @messages, { type => 'message', code => 'success_on_update_category' }; >- } >- } else { >- my $category = Koha::LibraryCategory->new( >- { categorycode => $categorycode, >- ( map { $_ => scalar $input->param($_) || undef } @fields ) >- } >- ); >- $category->show_in_pulldown( scalar $input->param('show_in_pulldown') eq 'on' ); >- eval { $category->store; }; >- if ($@) { >- push @messages, { type => 'alert', code => 'error_on_insert_category' }; >- } else { >- push @messages, { type => 'message', code => 'success_on_insert_category' }; >- } >- } >- $op = 'list'; >-} elsif ( $op eq 'delete_confirm_category' ) { >- my $category = Koha::LibraryCategories->find($categorycode); >- if ( my $libraries_count = $category->libraries->count ) { >- push @messages, >- { type => 'alert', >- code => 'cannot_delete_category', >- data => { libraries_count => $libraries_count, }, >- }; >- $op = 'list'; >- } else { >- $template->param( category => $category ); >- } >-} elsif ( $op eq 'delete_confirmed_category' ) { >- my $category = Koha::LibraryCategories->find($categorycode); >- my $deleted = eval { $category->delete; }; >- >- if ( $@ or not $deleted ) { >- push @messages, { type => 'alert', code => 'error_on_delete_category' }; >- } else { >- push @messages, { type => 'message', code => 'success_on_delete_category' }; >- } >- $op = 'list'; > } else { > $op = 'list'; > } > > if ( $op eq 'list' ) { > my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >- $template->param( >- libraries => $libraries, >- group_types => [ >- { categorytype => 'searchdomain', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'searchdomain' } ) ], >- }, >- { categorytype => 'properties', >- categories => [ Koha::LibraryCategories->search( { categorytype => 'properties' } ) ], >- }, >- ] >- ); >+ $template->param( libraries => $libraries, ); > } > > $template->param( >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 5855bf1..e139447 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -151,7 +151,7 @@ use URI::Escape; > use POSIX qw(ceil floor); > use C4::Search::History; > >-use Koha::LibraryCategories; >+use Koha::Library::Groups; > use Koha::Virtualshelves; > use Koha::SearchEngine::Search; > use Koha::SearchEngine::QueryBuilder; >@@ -212,12 +212,16 @@ if($cgi->cookie("intranet_bib_list")){ > @cart_list = split(/\//, $cart_list); > } > >-# load the branches >-my $categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } ); >+my @search_groups_opac = >+ Koha::Library::Groups->get_search_groups( { interface => 'opac' } ); >+my @search_groups_staff = >+ Koha::Library::Groups->get_search_groups( { interface => 'staff' } ); >+my @search_groups = ( @search_groups_opac, @search_groups_staff ); >+@search_groups = sort { $a->title cmp $b->title } @search_groups; > > $template->param( > selected_branchcode => ( C4::Context->IsSuperLibrarian ? C4::Context->userenv : '' ), >- searchdomainloop => $categories >+ search_groups => \@search_groups, > ); > > # load the Type stuff >@@ -398,8 +402,8 @@ my %is_nolimit = map { $_ => 1 } @nolimits; > @limits = grep { not $is_nolimit{$_} } @limits; > > if($params->{'multibranchlimit'}) { >- my $library_category = Koha::LibraryCategories->find( $params->{multibranchlimit} ); >- my @libraries = $library_category->libraries; >+ my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} ); >+ my @libraries = $search_group->libraries; > my $multibranch = '('.join( " or ", map { 'branch: ' . $_->id } @libraries ) .')'; > push @limits, $multibranch if ($multibranch ne '()'); > } >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index f1989df..f4b5a2e 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -13619,6 +13619,44 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "XXX"; >+if ( CheckVersion($DBversion) ) { >+ require Koha::Library::Group; >+ >+ my $search_groups_staff_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS__', description => "Library search groups - Staff only" } )->store(); >+ my $search_groups_opac_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS_OPAC__', description => "Library search groups - OPAC & Staff" } )->store(); >+ >+ my $sth = $dbh->prepare("SELECT * FROM branchcategories"); >+ $sth->execute(); >+ >+ while ( my $lc = $sth->fetchrow_hashref ) { >+ my $description = $lc->{categorycode}; >+ $description .= " - " . $lc->{codedescription} if $lc->{codedescription}; >+ >+ my $subgroup = Koha::Library::Group->new( >+ { >+ parent_id => $lc->{show_in_pulldown} ? $search_groups_opac_root->id : $search_groups_staff_root->id, >+ title => $lc->{categoryname}, >+ description => $description, >+ } >+ )->store(); >+ >+ my $sth2 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?"); >+ $sth2->execute( $lc->{categorycode} ); >+ >+ while ( my $l = $sth2->fetchrow_hashref ) { >+ Koha::Library::Group->new( { parent_id => $subgroup->id, branchcode => $l->{branchcode} } )->store(); >+ } >+ } >+ >+# RM Should uncomment these >+# $dbh->do("DROP TABLE branchrelations"); >+# $dbh->do("DROP TABLE branchcategories"); >+ >+ print "Upgrade to $DBversion done (Bug 16735 - Replace existing library search groups functionality with the new hierarchical groups system)\n"; >+ SetVersion($DBversion); >+} >+ > # DEVELOPER PROCESS, search for anything to execute in the db_update directory > # SEE bug 13068 > # if there is anything in the atomicupdate, read and execute it. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index 9a5a1cb..f5f3681 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -20,7 +20,7 @@ > > <h5>Basic parameters</h5> > <ul> >- <li><a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a></li> >+ <li><a href="/cgi-bin/koha/admin/branches.pl">Libraries</a></li> > <li><a href="/cgi-bin/koha/admin/library_groups.pl">Library groups</a></li> > <li><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a></li> > <li><a href="/cgi-bin/koha/admin/authorised_values.pl">Authorized values</a></li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 47bb5f6..635a86d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -29,10 +29,10 @@ > <div class="hint"><h4>Hint:</h4><p>Configure these parameters in the order they appear.</p></div> > <h3>Basic parameters</h3> > <dl> >- <dt><a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a></dt> >- <dd>Define libraries and groups.</dd> >+ <dt><a href="/cgi-bin/koha/admin/branches.pl">Libraries</a></dt> >+ <dd>Define libraries.</dd> > <dt><a href="/cgi-bin/koha/admin/library_groups.pl">Library groups</a></dt> >- <dd>Define library hierarchies.</dd> >+ <dd>Define hierarchical library groups.</dd> > <dt><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a></dt> > <dd>Define item types used for circulation rules.</dd> > <dt><a href="/cgi-bin/koha/admin/authorised_values.pl">Authorized values</a></dt> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >index 77356ac..6aade4b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >@@ -1,10 +1,6 @@ > [% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Administration › Libraries and groups >-[% IF op == 'editcategory' %] >- ›[% IF category.categorycode %]Edit group [% category.categorycode%][% ELSE %]New group[% END %] >-[% ELSIF op == 'delete_confirm_category' %] >- › Confirm deletion of group [% category.categorycode %] >-[% ELSIF op == 'add_form' %] >+<title>Koha › Administration › Libraries >+[% IF op == 'add_form' %] > ›[% IF library %]Modify library[% ELSE %]New library [% library.branchcode %][% END %] > [% ELSIF op == 'delete_confirm' %] > › Confirm deletion of library '[% library.branchcode %]' >@@ -61,12 +57,8 @@ tinyMCE.init({ > <div id="breadcrumbs"> > <a href="/cgi-bin/koha/mainpage.pl">Home</a> > › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >-› <a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a> >-[% IF op == 'add_form_category' %] >-› [% IF category.categorycode %]Edit group [% category.categorycode %][% ELSE %]New group[% END %] >-[% ELSIF op == 'delete_confirm_category' %] >-› Confirm deletion of group [% category.categorycode %] >-[% ELSIF op == 'add_form' %] >+› <a href="/cgi-bin/koha/admin/branches.pl">Libraries</a> >+[% IF op == 'add_form' %] > › [% IF library %]Modify library[% ELSE %]New library [% library.branchcode %][% END %] > [% ELSIF op == 'delete_confirm' %] > › Confirm deletion of library '[% library.branchcode %]' >@@ -126,7 +118,6 @@ tinyMCE.init({ > [% IF op == 'list' %] > <div id="toolbar" class="btn-toolbar"> > <a class="btn btn-small" id="newbranch" href="/cgi-bin/koha/admin/branches.pl?op=add_form"><i class="fa fa-plus"></i> New library</a> >- <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/branches.pl?op=add_form_category"><i class="fa fa-plus"></i> New group</a> > </div> > [% END %] > >@@ -225,7 +216,6 @@ tinyMCE.init({ > <th>Name</th> > <th>Code</th> > <th>Address</th> >- <th>Properties</th> > <th>IP</th> > <th>Actions</th> > </tr> >@@ -262,11 +252,6 @@ tinyMCE.init({ > [% IF library.branchnotes %] > <br />Notes: [% library.branchnotes |html %][% END %] > </td> >- <td> >- [% FOREACH category IN library.get_categories %] >- [% category.categoryname %]<br /> >- [% END %] >- </td> > <td>[% library.branchip %]</td> > <td class="actions"> > <a class="btn btn-mini" href="/cgi-bin/koha/admin/branches.pl?op=add_form&branchcode=[% library.branchcode %]"><i class="fa fa-pencil"></i> Edit</a> >@@ -279,119 +264,6 @@ tinyMCE.init({ > [% ELSE %] > <div class="dialog message">There are no libraries defined. <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">Start defining libraries</a>.</div> > [% END %] >- >- [% IF group_types %] >- [% FOREACH group_type IN group_types %] >- <h3>[% IF group_type.categorytype == 'properties' %]Properties[% ELSIF group_type.categorytype == 'searchdomain' %]Search domain[% END %]</h3> >- [% IF group_type.categories.size %] >- <table> >- <thead> >- <tr> >- <th>Name</th> >- <th>Code</th> >- <th>Description</th> >- <th>Actions</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH category IN group_type.categories %] >- <tr> >- <td>[% category.categoryname %]</td> >- <td>[% category.categorycode %]</td> >- <td>[% category.codedescription %]</td> >- <td class="actions"> >- <a class="btn btn-mini" href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&op=add_form_category"><i class="fa fa-pencil"></i> Edit</a> >- <a class="btn btn-mini" href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&op=delete_confirm_category"><i class="fa fa-trash"></i> Delete</a> >- </td> >- </tr> >- [% END %] >- </tbody> >- </table> >- [% ELSE %] >- [% IF group_type.categorytype == 'properties' %] >- No properties defined. >- [% ELSIF group_type.categorytype == 'searchdomain' %] >- No search domain defined. >- [% END %] >- <a href="/cgi-bin/koha/admin/branches.pl?op=add_form_category">Add a new group</a>. >- [% END %] >- [% END %] >- [% ELSE %] >- <p>No groups defined.</p> >- [% END %] >-[% END %] >- >-[% IF op == 'add_form_category' %] >- <h3>[% IF category.categorycode %]Edit group [% category.categorycode %][% ELSE %]Add group[% END %]</h3> >- <form action="/cgi-bin/koha/admin/branches.pl" name="Aform" method="post" class="validated"> >- <input type="hidden" name="op" value="add_validate_category" /> >- [% IF category.categorycode %] >- <input type="hidden" name="is_a_modif" value="1" /> >- [% END %] >- <fieldset class="rows"> >- <ol> >- <li> >- [% IF category.categorycode %] >- <span class="label">Category code: </span> >- <input type="hidden" name="categorycode" id="categorycode" value="[% category.categorycode |html %]" /> >- [% category.categorycode %] >- [% ELSE %] >- <label for="categorycode" class="required">Category code:</label> >- <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" class="required" required="required" /> >- <span class="required">Required</span> >- [% END %] >- </li> >- <li> >- <label for="categoryname" class="required">Name: </label> >- <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% category.categoryname |html %]" class="required" required="required" /> >- <span class="required">Required</span> >- </li> >- <li> >- <label for="codedescription">Description: </label> >- <input type="text" name="codedescription" id="codedescription" size="70" value="[% category.codedescription |html %]" /> >- </li> >- <li> >- <label for="categorytype">Category type: </label> >- <select id="categorytype" name="categorytype"> >- [% IF category.categorytype == 'properties' %] >- <option value="searchdomain">Search domain</option> >- <option value="properties" selected="selected">Properties</option> >- [% ELSE %] >- <option value="searchdomain">Search domain</option> >- <option value="properties">Properties</option> >- >- [% END %] >- </select> >- </li> >- <li> >- <label for="show_in_pulldown">Show in search pulldown: </label> >- [% IF category.show_in_pulldown %] >- <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/> >- [% ELSE %] >- <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" /> >- [% END %] >- </li> >- </ol> >- </fieldset> >- <fieldset class="action"> >- <input type="submit" value="Submit" /> >- <a href="/cgi-bin/koha/admin/branches.pl" class="cancel">Cancel</a> >- </fieldset> >- </form> >-[% END %] >- >-[% IF op == 'delete_confirm_category' %] >- <div class="dialog alert"> >- <h3>Are you sure you want to delete the group '[% category.codedescription %]' ([% category.categorycode %])?</h3> >- <form action="/cgi-bin/koha/admin/branches.pl" method="post"> >- <input type="hidden" name="op" value="delete_confirmed_category" /> >- <input type="hidden" name="categorycode" value="[% category.categorycode |html %]" /> >- <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button> >- </form> >- <form action="/cgi-bin/koha/admin/branches.pl" method="get"> >- <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button> >- </form> >- </div> > [% END %] > > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >index c6bdc23..18557bd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >@@ -257,14 +257,18 @@ > [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %] > </select></p> > <!-- <input type="hidden" name="limit" value="branch: MAIN" /> --> >- [% IF ( searchdomainloop ) %] >- <p>OR</p> <!-- should addjs to grey out group pulldown if a library is selected. --> >- <p><label for="categoryloop">Groups of libraries: </label><select name="multibranchlimit" id="categoryloop"> >- <option value=""> -- none -- </option> >- [% FOREACH searchdomainloo IN searchdomainloop %] >- <option value="[% searchdomainloo.categorycode %]">[% searchdomainloo.categoryname %]</option> >- [% END %] >- </select></p> >+ [% IF search_groups %] >+ <p>OR</p> <!-- should addjs to grey out group pulldown if a library is selected. --> >+ >+ <p> >+ <label for="categoryloop">Groups of libraries: </label> >+ <select name="multibranchlimit" id="categoryloop"> >+ <option value=""> -- none -- </option> >+ [% FOREACH sg IN search_groups %] >+ <option value="[% sg.id %]">[% sg.title %]</option> >+ [% END %] >+ </select> >+ </p> > [% END %] > </fieldset> > </fieldset> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index fdce32c..5f750d7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -228,22 +228,22 @@ > <div class="input-append"> > <select name="branch_group_limit" id="select_library"> > <option value="">All libraries</option> >- [% IF BranchCategoriesLoop %]<optgroup label="Libraries">[% END %] >- [% FOREACH BranchesLoo IN Branches.all( selected => opac_name ) %] >- [% IF BranchesLoo.selected %] >- <option selected="selected" value="branch:[% BranchesLoo.branchcode %]">[% BranchesLoo.branchname %]</option> >- [% ELSE %] >- <option value="branch:[% BranchesLoo.branchcode %]">[% BranchesLoo.branchname %]</option> >- [% END %] >- [% END %] >- [% IF BranchCategoriesLoop %] >+ >+ [% IF LibrarySearchGroups %]<optgroup label="Libraries">[% END %] >+ >+ [% FOREACH BranchesLoo IN BranchesLoop %] >+ [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option> >+ [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %] >+ [% END %] >+ >+ [% IF LibrarySearchGroups %] > </optgroup> > <optgroup label="Groups"> >- [% FOREACH bc IN BranchCategoriesLoop %] >- [% IF bc.categorycode == opac_name %] >- <option selected="selected" value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option> >+ [% FOREACH lsg IN LibrarySearchGroups %] >+ [% IF lsg.id == opac_name %] >+ <option selected="selected" value="multibranchlimit-[% lsg.id %]">[% lsg.title %]</option> > [% ELSE %] >- <option value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option> >+ <option value="multibranchlimit-[% lsg.id %]">[% lsg.title %]</option> > [% END # / bc.selected %] > [% END %] > </optgroup> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >index 5b461f4..484c729 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >@@ -223,13 +223,13 @@ > [% END %] > [% END %] > </select> >- [% IF ( searchdomainloop && searchdomainloop.count > 0) %] >+ [% IF search_groups %] > <p>OR</p> > <label for="categoryloop">Groups of libraries</label> > <select name="multibranchlimit" id="categoryloop"> > <option value=""> -- none -- </option> >- [% FOREACH searchdomainloo IN searchdomainloop %] >- <option value="[% searchdomainloo.categorycode %]">[% searchdomainloo.categoryname %]</option> >+ [% FOREACH sg IN search_groups %] >+ <option value="[% sg.id %]">[% sg.title %]</option> > [% END %] > </select> > [% END %] >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index ccbc025..a591468 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -52,9 +52,9 @@ use C4::Tags qw(get_tags); > use C4::SocialData; > use C4::External::OverDrive; > >-use Koha::LibraryCategories; > use Koha::Ratings; > use Koha::Virtualshelves; >+use Koha::Library::Groups; > > use POSIX qw(ceil floor strftime); > use URI::Escape; >@@ -213,8 +213,8 @@ if ($cgi->cookie("search_path_code")) { > } > } > >-my $library_categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } ); >-$template->param( searchdomainloop => $library_categories ); >+my $search_groups = Koha::Library::Groups->get_search_groups(); >+$template->param( search_groups => $search_groups ); > > # load the language limits (for search) > my $languages_limit_loop = getLanguages($lang, 1); >@@ -490,8 +490,8 @@ if (@searchCategories > 0) { > @limits = map { uri_unescape($_) } @limits; > > if($params->{'multibranchlimit'}) { >- my $library_category = Koha::LibraryCategories->find( $params->{multibranchlimit} ); >- my @libraries = $library_category->libraries; >+ my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} ); >+ my @libraries = $search_group->libraries; > my $multibranch = '('.join( " or ", map { 'branch: ' . $_->id } @libraries ) .')'; > push @limits, $multibranch if ($multibranch ne '()'); > } >diff --git a/t/db_dependent/Koha/Libraries.t b/t/db_dependent/Koha/Libraries.t >index 8126b8c..2c66554 100644 >--- a/t/db_dependent/Koha/Libraries.t >+++ b/t/db_dependent/Koha/Libraries.t >@@ -19,12 +19,10 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 3; > > use Koha::Library; > use Koha::Libraries; >-use Koha::LibraryCategory; >-use Koha::LibraryCategories; > use Koha::Database; > > use t::lib::TestBuilder; >@@ -34,7 +32,6 @@ $schema->storage->txn_begin; > > my $builder = t::lib::TestBuilder->new; > my $nb_of_libraries = Koha::Libraries->search->count; >-my $nb_of_categories = Koha::LibraryCategories->search->count; > my $new_library_1 = Koha::Library->new({ > branchcode => 'my_bc_1', > branchname => 'my_branchname_1', >@@ -45,46 +42,14 @@ my $new_library_2 = Koha::Library->new({ > branchname => 'my_branchname_2', > branchnotes => 'my_branchnotes_2', > })->store; >-my $new_category_1 = Koha::LibraryCategory->new({ >- categorycode => 'my_cc_1', >- categoryname => 'my_categoryname_1', >- codedescription => 'my_codedescription_1', >- categorytype => 'properties', >-} )->store; >-my $new_category_2 = Koha::LibraryCategory->new( { >- categorycode => 'my_cc_2', >- categoryname => 'my_categoryname_2', >- codedescription => 'my_codedescription_2', >- categorytype => 'searchdomain', >-} )->store; >-my $new_category_3 = Koha::LibraryCategory->new( { >- categorycode => 'my_cc_3', >- categoryname => 'my_categoryname_3', >- codedescription => 'my_codedescription_3', >- categorytype => 'searchdomain', >-} )->store; > > is( Koha::Libraries->search->count, $nb_of_libraries + 2, 'The 2 libraries should have been added' ); >-is( Koha::LibraryCategories->search->count, $nb_of_categories + 3, 'The 3 library categories should have been added' ); > >-$new_library_1->add_to_categories( [$new_category_1] ); >-$new_library_2->add_to_categories( [$new_category_2] ); > my $retrieved_library_1 = Koha::Libraries->find( $new_library_1->branchcode ); > is( $retrieved_library_1->branchname, $new_library_1->branchname, 'Find a library by branchcode should return the correct library' ); >-is( Koha::Libraries->find( $new_library_1->branchcode )->get_categories->count, 1, '1 library should have been linked to the category 1' ); >- >-$retrieved_library_1->update_categories( [ $new_category_2, $new_category_3 ] ); >-is( Koha::Libraries->find( $new_library_1->branchcode )->get_categories->count, 2, '2 libraries should have been linked to the category 2' ); >- >-my $retrieved_category_2 = Koha::LibraryCategories->find( $new_category_2->categorycode ); >-is( $retrieved_category_2->libraries->count, 2, '2 libraries should have been linked to the category_2' ); >-is( $retrieved_category_2->categorycode, uc('my_cc_2'), 'The Koha::LibraryCategory constructor should have upercased the categorycode' ); > > $retrieved_library_1->delete; > is( Koha::Libraries->search->count, $nb_of_libraries + 1, 'Delete should have deleted the library' ); > >-$retrieved_category_2->delete; >-is( Koha::LibraryCategories->search->count, $nb_of_categories + 2, 'Delete should have deleted the library category' ); >- > $schema->storage->txn_rollback; > 1; >diff --git a/t/db_dependent/RotatingCollections.t b/t/db_dependent/RotatingCollections.t >index fe47bb8..0527260 100644 >--- a/t/db_dependent/RotatingCollections.t >+++ b/t/db_dependent/RotatingCollections.t >@@ -57,7 +57,6 @@ $dbh->do(q|DELETE FROM collections_tracking |); > $dbh->do(q|DELETE FROM collections |); > $dbh->do(q|DELETE FROM branches |); > $dbh->do(q|DELETE FROM categories|); >-$dbh->do(q|DELETE FROM branchcategories|); > > #Test CreateCollection > my $collections = GetCollections(); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16735
:
52732
|
52733
|
52734
|
52735
|
57098
|
57099
|
57100
|
57101
|
58087
|
58088
|
58089
|
58090
|
60497
|
60498
|
60499
|
60500
|
60501
|
60502
|
60503
|
60772
|
60773
|
60774
|
60775
|
60776
|
60777
|
60778
|
60779
|
65658
|
65659
|
65660
|
65661
|
65662
|
65663
|
65664
|
65665
|
69533
|
69534
|
69535
|
69536
|
69537
|
69538
|
69539
|
69540
|
69541
|
69684
|
69685
|
69686
|
69687
|
69688
|
69689
|
69690
|
69691
|
69692
|
69693
|
69694
|
71386
|
71393