Lines 210-216
sub anonymise_issue_history {
Link Here
|
210 |
|
210 |
|
211 |
=head3 delete |
211 |
=head3 delete |
212 |
|
212 |
|
213 |
Koha::Patrons->search({ some filters here })->delete({ move => 1 }); |
213 |
Koha::Patrons->search({ some filters here })->delete({ move => 1, verbose => 1 }); |
214 |
|
214 |
|
215 |
Delete passed set of patron objects. |
215 |
Delete passed set of patron objects. |
216 |
Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron |
216 |
Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron |
Lines 227-237
sub delete {
Link Here
|
227 |
my $patrons_deleted; |
227 |
my $patrons_deleted; |
228 |
$self->_resultset->result_source->schema->txn_do( sub { |
228 |
$self->_resultset->result_source->schema->txn_do( sub { |
229 |
my ( $set, $params ) = @_; |
229 |
my ( $set, $params ) = @_; |
|
|
230 |
my $count = $set->count; |
230 |
while( my $patron = $set->next ) { |
231 |
while( my $patron = $set->next ) { |
231 |
$patron->move_to_deleted if $params->{move}; |
232 |
$patron->move_to_deleted if $params->{move}; |
232 |
$patron->delete == 1 || Koha::Exceptions::Patron::FailedDelete->throw; |
233 |
$patron->delete == 1 || Koha::Exceptions::Patron::FailedDelete->throw; |
233 |
$patrons_deleted++; |
234 |
$patrons_deleted++; |
234 |
} |
235 |
} |
|
|
236 |
warn "Deleted $count patrons\n" if $params->{verbose}; |
235 |
}, $self, $params ); |
237 |
}, $self, $params ); |
236 |
return $patrons_deleted; |
238 |
return $patrons_deleted; |
237 |
} |
239 |
} |
Lines 328-361
sub search_anonymized {
Link Here
|
328 |
|
330 |
|
329 |
=head3 lock |
331 |
=head3 lock |
330 |
|
332 |
|
331 |
Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1 }) |
333 |
Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1, verbose => 1 }) |
332 |
|
334 |
|
333 |
Lock the passed set of patron objects. Optionally expire and remove holds. |
335 |
Lock the passed set of patron objects. Optionally expire and remove holds. |
|
|
336 |
Optional verbose flag is used in cron job. |
334 |
Wrapper around Koha::Patron->lock. |
337 |
Wrapper around Koha::Patron->lock. |
335 |
|
338 |
|
336 |
=cut |
339 |
=cut |
337 |
|
340 |
|
338 |
sub lock { |
341 |
sub lock { |
339 |
my ( $self, $params ) = @_; |
342 |
my ( $self, $params ) = @_; |
|
|
343 |
my $count = $self->count; |
340 |
while( my $patron = $self->next ) { |
344 |
while( my $patron = $self->next ) { |
341 |
$patron->lock($params); |
345 |
$patron->lock($params); |
342 |
} |
346 |
} |
|
|
347 |
if( $params->{verbose} ) { |
348 |
warn "Locked $count patrons\n"; |
349 |
} |
343 |
} |
350 |
} |
344 |
|
351 |
|
345 |
=head3 anonymize |
352 |
=head3 anonymize |
346 |
|
353 |
|
347 |
Koha::Patrons->search({ some filters })->anonymize; |
354 |
Koha::Patrons->search({ some filters })->anonymize({ verbose => 1 }); |
348 |
|
355 |
|
349 |
Anonymize passed set of patron objects. |
356 |
Anonymize passed set of patron objects. |
|
|
357 |
Optional verbose flag is used in cron job. |
350 |
Wrapper around Koha::Patron->anonymize. |
358 |
Wrapper around Koha::Patron->anonymize. |
351 |
|
359 |
|
352 |
=cut |
360 |
=cut |
353 |
|
361 |
|
354 |
sub anonymize { |
362 |
sub anonymize { |
355 |
my ( $self ) = @_; |
363 |
my ( $self, $params ) = @_; |
|
|
364 |
my $count = $self->count; |
356 |
while( my $patron = $self->next ) { |
365 |
while( my $patron = $self->next ) { |
357 |
$patron->anonymize; |
366 |
$patron->anonymize; |
358 |
} |
367 |
} |
|
|
368 |
if( $params->{verbose} ) { |
369 |
warn "Anonymized $count patrons\n"; |
370 |
} |
359 |
} |
371 |
} |
360 |
|
372 |
|
361 |
=head3 _type |
373 |
=head3 _type |