$settings{$_} = get_setting($e, $user_id, $_) for @$setting;
return \%settings;
} else {
- return get_setting($e, $user_id, $setting);
+ return get_setting($e, $user_id, $setting);
}
} else {
my $s = $e->search_actor_user_setting({usr => $user_id});
api_name => "open-ils.actor.org_unit_setting.values.ranged.retrieve",
signature => {
desc => "Retrieves all org unit settings for the given org_id, up to whatever limit " .
- "is implied for retrieving OU settings by the authenticated users' permissions.",
+ "is implied for retrieving OU settings by the authenticated users' permissions.",
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'Org unit ID', type => 'number'},
# start at the context org and capture the setting value
# without clobbering settings we've already captured
for my $this_org_id (@$org_list) {
-
+
my @sets = grep { $_->org_unit == $this_org_id } @$settings;
for my $set (@sets) {
);
# ------------------------------------------------------------------
-# Attempts to find the org setting value for a given org. if not
-# found at the requested org, searches up the org tree until it
+# Attempts to find the org setting value for a given org. if not
+# found at the requested org, searches up the org tree until it
# finds a parent that has the requested setting.
# when found, returns { org => $id, value => $value }
# otherwise, returns NULL
signature => {
desc => q/
Update an existing user, or create a new one. Related objects,
- like cards, addresses, survey responses, and stat cats,
+ like cards, addresses, survey responses, and stat cats,
can be updated by attaching them to the user object in their
respective fields. For examples, the billing address object
- may be inserted into the 'billing_address' field, etc. For each
- attached object, indicate if the object should be created,
- updated, or deleted using the built-in 'isnew', 'ischanged',
+ may be inserted into the 'billing_address' field, etc. For each
+ attached object, indicate if the object should be created,
+ updated, or deleted using the built-in 'isnew', 'ischanged',
and 'isdeleted' fields on the object.
/,
params => [
my $e = new_editor(xact => 1, authtoken => $auth);
return $e->event unless $e->checkauth;
- $logger->info($patron->isnew ? "Creating new patron..." :
+ $logger->info($patron->isnew ? "Creating new patron..." :
"Updating Patron: " . $patron->id);
my $evt = check_group_perm($e, $e->requestor, $patron);
# unflesh the real items on the patron
$patron->card( $patron->card->id ) if(ref($patron->card));
- $patron->billing_address( $patron->billing_address->id )
+ $patron->billing_address( $patron->billing_address->id )
if(ref($patron->billing_address));
- $patron->mailing_address( $patron->mailing_address->id )
+ $patron->mailing_address( $patron->mailing_address->id )
if(ref($patron->mailing_address));
# create/update the patron first so we can use his id
my $perm = $U->is_true($old_patron->barred) ? 'UNBAR_PATRON' : 'BAR_PATRON';
return $e->die_event unless $e->allowed($perm, $patron->home_ou);
- $barred_hook = $U->is_true($new_patron->barred) ?
+ $barred_hook = $U->is_true($new_patron->barred) ?
'au.barred' : 'au.unbarred';
}
}
my $tses = OpenSRF::AppSession->create('open-ils.trigger');
if($patron->isnew) {
- $tses->request('open-ils.trigger.event.autocreate',
+ $tses->request('open-ils.trigger.event.autocreate',
'au.create', $new_patron, $new_patron->home_ou);
} else {
- $tses->request('open-ils.trigger.event.autocreate',
+ $tses->request('open-ils.trigger.event.autocreate',
'au.update', $new_patron, $new_patron->home_ou);
- $tses->request('open-ils.trigger.event.autocreate', $barred_hook,
+ $tses->request('open-ils.trigger.event.autocreate', $barred_hook,
$new_patron, $new_patron->home_ou) if $barred_hook;
}
# grab the invalid address penalty if set
my $penalties = OpenILS::Utils::Penalty->retrieve_usr_penalties($e, $patron->id, $patron->home_ou);
- my ($addr_penalty) = grep
+ my ($addr_penalty) = grep
{ $_->standing_penalty->name eq 'INVALID_PATRON_ADDRESS' } @$penalties;
-
+
# do we enforce invalid address penalty
my $enforce = $U->ou_ancestor_setting_value(
$patron->home_ou, 'circ.patron_invalid_address_apply_penalty') || 0;
$e->commit;
} elsif($enforce and $addr_count > 0 and !$addr_penalty) {
-
+
my $ptype = $e->retrieve_config_standing_penalty(29) or return $e->die_event;
my $depth = $ptype->org_depth;
my $ctx_org = $U->org_unit_ancestor_at_depth($patron->home_ou, $depth) if defined $depth;
$ctx_org = $patron->home_ou unless defined $ctx_org;
-
+
my $penalty = Fieldmapper::actor::user_standing_penalty->new;
$penalty->usr($patron->id);
$penalty->org_unit($ctx_org);
my $e = shift;
my $patron = shift;
- return (undef, $e->die_event) unless
+ return (undef, $e->die_event) unless
$e->allowed('CREATE_USER', $patron->home_ou);
my $ex = $e->search_actor_user(
my( $e, $requestor, $patron ) = @_;
my $evt;
- # first let's see if the requestor has
+ # first let's see if the requestor has
# priveleges to update this user in any way
if( ! $patron->isnew ) {
my $p = $e->retrieve_actor_user($patron->id);
# If we are the requestor (trying to update our own account)
# and we are not trying to change our profile, we're good
- if( $p->id == $requestor->id and
+ if( $p->id == $requestor->id and
$p->profile == $patron->profile ) {
return undef;
}
return $evt if $evt;
}
- # They are allowed to edit this patron.. can they put the
+ # They are allowed to edit this patron.. can they put the
# patron into the group requested?
$evt = group_perm_failed($e, $requestor, $patron);
return $evt if $evt;
return undef unless $patron->ident_value;
my $search = {
- ident_type => $patron->ident_type,
+ ident_type => $patron->ident_type,
ident_value => $patron->ident_value,
};
- $logger->debug("patron update searching for dup ident values: " .
+ $logger->debug("patron update searching for dup ident values: " .
$patron->ident_type . ':' . $patron->ident_value);
$search->{id} = {'!=' => $patron->id} if $patron->id and $patron->id > 0;
$new_patron->billing_address($address->id());
$new_patron->ischanged(1);
}
-
+
if( $patron->mailing_address() and
$patron->mailing_address() == $current_id ) {
$new_patron->mailing_address($address->id());
return (undef, $evt) if $evt;
# we need to get the new id
- if( $patron->billing_address() and
+ if( $patron->billing_address() and
$patron->billing_address() == $current_id ) {
$new_patron->billing_address($address->id());
$logger->info("setting billing addr to $current_id");
$evt = _delete_address($e, $address);
return (undef, $evt) if $evt;
- }
+ }
}
return ( $new_patron, undef );
$_->usr($new_patron->id) for (@$responses);
- my $evt = $U->simplereq( "open-ils.circ",
+ my $evt = $U->simplereq( "open-ils.circ",
"open-ils.circ.survey.submit.user_id", $responses );
return (undef, $evt) if defined($U->event_code($evt));
my @penalties_to_clear;
my ($field, $penalty_name);
- # For each field that might have an associated bad contact penalty,
+ # For each field that might have an associated bad contact penalty,
# check for such penalties and add them to the to-clear list if that
# field has changed.
while (($field, $penalty_name) = each(%$PNM)) {
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
my $user = $e->retrieve_actor_user($id) or return $e->event;
- return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
+ return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
return $user;
}
my $ident_types;
sub get_user_ident_types {
return $ident_types if $ident_types;
- return $ident_types =
+ return $ident_types =
new_editor()->retrieve_all_config_identification_type();
}
my $list = OpenILS::Application::AppUtils->simple_scalar_request(
"open-ils.cstore",
- "open-ils.cstore.direct.actor.org_unit.search.atomic",
+ "open-ils.cstore.direct.actor.org_unit.search.atomic",
{ $field => $value } );
return $list;
__PACKAGE__->register_method(
method => "get_org_tree",
api_name => "open-ils.actor.org_tree.retrieve",
- argc => 0,
+ argc => 0,
note => "Returns the entire org tree structure",
);
my @trees;
for my $i (0..scalar(@$org_unit)-1) {
my $list = $U->simple_scalar_request(
- "open-ils.storage",
+ "open-ils.storage",
"open-ils.storage.actor.org_unit.descendants.atomic",
$org_unit->[$i], $depth->[$i] );
push(@trees, $U->build_org_tree($list));
} else {
my $orglist = $apputils->simple_scalar_request(
- "open-ils.storage",
+ "open-ils.storage",
"open-ils.storage.actor.org_unit.descendants.atomic",
$org_unit, $depth );
return $U->build_org_tree($orglist);
sub get_org_ancestors {
my( $self, $client, $org_unit, $depth ) = @_;
my $orglist = $apputils->simple_scalar_request(
- "open-ils.storage",
+ "open-ils.storage",
"open-ils.storage.actor.org_unit.ancestors.atomic",
$org_unit, $depth );
return $U->build_org_tree($orglist);
my $user_standings;
sub get_standings {
return $user_standings if $user_standings;
- return $user_standings =
+ return $user_standings =
$apputils->simple_scalar_request(
"open-ils.cstore",
"open-ils.cstore.direct.config.standing.search.atomic",
# seeing results fairly quickly
max_chunk_size => 4096, # bundling
- # api_level => 2,
+ # api_level => 2,
# pending opensrf work -- also, not sure if needed since we're not
# actaully creating an alternate vesrion, only offering to return a
# different format.
);
sub patron_adv_search {
- my( $self, $client, $auth, $search_hash, $search_limit,
+ my( $self, $client, $auth, $search_hash, $search_limit,
$search_sort, $include_inactive, $search_ou, $flesh_fields, $offset) = @_;
# API params sanity checks.
}
my $ids = $U->storagereq(
- "open-ils.storage.actor.user.crazy_search", $search_hash,
- $search_limit, $search_sort, $include_inactive,
+ "open-ils.storage.actor.user.crazy_search", $search_hash,
+ $search_limit, $search_sort, $include_inactive,
$e->requestor->ws_ou, $search_ou, $opt_boundary, $offset);
return $ids unless $self->api_name =~ /fleshed/;
method => "update_passwd",
api_name => "open-ils.actor.user.password.update",
signature => {
- desc => "Update the operator's password",
+ desc => "Update the operator's password",
params => [
{ desc => 'Authentication token', type => 'string' },
{ desc => 'New password', type => 'string' },
method => "update_passwd",
api_name => "open-ils.actor.user.username.update",
signature => {
- desc => "Update the operator's username",
+ desc => "Update the operator's username",
params => [
{ desc => 'Authentication token', type => 'string' },
{ desc => 'New username', type => 'string' },
method => "update_passwd",
api_name => "open-ils.actor.user.email.update",
signature => {
- desc => "Update the operator's email address",
+ desc => "Update the operator's email address",
params => [
{ desc => 'Authentication token', type => 'string' },
{ desc => 'New email address', type => 'string' },
if( $api =~ /username/o ) {
# make sure no one else has this username
- my $exist = $e->search_actor_user({usrname=>$new_val},{idlist=>1});
+ my $exist = $e->search_actor_user({usrname=>$new_val},{idlist=>1});
if (@$exist) {
$e->rollback;
return new OpenILS::Event('USERNAME_EXISTS');
authoritative => 1,
signature => {
desc => q/
- Returns a set of org unit IDs which represent the highest orgs in
+ Returns a set of org unit IDs which represent the highest orgs in
the org tree where the user has the requested permission. The
purpose of this method is to return the smallest set of org units
which represent the full expanse of the user's ability to perform
params => [
{desc => 'authtoken', type => 'string'},
{desc => 'permission name', type => 'string'},
- {desc => q/user id, optional. If present, check perms for
+ {desc => q/user id, optional. If present, check perms for
this user instead of the logged in user/, type => 'number'},
],
return => {desc => 'An array of org IDs'}
'VIEW_PERMISSION' rights at the home org unit of the target user
@param authtoken The login session key
@param userid The id of the user in question
- @param perms An array of perm names to check
- @return An array of orgId's representing the org unit
+ @param perms An array of perm names to check
+ @return An array of orgId's representing the org unit
highest in the org tree within which the user has the requested permission
The arrah of orgId's has matches the order of the perms array
/);
sub check_user_perms4 {
my( $self, $client, $authtoken, $userid, $perms ) = @_;
-
+
my( $staff, $target, $org, $evt );
( $staff, $target, $evt ) = $apputils->checkses_requestor(
authoritative => 1,
signature => {
desc => 'Returns a short summary of the users total open fines, ' .
- 'excluding voided fines Params are login_session, user_id' ,
+ 'excluding voided fines Params are login_session, user_id' ,
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'User ID', type => 'string'} # number?
if( $user_id ne $e->requestor->id ) {
my $user = $e->retrieve_actor_user($user_id) or return $e->event;
- return $e->event unless
+ return $e->event unless
$e->allowed('VIEW_USER_FINES_SUMMARY', $user->home_ou);
}
authoritative => 1,
signature => {
desc => 'Returns a short summary of the users vital stats, including ' .
- 'identification information, accumulated balance, number of holds, ' .
- 'and current open circulation stats' ,
+ 'identification information, accumulated balance, number of holds, ' .
+ 'and current open circulation stats' ,
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'Optional User ID, for use in the staff client', type => 'number'} # number?
params => $common_params,
return => {
desc => "List of objects, or event on error. Each object is a hash containing: transaction, circ, record. "
- . 'These represent the relevant (mbts) transaction, attached circulation and title pointed to in the circ, respectively.',
+ . 'These represent the relevant (mbts) transaction, attached circulation and title pointed to in the circ, respectively.',
}
}
);
my $user = $e->retrieve_actor_user($user_id) or return $e->event;
- return $e->event unless
+ return $e->event unless
$e->requestor->id == $user_id or
$e->allowed('VIEW_USER_TRANSACTIONS', $user->home_ou);
$method = "$method.authoritative" if $api =~ /authoritative/;
my ($trans) = $self->method_lookup($method)->run($auth, $user_id, $type, $filter, $options);
- if($api =~ /total/o) {
+ if($api =~ /total/o) {
my $total = 0.0;
$total += $_->balance_owed for @$trans;
return $total;
my @resp;
for my $t (@$trans) {
-
+
if( $t->xact_type ne 'circulation' ) {
push @resp, {transaction => $t};
next;
push @resp, {transaction => $t, %$circ_data};
}
- return \@resp;
-}
+ return \@resp;
+}
__PACKAGE__->register_method(
argc => 1,
notes => q/
Returns hold ready vs. total counts.
- If a context org unit is provided, a third value
+ If a context org unit is provided, a third value
is returned with key 'behind_desk', which reports
- how many holds are ready at the pickup library
+ how many holds are ready at the pickup library
with the behind_desk flag set to true.
/
);
-
+
sub hold_request_count {
my( $self, $client, $authtoken, $user_id, $ctx_org ) = @_;
my $e = new_editor(authtoken => $authtoken);
}
});
- my @ready = grep {
+ my @ready = grep {
$_->{current_shelf_lib} and # avoid undef warnings
- $_->{pickup_lib} eq $_->{current_shelf_lib}
+ $_->{pickup_lib} eq $_->{current_shelf_lib}
} @$holds;
- my $resp = {
- total => scalar(@$holds),
+ my $resp = {
+ total => scalar(@$holds),
ready => scalar(@ready)
};
argc => 2,
signature => {
desc => "For a given user, returns a structure of circulations objects sorted by out, overdue, lost, claims_returned, long_overdue. "
- . "A list of IDs are returned of each type. Circs marked lost, long_overdue, and claims_returned will not be 'finished' "
- . "(i.e., outstanding balance or some other pending action on the circ). "
- . "The .count method also includes a 'total' field which sums all open circs.",
+ . "A list of IDs are returned of each type. Circs marked lost, long_overdue, and claims_returned will not be 'finished' "
+ . "(i.e., outstanding balance or some other pending action on the circ). "
+ . "The .count method also includes a 'total' field which sums all open circs.",
params => [
{ desc => 'Authentication Token', type => 'string'},
{ desc => 'User ID', type => 'string'},
],
return => {
desc => 'Returns event on error, or an object with ID lists, like: '
- . '{"out":[12552,451232], "claims_returned":[], "long_overdue":[23421] "overdue":[], "lost":[]}'
+ . '{"out":[12552,451232], "claims_returned":[], "long_overdue":[23421] "overdue":[], "lost":[]}'
},
}
);
# money is owed on these items and they are checked in
my $open = $e->search_action_circulation(
{
- usr => $userid,
+ usr => $userid,
xact_finish => undef,
checkin_time => { "!=" => undef },
}
api_name => "open-ils.actor.user.transactions.$api",
signature => {
desc => "For a given User ID, returns a list of billable transaction" .
- ($ids ? " id" : '') .
- "s$desc, optionally filtered by type and/or fields in money.billable_xact_summary. " .
- "The VIEW_USER_TRANSACTIONS permission is required to view another user's transactions",
+ ($ids ? " id" : '') .
+ "s$desc, optionally filtered by type and/or fields in money.billable_xact_summary. " .
+ "The VIEW_USER_TRANSACTIONS permission is required to view another user's transactions",
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'User ID', type => 'number'},
}
my $options_clause = { order_by => { mbt => 'xact_start DESC' } };
- $options_clause->{'limit'} = $options->{'limit'} if $options->{'limit'};
- $options_clause->{'offset'} = $options->{'offset'} if $options->{'offset'};
+ $options_clause->{'limit'} = $options->{'limit'} if $options->{'limit'};
+ $options_clause->{'offset'} = $options->{'offset'} if $options->{'offset'};
my $mbts = $e->search_money_billable_transaction_summary(
[ { usr => $userid, @xact_finish, %$filter },
my @resp;
for my $t (@$mbts) {
-
+
if( $t->xact_type ne 'circulation' ) {
push @resp, {transaction => $t};
next;
push @resp, {transaction => $t, %$circ_data};
}
- return \@resp;
+ return \@resp;
}
argc => 1,
notes => "Returns a list of permissions"
);
-
+
sub user_perms {
my( $self, $client, $authtoken, $user ) = @_;
api_name => "open-ils.actor.groups.tree.retrieve",
notes => "Returns a list of user groups"
);
-
+
sub retrieve_groups_tree {
my( $self, $client ) = @_;
return new_editor()->search_permission_grp_tree(
[
{ parent => undef},
- {
+ {
flesh => -1,
- flesh_fields => { pgt => ["children"] },
+ flesh_fields => { pgt => ["children"] },
order_by => { pgt => 'name'}
}
]
api_name => "open-ils.actor.user.set_groups",
notes => "Adds a user to one or more permission groups"
);
-
+
sub add_user_to_groups {
my( $self, $client, $authtoken, $userid, $groups ) = @_;
$apputils->simplereq(
'open-ils.storage',
'open-ils.storage.direct.permission.usr_grp_map.mass_delete', { usr => $userid } );
-
+
for my $group (@$groups) {
my $link = Fieldmapper::permission::usr_grp_map->new;
$link->grp($group);
return $apputils->simplereq(
'open-ils.cstore',
'open-ils.cstore.direct.permission.usr_grp_map.search.atomic', { usr => $userid } );
-}
+}
__PACKAGE__->register_method(
# client just wants a list of org IDs
return $U->get_user_work_ou_ids($e, $userid);
-}
+}
if( $existing ) {
if( $self->api_name =~ /override/o && ($oargs->{all} || grep { $_ eq 'WORKSTATION_NAME_EXISTS' } @{$oargs->{events}}) ) {
- # workstation with the given name exists.
+ # workstation with the given name exists.
if($owner ne $existing->owning_lib) {
# if necessary, update the owning_lib of the workstation
$logger->info("changing owning lib of workstation ".$existing->id.
" from ".$existing->owning_lib." to $owner");
- return $e->die_event unless
- $e->allowed('UPDATE_WORKSTATION', $existing->owning_lib);
+ return $e->die_event unless
+ $e->allowed('UPDATE_WORKSTATION', $existing->owning_lib);
- return $e->die_event unless $e->allowed('UPDATE_WORKSTATION', $owner);
+ return $e->die_event unless $e->allowed('UPDATE_WORKSTATION', $owner);
$existing->owning_lib($owner);
return $e->die_event unless $e->update_actor_workstation($existing);
$e->commit;
} else {
- $logger->info(
+ $logger->info(
"attempt to register an existing workstation. returning existing ID");
}
my %results;
for my $o (@orgs) {
- return $e->event
+ return $e->event
unless $e->allowed('REGISTER_WORKSTATION', $o);
$results{$o} = $e->search_actor_workstation({owning_lib=>$o});
}
return $evt if $evt;
}
return $U->cstorereq(
- 'open-ils.cstore.direct.actor.usr_note.search.atomic',
+ 'open-ils.cstore.direct.actor.usr_note.search.atomic',
{ usr => $patronid, pub => 't' } );
}
my $user = $e->retrieve_actor_user($note->usr)
or return $e->die_event;
- return $e->die_event unless
+ return $e->die_event unless
$e->allowed('UPDATE_USER',$user->home_ou);
$note->creator($e->requestor->id);
or return $e->die_event;
my $user = $e->retrieve_actor_user($note->usr)
or return $e->die_event;
- return $e->die_event unless
+ return $e->die_event unless
$e->allowed('UPDATE_USER', $user->home_ou);
-
+
$e->delete_actor_usr_note($note) or return $e->die_event;
$e->commit;
return 1;
return $e->die_event unless $e->checkauth;
my $patron = $e->retrieve_actor_user($note->usr)
or return $e->die_event;
- return $e->die_event unless
+ return $e->die_event unless
$e->allowed('UPDATE_USER', $patron->home_ou);
$e->update_actor_user_note($note)
or return $e->die_event;
# add more user fields as needed
$cache->put_cache(
- "safe-token-user-$safe_token", {
- id => $e->requestor->id,
+ "safe-token-user-$safe_token", {
+ id => $e->requestor->id,
home_ou_shortname => $e->retrieve_actor_org_unit(
$e->requestor->home_ou)->shortname,
},
return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
my $ptype = $e->retrieve_config_standing_penalty($penalty->standing_penalty) or return $e->die_event;
-
- my $ctx_org =
+
+ my $ctx_org =
(defined $ptype->org_depth) ?
$U->org_unit_ancestor_at_depth($penalty->org_unit, $ptype->org_depth) :
$penalty->org_unit;
$user->addresses([]) unless @{$user->addresses};
# don't expose "replaced" addresses by default
$user->addresses([grep {$_->id >= 0} @{$user->addresses}]);
-
+
if( ref $user->billing_address ) {
unless( grep { $user->billing_address->id == $_->id } @{$user->addresses} ) {
push( @{$user->addresses}, $user->billing_address );
}
}
-
+
if( ref $user->mailing_address ) {
unless( grep { $user->mailing_address->id == $_->id } @{$user->addresses} ) {
push( @{$user->addresses}, $user->mailing_address );
# grab the user penalties ranged for this location
$user->standing_penalties(
$e->search_actor_user_standing_penalty([
- { usr => $id,
+ { usr => $id,
'-or' => [
{stop_date => undef},
{stop_date => {'>' => 'now'}}
# max number to return for simple patron fleshing
my $limit = $U->ou_ancestor_setting_value(
- $e->requestor->ws_ou,
+ $e->requestor->ws_ou,
'circ.patron.usr_activity_retrieve.max');
my $opts = {
flesh => 1,
flesh_fields => {auact => ['etype']},
- order_by => {auact => 'event_time DESC'},
+ order_by => {auact => 'event_time DESC'},
};
# 0 == none, <0 == return all
$limit = 1 unless defined $limit;
$opts->{limit} = $limit if $limit > 0;
- $user->usr_activity(
- ($limit == 0) ?
+ $user->usr_activity(
+ ($limit == 0) ?
[] : # skip the DB call
$e->search_actor_usr_activity([{usr => $user->id}, $opts])
);
sub user_opt_in_enabled {
my($self, $conn) = @_;
my $sc = OpenSRF::Utils::SettingsClient->new;
- return 1 if lc($sc->config_value(share => user => 'opt_in')) eq 'true';
+ return 1 if lc($sc->config_value(share => user => 'opt_in')) eq 'true';
return 0;
}
-
+
__PACKAGE__->register_method(
method => 'user_opt_in_at_org',
# get the boundary setting
my $opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary');
-
+
# auto opt in if user falls within the opt boundary
my $opt_orgs = $U->get_org_descendants($ws_org, $opt_boundary);
my $e = new_editor(authtoken => $auth, xact=>1);
return $e->die_event unless $e->checkauth;
-
+
# if a specific org unit wasn't passed in, get one based on the defaults;
if(!$org_id){
my $wsou = $e->requestor->ws_ou;
# get the default opt depth
- my $opt_depth = $U->ou_ancestor_setting_value($wsou,'org.patron_opt_default');
+ my $opt_depth = $U->ou_ancestor_setting_value($wsou,'org.patron_opt_default');
# get the org unit at that depth
- my $org = $e->json_query({
+ my $org = $e->json_query({
from => [ 'actor.org_unit_ancestor_at_depth', $wsou, $opt_depth ]})->[0];
$org_id = $org->{id};
- }
+ }
if (!$org_id) {
# fall back to the workstation OU, the pre-opt-in-boundary way
$org_id = $e->requestor->ws_ou;
method => 'verify_user_password',
api_name => 'open-ils.actor.verify_user_password',
signature => q/
- Given a barcode or username and the MD5 encoded password,
+ Given a barcode or username and the MD5 encoded password,
returns 1 if the password is correct. Returns 0 otherwise.
/
);
$user = $user_by_username;
}
return 0 if (!$user);
- return 0 if ($user_by_username && $user_by_barcode && $user_by_username->id != $user_by_barcode->id);
+ return 0 if ($user_by_username && $user_by_barcode && $user_by_username->id != $user_by_barcode->id);
return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
return $U->verify_migrated_user_password(
$e, $user_by_username->id, $password, 1);
$user = $user_by_username;
}
return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if (!$user);
- return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if ($user_by_username && $user_by_barcode && $user_by_username->id != $user_by_barcode->id);
+ return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ) if ($user_by_username && $user_by_barcode && $user_by_username->id != $user_by_barcode->id);
return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
return $user->id;
}
signature => {
desc => q/
Given a list of source users and destination user, transfer all data from the source
- to the dest user and delete the source user. All user related data is
+ to the dest user and delete the source user. All user related data is
transferred, including circulations, holds, bookbags, etc.
/
}
return $e->die_event unless $e->allowed('MERGE_USERS', $master_user->home_ou);
}
- return $e->die_event unless
+ return $e->die_event unless
$e->json_query({from => [
- 'actor.usr_merge',
- $src_id,
+ 'actor.usr_merge',
+ $src_id,
$master_id,
$del_addrs,
$del_cards,
my $e = new_editor(xact => 1, authtoken => $auth);
return $e->die_event unless $e->checkauth;
if(ref $addr) {
- # if the caller passes an address object, assume they want to
+ # if the caller passes an address object, assume they want to
# update it first before approving it
$e->update_actor_user_address($addr) or return $e->die_event;
} else {
my $result = $e->json_query({from => ['actor.approve_pending_address', $addr->id]})->[0]
or return $e->die_event;
$e->commit;
- return [values %$result]->[0];
+ return [values %$result]->[0];
}
return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
}
- return OpenILS::Application::Actor::Friends->retrieve_friends(
+ return OpenILS::Application::Actor::Friends->retrieve_friends(
$e, $user_id, $options);
}
}
for my $perm (@perms) {
- my $evt =
+ my $evt =
OpenILS::Application::Actor::Friends->apply_friend_perm(
$e, $user_id, $delegate_id, $perm);
return $evt if $evt;
my $user_field = 'usr';
$filters ||= {};
- $filters->{target} = {
+ $filters->{target} = {
select => { $obj_type => ['id'] },
from => $obj_type,
where => {usr => $user_id}
}
my $ses = OpenSRF::AppSession->create('open-ils.trigger');
- my $req = $ses->request('open-ils.trigger.events_by_target',
+ my $req = $ses->request('open-ils.trigger.events_by_target',
$obj_type, $filters, {atevdef => ['reactor', 'validator']}, 2);
while(my $resp = $req->recv) {
$copy_field = 'current_copy' if $obj_type eq 'ahr';
$filters ||= {};
- $filters->{target} = {
+ $filters->{target} = {
select => { $obj_type => ['id'] },
from => $obj_type,
where => {$copy_field => $copy_id}
my $ses = OpenSRF::AppSession->create('open-ils.trigger');
- my $req = $ses->request('open-ils.trigger.events_by_target',
+ my $req = $ses->request('open-ils.trigger.events_by_target',
$obj_type, $filters, {atevdef => ['reactor', 'validator']}, 2);
while(my $resp = $req->recv) {
my $val = $resp->content;
my $tgt = $val->target;
-
+
my $user = $e->retrieve_actor_user($tgt->usr);
if($e->requestor->id != $user->id) {
return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
method => 'really_delete_user',
api_name => 'open-ils.actor.user.delete',
signature => q/
- It anonymizes all personally identifiable information in actor.usr. By calling actor.usr_purge_data()
+ It anonymizes all personally identifiable information in actor.usr. By calling actor.usr_purge_data()
it also purges related data from other tables, sometimes by transferring it to a designated destination user.
The usrname field (along with first_given_name and family_name) is updated to id '-PURGED-' now().
dest_usr_id is only required when deleting a user that performs staff functions.
return $e->die_event unless $e->checkauth;
my $user = $e->retrieve_actor_user($user_id) or return $e->event;
- return $e->event unless
+ return $e->event unless
$e->requestor->id == $user_id or
$e->allowed('VIEW_USER_TRANSACTIONS', $user->home_ou);
# Find all payments for all transactions for user $user_id
my $query = {
- select => {mp => ['id']},
- from => 'mp',
+ select => {mp => ['id']},
+ from => 'mp',
where => {
xact => {
in => {
- select => {mbt => ['id']},
- from => 'mbt',
+ select => {mbt => ['id']},
+ from => 'mbt',
where => {usr => $user_id}
- }
+ }
}
},
order_by => [
{ # by default, order newest payments first
- class => 'mp',
+ class => 'mp',
field => 'payment_ts',
direction => 'desc'
}, {
if(defined $filters->{where}) {
foreach (keys %{$filters->{where}}) {
# don't allow the caller to expand the result set to other users
- $query->{where}->{$_} = $filters->{where}->{$_} unless $_ eq 'xact';
+ $query->{where}->{$_} = $filters->{where}->{$_} unless $_ eq 'xact';
}
}
signature => q/
Returns all users that have an overall negative balance
@param auth Authentication token
- @param org_id The context org unit as an ID or list of IDs. This will be the home
+ @param org_id The context org unit as an ID or list of IDs. This will be the home
library of the user. If no org_unit is specified, no org unit filter is applied
/
);
return $e->die_event unless $e->allowed('VIEW_USER', $org_id);
my $query = {
- select => {
- mous => ['usr', 'balance_owed'],
- au => ['home_ou'],
+ select => {
+ mous => ['usr', 'balance_owed'],
+ au => ['home_ou'],
mbts => [
{column => 'last_billing_ts', transform => 'max', aggregate => 1},
{column => 'last_payment_ts', transform => 'max', aggregate => 1},
]
- },
- from => {
- mous => {
- au => {
- fkey => 'usr',
- field => 'id',
- join => {
- mbts => {
- key => 'id',
- field => 'usr'
- }
- }
- }
- }
- },
- where => {'+mous' => {balance_owed => {'<' => 0}}}
+ },
+ from => {
+ mous => {
+ au => {
+ fkey => 'usr',
+ field => 'id',
+ join => {
+ mbts => {
+ key => 'id',
+ field => 'usr'
+ }
+ }
+ }
+ }
+ },
+ where => {'+mous' => {balance_owed => {'<' => 0}}}
};
$query->{from}->{mous}->{au}->{filter}->{home_ou} = $org_id if $org_id;
my $card = $e->search_actor_card([
{barcode => $user_id},
{flesh => 1, flesh_fields => {ac => ['usr']}}])->[0];
- if (!$card) {
+ if (!$card) {
$e->die_event;
return OpenILS::Event->new('ACTOR_USER_NOT_FOUND');
}
$user = $card->usr;
}
-
+
# If the user doesn't have an email address, we can't help them
if (!$user->email) {
$e->die_event;
return OpenILS::Event->new('PATRON_NO_EMAIL_ADDRESS');
}
-
+
my $email_must_match = $U->ou_ancestor_setting_value($user->home_ou, 'circ.password_reset_request_requires_matching_email');
if ($email_must_match) {
if (lc($user->email) ne lc($email)) {
# TODO Check to see if the user is in a password-reset-restricted group
# Otherwise, go ahead and try to get the user.
-
+
# Check the number of active requests for this user
$active_requests = $e->json_query({
from => 'aupr',
sub check_password_strength_default {
my $password = shift;
# Use the default set of checks
- if ( (length($password) < 7) or
- ($password !~ m/.*\d+.*/) or
+ if ( (length($password) < 7) or
+ ($password !~ m/.*\d+.*/) or
($password !~ m/.*[A-Za-z]+.*/)
- ) {
+ ) {
return 0;
}
return 1;
desc => 'Streams the set of "cust" objects that are used as opt-in settings for event definitions',
params => [
{ desc => 'Authentication token', type => 'string'},
- {
- desc => 'Org Unit ID. (optional). If no org ID is present, the home_ou of the requesting user is used',
+ {
+ desc => 'Org Unit ID. (optional). If no org ID is present, the home_ou of the requesting user is used',
type => 'number'
},
],
return $e->event unless $e->checkauth;
if(defined $org_id and $org_id != $e->requestor->home_ou) {
- return $e->event unless
+ return $e->event unless
$e->allowed(['VIEW_USER_SETTING_TYPE', 'ADMIN_USER_SETTING_TYPE'], $org_id);
} else {
$org_id = $e->requestor->home_ou;
# find all config.user_setting_type's related to event_defs for the requested org unit
my $types = $e->json_query({
- select => {cust => ['name']},
- from => {atevdef => 'cust'},
+ select => {cust => ['name']},
+ from => {atevdef => 'cust'},
where => {
'+atevdef' => {
owner => $U->get_org_ancestors($org_id), # context org plus parents
});
if(@$types) {
- $conn->respond($_) for
+ $conn->respond($_) for
@{$e->search_config_usr_setting_type({name => [map {$_->{name}} @$types]})};
}
]);
if ($for_print) {
- return $U->fire_object_event(undef,
+ return $U->fire_object_event(undef,
'circ.format.history.print', $circs, $e->requestor->home_ou);
}
if ($for_email) {
# events will be fired from action_trigger_runner
- $U->create_events_for_hook('circ.format.history.email',
+ $U->create_events_for_hook('circ.format.history.email',
$circ, $e->editor->home_ou, undef, undef, 1);
} elsif ($for_clear) {
- $e->delete_action_user_circ_history($circ)
+ $e->delete_action_user_circ_history($circ)
or return $e->die_event;
} else {
offset => $$options{offset}
# TODO: I only want IDs. code below didn't get me there
- # {"select":{"au":[{"column":"id", "result_field":"id",
+ # {"select":{"au":[{"column":"id", "result_field":"id",
# "transform":"action.usr_visible_circs"}]}, "where":{"id":10}, "from":"au"}
},{
substream => 1
return => {
desc => q/The retrieved or updated saved search object, or id of a deleted object; Event on error/,
class => 'auss'
- }
+ }
}
);
return => {
desc => q/The saved search object, Event on error/,
class => 'auss'
- }
+ }
}
);
# map the json_query hashes to real objects
return [
- map {$e->retrieve_actor_address_alert($_)}
+ map {$e->retrieve_actor_address_alert($_)}
(map {$_->{id}} @$alerts)
];
}
type => "number"}
],
return => {
- desc => "Entry fleshed with query on Create, Retrieve, and Uupdate. 1 on Delete",
+ desc => "Entry fleshed with query on Create, Retrieve, and Uupdate. 1 on Delete",
type => "object"
}
}
if (ref $arg) {
if ($arg->isnew) {
-
+
my $grp = $e->retrieve_actor_search_filter_group($arg->grp)
or return $e->die_event;
]) or return $e->die_event;
return $e->die_event unless $e->allowed(
- ['ADMIN_SEARCH_FILTER_GROUP', 'VIEW_SEARCH_FILTER_GROUP'],
+ ['ADMIN_SEARCH_FILTER_GROUP', 'VIEW_SEARCH_FILTER_GROUP'],
$entry->grp->owner);
$e->rollback;
my $e = $self->editor;
# are we already in a transaction?
- my $local_xact = !$e->{xact_id};
+ my $local_xact = !$e->{xact_id};
$e->xact_begin if $local_xact;
# keep the original user object so we can restore
$self->ctx->{user}->addresses([
grep {$_->id > 0} @{$self->ctx->{user}->addresses} ]);
- return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR
+ return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR
unless $self->ctx->{user};
return;
return (0, 0);
}
-# context additions:
+# context additions:
# user : au object, fleshed
sub load_myopac_prefs {
my $self = shift;
}
}
- return Apache2::Const::OK unless
+ return Apache2::Const::OK unless
$pending_addr or $replace_addr or $delete_pending;
my @form_fields = qw/address_type street1 street2 city county state country post_code/;
} elsif( $delete_pending ) {
$paddr = $e->retrieve_actor_user_address($delete_pending);
- return Apache2::Const::HTTP_BAD_REQUEST unless
+ return Apache2::Const::HTTP_BAD_REQUEST unless
$paddr and $paddr->usr == $user->id and $U->is_true($paddr->pending);
$paddr->isdeleted(1);
}
my $resp = $U->simplereq(
- 'open-ils.actor',
+ 'open-ils.actor',
'open-ils.actor.user.address.pending.cud',
$e->authtoken, $paddr);
}
# in light of these changes, re-fetch latest data
- $e->xact_begin;
+ $e->xact_begin;
$self->prepare_extended_user_info;
$e->rollback;
my %settings;
my $set_map = $self->ctx->{user_setting_map};
-
+
foreach my $key (qw/
opac.default_phone
opac.default_sms_notify
# Send the modified settings off to be saved
$U->simplereq(
- 'open-ils.actor',
+ 'open-ils.actor',
'open-ils.actor.patron.settings.update',
$self->editor->authtoken, undef, \%settings);
- # re-fetch user prefs
+ # re-fetch user prefs
$self->ctx->{updated_user_settings} = \%settings;
return $self->_load_user_with_prefs || Apache2::Const::OK;
}
my $user_set = $U->simplereq(
'open-ils.actor',
'open-ils.actor.patron.settings.retrieve',
- $e->authtoken,
- $e->requestor->id,
+ $e->authtoken,
+ $e->requestor->id,
[map {$_->name} @$opt_ins]
);
if ($fetch_all) {
# fetch all the messages
($ctx->{patron_messages_count}, $messages) =
- $self->_fetch_user_messages($pcrud, $offset, $limit);
+ $self->_fetch_user_messages($pcrud, $offset, $limit);
}
$pcrud->kill_me;
message => $aum->message,
create_date => $aum->create_date,
is_read => defined($aum->read_date) ? 1 : 0,
- library => $aum->sending_lib->name,
+ library => $aum->sending_lib->name,
};
}
# remove now-false settings
for my $pref (grep { $_->{value} } @$user_prefs) {
- $newsets{$pref->{cust}->name} = undef
+ $newsets{$pref->{cust}->name} = undef
unless grep { $_ eq $pref->{cust}->name } @settings;
}
# update the local prefs to match reality
for my $pref (@$user_prefs) {
- $pref->{value} = $newsets{$pref->{cust}->name}
+ $pref->{value} = $newsets{$pref->{cust}->name}
if exists $newsets{$pref->{cust}->name};
}
return $stat if $stat; # not-OK
$self->ctx->{user_setting_map} = {
- map { $_->name => OpenSRF::Utils::JSON->JSON2perl($_->value) }
+ map { $_->name => OpenSRF::Utils::JSON->JSON2perl($_->value) }
@{$self->ctx->{user}->settings}
};
'circ.holds.behind_desk_pickup_supported');
if ($bdous) {
- my $setting =
+ my $setting =
$e->retrieve_config_usr_setting_type(
'circ.holds_behind_desk');
return Apache2::Const::OK
unless $self->cgi->request_method eq 'POST';
- # some setting values from the form don't match the
- # required value/format for the db, so they have to be
+ # some setting values from the form don't match the
+ # required value/format for the db, so they have to be
# individually translated.
my %settings;
if (!$hist_clear_confirmed) {
# when clearing circ history, only warn if history data exists.
-
+
if ($clear_circ_history) {
if ($self->fetch_user_circ_history(0, 1)->[0]) {
my $one_hold = $e->json_query({
select => {
au => [{
- column => 'id',
- transform => 'action.usr_visible_holds',
+ column => 'id',
+ transform => 'action.usr_visible_holds',
result_field => 'id'
}]
},
# Send the modified settings off to be saved
$U->simplereq(
- 'open-ils.actor',
+ 'open-ils.actor',
'open-ils.actor.patron.settings.update',
$self->editor->authtoken, undef, \%settings);
- # re-fetch user prefs
+ # re-fetch user prefs
$self->ctx->{updated_user_settings} = \%settings;
return $self->_load_user_with_prefs || Apache2::Const::OK;
}
my $circ = OpenSRF::AppSession->create('open-ils.circ');
$hold_ids = $circ->request(
- 'open-ils.circ.holds.id_list.retrieve.authoritative',
- $e->authtoken,
+ 'open-ils.circ.holds.id_list.retrieve.authoritative',
+ $e->authtoken,
$e->requestor->id,
$available
)->gather(1);
last unless $hold_id;
my $ses = OpenSRF::AppSession->create('open-ils.circ');
my $req = $ses->request(
- 'open-ils.circ.hold.details.retrieve',
+ 'open-ils.circ.hold.details.retrieve',
$e->authtoken, $hold_id, $args);
push(@ses, {ses => $ses, req => $req});
}
my $filter_data = $U->simplereq(
'open-ils.circ',
- 'open-ils.circ.mmr.holds.filters.authoritative.atomic',
+ 'open-ils.circ.mmr.holds.filters.authoritative.atomic',
$hold->target, $filter_org, [$hold->id]
);
- $blob->{metarecord_filters} =
+ $blob->{metarecord_filters} =
$filter_data->[0]->{metarecord};
- $blob->{metarecord_selected_filters} =
+ $blob->{metarecord_selected_filters} =
$filter_data->[1]->{hold};
} else {
}
} elsif ($action =~ /activate|suspend/) {
-
+
my $vlist = [];
for my $hold_id (@hold_ids) {
my $vals = {id => $hold_id};
}
my $resp = $circ->request('open-ils.circ.hold.update.batch.atomic', $e->authtoken, undef, $vlist)->gather(1);
- $self->ctx->{hold_suspend_post_capture} = 1 if
+ $self->ctx->{hold_suspend_post_capture} = 1 if
grep {$U->event_equals($_, 'HOLD_SUSPEND_AFTER_CAPTURE')} @$resp;
} elsif ($action eq 'edit') {
my $self = shift;
my $e = $self->editor;
my $ctx = $self->ctx;
-
+
my $limit = $self->cgi->param('limit') || 15;
my $offset = $self->cgi->param('offset') || 0;
my $action = $self->cgi->param('action') || '';
M => sub {
# target metarecords
my $mrecs = $e->batch_retrieve_metabib_metarecord([
- \@targets,
- {flesh => 1, flesh_fields => {mmr => ['master_record']}}],
+ \@targets,
+ {flesh => 1, flesh_fields => {mmr => ['master_record']}}],
{substream => 1}
);
'open-ils.circ',
'open-ils.circ.mmr.holds.filters.authoritative', $mr->id, $ou_id);
- my $holdable_formats =
+ my $holdable_formats =
$self->compile_holdable_formats($mr->id);
push(@hold_data, $data_filler->({
- target => $mr,
+ target => $mr,
record => $mr->master_record,
holdable_formats => $holdable_formats,
metarecord_filters => $filter_data->{metarecord}
my ($rec) = grep {$_->id eq $id} @$recs;
# NOTE: if tpac ever supports locked-down pickup libs,
- # we'll need to pass a pickup_lib param along with the
+ # we'll need to pass a pickup_lib param along with the
# record to filter the set of monographic parts.
my $parts = $U->simplereq(
'open-ils.search',
- 'open-ils.search.biblio.record_hold_parts',
+ 'open-ils.search.biblio.record_hold_parts',
{record => $rec->id}
);
- # T holds on records that have parts are OK, but if the record has
- # no non-part copies, the hold will ultimately fail. When that
+ # T holds on records that have parts are OK, but if the record has
+ # no non-part copies, the hold will ultimately fail. When that
# happens, require the user to select a part.
my $part_required = 0;
if (@$parts) {
my $np_copies = $e->json_query({
- select => { acp => [{column => 'id', transform => 'count', alias => 'count'}]},
- from => {acp => {acn => {}, acpm => {type => 'left'}}},
+ select => { acp => [{column => 'id', transform => 'count', alias => 'count'}]},
+ from => {acp => {acn => {}, acpm => {type => 'left'}}},
where => {
'+acp' => {deleted => 'f'},
- '+acn' => {deleted => 'f', record => $rec->id},
+ '+acn' => {deleted => 'f', record => $rec->id},
'+acpm' => {id => undef}
}
});
}
], {substream => 1});
- for my $id (@targets) {
+ for my $id (@targets) {
my ($vol) = grep {$_->id eq $id} @$vols;
push(@hold_data, $data_filler->({target => $vol, record => $vol->record}));
}
}
], {substream => 1});
- for my $id (@targets) {
+ for my $id (@targets) {
my ($copy) = grep {$_->id eq $id} @$copies;
push(@hold_data, $data_filler->({target => $copy, record => $copy->call_number->record}));
}
}
], {substream => 1});
- for my $id (@targets) {
+ for my $id (@targets) {
my ($iss) = grep {$_->id eq $id} @$isses;
push(@hold_data, $data_filler->({target => $iss, record => $iss->subscription->record_entry}));
}
# find the real hold target
$usr = $U->simplereq(
- 'open-ils.actor',
+ 'open-ils.actor',
"open-ils.actor.user.retrieve_id_by_barcode_or_username",
$e->authtoken, $cgi->param("hold_usr"));
}
}
- # target_id is the true target_id for holds placement.
+ # target_id is the true target_id for holds placement.
# needed for attempt_hold_placement()
# With the exception of P-type holds, target_id == target->id.
$_->{target_id} = $_->{target}->id for @hold_data;
if ($ctx->{hold_type} eq 'T') {
- # Much like quantum wave-particles, P-type holds pop into
+ # Much like quantum wave-particles, P-type holds pop into
# and out of existence at the user's whim. For our purposes,
- # we treat such holds as T(itle) holds with a selected_part
- # designation. When the time comes to pass the hold information
- # off for holds possibility testing and placement, make it look
+ # we treat such holds as T(itle) holds with a selected_part
+ # designation. When the time comes to pass the hold information
+ # off for holds possibility testing and placement, make it look
# like a real P-type hold.
my (@p_holds, @t_holds);
-
+
for my $idx (0..$#parts) {
my $hdata = $hold_data[$idx];
if (my $part = $parts[$idx]) {
$self->attempt_hold_placement($usr, $pickup_lib, $ctx->{hold_type}, @hold_data);
}
- # NOTE: we are leaving the staff-placed patron barcode cookie
- # in place. Otherwise, it's not possible to place more than
- # one hold for the patron within a staff/patron session. This
- # does leave the barcode to linger longer than is ideal, but
- # normal staff work flow will cause the cookie to be replaced
+ # NOTE: we are leaving the staff-placed patron barcode cookie
+ # in place. Otherwise, it's not possible to place more than
+ # one hold for the patron within a staff/patron session. This
+ # does leave the barcode to linger longer than is ideal, but
+ # normal staff work flow will cause the cookie to be replaced
# with each new patron anyway.
# TODO: See about getting the staff client to clear the cookie
my $ctx = $self->ctx;
my $e = $self->editor;
- # First see if we should warn/block for any holds that
+ # First see if we should warn/block for any holds that
# might have locally available items.
for my $hdata (@hold_data) {
my ($local_block, $local_alert) = $self->local_avail_concern(
$hdata->{target_id}, $hold_type, $pickup_lib);
-
+
if ($local_block) {
$hdata->{hold_failed} = 1;
$hdata->{hold_local_block} = 1;
# map each set to the ID of the target.
my $holdable_formats = {};
if ($hold_type eq 'M') {
- $holdable_formats->{$_->{target_id}} =
+ $holdable_formats->{$_->{target_id}} =
$_->{holdable_formats} for @hold_data;
}
my $bses = OpenSRF::AppSession->create('open-ils.circ');
- my $breq = $bses->request(
- $method,
- $e->authtoken,
- $data_filler->({
+ my $breq = $bses->request(
+ $method,
+ $e->authtoken,
+ $data_filler->({
patronid => $usr,
- pickup_lib => $pickup_lib,
+ pickup_lib => $pickup_lib,
hold_type => $hold_type,
holdable_formats_map => $holdable_formats
}),
$hdata->{hold_failed_event} = $result;
} else {
-
+
if(not ref $result and $result > 0) {
# successul hold returns the hold ID
- $hdata->{hold_success} = $result;
-
+ $hdata->{hold_success} = $result;
+
} else {
- # hold-specific failure event
+ # hold-specific failure event
$hdata->{hold_failed} = 1;
if (ref $result eq 'HASH') {
$hdata->{could_override} = $self->editor->allowed( $theTextcode );
$hdata->{age_protect} = 1;
} else {
- $hdata->{could_override} = $result->{place_unfillable} ||
+ $hdata->{could_override} = $result->{place_unfillable} ||
$self->test_could_override($hdata->{hold_failed_event});
}
} elsif (ref $result eq 'ARRAY') {
my $cgi = $self->cgi;
# exit early if not needed
- return undef unless
- grep /metarecord_formats_|metarecord_langs_/,
+ return undef unless
+ grep /metarecord_formats_|metarecord_langs_/,
$cgi->param;
# CGI params are based on the MR id, since during hold placement
- # we have no old ID. During hold edit, map the hold ID back to
+ # we have no old ID. During hold edit, map the hold ID back to
# the metarecod target.
- $mr_id =
- $e->retrieve_action_hold_request($hold_id)->target
+ $mr_id =
+ $e->retrieve_action_hold_request($hold_id)->target
unless $mr_id;
my $format_attr = $self->ctx->{get_cgf}->(
my $blob = {};
if (@selected_formats) {
$blob->{0} = [
- map { {_attr => $format_attr, _val => $_} }
+ map { {_attr => $format_attr, _val => $_} }
@selected_formats
];
}
if (@selected_langs) {
$blob->{1} = [
- map { {_attr => 'item_lang', _val => $_} }
+ map { {_attr => 'item_lang', _val => $_} }
@selected_langs
];
}
my @circs;
for my $circ (@$circs) {
push(@circs, {
- circ => $circ,
- marc_xml => ($flesh and $circ->target_copy->call_number->id != -1) ?
- XML::LibXML->new->parse_string($circ->target_copy->call_number->record->marc) :
+ circ => $circ,
+ marc_xml => ($flesh and $circ->target_copy->call_number->id != -1) ?
+ XML::LibXML->new->parse_string($circ->target_copy->call_number->record->marc) :
undef # pre-cat copy, use the dummy title/author instead
});
}
for my $circ (@$circs) {
my $evt = $U->simplereq(
- 'open-ils.circ',
+ 'open-ils.circ',
'open-ils.circ.renew',
$self->editor->authtoken,
{
}
);
- # TODO return these, then insert them into the circ data
+ # TODO return these, then insert them into the circ data
# blob that is shoved into the template for each circ
# so the template won't have to match them
push(@responses, {copy => $circ->{circ}->target_copy, evt => $evt});
return Apache2::Const::OK;
}
-# if 'flesh' is set, copy data etc. is loaded and the return value is
-# a hash of 'circ' and 'marc_xml'. Othwerwise, it's just a list of
+# if 'flesh' is set, copy data etc. is loaded and the return value is
+# a hash of 'circ' and 'marc_xml'. Othwerwise, it's just a list of
# auch objects.
sub fetch_user_circ_history {
my ($self, $flesh, $limit, $offset) = @_;
my @circs;
for my $circ (@$circs) {
push(@circs, {
- circ => $circ,
- marc_xml => ($circ->target_copy->call_number->id != -1) ?
+ circ => $circ,
+ marc_xml => ($circ->target_copy->call_number->id != -1) ?
XML::LibXML->new->parse_string(
- $circ->target_copy->call_number->record->marc) :
+ $circ->target_copy->call_number->record->marc) :
undef # pre-cat copy, use the dummy title/author instead
});
}
my $hold_ids = $e->json_query({
select => {
au => [{
- column => 'id',
- transform => 'action.usr_visible_holds',
+ column => 'id',
+ transform => 'action.usr_visible_holds',
result_field => 'id'
}]
},
my $min_ts = DateTime->now(
"time_zone" => DateTime::TimeZone->new("name" => "local"),
)->subtract("seconds" => interval_to_seconds($max_age))->iso8601();
-
+
$logger->info("XXX min_ts: $min_ts");
$args->{"where"} = {"payment_ts" => {">=" => $min_ts}};
}
return $stat if $stat;
@payment_xacts =
map { $_->{xact}->id } (
- @{$self->ctx->{fines}->{circulation}},
+ @{$self->ctx->{fines}->{circulation}},
@{$self->ctx->{fines}->{grocery}}
);
}
/);
my $cache_args = {
- cc_args => $cc_args,
+ cc_args => $cc_args,
user => $self->ctx->{user}->id,
xacts => \@payment_xacts
};
# after we render the processing page, we quickly redirect to submit
# the actual payment. The refresh url contains the payment token.
- # It also contains the list of xact IDs, which allows us to clear the
- # cache at the earliest possible time while leaving a trace of which
+ # It also contains the list of xact IDs, which allows us to clear the
+ # cache at the earliest possible time while leaving a trace of which
# transactions we were processing, so the UI can bring the user back
# to the payment form w/ the same xacts if the payment fails.
my @payment_xacts = @{$cache_args->{xacts}};
my $cc_args = $cache_args->{cc_args};
- # as an added security check, verify the user submitting
+ # as an added security check, verify the user submitting
# the form is the same as the user whose data was cached
return Apache2::Const::HTTP_BAD_REQUEST unless
$cache_args->{user} == $self->ctx->{user}->id;
unless ($resp->{"textcode"}) {
$self->ctx->{printable_receipt} = $U->simplereq(
- "open-ils.circ", "open-ils.circ.money.payment_receipt.print",
- $self->editor->authtoken, $resp->{payments}
+ "open-ils.circ", "open-ils.circ.money.payment_receipt.print",
+ $self->editor->authtoken, $resp->{payments}
);
}
my $self = shift;
$self->ctx->{printable_receipt} = $U->simplereq(
- "open-ils.circ", "open-ils.circ.money.payment_receipt.print",
- $self->editor->authtoken, [$self->cgi->param("payment")]
+ "open-ils.circ", "open-ils.circ.money.payment_receipt.print",
+ $self->editor->authtoken, [$self->cgi->param("payment")]
);
return Apache2::Const::OK;
# question has an email address, so we do.
if ($self->ctx->{user}->email) {
$self->ctx->{email_receipt_result} = $U->simplereq(
- "open-ils.circ", "open-ils.circ.money.payment_receipt.email",
- $self->editor->authtoken, [$self->cgi->param("payment")]
+ "open-ils.circ", "open-ils.circ.money.payment_receipt.email",
+ $self->editor->authtoken, [$self->cgi->param("payment")]
);
} else {
$self->ctx->{email_receipt_result} =
my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
- # TODO: This should really be a ML call, but the existing calls
+ # TODO: This should really be a ML call, but the existing calls
# return an excessive amount of data and don't offer streaming
my %paging = ($limit or $offset) ? (limit => $limit, offset => $offset) : ();
xact => $mobts,
last_grocery_billing => $last_billing,
marc_xml => $marc_xml
- }
+ }
);
}
# needed for most up-to-date email address
if (my $r = $self->prepare_extended_user_info) { return $r };
- return Apache2::Const::OK
+ return Apache2::Const::OK
unless $self->cgi->request_method eq 'POST';
unless($email =~ /.+\@.+\..+/) { # TODO better regex?
}
my $stat = $U->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.user.email.update',
+ 'open-ils.actor',
+ 'open-ils.actor.user.email.update',
$e->authtoken, $email, $current_pw);
if($U->event_equals($stat, 'INCORRECT_PASSWORD')) {
return $self->generic_redirect($url);
}
- return Apache2::Const::OK
+ return Apache2::Const::OK
unless $self->cgi->request_method eq 'POST';
unless($username and $username !~ /\s/) { # any other username restrictions?
if($username ne $e->requestor->usrname) {
my $evt = $U->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.user.username.update',
+ 'open-ils.actor',
+ 'open-ils.actor.user.username.update',
$e->authtoken, $username, $current_pw);
if($U->event_equals($evt, 'INCORRECT_PASSWORD')) {
my $e = $self->editor;
my $ctx = $self->ctx;
- return Apache2::Const::OK
+ return Apache2::Const::OK
unless $self->cgi->request_method eq 'POST';
my $current_pw = $self->cgi->param('current_pw') || '';
}
my $evt = $U->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.user.password.update',
+ 'open-ils.actor',
+ 'open-ils.actor.user.password.update',
$e->authtoken, $new_pw, $current_pw);
}
}
- # we're done with our CStoreEditor. Rollback here so
- # later calls don't cause a timeout, resulting in a
+ # we're done with our CStoreEditor. Rollback here so
+ # later calls don't cause a timeout, resulting in a
# transaction rollback under the covers.
$e->rollback;
my (undef, @recs) = $self->get_records_and_facets(
[ map {$_->target_biblio_record_entry->id} @$items ],
- undef,
+ undef,
{
flesh => '{mra,holdings_xml,acp,exclude_invisible_acn}',
flesh_depth => 1,
}
}
- # this rollback may be a dupe, but that's OK because
+ # this rollback may be a dupe, but that's OK because
# cstoreditor ignores dupe rollbacks
$e->rollback;
$item->bucket($list_id);
$item->target_biblio_record_entry($add_rec);
$success = $U->simplereq('open-ils.actor',
- 'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
+ 'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
last unless $success;
}
}
@hold_recs = map { $_->target_biblio_record_entry } @$items;
}
}
-
+
return Apache2::Const::OK unless @hold_recs;
$logger->info("placing holds from list page on: @hold_recs");
$list = $e->retrieve_container_biblio_record_entry_bucket($list_id);
- return Apache2::Const::HTTP_BAD_REQUEST unless
+ return Apache2::Const::HTTP_BAD_REQUEST unless
$list and $list->owner == $e->requestor->id;
}
if($action eq 'delete') {
- $success = $U->simplereq('open-ils.actor',
+ $success = $U->simplereq('open-ils.actor',
'open-ils.actor.container.full_delete', $e->authtoken, 'biblio', $list_id);
if ($success) {
# We check to see if we're deleting the user's default list.
} elsif($action eq 'show') {
unless($U->is_true($list->pub)) {
$list->pub('t');
- $success = $U->simplereq('open-ils.actor',
+ $success = $U->simplereq('open-ils.actor',
'open-ils.actor.container.update', $e->authtoken, 'biblio', $list);
}
} elsif($action eq 'hide') {
if($U->is_true($list->pub)) {
$list->pub('f');
- $success = $U->simplereq('open-ils.actor',
+ $success = $U->simplereq('open-ils.actor',
'open-ils.actor.container.update', $e->authtoken, 'biblio', $list);
}
} elsif($action eq 'rename') {
if($name) {
$list->name($name);
- $success = $U->simplereq('open-ils.actor',
+ $success = $U->simplereq('open-ils.actor',
'open-ils.actor.container.update', $e->authtoken, 'biblio', $list);
}
my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
$item->bucket($list_id);
$item->target_biblio_record_entry($add_rec);
- $success = $U->simplereq('open-ils.actor',
+ $success = $U->simplereq('open-ils.actor',
'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
last unless $success;
}
my $circs = $self->fetch_user_circ_history;
$self->ctx->{csv} = $U->fire_object_event(
- undef,
+ undef,
'circ.format.history.csv', $circs,
$self->editor->requestor->home_ou
);
if ($pwd1 eq $pwd2) {
my $response = $U->simplereq(
- 'open-ils.actor',
+ 'open-ils.actor',
'open-ils.actor.patron.password_reset.commit',
$uuid, $pwd1);
$logger->info("patron password reset response " . Dumper($response));
if ($U->event_code($response)) { # non-success event
-
+
my $code = $response->{textcode};
-
+
if ($code eq 'PATRON_NOT_AN_ACTIVE_PASSWORD_RESET_REQUEST') {
$ctx->{pwreset} = {style => 'error', status => 'NOT_ACTIVE'};
}
push(@params, $email) if $email;
$U->simplereq(
- 'open-ils.actor',
+ 'open-ils.actor',
'open-ils.actor.patron.password_reset.request', @params);
$ctx->{pwreset} = {status => 'REQUEST_SUCCESS'};