Bugzilla – Attachment 52715 Details for
Bug 15128
Add ability to limit the number of open purchase suggestions a patron can make
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15128 - Add ability to limit patrons open purchase suggestions
Bug-15128---Add-ability-to-limit-patrons-open-purc.patch (text/plain), 9.97 KB, created by
Nicole C. Engard
on 2016-06-23 13:24:56 UTC
(
hide
)
Description:
Bug 15128 - Add ability to limit patrons open purchase suggestions
Filename:
MIME Type:
Creator:
Nicole C. Engard
Created:
2016-06-23 13:24:56 UTC
Size:
9.97 KB
patch
obsolete
>From 7a3da0776603236b374e8523da0e51a7f0566b5d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 14 Jun 2016 16:47:43 -0400 >Subject: [PATCH] Bug 15128 - Add ability to limit patrons open purchase > suggestions > >To test: >1 - Define a number of MaxOpenSuggestions >2 - Add some suggestions for a patron >3 - Note they cannot add any more suggestions if limit is reached >4 - Delete a suggestion and note you can add another >5 - Add them to limit again >6 - Accept a suggestion in the staff client and note user can add more >7 - Repeat above with rejecting or deleting >8 - Sign off. > >Sponsored by: > North Central Regional Library (http://ncrl.org/) > >Signed-off-by: Barbara Walters <bwalters@ncrl.org> >--- > .../Bug_15128_Add_MaxOpenSuggestions_Syspref.sql | 1 + > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/opac.pref | 6 +++++- > .../bootstrap/en/modules/opac-suggestions.tt | 19 +++++++++++++++++-- > opac/opac-suggestions.pl | 11 ++++++++++- > 5 files changed, 34 insertions(+), 4 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/Bug_15128_Add_MaxOpenSuggestions_Syspref.sql > >diff --git a/installer/data/mysql/atomicupdate/Bug_15128_Add_MaxOpenSuggestions_Syspref.sql b/installer/data/mysql/atomicupdate/Bug_15128_Add_MaxOpenSuggestions_Syspref.sql >new file mode 100644 >index 0000000..af0f72c >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug_15128_Add_MaxOpenSuggestions_Syspref.sql >@@ -0,0 +1 @@ >+INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once, unlimited if blank','Integer') >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 2b95c99..260bc1f 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -233,6 +233,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('MaxFine',NULL,'','Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.','Integer'), > ('MaxItemsForBatch','1000',NULL,'Max number of items record to process in a batch (modification or deletion)','Integer'), > ('maxItemsInSearchResults','20',NULL,'Specify the maximum number of items to display for each result on a page of results','free'), >+('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once','Integer') > ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), > ('maxRecordsForFacets','20',NULL,NULL,'Integer'), > ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index e1c72f0..b3e43bd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -566,7 +566,11 @@ OPAC: > yes: "Block" > no: "Don't block" > - expired patrons from OPAC actions such as placing a hold or renewing. Note that the setting for a patron category takes priority over this system preference. >- >+ - >+ - Limit patrons to >+ - pref: MaxOpenSuggestions >+ class: integer >+ - "open suggestions. Leave empty for no limit. **Note: this setting does not affect anonymous suggestions" > Privacy: > - > - pref: StoreLastBorrower >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >index 45b5e59..140b902 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >@@ -28,6 +28,10 @@ > <div class="span10"> > <div id="usersuggestions" class="maincontent"> > [% IF ( op_add ) %] >+ [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] >+ <h1 class="TooManySuggestions">You cannot place any more suggestions</h1> >+ <h2 class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') %]). Once the library has processed those suggestions you will be able to place more.</h2> >+ [% ELSE %] > <h1>Enter a new purchase suggestion</h1> > > <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p> >@@ -88,6 +92,7 @@ > <input type="submit" onclick="Check(this.form); return false;" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a> > </fieldset> > </form> >+ [% END %] > [% END # IF op_add %] > > [% IF ( op_else ) %] >@@ -105,6 +110,8 @@ > [% FOR m IN messages %] > <div class="alert alert-[% m.type %]"> > [% SWITCH m.code %] >+ [% CASE 'too_many' %] >+ The suggestion has not been added. You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') %]). Once the library has processed those suggestions you will be able to place more. > [% CASE 'already_exists' %] > The suggestion has not been added. A suggestion with this title already exists. > [% CASE 'success_on_inserted' %] >@@ -145,7 +152,11 @@ > <input type="hidden" name="op" value="delete_confirm" /> > [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %] > <div id="toolbar" class="toolbar clearfix"> >- <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a> >+ [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] >+ <p class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') %]).</br>Once the library has processed those suggestions you will be able to place more.</p> >+ [% ELSE %] >+ <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a> >+ [% END %] > </div> > [% END %] > >@@ -245,7 +256,11 @@ > <p>There are no pending purchase suggestions.</p> > [% END %] > [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %] >- <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p> >+ [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %] >+ <p class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time.</br>Once the library has processed those suggestions you will be able to place more</p> >+ [% ELSE %] >+ <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p> >+ [% END %] > [% END %] > [% END # / IF suggestions_loop %] > >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index aad0e85..c9dc7f0 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -115,7 +115,11 @@ if ( $op eq 'else' ) { > my $suggestions_loop = > &SearchSuggestion( $suggestion); > if ( $op eq "add_confirm" ) { >- if (@$suggestions_loop>=1){ >+ my $count_own_suggestions = $borrowernumber ? &SearchSuggestion( { suggestedby => $borrowernumber}) : 0; >+ if( @$count_own_suggestions >= C4::Context->preference("MaxOpenSuggestions") ){ >+ push @messages, { type => 'error', code => 'too_many'}; >+ } >+ elsif (@$suggestions_loop>=1){ > #some suggestion are answering the request Donot Add > for my $suggestion ( @$suggestions_loop ) { > push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} }; >@@ -157,9 +161,13 @@ map{ > $library ? $s->{branchcodesuggestedby} = $library->branchname : () > } @$suggestions_loop; > >+my $own_suggestions_count = 0; > foreach my $suggestion(@$suggestions_loop) { > if($suggestion->{'suggestedby'} == $borrowernumber) { > $suggestion->{'showcheckbox'} = $borrowernumber; >+ if ( $suggestion->{'STATUS'} eq 'ASKED' ) { >+ $own_suggestions_count++; >+ } > } else { > $suggestion->{'showcheckbox'} = 0; > } >@@ -195,6 +203,7 @@ $template->param( > messages => \@messages, > suggestionsview => 1, > suggested_by_anyone => $suggested_by_anyone, >+ own_suggestions_count => $own_suggestions_count, > ); > > output_html_with_http_headers $input, $cookie, $template->output; >-- >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 15128
:
52452
|
52502
|
52596
|
52610
|
52611
|
52623
|
52624
|
52625
|
52626
|
52715
|
52716
|
52717
|
52718
|
52719
|
52720
|
52721
|
52722
|
52997
|
53033
|
53034
|
53037
|
53038
|
53039
|
53040
|
53041
|
53042
|
53043
|
53044
|
53045