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