Bugzilla – Attachment 71323 Details for
Bug 20157
Use group 'features' to decide which groups to use for group searching functionality
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20157 - Use group 'features' to decide which groups to use for group searching functionality
Bug-20157---Use-group-features-to-decide-which-gro.patch (text/plain), 13.98 KB, created by
Kyle M Hall (khall)
on 2018-02-07 20:14:40 UTC
(
hide
)
Description:
Bug 20157 - Use group 'features' to decide which groups to use for group searching functionality
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-02-07 20:14:40 UTC
Size:
13.98 KB
patch
obsolete
>From 950a1b4ce08de8ba87e162876f604f0044e937b3 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 7 Feb 2018 19:44:28 +0000 >Subject: [PATCH] Bug 20157 - Use group 'features' to decide which groups to > use for group searching functionality > >Instead of basing the group searches on the group name, which is an >inherently touchy system, we should use the same checkbox style that >Jonathan introduced for the patron limits by group feature. > >Test Plan: >1) Check to ensure existing group searches still show as they used to >--- > C4/Auth.pm | 4 +- > Koha/Library/Groups.pm | 11 ++- > installer/data/mysql/atomicupdate/bug_20157.perl | 13 ++++ > installer/data/mysql/kohastructure.sql | 2 + > .../prog/en/modules/admin/library_groups.tt | 87 +++++++++++++++------- > opac/opac-search.pl | 4 +- > 6 files changed, 85 insertions(+), 36 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_20157.perl > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index f80a26e..dd1d0d0 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -512,11 +512,11 @@ sub get_template_and_user { > $opac_name = C4::Context->userenv->{'branch'}; > } > >- my $search_groups = Koha::Library::Groups->get_search_groups(); >+ my @search_groups = Koha::Library::Groups->get_search_groups(); > $template->param( > OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"), > AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), >- LibrarySearchGroups => $search_groups, >+ LibrarySearchGroups => \@search_groups, > opac_name => $opac_name, > LibraryName => "" . C4::Context->preference("LibraryName"), > LibraryNameTitle => "" . $LibraryNameTitle, >diff --git a/Koha/Library/Groups.pm b/Koha/Library/Groups.pm >index d3cb72a..ea66fe7 100644 >--- a/Koha/Library/Groups.pm >+++ b/Koha/Library/Groups.pm >@@ -56,16 +56,15 @@ sub get_search_groups { > my ( $self, $params ) = @_; > my $interface = $params->{interface} || q{}; > >- my $title = $interface eq 'staff' ? '__SEARCH_GROUPS__' : '__SEARCH_GROUPS_OPAC__'; >+ my $field = $interface eq 'staff' ? 'ft_search_groups_staff' : 'ft_search_groups_opac'; > >- my ($search_groups_root) = >- $self->search( { parent_id => undef, title => $title } ); >+ my @search_groups = $self->search( { $field => 1 } ); > >- return unless $search_groups_root; >+ return unless @search_groups; > >- my $children = $search_groups_root->children(); >+ my @children = map { $_->children() } @search_groups; > >- return wantarray ? $children->as_list : $children; >+ return @children; > } > > =head3 type >diff --git a/installer/data/mysql/atomicupdate/bug_20157.perl b/installer/data/mysql/atomicupdate/bug_20157.perl >new file mode 100644 >index 0000000..de87756 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_20157.perl >@@ -0,0 +1,13 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ >+ if( !column_exists( 'library_groups', 'ft_search_groups_opac' ) ) { >+ $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_opac tinyint(1) NOT NULL DEFAULT 0 AFTER ft_hide_patron_info" ); >+ $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_opac" ); >+ $dbh->do( "UPDATE library_groups SET ft_search_groups_staff = 1 WHERE title = '__SEARCH_GROUPS__'" ); >+ $dbh->do( "UPDATE library_groups SET ft_search_groups_opac = 1 WHERE title = '__SEARCH_GROUPS_OPAC__'" ); >+ } >+ >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 20157 - Use group 'features' to decide which groups to use for group searching functionality)\n"; >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 2c6c922..204e773 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -4144,6 +4144,8 @@ CREATE TABLE library_groups ( > title VARCHAR(100) NULL DEFAULT NULL, -- Short description of the goup > description TEXT NULL DEFAULT NULL, -- Longer explanation of the group, if necessary > ft_hide_patron_info tinyint(1) NOT NULL DEFAULT 0, -- Turn on the feature "Hide patron's info" for this group >+ ft_search_groups_opac tinyint(1) NOT NULL DEFAULT 0, -- Use this group for staff side search groups >+ ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0, -- Use this group for opac side search groups > created_on DATETIME NOT NULL, -- Date and time of creation > updated_on DATETIME NULL DEFAULT NULL, -- Date and time of last > PRIMARY KEY id ( id ), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt >index 3d90144..e54a08a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt >@@ -26,7 +26,9 @@ > var title = $(this).data('groupTitle'); > var description = $(this).data('groupDescription'); > var ft_hide_patron_info = $(this).data('groupFt_hide_patron_info'); >- edit_group( id, parent_id, title, description, ft_hide_patron_info ); >+ var ft_search_groups_opac = $(this).data('groupFt_search_groups_opac'); >+ var ft_search_groups_staff = $(this).data('groupFt_search_groups_staff'); >+ edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff ); > }); > > $('.delete-group').on('click', function() { >@@ -54,30 +56,31 @@ > }); > > $('#add-group-modal-ft_hide_patron_info').prop('checked', false); >+ $('#add-group-modal-ft_search_groups_opac').prop('checked', false); >+ $('#add-group-modal-ft_search_groups_staff').prop('checked', false); > if ( parent_id ) { >- $('#add-group-modal-ft_hide_patron_info').parent().hide(); >+ $('#root-group-features-edit').hide(); > } else { >- $('#add-group-modal-ft_hide_patron_info').parent().show(); >+ $('#root-group-features-edit').show(); > } > $('#add-group-modal').modal('show'); > } > >- function edit_group( id, parent_id, title, description, ft_hide_patron_info ) { >+ function edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff ) { > $('#edit-group-modal-id').val( id ); > $('#edit-group-modal-title').val( title ); > $('#edit-group-modal-description').val( description ); > > if ( parent_id ) { > $('#edit-group-modal-ft_hide_patron_info').prop('checked', false); >- $('#edit-group-modal-ft_hide_patron_info').parent().hide(); >+ $('#edit-group-modal-ft_search_groups_opac').prop('checked', false); >+ $('#edit-group-modal-ft_search_groups_staff').prop('checked', false); >+ $('#root-group-features-edit').hide(); > } else { >- if ( ft_hide_patron_info ) { >- $('#edit-group-modal-ft_hide_patron_info').prop('checked', true); >- } else { >- $('#edit-group-modal-ft_hide_patron_info').prop('checked', false); >- } >- >- $('#edit-group-modal-ft_hide_patron_info').parent().show(); >+ $('#edit-group-modal-ft_hide_patron_info').prop('checked', ft_hide_patron_info ? true : false ); >+ $('#edit-group-modal-ft_search_groups_opac').prop('checked', ft_search_groups_opac ? true : false ); >+ $('#edit-group-modal-ft_search_groups_staff').prop('checked', ft_search_groups_staff ? true : false ); >+ $('#root-group-features-edit').show(); > } > > $('#edit-group-modal').on('shown', function() { >@@ -188,12 +191,24 @@ > <label for="add-group-modal-description">Description: </label> > <input type="text" name="description" id="add-group-modal-description" /> > </p> >- <h3>Features</h3> >- <div class="checkbox"> >- <label> >- <input type="checkbox" name="ft_hide_patron_info" id="add-group-modal-ft_hide_patron_info" value="1" /> >- Limit patron data access by group >- </label> >+ <div id="root-group-features-add"> >+ <h3>Features</h3> >+ <div class="checkbox"> >+ <label> >+ <input type="checkbox" name="ft_hide_patron_info" id="add-group-modal-ft_hide_patron_info" value="1" /> >+ Limit patron data access by group >+ </label> >+ <p> >+ <label> >+ <input type="checkbox" name="ft_search_groups_opac" id="add-group-modal-ft_search_groups_opac" value="1" /> >+ Use for OPAC search groups >+ </label> >+ <p> >+ <label> >+ <input type="checkbox" name="ft_search_groups_staff" id="add-group-modal-ft_search_groups_staff" value="1" /> >+ Use for staff search groups >+ </label> >+ </div> > </div> > </div> > <div class="modal-footer"> >@@ -226,12 +241,24 @@ > <label for="edit-group-modal-description">Description: </label> > <input type="text" id="edit-group-modal-description" name="description" value="" /> > </p> >- <h3>Features</h3> >- <div class="checkbox"> >- <label> >- <input type="checkbox" id="edit-group-modal-ft_hide_patron_info" name="ft_hide_patron_info" value="1" /> >- Limit patron data access by group >- </label> >+ <div id="root-group-features-edit"> >+ <h3>Features</h3> >+ <div class="checkbox"> >+ <label> >+ <input type="checkbox" id="edit-group-modal-ft_hide_patron_info" name="ft_hide_patron_info" value="1" /> >+ Limit patron data access by group >+ </label> >+ <p> >+ <label> >+ <input type="checkbox" id="edit-group-modal-ft_search_groups_opac" name="ft_search_groups_opac" value="1" /> >+ Use for OPAC search groups >+ </label> >+ <p> >+ <label> >+ <input type="checkbox" id="edit-group-modal-ft_search_groups_staff" name="ft_search_groups_staff" value="1" /> >+ Use for staff search groups >+ </label> >+ </div> > </div> > </div> > <div class="modal-footer"> >@@ -306,9 +333,17 @@ > </td> > <td> > [% UNLESS group.branchcode %] >+ <ul> > [% IF group.ft_hide_patron_info %] >- <span> * Hide patron's info for librarians outside of this group.</span> >+ <li>Hide patron's info for librarians outside of this group.</li> >+ [% END %] >+ [% IF group.ft_search_groups_opac %] >+ <li>Use for OPAC search groups</li> >+ [% END %] >+ [% IF group.ft_search_groups_staff %] >+ <li>Use for staff search groups</li> > [% END %] >+ </ul> > [% END %] > </td> > <td> >@@ -325,7 +360,7 @@ > </li> > > <li> >- <a class="edit-group" id="edit-group-[% group.id %]" href="#" class="edit-group" data-group-id="[% group.id %]" data-group-parent-id="[% group.parent_id %]" data-group-title="[% group.title | html %]" data-group-description="[% group.description | html %]" data-group-ft_hide_patron_info="[% group.ft_hide_patron_info | html %]"> >+ <a class="edit-group" id="edit-group-[% group.id %]" href="#" class="edit-group" data-group-id="[% group.id %]" data-group-parent-id="[% group.parent_id %]" data-group-title="[% group.title | html %]" data-group-description="[% group.description | html %]" data-group-ft_hide_patron_info="[% group.ft_hide_patron_info | html %]" data-group-ft_search_groups_opac="[% group.ft_search_groups_opac | html %]" data-group-ft_search_groups_staff="[% group.ft_search_groups_staff | html %]" > > <i class="fa fa-pencil"></i> Edit > </a> > </li> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 763c844..0b61869 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -214,8 +214,8 @@ if ($cgi->cookie("search_path_code")) { > } > } > >-my $search_groups = Koha::Library::Groups->get_search_groups(); >-$template->param( search_groups => $search_groups ); >+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); >-- >2.10.2
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 20157
:
71320
|
71321
|
71323
|
71324
|
71382
|
71383
|
71385
|
71387
|
71395
|
71396
|
71397
|
71398
|
71399
|
71400