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

(-)a/C4/Auth.pm (-1 lines)
Lines 481-487 sub get_template_and_user { Link Here
481
            OPACShelfBrowser                      => "" . C4::Context->preference("OPACShelfBrowser"),
481
            OPACShelfBrowser                      => "" . C4::Context->preference("OPACShelfBrowser"),
482
            OPACURLOpenInNewWindow                => "" . C4::Context->preference("OPACURLOpenInNewWindow"),
482
            OPACURLOpenInNewWindow                => "" . C4::Context->preference("OPACURLOpenInNewWindow"),
483
            OPACUserCSS                           => "" . C4::Context->preference("OPACUserCSS"),
483
            OPACUserCSS                           => "" . C4::Context->preference("OPACUserCSS"),
484
            OPACViewOthersSuggestions             => "" . C4::Context->preference("OPACViewOthersSuggestions"),
485
            OpacAuthorities                       => C4::Context->preference("OpacAuthorities"),
484
            OpacAuthorities                       => C4::Context->preference("OpacAuthorities"),
486
            OPACBaseURL                           => ( $using_https ? "https://" : "http://" ) . $opac_base_url,
485
            OPACBaseURL                           => ( $using_https ? "https://" : "http://" ) . $opac_base_url,
487
            opac_css_override                     => $ENV{'OPAC_CSS_OVERRIDE'},
486
            opac_css_override                     => $ENV{'OPAC_CSS_OVERRIDE'},
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc (-7 / +5 lines)
Lines 68-81 Link Here
68
            [% END # / opacreadinghistory %]
68
            [% END # / opacreadinghistory %]
69
69
70
            [% IF Koha.Preference( 'suggestion' ) == 1 %]
70
            [% IF Koha.Preference( 'suggestion' ) == 1 %]
71
                [% UNLESS ( Koha.Preference( 'AnonSuggestions' ) == 1 ) %]
71
                [% IF ( suggestionsview ) %]
72
                    [% IF ( suggestionsview ) %]
72
                    <li class="active">
73
                        <li class="active">
73
                [% ELSE %]
74
                    [% ELSE %]
74
                    <li>
75
                        <li>
76
                    [% END %]
77
                    <a href="/cgi-bin/koha/opac-suggestions.pl">your purchase suggestions</a></li>
78
                [% END %]
75
                [% END %]
76
                <a href="/cgi-bin/koha/opac-suggestions.pl">your purchase suggestions</a></li>
79
            [% END %]
77
            [% END %]
80
78
81
            [% IF ( EnhancedMessagingPreferences ) %]
79
            [% IF ( EnhancedMessagingPreferences ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-23 / +34 lines)
Lines 92-98 Link Here
92
                                    </ol>
92
                                    </ol>
93
                                </fieldset>
93
                                </fieldset>
94
                                <fieldset class="action">
94
                                <fieldset class="action">
95
                                    <input type="hidden" name="suggestedby" value="[% suggestedbyme %]" />
95
                                    <input type="hidden" name="suggested_by_anyone" value="[% suggested_by_anyone %]" />
96
                                    <input type="hidden" name="op" value="add_confirm" />
96
                                    <input type="hidden" name="op" value="add_confirm" />
97
                                    <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>
97
                                    <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>
98
                                </fieldset>
98
                                </fieldset>
Lines 127-155 Link Here
127
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
127
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
128
128
129
                            [% IF ( suggestions_loop ) %]
129
                            [% IF ( suggestions_loop ) %]
130
                                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
130
                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" method="get">
131
                                    <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" method="get">
131
                                    <fieldset>
132
                                        <fieldset>
132
                                        <label for="title">Search for:</label>
133
                                            <label for="title">Search for:</label>
133
                                        <input type="text" name="title" id="title" value="[% title |html %]" />
134
                                            <input type="text" name="title" id="title" value="[% title |html %]" />
134
                                        [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
135
                                            <label for="suggestedby">Suggested by:</label>
135
                                            [% IF loggedinusername %]
136
                                            <div class="input-append">
136
                                                <label for="suggested_by_anyone">Suggested by:</label>
137
                                                <select name="suggestedby" id="suggestedby">
137
                                                <div class="input-append">
138
                                                    <option value="0">Anyone</option>
138
                                                    <select name="suggested_by_anyone" id="suggested_by_anyone">
139
                                                    <option value="1">Me</option>
139
                                                        [% IF suggested_by_anyone %]
140
                                                </select>
140
                                                            <option value="0">Me</option>
141
                                                <button type="submit" class="btn">Go</button>
141
                                                            <option value="1" selected="selected">Anyone</option>
142
                                            </div>
142
                                                        [% ELSE %]
143
                                        </fieldset>
143
                                                            <option value="0" selected="selected">Me</option>
144
                                    </form>
144
                                                            <option value="1">Anyone</option>
145
                                [% END %]
145
                                                        [% END %]
146
                                                    </select>
147
                                                    <button type="submit" class="btn">Go</button>
148
                                                </div>
149
                                            [% END %]
150
                                        [% END %]
151
                                    </fieldset>
152
                                </form>
146
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="myform">
153
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="myform">
147
                                    <input type="hidden" name="op" value="delete_confirm" />
154
                                    <input type="hidden" name="op" value="delete_confirm" />
148
                                    <div id="toolbar" class="toolbar clearfix">
155
                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
149
                                        [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
156
                                        <div id="toolbar" class="toolbar clearfix">
150
                                            <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
157
                                            <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
151
                                        [% END %]
158
                                        </div>
152
                                    </div>
159
                                    [% END %]
153
160
154
                                    [% IF ( loggedinusername ) %]
161
                                    [% IF ( loggedinusername ) %]
155
                                        <div id="selections-toolbar" class="toolbar">
162
                                        <div id="selections-toolbar" class="toolbar">
Lines 237-243 Link Here
237
                                    [% END %]
244
                                    [% END %]
238
                                </form>
245
                                </form>
239
                            [% ELSE %]
246
                            [% ELSE %]
240
                                <p>There are no pending purchase suggestions.</p>
247
                                [% UNLESS Koha.Preference( 'OPACViewOthersSuggestions' ) or $loggedinusername %]
248
                                    <p>You are not authorized to see pending purchase suggestions.</p>
249
                                [% ELSE %]
250
                                    <p>There are no pending purchase suggestions.</p>
251
                                [% END %]
241
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
252
                                [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
242
                                    <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
253
                                    <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
243
                                [% END %]
254
                                [% END %]
Lines 280-286 Link Here
280
                [% IF ( loggedinusername ) %]null,[% END %]
291
                [% IF ( loggedinusername ) %]null,[% END %]
281
                { "sType": "anti-the" },
292
                { "sType": "anti-the" },
282
                null,
293
                null,
283
                [% IF ( OPACViewOthersSuggestions ) %]null,[% END %]
294
                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]
284
                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
295
                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
285
                null
296
                null
286
            ]
297
            ]
(-)a/opac/opac-suggestions.pl (-14 / +33 lines)
Lines 33-43 use C4::Scrubber; Link Here
33
use Koha::DateUtils qw( dt_from_string );
33
use Koha::DateUtils qw( dt_from_string );
34
34
35
my $input           = new CGI;
35
my $input           = new CGI;
36
my $allsuggestions  = $input->param('showall');
37
my $op              = $input->param('op');
36
my $op              = $input->param('op');
38
my $suggestion      = $input->Vars;
37
my $suggestion      = $input->Vars;
39
delete $suggestion->{negcap};
38
delete $suggestion->{negcap};
40
my $negcaptcha      = $input->param('negcap');
39
my $negcaptcha      = $input->param('negcap');
40
my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0;
41
41
42
# If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return.
42
# If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return.
43
if ($negcaptcha ) {
43
if ($negcaptcha ) {
Lines 51-64 if ( ! C4::Context->preference('suggestion') ) { Link Here
51
    exit;
51
    exit;
52
}
52
}
53
53
54
delete $$suggestion{$_} foreach qw<op suggestedbyme>;
54
delete $suggestion->{$_} foreach qw<op suggested_by_anyone>;
55
$op = 'else' unless $op;
55
$op = 'else' unless $op;
56
56
57
my ( $template, $borrowernumber, $cookie, @messages );
57
my ( $template, $borrowernumber, $cookie, @messages );
58
my $deleted = $input->param('deleted');
58
my $deleted = $input->param('deleted');
59
my $submitted = $input->param('submitted');
59
my $submitted = $input->param('submitted');
60
60
61
if ( C4::Context->preference("AnonSuggestions") ) {
61
if ( C4::Context->preference("AnonSuggestions") or ( C4::Context->preference("OPACViewOthersSuggestions") and $op eq 'else' ) ) {
62
    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
62
    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
63
        {
63
        {
64
            template_name   => "opac-suggestions.tt",
64
            template_name   => "opac-suggestions.tt",
Lines 67-75 if ( C4::Context->preference("AnonSuggestions") ) { Link Here
67
            authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
67
            authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
68
        }
68
        }
69
    );
69
    );
70
    if ( !$$suggestion{suggestedby} ) {
71
        $$suggestion{suggestedby} = C4::Context->preference("AnonymousPatron");
72
    }
73
}
70
}
74
else {
71
else {
75
    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
72
    ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 81-93 else { Link Here
81
        }
78
        }
82
    );
79
    );
83
}
80
}
84
if ($allsuggestions){
81
85
	delete $$suggestion{suggestedby};
82
if ( $op eq 'else' ) {
86
}
83
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
87
else {
84
        if ( $borrowernumber ) {
88
	$$suggestion{suggestedby} ||= $borrowernumber unless ($allsuggestions);
85
            # A logged in user is able to see suggestions from others
86
            $suggestion->{suggestedby} = $suggested_by_anyone
87
                ? undef
88
                : $borrowernumber;
89
        }
90
        else {
91
            # Non logged in user is able to see all suggestions
92
            $suggestion->{suggestedby} = undef;
93
        }
94
    }
95
    else {
96
        if ( $borrowernumber ) {
97
            $suggestion->{suggestedby} = $borrowernumber;
98
        }
99
        else {
100
            $suggestion->{suggestedby} = -1;
101
        }
102
    }
103
} else {
104
    if ( $borrowernumber ) {
105
        $suggestion->{suggestedby} = $borrowernumber;
106
    }
107
    else {
108
        $suggestion->{suggestedby} = C4::Context->preference("AnonymousPatron");
109
    }
89
}
110
}
90
# warn "bornum:",$borrowernumber;
91
111
92
my $suggestions_loop =
112
my $suggestions_loop =
93
  &SearchSuggestion( $suggestion);
113
  &SearchSuggestion( $suggestion);
Lines 172-182 $template->param( Link Here
172
	itemtypeloop=> $supportlist,
192
	itemtypeloop=> $supportlist,
173
    suggestions_loop => $suggestions_loop,
193
    suggestions_loop => $suggestions_loop,
174
    patron_reason_loop => $patron_reason_loop,
194
    patron_reason_loop => $patron_reason_loop,
175
    showall    => $allsuggestions,
176
    "op_$op"         => 1,
195
    "op_$op"         => 1,
177
    $op => 1,
196
    $op => 1,
178
    messages => \@messages,
197
    messages => \@messages,
179
    suggestionsview => 1,
198
    suggestionsview => 1,
199
    suggested_by_anyone => $suggested_by_anyone,
180
);
200
);
181
201
182
output_html_with_http_headers $input, $cookie, $template->output;
202
output_html_with_http_headers $input, $cookie, $template->output;
183
- 

Return to bug 4137