Lines 32-37
use Koha::Exceptions::Ill;
Link Here
|
32 |
use Koha::Illcomments; |
32 |
use Koha::Illcomments; |
33 |
use Koha::Illrequestattributes; |
33 |
use Koha::Illrequestattributes; |
34 |
use Koha::AuthorisedValue; |
34 |
use Koha::AuthorisedValue; |
|
|
35 |
use Koha::Illrequest::Logger; |
35 |
use Koha::Patron; |
36 |
use Koha::Patron; |
36 |
use Koha::AuthorisedValues; |
37 |
use Koha::AuthorisedValues; |
37 |
|
38 |
|
Lines 157-162
sub illcomments {
Link Here
|
157 |
); |
158 |
); |
158 |
} |
159 |
} |
159 |
|
160 |
|
|
|
161 |
=head3 logs |
162 |
|
163 |
=cut |
164 |
|
165 |
sub logs { |
166 |
my ( $self ) = @_; |
167 |
my $logger = Koha::Illrequest::Logger->new; |
168 |
return $logger->get_request_logs($self); |
169 |
} |
170 |
|
160 |
=head3 patron |
171 |
=head3 patron |
161 |
|
172 |
|
162 |
=cut |
173 |
=cut |
Lines 169-183
sub patron {
Link Here
|
169 |
} |
180 |
} |
170 |
|
181 |
|
171 |
=head3 status_alias |
182 |
=head3 status_alias |
|
|
183 |
|
184 |
$Illrequest->status_alias(143); |
185 |
|
172 |
Overloaded getter/setter for status_alias, |
186 |
Overloaded getter/setter for status_alias, |
173 |
that only returns authorised values from the |
187 |
that only returns authorised values from the |
174 |
correct category |
188 |
correct category and records the fact that the status has changed |
175 |
|
189 |
|
176 |
=cut |
190 |
=cut |
177 |
|
191 |
|
178 |
sub status_alias { |
192 |
sub status_alias { |
179 |
my ($self, $newval) = @_; |
193 |
my ($self, $new_status_alias) = @_; |
180 |
if ($newval) { |
194 |
|
|
|
195 |
my $current_status_alias = $self->SUPER::status_alias; |
196 |
|
197 |
if ($new_status_alias) { |
198 |
# Keep a record of the previous status before we change it, |
199 |
# we might need it |
200 |
$self->{previous_status} = $current_status_alias ? |
201 |
$current_status_alias : |
202 |
scalar $self->status; |
181 |
# This is hackery to enable us to undefine |
203 |
# This is hackery to enable us to undefine |
182 |
# status_alias, since we need to have an overloaded |
204 |
# status_alias, since we need to have an overloaded |
183 |
# status_alias method to get us around the problem described |
205 |
# status_alias method to get us around the problem described |
Lines 185-197
sub status_alias {
Link Here
|
185 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
207 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
186 |
# We need a way of accepting implied undef, so we can nullify |
208 |
# We need a way of accepting implied undef, so we can nullify |
187 |
# the status_alias column, when called from $self->status |
209 |
# the status_alias column, when called from $self->status |
188 |
my $val = $newval eq "-1" ? undef : $newval; |
210 |
my $val = $new_status_alias eq "-1" ? undef : $new_status_alias; |
189 |
my $newval = $self->SUPER::status_alias($val); |
211 |
my $ret = $self->SUPER::status_alias($val); |
190 |
if ($newval) { |
212 |
my $val_to_log = $val ? $new_status_alias : scalar $self->status; |
191 |
return $newval; |
213 |
if ($ret) { |
|
|
214 |
my $logger = Koha::Illrequest::Logger->new; |
215 |
$logger->log_status_change({ |
216 |
request => $self, |
217 |
value => $val_to_log |
218 |
}); |
192 |
} else { |
219 |
} else { |
193 |
return; |
220 |
delete $self->{previous_status}; |
194 |
} |
221 |
} |
|
|
222 |
return $ret; |
195 |
} |
223 |
} |
196 |
# We can't know which result is the right one if there are multiple |
224 |
# We can't know which result is the right one if there are multiple |
197 |
# ILLSTATUS authorised values with the same authorised_value column value |
225 |
# ILLSTATUS authorised values with the same authorised_value column value |
Lines 210-234
sub status_alias {
Link Here
|
210 |
|
238 |
|
211 |
=head3 status |
239 |
=head3 status |
212 |
|
240 |
|
|
|
241 |
$Illrequest->status('CANREQ'); |
242 |
|
213 |
Overloaded getter/setter for request status, |
243 |
Overloaded getter/setter for request status, |
214 |
also nullifies status_alias |
244 |
also nullifies status_alias and records the fact that the status has changed |
215 |
|
245 |
|
216 |
=cut |
246 |
=cut |
217 |
|
247 |
|
218 |
sub status { |
248 |
sub status { |
219 |
my ( $self, $newval) = @_; |
249 |
my ( $self, $new_status) = @_; |
220 |
if ($newval) { |
250 |
|
221 |
# This is hackery to enable us to undefine |
251 |
my $current_status = $self->SUPER::status; |
222 |
# status_alias, since we need to have an overloaded |
252 |
my $current_status_alias = $self->SUPER::status_alias; |
223 |
# status_alias method to get us around the problem described |
253 |
|
224 |
# here: |
254 |
if ($new_status) { |
225 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
255 |
# Keep a record of the previous status before we change it, |
226 |
# We need a way of passing implied undef to nullify status_alias |
256 |
# we might need it |
227 |
# so we pass -1, which is special cased in the overloaded setter |
257 |
$self->{previous_status} = $current_status_alias ? |
228 |
$self->status_alias("-1"); |
258 |
$current_status_alias : |
229 |
return $self->SUPER::status($newval); |
259 |
$current_status; |
|
|
260 |
my $ret = $self->SUPER::status($new_status)->store; |
261 |
if ($current_status_alias) { |
262 |
# This is hackery to enable us to undefine |
263 |
# status_alias, since we need to have an overloaded |
264 |
# status_alias method to get us around the problem described |
265 |
# here: |
266 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
267 |
# We need a way of passing implied undef to nullify status_alias |
268 |
# so we pass -1, which is special cased in the overloaded setter |
269 |
$self->status_alias("-1"); |
270 |
} else { |
271 |
my $logger = Koha::Illrequest::Logger->new; |
272 |
$logger->log_status_change({ |
273 |
request => $self, |
274 |
value => $new_status |
275 |
}); |
276 |
} |
277 |
delete $self->{previous_status}; |
278 |
return $ret; |
279 |
} else { |
280 |
return $current_status; |
230 |
} |
281 |
} |
231 |
return $self->SUPER::status; |
|
|
232 |
} |
282 |
} |
233 |
|
283 |
|
234 |
=head3 load_backend |
284 |
=head3 load_backend |
Lines 252-258
sub load_backend {
Link Here
|
252 |
my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load |
302 |
my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load |
253 |
my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name |
303 |
my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name |
254 |
require $location; |
304 |
require $location; |
255 |
$self->{_my_backend} = $backend_class->new({ config => $self->_config }); |
305 |
$self->{_my_backend} = $backend_class->new({ |
|
|
306 |
config => $self->_config, |
307 |
logger => Koha::Illrequest::Logger->new |
308 |
}); |
256 |
return $self; |
309 |
return $self; |
257 |
} |
310 |
} |
258 |
|
311 |
|
Lines 1107-1112
sub _censor {
Link Here
|
1107 |
return $params; |
1160 |
return $params; |
1108 |
} |
1161 |
} |
1109 |
|
1162 |
|
|
|
1163 |
=head3 store |
1164 |
|
1165 |
$Illrequest->store; |
1166 |
|
1167 |
Overloaded I<store> method that, in addition to performing the 'store', |
1168 |
possibly records the fact that something happened |
1169 |
|
1170 |
=cut |
1171 |
|
1172 |
sub store { |
1173 |
my ( $self, $attrs ) = @_; |
1174 |
|
1175 |
my $ret = $self->SUPER::store; |
1176 |
|
1177 |
$attrs->{log_origin} = 'core'; |
1178 |
|
1179 |
if ($ret && defined $attrs) { |
1180 |
my $logger = Koha::Illrequest::Logger->new; |
1181 |
$logger->log_maybe({ |
1182 |
request => $self, |
1183 |
attrs => $attrs |
1184 |
}); |
1185 |
} |
1186 |
|
1187 |
return $ret; |
1188 |
} |
1189 |
|
1110 |
=head3 TO_JSON |
1190 |
=head3 TO_JSON |
1111 |
|
1191 |
|
1112 |
$json = $illrequest->TO_JSON |
1192 |
$json = $illrequest->TO_JSON |