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

(-)a/installer/data/mysql/atomicupdate/Bug_15128_Add_MaxOpenSuggestions_Syspref.sql (+1 lines)
Line 0 Link Here
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')
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 234-239 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
234
('MaxItemsToDisplayForBatchDel','1000',NULL,'Display up to a given number of items in a single item deletionbatch.','Integer'),
234
('MaxItemsToDisplayForBatchDel','1000',NULL,'Display up to a given number of items in a single item deletionbatch.','Integer'),
235
('MaxItemsToProcessForBatchMod','1000',NULL,'Process up to a given number of items in a single item modification batch.','Integer'),
235
('MaxItemsToProcessForBatchMod','1000',NULL,'Process up to a given number of items in a single item modification batch.','Integer'),
236
('maxItemsInSearchResults','20',NULL,'Specify the maximum number of items to display for each result on a page of results','free'),
236
('maxItemsInSearchResults','20',NULL,'Specify the maximum number of items to display for each result on a page of results','free'),
237
('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once','Integer')
237
('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'),
238
('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'),
238
('maxRecordsForFacets','20',NULL,NULL,'Integer'),
239
('maxRecordsForFacets','20',NULL,NULL,'Integer'),
239
('maxreserves','50','','Define maximum number of holds a patron can place','Integer'),
240
('maxreserves','50','','Define maximum number of holds a patron can place','Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +5 lines)
Lines 571-577 OPAC: Link Here
571
                yes: "Block"
571
                yes: "Block"
572
                no: "Don't block"
572
                no: "Don't block"
573
            - 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.
573
            - 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.
574
574
        -
575
            - Limit patrons to
576
            - pref: MaxOpenSuggestions
577
              class: integer
578
            - "open suggestions. Leave empty for no limit. **Note: this setting does not affect anonymous suggestions"
575
    Privacy:
579
    Privacy:
576
        -
580
        -
577
            - pref: StoreLastBorrower
581
            - pref: StoreLastBorrower
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-2 / +17 lines)
Lines 28-33 Link Here
28
                <div class="span10">
28
                <div class="span10">
29
                    <div id="usersuggestions" class="maincontent">
29
                    <div id="usersuggestions" class="maincontent">
30
                        [% IF ( op_add ) %]
30
                        [% IF ( op_add ) %]
31
                            [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
32
                                    <h1 class="TooManySuggestions">You cannot place any more suggestions</h1>
33
                                    <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>
34
                            [% ELSE %]
31
                            <h1>Enter a new purchase suggestion</h1>
35
                            <h1>Enter a new purchase suggestion</h1>
32
36
33
                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
37
                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
Lines 88-93 Link Here
88
                                    <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>
92
                                    <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>
89
                                </fieldset>
93
                                </fieldset>
90
                            </form>
94
                            </form>
95
                            [% END %]
91
                        [% END #  IF op_add %]
96
                        [% END #  IF op_add %]
92
97
93
                        [% IF ( op_else ) %]
98
                        [% IF ( op_else ) %]
Lines 105-110 Link Here
105
                            [% FOR m IN messages %]
110
                            [% FOR m IN messages %]
106
                                <div class="alert alert-[% m.type %]">
111
                                <div class="alert alert-[% m.type %]">
107
                                    [% SWITCH m.code %]
112
                                    [% SWITCH m.code %]
113
                                    [% CASE 'too_many' %]
114
                                        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.
108
                                    [% CASE 'already_exists' %]
115
                                    [% CASE 'already_exists' %]
109
                                        The suggestion has not been added. A suggestion with this title already exists.
116
                                        The suggestion has not been added. A suggestion with this title already exists.
110
                                    [% CASE 'success_on_inserted' %]
117
                                    [% CASE 'success_on_inserted' %]
Lines 145-151 Link Here
145
                                    <input type="hidden" name="op" value="delete_confirm" />
152
                                    <input type="hidden" name="op" value="delete_confirm" />
146
                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
153
                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
147
                                        <div id="toolbar" class="toolbar clearfix">
154
                                        <div id="toolbar" class="toolbar clearfix">
148
                                            <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
155
                                        [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
156
                                                <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>
157
                                        [% ELSE %]
158
                                                <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
159
                                        [% END %]
149
                                        </div>
160
                                        </div>
150
                                    [% END %]
161
                                    [% END %]
151
162
Lines 245-251 Link Here
245
                                    <p>There are no pending purchase suggestions.</p>
256
                                    <p>There are no pending purchase suggestions.</p>
246
                                [% END %]
257
                                [% END %]
247
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
258
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
248
                                    <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
259
                                    [% IF ( Koha.Preference('MaxOpenSuggestions') && own_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
260
                                        <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>
261
                                    [% ELSE %]
262
                                        <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
263
                                    [% END %]
249
                                [% END %]
264
                                [% END %]
250
                            [% END # / IF suggestions_loop %]
265
                            [% END # / IF suggestions_loop %]
251
266
(-)a/opac/opac-suggestions.pl (-2 / +10 lines)
Lines 115-121 if ( $op eq 'else' ) { Link Here
115
my $suggestions_loop =
115
my $suggestions_loop =
116
  &SearchSuggestion( $suggestion);
116
  &SearchSuggestion( $suggestion);
117
if ( $op eq "add_confirm" ) {
117
if ( $op eq "add_confirm" ) {
118
	if (@$suggestions_loop>=1){
118
        my $count_own_suggestions = $borrowernumber ?  &SearchSuggestion( { suggestedby => $borrowernumber}) : 0;
119
    if( @$count_own_suggestions >= C4::Context->preference("MaxOpenSuggestions") ){
120
        push @messages, { type => 'error', code => 'too_many'};
121
    }
122
	elsif (@$suggestions_loop>=1){
119
		#some suggestion are answering the request Donot Add
123
		#some suggestion are answering the request Donot Add
120
        for my $suggestion ( @$suggestions_loop ) {
124
        for my $suggestion ( @$suggestions_loop ) {
121
            push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
125
            push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
Lines 157-165 map{ Link Here
157
    $library ? $s->{branchcodesuggestedby} = $library->branchname : ()
161
    $library ? $s->{branchcodesuggestedby} = $library->branchname : ()
158
} @$suggestions_loop;
162
} @$suggestions_loop;
159
163
164
my $own_suggestions_count = 0;
160
foreach my $suggestion(@$suggestions_loop) {
165
foreach my $suggestion(@$suggestions_loop) {
161
    if($suggestion->{'suggestedby'} == $borrowernumber) {
166
    if($suggestion->{'suggestedby'} == $borrowernumber) {
162
        $suggestion->{'showcheckbox'} = $borrowernumber;
167
        $suggestion->{'showcheckbox'} = $borrowernumber;
168
        if ( $suggestion->{'STATUS'} eq 'ASKED' ) {
169
            $own_suggestions_count++;
170
        }
163
    } else {
171
    } else {
164
        $suggestion->{'showcheckbox'} = 0;
172
        $suggestion->{'showcheckbox'} = 0;
165
    }
173
    }
Lines 195-200 $template->param( Link Here
195
    messages => \@messages,
203
    messages => \@messages,
196
    suggestionsview => 1,
204
    suggestionsview => 1,
197
    suggested_by_anyone => $suggested_by_anyone,
205
    suggested_by_anyone => $suggested_by_anyone,
206
    own_suggestions_count => $own_suggestions_count,
198
);
207
);
199
208
200
output_html_with_http_headers $input, $cookie, $template->output;
209
output_html_with_http_headers $input, $cookie, $template->output;
201
- 

Return to bug 15128