}
sub publish_fieldmapper {
- my ($self,$client,$class) = @_;
+ my ($self,$client,$class) = @_;
- return $Fieldmapper::fieldmap unless (defined $class);
- return undef unless (exists($$Fieldmapper::fieldmap{$class}));
- return {$class => $$Fieldmapper::fieldmap{$class}};
+ return $Fieldmapper::fieldmap unless (defined $class);
+ return undef unless (exists($$Fieldmapper::fieldmap{$class}));
+ return {$class => $$Fieldmapper::fieldmap{$class}};
}
__PACKAGE__->register_method(
- api_name => 'opensrf.open-ils.system.fieldmapper',
- api_level => 1,
- method => 'publish_fieldmapper',
+ api_name => 'opensrf.open-ils.system.fieldmapper',
+ api_level => 1,
+ method => 'publish_fieldmapper',
);
sub register_method {
__PACKAGE__->register_method(
- method => 'claim_ready_items',
- api_name => 'open-ils.acq.claim.eligible.lineitem_detail',
+ method => 'claim_ready_items',
+ api_name => 'open-ils.acq.claim.eligible.lineitem_detail',
stream => 1,
- signature => {
+ signature => {
desc => q/Locates lineitem_details that are eligible for claiming/,
params => [
{desc => 'Authentication token', type => 'string'},
);
__PACKAGE__->register_method(
- method => 'claim_item',
- api_name => 'open-ils.acq.claim.lineitem_detail',
+ method => 'claim_item',
+ api_name => 'open-ils.acq.claim.lineitem_detail',
stream => 1,
- signature => {
+ signature => {
desc => q/Initiates a claim for an individual lineitem_detail/,
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve',
- api_name => 'open-ils.acq.edi.retrieve',
+ method => 'retrieve',
+ api_name => 'open-ils.acq.edi.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Fetch incoming message(s) from EDI accounts. ' .
'Optional arguments to restrict to one vendor and/or a max number of messages. ' .
'Note that messages are not parsed or processed here, just fetched and translated.',
# ----------------------------------------------------------------------------
__PACKAGE__->register_method(
- method => 'create_funding_source',
- api_name => 'open-ils.acq.funding_source.create',
- signature => {
+ method => 'create_funding_source',
+ api_name => 'open-ils.acq.funding_source.create',
+ signature => {
desc => 'Creates a new funding_source',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'delete_funding_source',
- api_name => 'open-ils.acq.funding_source.delete',
- signature => {
+ method => 'delete_funding_source',
+ api_name => 'open-ils.acq.funding_source.delete',
+ signature => {
desc => 'Deletes a funding_source',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_funding_source',
- api_name => 'open-ils.acq.funding_source.retrieve',
+ method => 'retrieve_funding_source',
+ api_name => 'open-ils.acq.funding_source.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Retrieves a new funding_source',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_org_funding_sources',
- api_name => 'open-ils.acq.funding_source.org.retrieve',
+ method => 'retrieve_org_funding_sources',
+ api_name => 'open-ils.acq.funding_source.org.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves all the funding_sources associated with an org unit that the requestor has access to see',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'create_funding_source_credit',
- api_name => 'open-ils.acq.funding_source_credit.create',
- signature => {
+ method => 'create_funding_source_credit',
+ api_name => 'open-ils.acq.funding_source_credit.create',
+ signature => {
desc => 'Create a new funding source credit',
params => [
{desc => 'Authentication token', type => 'string'},
# ---------------------------------------------------------------
__PACKAGE__->register_method(
- method => 'create_fund',
- api_name => 'open-ils.acq.fund.create',
- signature => {
+ method => 'create_fund',
+ api_name => 'open-ils.acq.fund.create',
+ signature => {
desc => 'Creates a new fund',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'delete_fund',
- api_name => 'open-ils.acq.fund.delete',
- signature => {
+ method => 'delete_fund',
+ api_name => 'open-ils.acq.fund.delete',
+ signature => {
desc => 'Deletes a fund',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_fund',
- api_name => 'open-ils.acq.fund.retrieve',
+ method => 'retrieve_fund',
+ api_name => 'open-ils.acq.fund.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Retrieves a new fund',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_org_funds',
- api_name => 'open-ils.acq.fund.org.retrieve',
+ method => 'retrieve_org_funds',
+ api_name => 'open-ils.acq.fund.org.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves all the funds associated with an org unit',
params => [
{desc => 'Authentication token', type => 'string'},
);
__PACKAGE__->register_method(
- method => 'retrieve_org_funds',
- api_name => 'open-ils.acq.fund.org.years.retrieve');
+ method => 'retrieve_org_funds',
+ api_name => 'open-ils.acq.fund.org.years.retrieve');
sub retrieve_org_funds {
}
__PACKAGE__->register_method(
- method => 'retrieve_fund_summary',
- api_name => 'open-ils.acq.fund.summary.retrieve',
+ method => 'retrieve_fund_summary',
+ api_name => 'open-ils.acq.fund.summary.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Returns a summary of credits/debits/encumbrances for a fund',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'transfer_money_between_funds',
- api_name => 'open-ils.acq.funds.transfer_money',
- signature => {
+ method => 'transfer_money_between_funds',
+ api_name => 'open-ils.acq.funds.transfer_money',
+ signature => {
desc => 'Method for transfering money between funds',
params => [
{desc => 'Authentication token', type => 'string'},
# ---------------------------------------------------------------
__PACKAGE__->register_method(
- method => 'create_fund_alloc',
- api_name => 'open-ils.acq.fund_allocation.create',
- signature => {
+ method => 'create_fund_alloc',
+ api_name => 'open-ils.acq.fund_allocation.create',
+ signature => {
desc => 'Creates a new fund_allocation',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'delete_fund_alloc',
- api_name => 'open-ils.acq.fund_allocation.delete',
- signature => {
+ method => 'delete_fund_alloc',
+ api_name => 'open-ils.acq.fund_allocation.delete',
+ signature => {
desc => 'Deletes a fund_allocation',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_fund_alloc',
- api_name => 'open-ils.acq.fund_allocation.retrieve',
+ method => 'retrieve_fund_alloc',
+ api_name => 'open-ils.acq.fund_allocation.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Retrieves a new fund_allocation',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve_funding_source_allocations',
- api_name => 'open-ils.acq.funding_source.allocations.retrieve',
+ method => 'retrieve_funding_source_allocations',
+ api_name => 'open-ils.acq.funding_source.allocations.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Retrieves a new fund_allocation',
params => [
{desc => 'Authentication token', type => 'string'},
# ----------------------------------------------------------------------------
__PACKAGE__->register_method(
- method => 'retrieve_all_currency_type',
- api_name => 'open-ils.acq.currency_type.all.retrieve',
+ method => 'retrieve_all_currency_type',
+ api_name => 'open-ils.acq.currency_type.all.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves all currency_type objects',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'create_lineitem_assets',
- api_name => 'open-ils.acq.lineitem.assets.create',
- signature => {
+ method => 'create_lineitem_assets',
+ api_name => 'open-ils.acq.lineitem.assets.create',
+ signature => {
desc => q/Creates the bibliographic data, volume, and copies associated with a lineitem./,
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve_all_user_purchase_order',
- api_name => 'open-ils.acq.purchase_order.user.all.retrieve',
+ method => 'retrieve_all_user_purchase_order',
+ api_name => 'open-ils.acq.purchase_order.user.all.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves a purchase order',
params => [
{desc => 'Authentication token', type => 'string'},
# grab purchase orders I have
my $perm_orgs = $U->user_has_work_perm_at($e, 'MANAGE_PROVIDER', {descendants =>1});
- return OpenILS::Event->new('PERM_FAILURE', ilsperm => 'MANAGE_PROVIDER')
+ return OpenILS::Event->new('PERM_FAILURE', ilsperm => 'MANAGE_PROVIDER')
unless @$perm_orgs;
my $provider_ids = $e->search_acq_provider({owner => $perm_orgs}, {idlist=>1});
my $po_ids = $e->search_acq_purchase_order({provider => $provider_ids}, {idlist=>1});
__PACKAGE__->register_method(
- method => 'search_purchase_order',
- api_name => 'open-ils.acq.purchase_order.search',
+ method => 'search_purchase_order',
+ api_name => 'open-ils.acq.purchase_order.search',
stream => 1,
- signature => {
+ signature => {
desc => 'Search for a purchase order',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'format_po',
- api_name => 'open-ils.acq.purchase_order.format'
+ method => 'format_po',
+ api_name => 'open-ils.acq.purchase_order.format'
);
sub format_po {
}
__PACKAGE__->register_method(
- method => 'format_lineitem',
- api_name => 'open-ils.acq.lineitem.format'
+ method => 'format_lineitem',
+ api_name => 'open-ils.acq.lineitem.format'
);
sub format_lineitem {
}
__PACKAGE__->register_method (
- method => 'update_po_events',
+ method => 'update_po_events',
api_name => 'open-ils.acq.purchase_order.event.cancel.batch',
stream => 1,
);
__PACKAGE__->register_method (
- method => 'update_po_events',
+ method => 'update_po_events',
api_name => 'open-ils.acq.purchase_order.event.reset.batch',
stream => 1,
);
__PACKAGE__->register_method (
- method => 'process_fiscal_rollover',
+ method => 'process_fiscal_rollover',
api_name => 'open-ils.acq.fiscal_rollover.combined',
stream => 1,
- signature => {
+ signature => {
desc => q/
Performs a combined fiscal fund rollover process.
);
__PACKAGE__->register_method (
- method => 'process_fiscal_rollover',
+ method => 'process_fiscal_rollover',
api_name => 'open-ils.acq.fiscal_rollover.combined.dry_run',
stream => 1,
- signature => {
+ signature => {
desc => q/
@see open-ils.acq.fiscal_rollover.combined
This is the dry-run version. The action is performed,
);
__PACKAGE__->register_method (
- method => 'process_fiscal_rollover',
+ method => 'process_fiscal_rollover',
api_name => 'open-ils.acq.fiscal_rollover.propagate',
stream => 1,
- signature => {
+ signature => {
desc => q/
@see open-ils.acq.fiscal_rollover.combined
This version performs fund propagation only. I.e, creation of
);
__PACKAGE__->register_method (
- method => 'process_fiscal_rollover',
+ method => 'process_fiscal_rollover',
api_name => 'open-ils.acq.fiscal_rollover.propagate.dry_run',
stream => 1,
- signature => { desc => q/
+ signature => { desc => q/
@see open-ils.acq.fiscal_rollover.propagate
This is the dry-run version. The action is performed,
new fund information is returned, then all changes are rolled back.
}
__PACKAGE__->register_method(
- method => 'org_fiscal_year',
- api_name => 'open-ils.acq.org_unit.current_fiscal_year',
- signature => {
+ method => 'org_fiscal_year',
+ api_name => 'open-ils.acq.org_unit.current_fiscal_year',
+ signature => {
desc => q/
Returns the current fiscal year for the given org unit.
If no fiscal year is configured, the current calendar
}
__PACKAGE__->register_method(
- method => 'build_invoice_api',
- api_name => 'open-ils.acq.invoice.update',
- signature => {
+ method => 'build_invoice_api',
+ api_name => 'open-ils.acq.invoice.update',
+ signature => {
desc => q/Creates, updates, and deletes invoices, and related invoice entries, and invoice items/,
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'build_invoice_api',
- api_name => 'open-ils.acq.invoice.retrieve',
+ method => 'build_invoice_api',
+ api_name => 'open-ils.acq.invoice.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => q/Creates a new stub invoice/,
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'prorate_invoice',
- api_name => 'open-ils.acq.invoice.apply_prorate',
- signature => {
+ method => 'prorate_invoice',
+ api_name => 'open-ils.acq.invoice.apply_prorate',
+ signature => {
desc => q/
For all invoice items that have the prorate flag set to true, this will create the necessary
additional invoice_item's to prorate the cost across all affected funds by percent spent for each fund.
}
__PACKAGE__->register_method(
- method => 'lineitem_search',
- api_name => 'open-ils.acq.lineitem.search',
+ method => 'lineitem_search',
+ api_name => 'open-ils.acq.lineitem.search',
stream => 1,
- signature => {
+ signature => {
desc => 'Searches lineitems',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'lineitem_search_ident',
- api_name => 'open-ils.acq.lineitem.search.ident',
+ method => 'lineitem_search_ident',
+ api_name => 'open-ils.acq.lineitem.search.ident',
stream => 1,
- signature => {
+ signature => {
desc => 'Performs a search against lineitem_attrs where ident is true',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- "method" => "fund_exceeds_balance_percent_api",
- "api_name" => "open-ils.acq.fund.check_balance_percentages",
- "signature" => {
+ "method" => "fund_exceeds_balance_percent_api",
+ "api_name" => "open-ils.acq.fund.check_balance_percentages",
+ "signature" => {
"desc" => q/Determine whether a given fund exceeds its defined
"balance stop and warning percentages"/,
"params" => [
# ----------------------------------------------------------------------------
__PACKAGE__->register_method(
- method => 'zsearch',
- api_name => 'open-ils.acq.picklist.search.z3950',
+ method => 'zsearch',
+ api_name => 'open-ils.acq.picklist.search.z3950',
stream => 1,
- signature => {
+ signature => {
desc => 'Performs a z3950 federated search and creates a picklist and associated lineitems',
params => [
{desc => 'Authentication token', type => 'string'},
my($self, $conn, $auth, $key, $args) = @_;
$args ||= {};
- my $e = new_editor(authtoken => $auth, xact => 1);
+ my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn);
$logger->info("acq processing MARC file=$filename");
- my $batch = new MARC::Batch ('USMARC', $filename);
- $batch->strict_off;
+ my $batch = new MARC::Batch ('USMARC', $filename);
+ $batch->strict_off;
- my $count = 0;
+ my $count = 0;
my @li_list;
- while(1) {
+ while(1) {
- my ($err, $xml, $r);
- $count++;
+ my ($err, $xml, $r);
+ $count++;
- try {
+ try {
$r = $batch->next;
} catch Error with {
$err = shift;
- $logger->warn("Proccessing of record $count in set $key failed with error $err. Skipping this record");
+ $logger->warn("Proccessing of record $count in set $key failed with error $err. Skipping this record");
};
next if $err;
last unless $r;
- try {
+ try {
$xml = clean_marc($r);
- } catch Error with {
- $err = shift;
- $logger->warn("Proccessing XML of record $count in set $key failed with error $err. Skipping this record");
- };
+ } catch Error with {
+ $err = shift;
+ $logger->warn("Proccessing XML of record $count in set $key failed with error $err. Skipping this record");
+ };
next if $err or not $xml;
push(@li_list, $li->id);
$mgr->respond;
- }
+ }
if ($po) {
$evt = extract_po_name($mgr, $po, \@li_list);
return $evt if $evt;
}
- $e->commit;
+ $e->commit;
unlink($filename);
$cache->delete_cache('vandelay_import_spool_' . $key);
# ----------------------------------------------------------------------------
__PACKAGE__->register_method(
- method => 'create_po_assets',
- api_name => 'open-ils.acq.purchase_order.assets.create',
- signature => {
+ method => 'create_po_assets',
+ api_name => 'open-ils.acq.purchase_order.assets.create',
+ signature => {
desc => q/Creates assets for each lineitem in the purchase order/,
params => [
{desc => 'Authentication token', type => 'string'},
# the same way the LIs and LIDs do.
__PACKAGE__->register_method(
- method => 'receive_lineitem_detail_api',
- api_name => 'open-ils.acq.lineitem_detail.receive',
- signature => {
+ method => 'receive_lineitem_detail_api',
+ api_name => 'open-ils.acq.lineitem_detail.receive',
+ signature => {
desc => 'Mark a lineitem_detail as received',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'receive_lineitem_api',
- api_name => 'open-ils.acq.lineitem.receive',
- signature => {
+ method => 'receive_lineitem_api',
+ api_name => 'open-ils.acq.lineitem.receive',
+ signature => {
desc => 'Mark a lineitem as received',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'receive_lineitem_batch_api',
- api_name => 'open-ils.acq.lineitem.receive.batch',
+ method => 'receive_lineitem_batch_api',
+ api_name => 'open-ils.acq.lineitem.receive.batch',
stream => 1,
- signature => {
+ signature => {
desc => 'Mark lineitems as received',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => "cancel_purchase_order_api",
- api_name => "open-ils.acq.purchase_order.cancel",
- signature => {
+ method => "cancel_purchase_order_api",
+ api_name => "open-ils.acq.purchase_order.cancel",
+ signature => {
desc => q/Cancels an on-order purchase order/,
params => [
{desc => "Authentication token", type => "string"},
__PACKAGE__->register_method(
- method => "cancel_lineitem_api",
- api_name => "open-ils.acq.lineitem.cancel",
- signature => {
+ method => "cancel_lineitem_api",
+ api_name => "open-ils.acq.lineitem.cancel",
+ signature => {
desc => q/Cancels an on-order lineitem/,
params => [
{desc => "Authentication token", type => "string"},
);
__PACKAGE__->register_method(
- method => "cancel_lineitem_api",
- api_name => "open-ils.acq.lineitem.cancel.batch",
- signature => {
+ method => "cancel_lineitem_api",
+ api_name => "open-ils.acq.lineitem.cancel.batch",
+ signature => {
desc => q/Batched version of open-ils.acq.lineitem.cancel/,
return => {desc => q/Object describing changed LIs and LIDs on success;
Event on error./}
__PACKAGE__->register_method(
- method => "cancel_lineitem_detail_api",
- api_name => "open-ils.acq.lineitem_detail.cancel",
- signature => {
+ method => "cancel_lineitem_detail_api",
+ api_name => "open-ils.acq.lineitem_detail.cancel",
+ signature => {
desc => q/Cancels an on-order lineitem detail/,
params => [
{desc => "Authentication token", type => "string"},
__PACKAGE__->register_method(
- method => "po_note_CUD_batch",
- api_name => "open-ils.acq.po_note.cud.batch",
+ method => "po_note_CUD_batch",
+ api_name => "open-ils.acq.po_note.cud.batch",
stream => 1,
- signature => {
+ signature => {
desc => q/Manage purchase order notes/,
params => [
{desc => "Authentication token", type => "string"},
__PACKAGE__->register_method(
- method => "clone_distrib_form",
- api_name => "open-ils.acq.distribution_formula.clone",
+ method => "clone_distrib_form",
+ api_name => "open-ils.acq.distribution_formula.clone",
stream => 1,
- signature => {
+ signature => {
desc => q/Clone a distribution formula/,
params => [
{desc => "Authentication token", type => "string"},
}
__PACKAGE__->register_method(
- method => 'add_li_to_po',
- api_name => 'open-ils.acq.purchase_order.add_lineitem',
- signature => {
+ method => 'add_li_to_po',
+ api_name => 'open-ils.acq.purchase_order.add_lineitem',
+ signature => {
desc => q/Adds a lineitem to an existing purchase order/,
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'create_picklist',
- api_name => 'open-ils.acq.picklist.create',
- signature => {
+ method => 'create_picklist',
+ api_name => 'open-ils.acq.picklist.create',
+ signature => {
desc => 'Creates a new picklist',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'update_picklist',
- api_name => 'open-ils.acq.picklist.update',
- signature => {
+ method => 'update_picklist',
+ api_name => 'open-ils.acq.picklist.update',
+ signature => {
desc => 'Updates a new picklist',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_picklist',
- api_name => 'open-ils.acq.picklist.retrieve',
+ method => 'retrieve_picklist',
+ api_name => 'open-ils.acq.picklist.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Retrieves a picklist',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve_picklist_name',
- api_name => 'open-ils.acq.picklist.name.retrieve',
+ method => 'retrieve_picklist_name',
+ api_name => 'open-ils.acq.picklist.name.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Retrieves a picklist by name. Owner is implied by the caller',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve_user_picklist',
- api_name => 'open-ils.acq.picklist.user.retrieve',
+ method => 'retrieve_user_picklist',
+ api_name => 'open-ils.acq.picklist.user.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves a user\'s picklists',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve_all_user_picklist',
- api_name => 'open-ils.acq.picklist.user.all.retrieve',
+ method => 'retrieve_all_user_picklist',
+ api_name => 'open-ils.acq.picklist.user.all.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves all of the picklists a user is allowed to see',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_pl_lineitem',
- api_name => 'open-ils.acq.lineitem.picklist.retrieve',
+ method => 'retrieve_pl_lineitem',
+ api_name => 'open-ils.acq.lineitem.picklist.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves lineitem objects according to picklist',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'ranged_distrib_formulas',
- api_name => 'open-ils.acq.distribution_formula.ranged.retrieve',
+ method => 'ranged_distrib_formulas',
+ api_name => 'open-ils.acq.distribution_formula.ranged.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Ranged distribution formulas, fleshed with entries',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => "ranged_distrib_formula_applications",
- api_name => "open-ils.acq.distribution_formula_application.ranged.retrieve",
+ method => "ranged_distrib_formula_applications",
+ api_name => "open-ils.acq.distribution_formula_application.ranged.retrieve",
stream => 1,
- signature => {
+ signature => {
desc => "Ranged distribution formulas applications, fleshed with formulas and users",
params => [
{desc => "Authentication token", type => "string"},
my $U = 'OpenILS::Application::AppUtils';
__PACKAGE__->register_method(
- method => 'create_provider',
- api_name => 'open-ils.acq.provider.create',
- signature => {
+ method => 'create_provider',
+ api_name => 'open-ils.acq.provider.create',
+ signature => {
desc => 'Creates a new provider',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve_provider',
- api_name => 'open-ils.acq.provider.retrieve',
+ method => 'retrieve_provider',
+ api_name => 'open-ils.acq.provider.retrieve',
authoritative => 1,
- signature => {
+ signature => {
desc => 'Retrieves a new provider',
params => [
{desc => 'Authentication token', type => 'string'},
__PACKAGE__->register_method(
- method => 'retrieve_org_providers',
- api_name => 'open-ils.acq.provider.org.retrieve',
+ method => 'retrieve_org_providers',
+ api_name => 'open-ils.acq.provider.org.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves all the providers associated with an org unit that the requestor has access to see',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'retrieve_provider_attr_def',
- api_name => 'open-ils.acq.lineitem_provider_attr_definition.provider.retrieve',
+ method => 'retrieve_provider_attr_def',
+ api_name => 'open-ils.acq.lineitem_provider_attr_definition.provider.retrieve',
stream => 1,
- signature => {
+ signature => {
desc => 'Retrieves all of the lineitem_provider_attr_definition for a given provider',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'create_provider_attr_def',
- api_name => 'open-ils.acq.lineitem_provider_attr_definition.create',
- signature => {
+ method => 'create_provider_attr_def',
+ api_name => 'open-ils.acq.lineitem_provider_attr_definition.create',
+ signature => {
desc => 'Retrieves all of the lineitem_provider_attr_definition for a given provider',
params => [
{desc => 'Authentication token', type => 'string'},
}
__PACKAGE__->register_method(
- method => 'delete_provider_attr_def',
- api_name => 'open-ils.acq.lineitem_provider_attr_definition.delete',
- signature => {
+ method => 'delete_provider_attr_def',
+ api_name => 'open-ils.acq.lineitem_provider_attr_definition.delete',
+ signature => {
desc => 'Deletes a lineitem_provider_attr_definition',
params => [
{desc => 'Authentication token', type => 'string'},
use UUID::Tiny qw/:std/;
sub initialize {
- OpenILS::Application::Actor::Container->initialize();
- OpenILS::Application::Actor::UserGroups->initialize();
- OpenILS::Application::Actor::ClosedDates->initialize();
+ OpenILS::Application::Actor::Container->initialize();
+ OpenILS::Application::Actor::UserGroups->initialize();
+ OpenILS::Application::Actor::ClosedDates->initialize();
}
my $apputils = "OpenILS::Application::AppUtils";
#__PACKAGE__->register_method(
-# method => "allowed_test",
-# api_name => "open-ils.actor.allowed_test",
+# method => "allowed_test",
+# api_name => "open-ils.actor.allowed_test",
#);
#sub allowed_test {
# my($self, $conn, $auth, $orgid, $permcode) = @_;
#}
__PACKAGE__->register_method(
- method => "update_user_setting",
- api_name => "open-ils.actor.patron.settings.update",
+ method => "update_user_setting",
+ api_name => "open-ils.actor.patron.settings.update",
);
sub update_user_setting {
- my($self, $conn, $auth, $user_id, $settings) = @_;
+ my($self, $conn, $auth, $user_id, $settings) = @_;
my $e = new_editor(xact => 1, authtoken => $auth);
return $e->die_event unless $e->checkauth;
);
sub set_ou_settings {
- my( $self, $client, $auth, $org_id, $settings ) = @_;
+ my( $self, $client, $auth, $org_id, $settings ) = @_;
my $e = new_editor(authtoken => $auth, xact => 1);
return $e->die_event unless $e->checkauth;
my $all_allowed = $e->allowed("UPDATE_ORG_UNIT_SETTING_ALL", $org_id);
- for my $name (keys %$settings) {
+ for my $name (keys %$settings) {
my $val = $$settings{$name};
my $type = $e->retrieve_config_org_unit_setting_type([
api_name => "open-ils.actor.patron.settings.retrieve",
);
sub user_settings {
- my( $self, $client, $auth, $user_id, $setting ) = @_;
+ my( $self, $client, $auth, $user_id, $setting ) = @_;
my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
}
} else {
my $s = $e->search_actor_user_setting({usr => $user_id});
- return { map { ( $_->name => OpenSRF::Utils::JSON->JSON2perl($_->value) ) } @$s };
+ return { map { ( $_->name => OpenSRF::Utils::JSON->JSON2perl($_->value) ) } @$s };
}
}
}
);
sub ranged_ou_settings {
- my( $self, $client, $auth, $org_id ) = @_;
+ my( $self, $client, $auth, $org_id ) = @_;
- my $e = new_editor(authtoken => $auth);
+ my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
my %ranged_settings;
}
}
- return \%ranged_settings;
+ return \%ranged_settings;
}
);
sub update_patron {
- my( $self, $client, $user_session, $patron ) = @_;
+ my( $self, $client, $user_session, $patron ) = @_;
- my $session = $apputils->start_db_session();
+ my $session = $apputils->start_db_session();
- $logger->info($patron->isnew ? "Creating new patron..." : "Updating Patron: " . $patron->id);
+ $logger->info($patron->isnew ? "Creating new patron..." : "Updating Patron: " . $patron->id);
- my( $user_obj, $evt ) = $U->checkses($user_session);
- return $evt if $evt;
+ my( $user_obj, $evt ) = $U->checkses($user_session);
+ return $evt if $evt;
- $evt = check_group_perm($session, $user_obj, $patron);
- return $evt if $evt;
+ $evt = check_group_perm($session, $user_obj, $patron);
+ return $evt if $evt;
- $apputils->set_audit_info($session, $user_session, $user_obj->id, $user_obj->wsid);
+ $apputils->set_audit_info($session, $user_session, $user_obj->id, $user_obj->wsid);
- # $new_patron is the patron in progress. $patron is the original patron
- # passed in with the method. new_patron will change as the components
- # of patron are added/updated.
+ # $new_patron is the patron in progress. $patron is the original patron
+ # passed in with the method. new_patron will change as the components
+ # of patron are added/updated.
- my $new_patron;
+ my $new_patron;
- # unflesh the real items on the patron
- $patron->card( $patron->card->id ) if(ref($patron->card));
- $patron->billing_address( $patron->billing_address->id )
- if(ref($patron->billing_address));
- $patron->mailing_address( $patron->mailing_address->id )
- if(ref($patron->mailing_address));
+ # unflesh the real items on the patron
+ $patron->card( $patron->card->id ) if(ref($patron->card));
+ $patron->billing_address( $patron->billing_address->id )
+ if(ref($patron->billing_address));
+ $patron->mailing_address( $patron->mailing_address->id )
+ if(ref($patron->mailing_address));
- # create/update the patron first so we can use his id
+ # create/update the patron first so we can use his id
# $patron is the obj from the client (new data) and $new_patron is the
# patron object properly built for db insertion, so we need a third variable
my $old_patron;
my $barred_hook = '';
- if($patron->isnew()) {
- ( $new_patron, $evt ) = _add_patron($session, _clone_patron($patron), $user_obj);
- return $evt if $evt;
- if($U->is_true($patron->barred)) {
- $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'BAR_PATRON');
- return $evt if $evt;
- }
- } else {
+ if($patron->isnew()) {
+ ( $new_patron, $evt ) = _add_patron($session, _clone_patron($patron), $user_obj);
+ return $evt if $evt;
+ if($U->is_true($patron->barred)) {
+ $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'BAR_PATRON');
+ return $evt if $evt;
+ }
+ } else {
$new_patron = $patron;
# Did auth checking above already.
}
}
- ( $new_patron, $evt ) = _add_update_addresses($session, $patron, $new_patron, $user_obj);
- return $evt if $evt;
+ ( $new_patron, $evt ) = _add_update_addresses($session, $patron, $new_patron, $user_obj);
+ return $evt if $evt;
- ( $new_patron, $evt ) = _add_update_cards($session, $patron, $new_patron, $user_obj);
- return $evt if $evt;
+ ( $new_patron, $evt ) = _add_update_cards($session, $patron, $new_patron, $user_obj);
+ return $evt if $evt;
- ( $new_patron, $evt ) = _add_survey_responses($session, $patron, $new_patron, $user_obj);
- return $evt if $evt;
+ ( $new_patron, $evt ) = _add_survey_responses($session, $patron, $new_patron, $user_obj);
+ return $evt if $evt;
- # re-update the patron if anything has happened to him during this process
- if($new_patron->ischanged()) {
- ( $new_patron, $evt ) = _update_patron($session, $new_patron, $user_obj);
- return $evt if $evt;
- }
+ # re-update the patron if anything has happened to him during this process
+ if($new_patron->ischanged()) {
+ ( $new_patron, $evt ) = _update_patron($session, $new_patron, $user_obj);
+ return $evt if $evt;
+ }
- ( $new_patron, $evt ) = _clear_badcontact_penalties($session, $old_patron, $new_patron, $user_obj);
- return $evt if $evt;
+ ( $new_patron, $evt ) = _clear_badcontact_penalties($session, $old_patron, $new_patron, $user_obj);
+ return $evt if $evt;
- ($new_patron, $evt) = _create_stat_maps($session, $user_session, $patron, $new_patron, $user_obj);
- return $evt if $evt;
+ ($new_patron, $evt) = _create_stat_maps($session, $user_session, $patron, $new_patron, $user_obj);
+ return $evt if $evt;
- ($new_patron, $evt) = _create_perm_maps($session, $user_session, $patron, $new_patron, $user_obj);
- return $evt if $evt;
+ ($new_patron, $evt) = _create_perm_maps($session, $user_session, $patron, $new_patron, $user_obj);
+ return $evt if $evt;
- $apputils->commit_db_session($session);
+ $apputils->commit_db_session($session);
$evt = apply_invalid_addr_penalty($patron);
return $evt if $evt;
my $tses = OpenSRF::AppSession->create('open-ils.trigger');
- if($patron->isnew) {
+ if($patron->isnew) {
$tses->request('open-ils.trigger.event.autocreate', 'au.create', $new_patron, $new_patron->home_ou);
- } else {
+ } else {
$tses->request('open-ils.trigger.event.autocreate', 'au.update', $new_patron, $new_patron->home_ou);
$tses->request('open-ils.trigger.event.autocreate', $barred_hook,
$new_patron, $new_patron->home_ou) if $barred_hook;
}
- return flesh_user($new_patron->id(), new_editor(requestor => $user_obj, xact => 1));
+ return flesh_user($new_patron->id(), new_editor(requestor => $user_obj, xact => 1));
}
sub apply_invalid_addr_penalty {
sub flesh_user {
- my $id = shift;
+ my $id = shift;
my $e = shift;
my $home_ou = shift;
my $fields = [
- "cards",
- "card",
- "standing_penalties",
- "addresses",
- "billing_address",
- "mailing_address",
- "stat_cat_entries",
- "settings",
- "usr_activity"
+ "cards",
+ "card",
+ "standing_penalties",
+ "addresses",
+ "billing_address",
+ "mailing_address",
+ "stat_cat_entries",
+ "settings",
+ "usr_activity"
];
push @$fields, "home_ou" if $home_ou;
- return new_flesh_user($id, $fields, $e );
+ return new_flesh_user($id, $fields, $e );
}
# clone and clear stuff that would break the database
sub _clone_patron {
- my $patron = shift;
-
- my $new_patron = $patron->clone;
- # clear these
- $new_patron->clear_billing_address();
- $new_patron->clear_mailing_address();
- $new_patron->clear_addresses();
- $new_patron->clear_card();
- $new_patron->clear_cards();
- $new_patron->clear_id();
- $new_patron->clear_isnew();
- $new_patron->clear_ischanged();
- $new_patron->clear_isdeleted();
- $new_patron->clear_stat_cat_entries();
- $new_patron->clear_permissions();
- $new_patron->clear_standing_penalties();
-
- return $new_patron;
+ my $patron = shift;
+
+ my $new_patron = $patron->clone;
+ # clear these
+ $new_patron->clear_billing_address();
+ $new_patron->clear_mailing_address();
+ $new_patron->clear_addresses();
+ $new_patron->clear_card();
+ $new_patron->clear_cards();
+ $new_patron->clear_id();
+ $new_patron->clear_isnew();
+ $new_patron->clear_ischanged();
+ $new_patron->clear_isdeleted();
+ $new_patron->clear_stat_cat_entries();
+ $new_patron->clear_permissions();
+ $new_patron->clear_standing_penalties();
+
+ return $new_patron;
}
sub _add_patron {
- my $session = shift;
- my $patron = shift;
- my $user_obj = shift;
+ my $session = shift;
+ my $patron = shift;
+ my $user_obj = shift;
- my $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'CREATE_USER');
- return (undef, $evt) if $evt;
+ my $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'CREATE_USER');
+ return (undef, $evt) if $evt;
- my $ex = $session->request(
- 'open-ils.storage.direct.actor.user.search.usrname', $patron->usrname())->gather(1);
- if( $ex and @$ex ) {
- return (undef, OpenILS::Event->new('USERNAME_EXISTS'));
- }
+ my $ex = $session->request(
+ 'open-ils.storage.direct.actor.user.search.usrname', $patron->usrname())->gather(1);
+ if( $ex and @$ex ) {
+ return (undef, OpenILS::Event->new('USERNAME_EXISTS'));
+ }
- $logger->info("Creating new user in the DB with username: ".$patron->usrname());
+ $logger->info("Creating new user in the DB with username: ".$patron->usrname());
- my $id = $session->request(
- "open-ils.storage.direct.actor.user.create", $patron)->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($patron)) unless $id;
+ my $id = $session->request(
+ "open-ils.storage.direct.actor.user.create", $patron)->gather(1);
+ return (undef, $U->DB_UPDATE_FAILED($patron)) unless $id;
- $logger->info("Successfully created new user [$id] in DB");
+ $logger->info("Successfully created new user [$id] in DB");
- return ( $session->request(
- "open-ils.storage.direct.actor.user.retrieve", $id)->gather(1), undef );
+ return ( $session->request(
+ "open-ils.storage.direct.actor.user.retrieve", $id)->gather(1), undef );
}
sub check_group_perm {
- my( $session, $requestor, $patron ) = @_;
- my $evt;
-
- # first let's see if the requestor has
- # priveleges to update this user in any way
- if( ! $patron->isnew ) {
- my $p = $session->request(
- 'open-ils.storage.direct.actor.user.retrieve', $patron->id )->gather(1);
-
- # 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
- $p->profile == $patron->profile ) {
- return undef;
- }
-
-
- $evt = group_perm_failed($session, $requestor, $p);
- return $evt if $evt;
- }
-
- # They are allowed to edit this patron.. can they put the
- # patron into the group requested?
- $evt = group_perm_failed($session, $requestor, $patron);
- return $evt if $evt;
- return undef;
+ my( $session, $requestor, $patron ) = @_;
+ my $evt;
+
+ # first let's see if the requestor has
+ # priveleges to update this user in any way
+ if( ! $patron->isnew ) {
+ my $p = $session->request(
+ 'open-ils.storage.direct.actor.user.retrieve', $patron->id )->gather(1);
+
+ # 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
+ $p->profile == $patron->profile ) {
+ return undef;
+ }
+
+
+ $evt = group_perm_failed($session, $requestor, $p);
+ return $evt if $evt;
+ }
+
+ # They are allowed to edit this patron.. can they put the
+ # patron into the group requested?
+ $evt = group_perm_failed($session, $requestor, $patron);
+ return $evt if $evt;
+ return undef;
}
sub group_perm_failed {
- my( $session, $requestor, $patron ) = @_;
+ my( $session, $requestor, $patron ) = @_;
- my $perm;
- my $grp;
- my $grpid = $patron->profile;
+ my $perm;
+ my $grp;
+ my $grpid = $patron->profile;
- do {
+ do {
- $logger->debug("user update looking for group perm for group $grpid");
- $grp = $session->request(
- 'open-ils.storage.direct.permission.grp_tree.retrieve', $grpid )->gather(1);
- return OpenILS::Event->new('PERMISSION_GRP_TREE_NOT_FOUND') unless $grp;
+ $logger->debug("user update looking for group perm for group $grpid");
+ $grp = $session->request(
+ 'open-ils.storage.direct.permission.grp_tree.retrieve', $grpid )->gather(1);
+ return OpenILS::Event->new('PERMISSION_GRP_TREE_NOT_FOUND') unless $grp;
- } while( !($perm = $grp->application_perm) and ($grpid = $grp->parent) );
+ } while( !($perm = $grp->application_perm) and ($grpid = $grp->parent) );
- $logger->info("user update checking perm $perm on user ".
- $requestor->id." for update/create on user username=".$patron->usrname);
+ $logger->info("user update checking perm $perm on user ".
+ $requestor->id." for update/create on user username=".$patron->usrname);
- my $evt = $U->check_perms($requestor->id, $patron->home_ou, $perm);
- return $evt if $evt;
- return undef;
+ my $evt = $U->check_perms($requestor->id, $patron->home_ou, $perm);
+ return $evt if $evt;
+ return undef;
}
sub _update_patron {
- my( $session, $patron, $user_obj, $noperm) = @_;
+ my( $session, $patron, $user_obj, $noperm) = @_;
- $logger->info("Updating patron ".$patron->id." in DB");
+ $logger->info("Updating patron ".$patron->id." in DB");
- my $evt;
+ my $evt;
- if(!$noperm) {
- $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'UPDATE_USER');
- return (undef, $evt) if $evt;
- }
+ if(!$noperm) {
+ $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'UPDATE_USER');
+ return (undef, $evt) if $evt;
+ }
- # update the password by itself to avoid the password protection magic
- if( $patron->passwd ) {
- my $s = $session->request(
- 'open-ils.storage.direct.actor.user.remote_update',
- {id => $patron->id}, {passwd => $patron->passwd})->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($patron)) unless defined($s);
- $patron->clear_passwd;
- }
+ # update the password by itself to avoid the password protection magic
+ if( $patron->passwd ) {
+ my $s = $session->request(
+ 'open-ils.storage.direct.actor.user.remote_update',
+ {id => $patron->id}, {passwd => $patron->passwd})->gather(1);
+ return (undef, $U->DB_UPDATE_FAILED($patron)) unless defined($s);
+ $patron->clear_passwd;
+ }
- if(!$patron->ident_type) {
- $patron->clear_ident_type;
- $patron->clear_ident_value;
- }
+ if(!$patron->ident_type) {
+ $patron->clear_ident_type;
+ $patron->clear_ident_value;
+ }
$evt = verify_last_xact($session, $patron);
return (undef, $evt) if $evt;
- my $stat = $session->request(
- "open-ils.storage.direct.actor.user.update",$patron )->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($patron)) unless defined($stat);
+ my $stat = $session->request(
+ "open-ils.storage.direct.actor.user.update",$patron )->gather(1);
+ return (undef, $U->DB_UPDATE_FAILED($patron)) unless defined($stat);
- return ($patron);
+ return ($patron);
}
sub verify_last_xact {
sub _check_dup_ident {
- my( $session, $patron ) = @_;
+ my( $session, $patron ) = @_;
- return undef unless $patron->ident_value;
+ return undef unless $patron->ident_value;
- my $search = {
- ident_type => $patron->ident_type,
- ident_value => $patron->ident_value,
- };
+ my $search = {
+ ident_type => $patron->ident_type,
+ ident_value => $patron->ident_value,
+ };
- $logger->debug("patron update searching for dup ident values: " .
- $patron->ident_type . ':' . $patron->ident_value);
+ $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;
+ $search->{id} = {'!=' => $patron->id} if $patron->id and $patron->id > 0;
- my $dups = $session->request(
- 'open-ils.storage.direct.actor.user.search_where.atomic', $search )->gather(1);
+ my $dups = $session->request(
+ 'open-ils.storage.direct.actor.user.search_where.atomic', $search )->gather(1);
- return OpenILS::Event->new('PATRON_DUP_IDENT1', payload => $patron )
- if $dups and @$dups;
+ return OpenILS::Event->new('PATRON_DUP_IDENT1', payload => $patron )
+ if $dups and @$dups;
- return undef;
+ return undef;
}
sub _add_update_addresses {
- my $session = shift;
- my $patron = shift;
- my $new_patron = shift;
+ my $session = shift;
+ my $patron = shift;
+ my $new_patron = shift;
- my $evt;
+ my $evt;
- my $current_id; # id of the address before creation
+ my $current_id; # id of the address before creation
- my $addresses = $patron->addresses();
+ my $addresses = $patron->addresses();
- for my $address (@$addresses) {
+ for my $address (@$addresses) {
- next unless ref $address;
- $current_id = $address->id();
+ next unless ref $address;
+ $current_id = $address->id();
- if( $patron->billing_address() and
- $patron->billing_address() == $current_id ) {
- $logger->info("setting billing addr to $current_id");
- $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());
- $logger->info("setting mailing addr to $current_id");
- $new_patron->ischanged(1);
- }
+ if( $patron->billing_address() and
+ $patron->billing_address() == $current_id ) {
+ $logger->info("setting billing addr to $current_id");
+ $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());
+ $logger->info("setting mailing addr to $current_id");
+ $new_patron->ischanged(1);
+ }
- if($address->isnew()) {
+ if($address->isnew()) {
- $address->usr($new_patron->id());
+ $address->usr($new_patron->id());
- ($address, $evt) = _add_address($session,$address);
- return (undef, $evt) if $evt;
+ ($address, $evt) = _add_address($session,$address);
+ return (undef, $evt) if $evt;
- # we need to get the new id
- if( $patron->billing_address() and
- $patron->billing_address() == $current_id ) {
- $new_patron->billing_address($address->id());
- $logger->info("setting billing addr to $current_id");
- $new_patron->ischanged(1);
- }
+ # we need to get the new id
+ if( $patron->billing_address() and
+ $patron->billing_address() == $current_id ) {
+ $new_patron->billing_address($address->id());
+ $logger->info("setting billing addr to $current_id");
+ $new_patron->ischanged(1);
+ }
- if( $patron->mailing_address() and
- $patron->mailing_address() == $current_id ) {
- $new_patron->mailing_address($address->id());
- $logger->info("setting mailing addr to $current_id");
- $new_patron->ischanged(1);
- }
+ if( $patron->mailing_address() and
+ $patron->mailing_address() == $current_id ) {
+ $new_patron->mailing_address($address->id());
+ $logger->info("setting mailing addr to $current_id");
+ $new_patron->ischanged(1);
+ }
- } elsif($address->ischanged() ) {
+ } elsif($address->ischanged() ) {
- ($address, $evt) = _update_address($session, $address);
- return (undef, $evt) if $evt;
+ ($address, $evt) = _update_address($session, $address);
+ return (undef, $evt) if $evt;
- } elsif($address->isdeleted() ) {
+ } elsif($address->isdeleted() ) {
- if( $address->id() == $new_patron->mailing_address() ) {
- $new_patron->clear_mailing_address();
- ($new_patron, $evt) = _update_patron($session, $new_patron);
- return (undef, $evt) if $evt;
- }
+ if( $address->id() == $new_patron->mailing_address() ) {
+ $new_patron->clear_mailing_address();
+ ($new_patron, $evt) = _update_patron($session, $new_patron);
+ return (undef, $evt) if $evt;
+ }
- if( $address->id() == $new_patron->billing_address() ) {
- $new_patron->clear_billing_address();
- ($new_patron, $evt) = _update_patron($session, $new_patron);
- return (undef, $evt) if $evt;
- }
+ if( $address->id() == $new_patron->billing_address() ) {
+ $new_patron->clear_billing_address();
+ ($new_patron, $evt) = _update_patron($session, $new_patron);
+ return (undef, $evt) if $evt;
+ }
- $evt = _delete_address($session, $address);
- return (undef, $evt) if $evt;
- }
- }
+ $evt = _delete_address($session, $address);
+ return (undef, $evt) if $evt;
+ }
+ }
- return ( $new_patron, undef );
+ return ( $new_patron, undef );
}
# adds an address to the db and returns the address with new id
sub _add_address {
- my($session, $address) = @_;
- $address->clear_id();
+ my($session, $address) = @_;
+ $address->clear_id();
- $logger->info("Creating new address at street ".$address->street1);
+ $logger->info("Creating new address at street ".$address->street1);
- # put the address into the database
- my $id = $session->request(
- "open-ils.storage.direct.actor.user_address.create", $address )->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($address)) unless $id;
+ # put the address into the database
+ my $id = $session->request(
+ "open-ils.storage.direct.actor.user_address.create", $address )->gather(1);
+ return (undef, $U->DB_UPDATE_FAILED($address)) unless $id;
- $address->id( $id );
- return ($address, undef);
+ $address->id( $id );
+ return ($address, undef);
}
sub _update_address {
- my( $session, $address ) = @_;
+ my( $session, $address ) = @_;
- $logger->info("Updating address ".$address->id." in the DB");
+ $logger->info("Updating address ".$address->id." in the DB");
- my $stat = $session->request(
- "open-ils.storage.direct.actor.user_address.update", $address )->gather(1);
+ my $stat = $session->request(
+ "open-ils.storage.direct.actor.user_address.update", $address )->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($address)) unless defined($stat);
- return ($address, undef);
+ return (undef, $U->DB_UPDATE_FAILED($address)) unless defined($stat);
+ return ($address, undef);
}
sub _add_update_cards {
- my $session = shift;
- my $patron = shift;
- my $new_patron = shift;
+ my $session = shift;
+ my $patron = shift;
+ my $new_patron = shift;
- my $evt;
+ my $evt;
- my $virtual_id; #id of the card before creation
+ my $virtual_id; #id of the card before creation
- my $cards = $patron->cards();
- for my $card (@$cards) {
+ my $cards = $patron->cards();
+ for my $card (@$cards) {
- $card->usr($new_patron->id());
+ $card->usr($new_patron->id());
- if(ref($card) and $card->isnew()) {
+ if(ref($card) and $card->isnew()) {
- $virtual_id = $card->id();
- ( $card, $evt ) = _add_card($session,$card);
- return (undef, $evt) if $evt;
+ $virtual_id = $card->id();
+ ( $card, $evt ) = _add_card($session,$card);
+ return (undef, $evt) if $evt;
- #if(ref($patron->card)) { $patron->card($patron->card->id); }
- if($patron->card() == $virtual_id) {
- $new_patron->card($card->id());
- $new_patron->ischanged(1);
- }
+ #if(ref($patron->card)) { $patron->card($patron->card->id); }
+ if($patron->card() == $virtual_id) {
+ $new_patron->card($card->id());
+ $new_patron->ischanged(1);
+ }
- } elsif( ref($card) and $card->ischanged() ) {
- $evt = _update_card($session, $card);
- return (undef, $evt) if $evt;
- }
- }
+ } elsif( ref($card) and $card->ischanged() ) {
+ $evt = _update_card($session, $card);
+ return (undef, $evt) if $evt;
+ }
+ }
- return ( $new_patron, undef );
+ return ( $new_patron, undef );
}
# adds an card to the db and returns the card with new id
sub _add_card {
- my( $session, $card ) = @_;
- $card->clear_id();
+ my( $session, $card ) = @_;
+ $card->clear_id();
- $logger->info("Adding new patron card ".$card->barcode);
+ $logger->info("Adding new patron card ".$card->barcode);
- my $id = $session->request(
- "open-ils.storage.direct.actor.card.create", $card )->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($card)) unless $id;
- $logger->info("Successfully created patron card $id");
+ my $id = $session->request(
+ "open-ils.storage.direct.actor.card.create", $card )->gather(1);
+ return (undef, $U->DB_UPDATE_FAILED($card)) unless $id;
+ $logger->info("Successfully created patron card $id");
- $card->id($id);
- return ( $card, undef );
+ $card->id($id);
+ return ( $card, undef );
}
# returns event on error. returns undef otherwise
sub _update_card {
- my( $session, $card ) = @_;
- $logger->info("Updating patron card ".$card->id);
+ my( $session, $card ) = @_;
+ $logger->info("Updating patron card ".$card->id);
- my $stat = $session->request(
- "open-ils.storage.direct.actor.card.update", $card )->gather(1);
- return $U->DB_UPDATE_FAILED($card) unless defined($stat);
- return undef;
+ my $stat = $session->request(
+ "open-ils.storage.direct.actor.card.update", $card )->gather(1);
+ return $U->DB_UPDATE_FAILED($card) unless defined($stat);
+ return undef;
}
# returns event on error. returns undef otherwise
sub _delete_address {
- my( $session, $address ) = @_;
+ my( $session, $address ) = @_;
- $logger->info("Deleting address ".$address->id." from DB");
+ $logger->info("Deleting address ".$address->id." from DB");
- my $stat = $session->request(
- "open-ils.storage.direct.actor.user_address.delete", $address )->gather(1);
+ my $stat = $session->request(
+ "open-ils.storage.direct.actor.user_address.delete", $address )->gather(1);
- return $U->DB_UPDATE_FAILED($address) unless defined($stat);
- return undef;
+ return $U->DB_UPDATE_FAILED($address) unless defined($stat);
+ return undef;
}
sub _add_survey_responses {
- my ($session, $patron, $new_patron) = @_;
+ my ($session, $patron, $new_patron) = @_;
- $logger->info( "Updating survey responses for patron ".$new_patron->id );
+ $logger->info( "Updating survey responses for patron ".$new_patron->id );
- my $responses = $patron->survey_responses;
+ my $responses = $patron->survey_responses;
- if($responses) {
+ if($responses) {
- $_->usr($new_patron->id) for (@$responses);
+ $_->usr($new_patron->id) for (@$responses);
- my $evt = $U->simplereq( "open-ils.circ",
- "open-ils.circ.survey.submit.user_id", $responses );
+ my $evt = $U->simplereq( "open-ils.circ",
+ "open-ils.circ.survey.submit.user_id", $responses );
- return (undef, $evt) if defined($U->event_code($evt));
+ return (undef, $evt) if defined($U->event_code($evt));
- }
+ }
- return ( $new_patron, undef );
+ return ( $new_patron, undef );
}
sub _clear_badcontact_penalties {
sub _create_stat_maps {
- my($session, $user_session, $patron, $new_patron) = @_;
+ my($session, $user_session, $patron, $new_patron) = @_;
- my $maps = $patron->stat_cat_entries();
+ my $maps = $patron->stat_cat_entries();
- for my $map (@$maps) {
+ for my $map (@$maps) {
- my $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.update";
+ my $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.update";
- if ($map->isdeleted()) {
- $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.delete";
+ if ($map->isdeleted()) {
+ $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.delete";
- } elsif ($map->isnew()) {
- $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.create";
- $map->clear_id;
- }
+ } elsif ($map->isnew()) {
+ $method = "open-ils.storage.direct.actor.stat_cat_entry_user_map.create";
+ $map->clear_id;
+ }
- $map->target_usr($new_patron->id);
+ $map->target_usr($new_patron->id);
- #warn "
- $logger->info("Updating stat entry with method $method and map $map");
+ #warn "
+ $logger->info("Updating stat entry with method $method and map $map");
- my $stat = $session->request($method, $map)->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($map)) unless defined($stat);
+ my $stat = $session->request($method, $map)->gather(1);
+ return (undef, $U->DB_UPDATE_FAILED($map)) unless defined($stat);
- }
+ }
- return ($new_patron, undef);
+ return ($new_patron, undef);
}
sub _create_perm_maps {
- my($session, $user_session, $patron, $new_patron) = @_;
+ my($session, $user_session, $patron, $new_patron) = @_;
- my $maps = $patron->permissions;
+ my $maps = $patron->permissions;
- for my $map (@$maps) {
+ for my $map (@$maps) {
- my $method = "open-ils.storage.direct.permission.usr_perm_map.update";
- if ($map->isdeleted()) {
- $method = "open-ils.storage.direct.permission.usr_perm_map.delete";
- } elsif ($map->isnew()) {
- $method = "open-ils.storage.direct.permission.usr_perm_map.create";
- $map->clear_id;
- }
+ my $method = "open-ils.storage.direct.permission.usr_perm_map.update";
+ if ($map->isdeleted()) {
+ $method = "open-ils.storage.direct.permission.usr_perm_map.delete";
+ } elsif ($map->isnew()) {
+ $method = "open-ils.storage.direct.permission.usr_perm_map.create";
+ $map->clear_id;
+ }
- $map->usr($new_patron->id);
+ $map->usr($new_patron->id);
- #warn( "Updating permissions with method $method and session $user_session and map $map" );
- $logger->info( "Updating permissions with method $method and map $map" );
+ #warn( "Updating permissions with method $method and session $user_session and map $map" );
+ $logger->info( "Updating permissions with method $method and map $map" );
- my $stat = $session->request($method, $map)->gather(1);
- return (undef, $U->DB_UPDATE_FAILED($map)) unless defined($stat);
+ my $stat = $session->request($method, $map)->gather(1);
+ return (undef, $U->DB_UPDATE_FAILED($map)) unless defined($stat);
- }
+ }
- return ($new_patron, undef);
+ return ($new_patron, undef);
}
my $ses = shift;
my $maps = shift;
- my( $requestor, $evt ) = $apputils->checksesperm( $ses, 'ASSIGN_WORK_ORG_UNIT' );
- return $evt if $evt;
+ my( $requestor, $evt ) = $apputils->checksesperm( $ses, 'ASSIGN_WORK_ORG_UNIT' );
+ return $evt if $evt;
- my $session = $apputils->start_db_session();
- $apputils->set_audit_info($session, $ses, $requestor->id, $requestor->wsid);
+ my $session = $apputils->start_db_session();
+ $apputils->set_audit_info($session, $ses, $requestor->id, $requestor->wsid);
- for my $map (@$maps) {
+ for my $map (@$maps) {
- my $method = "open-ils.storage.direct.permission.usr_work_ou_map.update";
- if ($map->isdeleted()) {
- $method = "open-ils.storage.direct.permission.usr_work_ou_map.delete";
- } elsif ($map->isnew()) {
- $method = "open-ils.storage.direct.permission.usr_work_ou_map.create";
- $map->clear_id;
- }
+ my $method = "open-ils.storage.direct.permission.usr_work_ou_map.update";
+ if ($map->isdeleted()) {
+ $method = "open-ils.storage.direct.permission.usr_work_ou_map.delete";
+ } elsif ($map->isnew()) {
+ $method = "open-ils.storage.direct.permission.usr_work_ou_map.create";
+ $map->clear_id;
+ }
- #warn( "Updating permissions with method $method and session $ses and map $map" );
- $logger->info( "Updating work_ou map with method $method and map $map" );
+ #warn( "Updating permissions with method $method and session $ses and map $map" );
+ $logger->info( "Updating work_ou map with method $method and map $map" );
- my $stat = $session->request($method, $map)->gather(1);
- $logger->warn( "update failed: ".$U->DB_UPDATE_FAILED($map) ) unless defined($stat);
+ my $stat = $session->request($method, $map)->gather(1);
+ $logger->warn( "update failed: ".$U->DB_UPDATE_FAILED($map) ) unless defined($stat);
- }
+ }
- $apputils->commit_db_session($session);
+ $apputils->commit_db_session($session);
- return scalar(@$maps);
+ return scalar(@$maps);
}
);
sub set_user_perms {
- my $self = shift;
- my $client = shift;
- my $ses = shift;
- my $maps = shift;
+ my $self = shift;
+ my $client = shift;
+ my $ses = shift;
+ my $maps = shift;
- my $session = $apputils->start_db_session();
+ my $session = $apputils->start_db_session();
- my( $user_obj, $evt ) = $U->checkses($ses);
- return $evt if $evt;
- $apputils->set_audit_info($session, $ses, $user_obj->id, $user_obj->wsid);
+ my( $user_obj, $evt ) = $U->checkses($ses);
+ return $evt if $evt;
+ $apputils->set_audit_info($session, $ses, $user_obj->id, $user_obj->wsid);
- my $perms = $session->request('open-ils.storage.permission.user_perms.atomic', $user_obj->id)->gather(1);
+ my $perms = $session->request('open-ils.storage.permission.user_perms.atomic', $user_obj->id)->gather(1);
- my $all = undef;
- $all = 1 if ($U->is_true($user_obj->super_user()));
+ my $all = undef;
+ $all = 1 if ($U->is_true($user_obj->super_user()));
$all = 1 unless ($U->check_perms($user_obj->id, $user_obj->home_ou, 'EVERYTHING'));
- for my $map (@$maps) {
+ for my $map (@$maps) {
- my $method = "open-ils.storage.direct.permission.usr_perm_map.update";
- if ($map->isdeleted()) {
- $method = "open-ils.storage.direct.permission.usr_perm_map.delete";
- } elsif ($map->isnew()) {
- $method = "open-ils.storage.direct.permission.usr_perm_map.create";
- $map->clear_id;
- }
+ my $method = "open-ils.storage.direct.permission.usr_perm_map.update";
+ if ($map->isdeleted()) {
+ $method = "open-ils.storage.direct.permission.usr_perm_map.delete";
+ } elsif ($map->isnew()) {
+ $method = "open-ils.storage.direct.permission.usr_perm_map.create";
+ $map->clear_id;
+ }
- next if (!$all and !grep { $_->perm eq $map->perm and $U->is_true($_->grantable) and $_->depth <= $map->depth } @$perms);
- #warn( "Updating permissions with method $method and session $ses and map $map" );
- $logger->info( "Updating permissions with method $method and map $map" );
+ next if (!$all and !grep { $_->perm eq $map->perm and $U->is_true($_->grantable) and $_->depth <= $map->depth } @$perms);
+ #warn( "Updating permissions with method $method and session $ses and map $map" );
+ $logger->info( "Updating permissions with method $method and map $map" );
- my $stat = $session->request($method, $map)->gather(1);
- $logger->warn( "update failed: ".$U->DB_UPDATE_FAILED($map) ) unless defined($stat);
+ my $stat = $session->request($method, $map)->gather(1);
+ $logger->warn( "update failed: ".$U->DB_UPDATE_FAILED($map) ) unless defined($stat);
- }
+ }
- $apputils->commit_db_session($session);
+ $apputils->commit_db_session($session);
- return scalar(@$maps);
+ return scalar(@$maps);
}
__PACKAGE__->register_method(
- method => "user_retrieve_by_barcode",
+ method => "user_retrieve_by_barcode",
authoritative => 1,
- api_name => "open-ils.actor.user.fleshed.retrieve_by_barcode",);
+ api_name => "open-ils.actor.user.fleshed.retrieve_by_barcode",);
sub user_retrieve_by_barcode {
- my($self, $client, $auth, $barcode, $flesh_home_ou) = @_;
+ my($self, $client, $auth, $barcode, $flesh_home_ou) = @_;
my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
my $card = $e->search_actor_card({barcode => $barcode})->[0]
or return $e->event;
- my $user = flesh_user($card->usr, $e, $flesh_home_ou);
+ my $user = flesh_user($card->usr, $e, $flesh_home_ou);
return $e->event unless $e->allowed(
"VIEW_USER", $flesh_home_ou ? $user->home_ou->id : $user->home_ou
);
);
sub get_user_by_id {
- my ($self, $client, $auth, $id) = @_;
- 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 $user;
+ my ($self, $client, $auth, $id) = @_;
+ 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 $user;
}
);
my $ident_types;
sub get_user_ident_types {
- return $ident_types if $ident_types;
- return $ident_types =
- new_editor()->retrieve_all_config_identification_type();
+ return $ident_types if $ident_types;
+ return $ident_types =
+ new_editor()->retrieve_all_config_identification_type();
}
);
sub get_org_unit {
- my( $self, $client, $user_session, $org_id ) = @_;
- my $e = new_editor(authtoken => $user_session);
- if(!$org_id) {
- return $e->event unless $e->checkauth;
- $org_id = $e->requestor->ws_ou;
- }
- my $o = $e->retrieve_actor_org_unit($org_id)
- or return $e->event;
- return $o;
+ my( $self, $client, $user_session, $org_id ) = @_;
+ my $e = new_editor(authtoken => $user_session);
+ if(!$org_id) {
+ return $e->event unless $e->checkauth;
+ $org_id = $e->requestor->ws_ou;
+ }
+ my $o = $e->retrieve_actor_org_unit($org_id)
+ or return $e->event;
+ return $o;
}
__PACKAGE__->register_method(
sub search_org_unit {
- my( $self, $client, $field, $value ) = @_;
+ my( $self, $client, $field, $value ) = @_;
- my $list = OpenILS::Application::AppUtils->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.actor.org_unit.search.atomic",
- { $field => $value } );
+ my $list = OpenILS::Application::AppUtils->simple_scalar_request(
+ "open-ils.cstore",
+ "open-ils.cstore.direct.actor.org_unit.search.atomic",
+ { $field => $value } );
- return $list;
+ return $list;
}
# build the org tree
__PACKAGE__->register_method(
- method => "get_org_tree",
- api_name => "open-ils.actor.org_tree.retrieve",
- argc => 0,
- note => "Returns the entire org tree structure",
+ method => "get_org_tree",
+ api_name => "open-ils.actor.org_tree.retrieve",
+ argc => 0,
+ note => "Returns the entire org tree structure",
);
sub get_org_tree {
- my $self = shift;
- my $client = shift;
- return $U->get_org_tree($client->session->session_locale);
+ my $self = shift;
+ my $client = shift;
+ return $U->get_org_tree($client->session->session_locale);
}
__PACKAGE__->register_method(
- method => "get_org_descendants",
- api_name => "open-ils.actor.org_tree.descendants.retrieve"
+ method => "get_org_descendants",
+ api_name => "open-ils.actor.org_tree.descendants.retrieve"
);
# depth is optional. org_unit is the id
sub get_org_descendants {
- my( $self, $client, $org_unit, $depth ) = @_;
+ my( $self, $client, $org_unit, $depth ) = @_;
if(ref $org_unit eq 'ARRAY') {
$depth ||= [];
my @trees;
for my $i (0..scalar(@$org_unit)-1) {
my $list = $U->simple_scalar_request(
- "open-ils.storage",
- "open-ils.storage.actor.org_unit.descendants.atomic",
- $org_unit->[$i], $depth->[$i] );
+ "open-ils.storage",
+ "open-ils.storage.actor.org_unit.descendants.atomic",
+ $org_unit->[$i], $depth->[$i] );
push(@trees, $U->build_org_tree($list));
}
return \@trees;
} else {
- my $orglist = $apputils->simple_scalar_request(
- "open-ils.storage",
- "open-ils.storage.actor.org_unit.descendants.atomic",
- $org_unit, $depth );
- return $U->build_org_tree($orglist);
+ my $orglist = $apputils->simple_scalar_request(
+ "open-ils.storage",
+ "open-ils.storage.actor.org_unit.descendants.atomic",
+ $org_unit, $depth );
+ return $U->build_org_tree($orglist);
}
}
__PACKAGE__->register_method(
- method => "get_org_ancestors",
- api_name => "open-ils.actor.org_tree.ancestors.retrieve"
+ method => "get_org_ancestors",
+ api_name => "open-ils.actor.org_tree.ancestors.retrieve"
);
# depth is optional. org_unit is the id
sub get_org_ancestors {
- my( $self, $client, $org_unit, $depth ) = @_;
- my $orglist = $apputils->simple_scalar_request(
- "open-ils.storage",
- "open-ils.storage.actor.org_unit.ancestors.atomic",
- $org_unit, $depth );
- return $U->build_org_tree($orglist);
+ my( $self, $client, $org_unit, $depth ) = @_;
+ my $orglist = $apputils->simple_scalar_request(
+ "open-ils.storage",
+ "open-ils.storage.actor.org_unit.ancestors.atomic",
+ $org_unit, $depth );
+ return $U->build_org_tree($orglist);
}
__PACKAGE__->register_method(
- method => "get_standings",
- api_name => "open-ils.actor.standings.retrieve"
+ method => "get_standings",
+ api_name => "open-ils.actor.standings.retrieve"
);
my $user_standings;
sub get_standings {
- return $user_standings if $user_standings;
- return $user_standings =
- $apputils->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.config.standing.search.atomic",
- { id => { "!=" => undef } }
- );
+ return $user_standings if $user_standings;
+ return $user_standings =
+ $apputils->simple_scalar_request(
+ "open-ils.cstore",
+ "open-ils.cstore.direct.config.standing.search.atomic",
+ { id => { "!=" => undef } }
+ );
}
);
sub get_my_org_path {
- my( $self, $client, $auth, $org_id ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- $org_id = $e->requestor->ws_ou unless defined $org_id;
-
- return $apputils->simple_scalar_request(
- "open-ils.storage",
- "open-ils.storage.actor.org_unit.full_path.atomic",
- $org_id );
+ my( $self, $client, $auth, $org_id ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ $org_id = $e->requestor->ws_ou unless defined $org_id;
+
+ return $apputils->simple_scalar_request(
+ "open-ils.storage",
+ "open-ils.storage.actor.org_unit.full_path.atomic",
+ $org_id );
}
api_name => "open-ils.actor.patron.search.advanced"
);
sub patron_adv_search {
- my( $self, $client, $auth, $search_hash,
+ my( $self, $client, $auth, $search_hash,
$search_limit, $search_sort, $include_inactive, $search_ou ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- return $e->event unless $e->allowed('VIEW_USER');
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ return $e->event unless $e->allowed('VIEW_USER');
- # depth boundary outside of which patrons must opt-in, default to 0
- my $opt_boundary = 0;
- $opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary') if user_opt_in_enabled($self);
+ # depth boundary outside of which patrons must opt-in, default to 0
+ my $opt_boundary = 0;
+ $opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary') if user_opt_in_enabled($self);
- return $U->storagereq(
- "open-ils.storage.actor.user.crazy_search", $search_hash,
+ return $U->storagereq(
+ "open-ils.storage.actor.user.crazy_search", $search_hash,
$search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_ou, $opt_boundary);
}
__PACKAGE__->register_method(
method => "check_user_perms",
api_name => "open-ils.actor.user.perm.check",
- notes => <<" NOTES");
- Takes a login session, user id, an org id, and an array of perm type strings. For each
- perm type, if the user does *not* have the given permission it is added
- to a list which is returned from the method. If all permissions
- are allowed, an empty list is returned
- if the logged in user does not match 'user_id', then the logged in user must
- have VIEW_PERMISSION priveleges.
- NOTES
+ notes => <<" NOTES");
+ Takes a login session, user id, an org id, and an array of perm type strings. For each
+ perm type, if the user does *not* have the given permission it is added
+ to a list which is returned from the method. If all permissions
+ are allowed, an empty list is returned
+ if the logged in user does not match 'user_id', then the logged in user must
+ have VIEW_PERMISSION priveleges.
+ NOTES
sub check_user_perms {
- my( $self, $client, $login_session, $user_id, $org_id, $perm_types ) = @_;
-
- my( $staff, $evt ) = $apputils->checkses($login_session);
- return $evt if $evt;
-
- if($staff->id ne $user_id) {
- if( $evt = $apputils->check_perms(
- $staff->id, $org_id, 'VIEW_PERMISSION') ) {
- return $evt;
- }
- }
-
- my @not_allowed;
- for my $perm (@$perm_types) {
- if($apputils->check_perms($user_id, $org_id, $perm)) {
- push @not_allowed, $perm;
- }
- }
-
- return \@not_allowed
+ my( $self, $client, $login_session, $user_id, $org_id, $perm_types ) = @_;
+
+ my( $staff, $evt ) = $apputils->checkses($login_session);
+ return $evt if $evt;
+
+ if($staff->id ne $user_id) {
+ if( $evt = $apputils->check_perms(
+ $staff->id, $org_id, 'VIEW_PERMISSION') ) {
+ return $evt;
+ }
+ }
+
+ my @not_allowed;
+ for my $perm (@$perm_types) {
+ if($apputils->check_perms($user_id, $org_id, $perm)) {
+ push @not_allowed, $perm;
+ }
+ }
+
+ return \@not_allowed
}
__PACKAGE__->register_method(
- method => "check_user_perms2",
- api_name => "open-ils.actor.user.perm.check.multi_org",
- notes => q/
- Checks the permissions on a list of perms and orgs for a user
- @param authtoken The login session key
- @param user_id The id of the user to check
- @param orgs The array of org ids
- @param perms The array of permission names
- @return An array of [ orgId, permissionName ] arrays that FAILED the check
- if the logged in user does not match 'user_id', then the logged in user must
- have VIEW_PERMISSION priveleges.
- /);
+ method => "check_user_perms2",
+ api_name => "open-ils.actor.user.perm.check.multi_org",
+ notes => q/
+ Checks the permissions on a list of perms and orgs for a user
+ @param authtoken The login session key
+ @param user_id The id of the user to check
+ @param orgs The array of org ids
+ @param perms The array of permission names
+ @return An array of [ orgId, permissionName ] arrays that FAILED the check
+ if the logged in user does not match 'user_id', then the logged in user must
+ have VIEW_PERMISSION priveleges.
+ /);
sub check_user_perms2 {
- my( $self, $client, $authtoken, $user_id, $orgs, $perms ) = @_;
-
- my( $staff, $target, $evt ) = $apputils->checkses_requestor(
- $authtoken, $user_id, 'VIEW_PERMISSION' );
- return $evt if $evt;
-
- my @not_allowed;
- for my $org (@$orgs) {
- for my $perm (@$perms) {
- if($apputils->check_perms($user_id, $org, $perm)) {
- push @not_allowed, [ $org, $perm ];
- }
- }
- }
-
- return \@not_allowed
+ my( $self, $client, $authtoken, $user_id, $orgs, $perms ) = @_;
+
+ my( $staff, $target, $evt ) = $apputils->checkses_requestor(
+ $authtoken, $user_id, 'VIEW_PERMISSION' );
+ return $evt if $evt;
+
+ my @not_allowed;
+ for my $org (@$orgs) {
+ for my $perm (@$perms) {
+ if($apputils->check_perms($user_id, $org, $perm)) {
+ push @not_allowed, [ $org, $perm ];
+ }
+ }
+ }
+
+ return \@not_allowed
}
__PACKAGE__->register_method(
- method => 'check_user_perms3',
- api_name => 'open-ils.actor.user.perm.highest_org',
- notes => q/
- Returns the highest org unit id at which a user has a given permission
- If the requestor does not match the target user, the requestor must have
- '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 perm The permission to check
- @return The org unit highest in the org tree within which the user has
- the requested permission
- /);
+ method => 'check_user_perms3',
+ api_name => 'open-ils.actor.user.perm.highest_org',
+ notes => q/
+ Returns the highest org unit id at which a user has a given permission
+ If the requestor does not match the target user, the requestor must have
+ '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 perm The permission to check
+ @return The org unit highest in the org tree within which the user has
+ the requested permission
+ /);
sub check_user_perms3 {
- my($self, $client, $authtoken, $user_id, $perm) = @_;
- my $e = new_editor(authtoken=>$authtoken);
- return $e->event unless $e->checkauth;
+ my($self, $client, $authtoken, $user_id, $perm) = @_;
+ my $e = new_editor(authtoken=>$authtoken);
+ return $e->event unless $e->checkauth;
- my $tree = $U->get_org_tree();
+ my $tree = $U->get_org_tree();
unless($e->requestor->id == $user_id) {
my $user = $e->retrieve_actor_user($user_id)
or return $e->event;
return $e->event unless $e->allowed('VIEW_PERMISSION', $user->home_ou);
- return $U->find_highest_perm_org($perm, $user_id, $user->home_ou, $tree );
+ return $U->find_highest_perm_org($perm, $user_id, $user->home_ou, $tree );
}
return $U->find_highest_perm_org($perm, $user_id, $e->requestor->ws_ou, $tree);
}
__PACKAGE__->register_method(
- method => 'user_has_work_perm_at',
- api_name => 'open-ils.actor.user.has_work_perm_at',
+ method => 'user_has_work_perm_at',
+ api_name => 'open-ils.actor.user.has_work_perm_at',
authoritative => 1,
signature => {
desc => q/
the requested action. The user whose perms this method should
check is implied by the authtoken. /,
params => [
- {desc => 'authtoken', type => 'string'},
+ {desc => 'authtoken', type => 'string'},
{desc => 'permission name', type => 'string'},
{desc => q/user id, optional. If present, check perms for
this user instead of the logged in user/, type => 'number'},
}
__PACKAGE__->register_method(
- method => 'user_has_work_perm_at_batch',
- api_name => 'open-ils.actor.user.has_work_perm_at.batch',
+ method => 'user_has_work_perm_at_batch',
+ api_name => 'open-ils.actor.user.has_work_perm_at.batch',
authoritative => 1,
);
__PACKAGE__->register_method(
- method => 'check_user_perms4',
- api_name => 'open-ils.actor.user.perm.highest_org.batch',
- notes => q/
- Returns the highest org unit id at which a user has a given permission
- If the requestor does not match the target user, the requestor must have
- '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
- 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
- /);
+ method => 'check_user_perms4',
+ api_name => 'open-ils.actor.user.perm.highest_org.batch',
+ notes => q/
+ Returns the highest org unit id at which a user has a given permission
+ If the requestor does not match the target user, the requestor must have
+ '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
+ 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(
- $authtoken, $userid, 'VIEW_PERMISSION' );
- return $evt if $evt;
-
- my @arr;
- return [] unless ref($perms);
- my $tree = $U->get_org_tree();
-
- for my $p (@$perms) {
- push( @arr, $U->find_highest_perm_org( $p, $userid, $target->home_ou, $tree ) );
- }
- return \@arr;
+ my( $self, $client, $authtoken, $userid, $perms ) = @_;
+
+ my( $staff, $target, $org, $evt );
+
+ ( $staff, $target, $evt ) = $apputils->checkses_requestor(
+ $authtoken, $userid, 'VIEW_PERMISSION' );
+ return $evt if $evt;
+
+ my @arr;
+ return [] unless ref($perms);
+ my $tree = $U->get_org_tree();
+
+ for my $p (@$perms) {
+ push( @arr, $U->find_highest_perm_org( $p, $userid, $target->home_ou, $tree ) );
+ }
+ return \@arr;
}
);
sub user_fines_summary {
- my( $self, $client, $auth, $user_id ) = @_;
+ my( $self, $client, $auth, $user_id ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
- if( $user_id ne $e->requestor->id ) {
- my $user = $e->retrieve_actor_user($user_id) or return $e->event;
- return $e->event unless
- $e->allowed('VIEW_USER_FINES_SUMMARY', $user->home_ou);
- }
+ if( $user_id ne $e->requestor->id ) {
+ my $user = $e->retrieve_actor_user($user_id) or return $e->event;
+ return $e->event unless
+ $e->allowed('VIEW_USER_FINES_SUMMARY', $user->home_ou);
+ }
return $e->search_money_open_user_summary({usr => $user_id})->[0];
}
);
sub user_opac_vitals {
- my( $self, $client, $auth, $user_id ) = @_;
+ my( $self, $client, $auth, $user_id ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
$user_id ||= $e->requestor->id;
sub user_transactions {
- my( $self, $client, $auth, $user_id, $type, $options ) = @_;
+ my( $self, $client, $auth, $user_id, $type, $options ) = @_;
$options ||= {};
my $e = new_editor(authtoken => $auth);
$method = "$method.authoritative" if $api =~ /authoritative/;
my ($trans) = $self->method_lookup($method)->run($auth, $user_id, $type, $filter, $options);
- if($api =~ /total/o) {
- my $total = 0.0;
+ if($api =~ /total/o) {
+ my $total = 0.0;
$total += $_->balance_owed for @$trans;
- return $total;
- }
+ return $total;
+ }
($api =~ /count/o ) and return scalar @$trans;
($api !~ /fleshed/o) and return $trans;
- my @resp;
- for my $t (@$trans) {
-
- if( $t->xact_type ne 'circulation' ) {
- push @resp, {transaction => $t};
- next;
- }
+ my @resp;
+ for my $t (@$trans) {
+
+ if( $t->xact_type ne 'circulation' ) {
+ push @resp, {transaction => $t};
+ next;
+ }
my $circ_data = flesh_circ($e, $t->id);
- push @resp, {transaction => $t, %$circ_data};
- }
+ push @resp, {transaction => $t, %$circ_data};
+ }
- return \@resp;
+ return \@resp;
}
);
sub user_transaction_retrieve {
- my($self, $client, $auth, $bill_id) = @_;
+ my($self, $client, $auth, $bill_id) = @_;
my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
my $circ_data = flesh_circ($e, $trans->id, 1);
- return {transaction => $trans, %$circ_data};
+ return {transaction => $trans, %$circ_data};
}
sub flesh_circ {
}
]);
- my $mods;
+ my $mods;
my $copy = $circ->target_copy;
if($circ->target_copy->call_number->id == OILS_PRECAT_CALL_NUMBER) {
$circ->target_copy($circ->target_copy->id);
$copy->call_number($copy->call_number->id);
- return {circ => $circ, record => $mods, copy => ($flesh_copy) ? $copy : undef };
+ return {circ => $circ, record => $mods, copy => ($flesh_copy) ? $copy : undef };
}
argc => 1,
notes => 'Returns hold ready/total counts'
);
-
+
sub hold_request_count {
- my( $self, $client, $authtoken, $user_id ) = @_;
+ my( $self, $client, $authtoken, $user_id ) = @_;
my $e = new_editor(authtoken => $authtoken);
return $e->event unless $e->checkauth;
}
});
- return {
+ return {
total => scalar(@$holds),
ready => scalar(
grep {
api_name => "open-ils.actor.user.checked_out",
authoritative => 1,
argc => 2,
- signature => {
+ 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). "
);
sub checked_out {
- my( $self, $conn, $auth, $userid ) = @_;
+ my( $self, $conn, $auth, $userid ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
- if( $userid ne $e->requestor->id ) {
+ if( $userid ne $e->requestor->id ) {
my $user = $e->retrieve_actor_user($userid) or return $e->event;
- unless($e->allowed('VIEW_CIRCULATIONS', $user->home_ou)) {
+ unless($e->allowed('VIEW_CIRCULATIONS', $user->home_ou)) {
# see if there is a friend link allowing circ.view perms
my $allowed = OpenILS::Application::Actor::Friends->friend_perm_allowed(
$e, $userid, $e->requestor->id, 'circ.view');
return $e->event unless $allowed;
}
- }
+ }
- my $count = $self->api_name =~ /count/;
- return _checked_out( $count, $e, $userid );
+ my $count = $self->api_name =~ /count/;
+ return _checked_out( $count, $e, $userid );
}
sub _checked_out {
- my( $iscount, $e, $userid ) = @_;
+ my( $iscount, $e, $userid ) = @_;
my %result = (
out => [],
claims_returned => [],
long_overdue => []
);
- my $meth = 'retrieve_action_open_circ_';
+ my $meth = 'retrieve_action_open_circ_';
if ($iscount) {
- $meth .= 'count';
+ $meth .= 'count';
%result = (
out => 0,
overdue => 0,
long_overdue => 0
);
} else {
- $meth .= 'list';
+ $meth .= 'list';
}
my $data = $e->$meth($userid);
);
sub checked_in_with_fines {
- my( $self, $conn, $auth, $userid ) = @_;
-
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
-
- if( $userid ne $e->requestor->id ) {
- return $e->event unless $e->allowed('VIEW_CIRCULATIONS');
- }
-
- # money is owed on these items and they are checked in
- my $open = $e->search_action_circulation(
- {
- usr => $userid,
- xact_finish => undef,
- checkin_time => { "!=" => undef },
- }
- );
-
-
- my( @lost, @cr, @lo );
- for my $c (@$open) {
- push( @lost, $c->id ) if $c->stop_fines eq 'LOST';
- push( @cr, $c->id ) if $c->stop_fines eq 'CLAIMSRETURNED';
- push( @lo, $c->id ) if $c->stop_fines eq 'LONGOVERDUE';
- }
-
- return {
- lost => \@lost,
- claims_returned => \@cr,
- long_overdue => \@lo
- };
+ my( $self, $conn, $auth, $userid ) = @_;
+
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+
+ if( $userid ne $e->requestor->id ) {
+ return $e->event unless $e->allowed('VIEW_CIRCULATIONS');
+ }
+
+ # money is owed on these items and they are checked in
+ my $open = $e->search_action_circulation(
+ {
+ usr => $userid,
+ xact_finish => undef,
+ checkin_time => { "!=" => undef },
+ }
+ );
+
+
+ my( @lost, @cr, @lo );
+ for my $c (@$open) {
+ push( @lost, $c->id ) if $c->stop_fines eq 'LOST';
+ push( @cr, $c->id ) if $c->stop_fines eq 'CLAIMSRETURNED';
+ push( @lo, $c->id ) if $c->stop_fines eq 'LONGOVERDUE';
+ }
+
+ return {
+ lost => \@lost,
+ claims_returned => \@cr,
+ long_overdue => \@lo
+ };
}
}
sub user_transaction_history {
- my( $self, $conn, $auth, $userid, $type, $filter, $options ) = @_;
+ my( $self, $conn, $auth, $userid, $type, $filter, $options ) = @_;
$filter ||= {};
$options ||= {};
- my $e = new_editor(authtoken=>$auth);
- return $e->die_event unless $e->checkauth;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->die_event unless $e->checkauth;
- if ($e->requestor->id ne $userid) {
+ if ($e->requestor->id ne $userid) {
return $e->die_event unless $e->allowed('VIEW_USER_TRANSACTIONS');
- }
+ }
- my $api = $self->api_name;
- my @xact_finish = (xact_finish => undef ) if ($api =~ /history\.still_open$/); # What about history.still_open.ids?
+ my $api = $self->api_name;
+ my @xact_finish = (xact_finish => undef ) if ($api =~ /history\.still_open$/); # What about history.still_open.ids?
- if(defined($type)) {
- $filter->{'xact_type'} = $type;
- }
+ if(defined($type)) {
+ $filter->{'xact_type'} = $type;
+ }
- if($api =~ /have_bill_or_payment/o) {
+ if($api =~ /have_bill_or_payment/o) {
# transactions that have a non-zero sum across all billings or at least 1 payment
$filter->{'-or'} = {
# transactions that have a non-zero overall balance
$filter->{'balance_owed'} = { '<>' => 0 };
- } elsif( $api =~ /have_charge/o) {
+ } elsif( $api =~ /have_charge/o) {
# transactions that have at least 1 billing, regardless of whether it was voided
$filter->{'last_billing_ts'} = { '<>' => undef };
- } elsif( $api =~ /have_bill/o) { # needs to be an elsif, or we double-match have_bill_or_payment!
+ } elsif( $api =~ /have_bill/o) { # needs to be an elsif, or we double-match have_bill_or_payment!
# transactions that have non-zero sum across all billings. This will exclude
# xacts where all billings have been voided
$filter->{'total_owed'} = { '<>' => 0 };
- }
+ }
my $options_clause = { order_by => { mbt => 'xact_start DESC' } };
$options_clause->{'limit'} = $options->{'limit'} if $options->{'limit'};
return [map {$_->id} @$mbts] if $api =~ /\.ids/;
return $mbts unless $api =~ /fleshed/;
- my @resp;
- for my $t (@$mbts) {
-
- if( $t->xact_type ne 'circulation' ) {
- push @resp, {transaction => $t};
- next;
- }
+ my @resp;
+ for my $t (@$mbts) {
+
+ if( $t->xact_type ne 'circulation' ) {
+ push @resp, {transaction => $t};
+ next;
+ }
my $circ_data = flesh_circ($e, $t->id);
- push @resp, {transaction => $t, %$circ_data};
- }
+ 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 ) = @_;
+ my( $self, $client, $authtoken, $user ) = @_;
- my( $staff, $evt ) = $apputils->checkses($authtoken);
- return $evt if $evt;
+ my( $staff, $evt ) = $apputils->checkses($authtoken);
+ return $evt if $evt;
- $user ||= $staff->id;
+ $user ||= $staff->id;
- if( $user != $staff->id and $evt = $apputils->check_perms( $staff->id, $staff->home_ou, 'VIEW_PERMISSION') ) {
- return $evt;
- }
+ if( $user != $staff->id and $evt = $apputils->check_perms( $staff->id, $staff->home_ou, 'VIEW_PERMISSION') ) {
+ return $evt;
+ }
- return $apputils->simple_scalar_request(
- "open-ils.storage",
- "open-ils.storage.permission.user_perms.atomic",
- $user);
+ return $apputils->simple_scalar_request(
+ "open-ils.storage",
+ "open-ils.storage.permission.user_perms.atomic",
+ $user);
}
__PACKAGE__->register_method(
notes => "Returns a list of permissions"
);
sub retrieve_perms {
- my( $self, $client ) = @_;
- return $apputils->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.permission.perm_list.search.atomic",
- { id => { '!=' => undef } }
- );
+ my( $self, $client ) = @_;
+ return $apputils->simple_scalar_request(
+ "open-ils.cstore",
+ "open-ils.cstore.direct.permission.perm_list.search.atomic",
+ { id => { '!=' => undef } }
+ );
}
__PACKAGE__->register_method(
notes => "Returns a list of user groups"
);
sub retrieve_groups {
- my( $self, $client ) = @_;
- return new_editor()->retrieve_all_permission_grp_tree();
+ my( $self, $client ) = @_;
+ return new_editor()->retrieve_all_permission_grp_tree();
}
__PACKAGE__->register_method(
- method => "retrieve_org_address",
- api_name => "open-ils.actor.org_unit.address.retrieve",
- notes => <<' NOTES');
- Returns an org_unit address by ID
- @param An org_address ID
- NOTES
+ method => "retrieve_org_address",
+ api_name => "open-ils.actor.org_unit.address.retrieve",
+ notes => <<' NOTES');
+ Returns an org_unit address by ID
+ @param An org_address ID
+ NOTES
sub retrieve_org_address {
- my( $self, $client, $id ) = @_;
- return $apputils->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.actor.org_address.retrieve",
- $id
- );
+ my( $self, $client, $id ) = @_;
+ return $apputils->simple_scalar_request(
+ "open-ils.cstore",
+ "open-ils.cstore.direct.actor.org_address.retrieve",
+ $id
+ );
}
__PACKAGE__->register_method(
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"] },
- order_by => { pgt => 'name'}
- }
- ]
- )->[0];
+ my( $self, $client ) = @_;
+ return new_editor()->search_permission_grp_tree(
+ [
+ { parent => undef},
+ {
+ flesh => -1,
+ flesh_fields => { pgt => ["children"] },
+ order_by => { pgt => 'name'}
+ }
+ ]
+ )->[0];
}
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 ) = @_;
-
- my( $requestor, $target, $evt ) = $apputils->checkses_requestor(
- $authtoken, $userid, 'CREATE_USER_GROUP_LINK' );
- return $evt if $evt;
-
- ( $requestor, $target, $evt ) = $apputils->checkses_requestor(
- $authtoken, $userid, 'REMOVE_USER_GROUP_LINK' );
- return $evt if $evt;
-
- $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);
- $link->usr($userid);
-
- my $id = $apputils->simplereq(
- 'open-ils.storage',
- 'open-ils.storage.direct.permission.usr_grp_map.create', $link );
- }
-
- return 1;
+ my( $self, $client, $authtoken, $userid, $groups ) = @_;
+
+ my( $requestor, $target, $evt ) = $apputils->checkses_requestor(
+ $authtoken, $userid, 'CREATE_USER_GROUP_LINK' );
+ return $evt if $evt;
+
+ ( $requestor, $target, $evt ) = $apputils->checkses_requestor(
+ $authtoken, $userid, 'REMOVE_USER_GROUP_LINK' );
+ return $evt if $evt;
+
+ $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);
+ $link->usr($userid);
+
+ my $id = $apputils->simplereq(
+ 'open-ils.storage',
+ 'open-ils.storage.direct.permission.usr_grp_map.create', $link );
+ }
+
+ return 1;
}
__PACKAGE__->register_method(
sub get_user_perm_groups {
- my( $self, $client, $authtoken, $userid ) = @_;
+ my( $self, $client, $authtoken, $userid ) = @_;
- my( $requestor, $target, $evt ) = $apputils->checkses_requestor(
- $authtoken, $userid, 'VIEW_PERM_GROUPS' );
- return $evt if $evt;
+ my( $requestor, $target, $evt ) = $apputils->checkses_requestor(
+ $authtoken, $userid, 'VIEW_PERM_GROUPS' );
+ return $evt if $evt;
- return $apputils->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.permission.usr_grp_map.search.atomic', { usr => $userid } );
-}
+ return $apputils->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.permission.usr_grp_map.search.atomic', { usr => $userid } );
+}
__PACKAGE__->register_method(
);
sub get_user_work_ous {
- my( $self, $client, $auth, $userid ) = @_;
+ my( $self, $client, $auth, $userid ) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
$userid ||= $e->requestor->id;
# client just wants a list of org IDs
return $U->get_user_work_ou_ids($e, $userid);
-}
+}
method => 'register_workstation',
api_name => 'open-ils.actor.workstation.register',
signature => q/
- Registers a new workstion in the system
- @param authtoken The login session key
- @param name The name of the workstation id
- @param owner The org unit that owns this workstation
- @return The workstation id on success, WORKSTATION_NAME_EXISTS
- if the name is already in use.
- /
+ Registers a new workstion in the system
+ @param authtoken The login session key
+ @param name The name of the workstation id
+ @param owner The org unit that owns this workstation
+ @return The workstation id on success, WORKSTATION_NAME_EXISTS
+ if the name is already in use.
+ /
);
sub register_workstation {
- my( $self, $conn, $authtoken, $name, $owner, $oargs ) = @_;
+ my( $self, $conn, $authtoken, $name, $owner, $oargs ) = @_;
- my $e = new_editor(authtoken=>$authtoken, xact=>1);
- return $e->die_event unless $e->checkauth;
- return $e->die_event unless $e->allowed('REGISTER_WORKSTATION', $owner);
- my $existing = $e->search_actor_workstation({name => $name})->[0];
+ my $e = new_editor(authtoken=>$authtoken, xact=>1);
+ return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->allowed('REGISTER_WORKSTATION', $owner);
+ my $existing = $e->search_actor_workstation({name => $name})->[0];
$oargs = { all => 1 } unless defined $oargs;
- if( $existing ) {
+ if( $existing ) {
- if( $self->api_name =~ /override/o && ($oargs->{all} || grep { $_ eq 'WORKSTATION_NAME_EXISTS' } @{$oargs->{events}}) ) {
+ if( $self->api_name =~ /override/o && ($oargs->{all} || grep { $_ eq 'WORKSTATION_NAME_EXISTS' } @{$oargs->{events}}) ) {
# workstation with the given name exists.
if($owner ne $existing->owning_lib) {
$logger->info("changing owning lib of workstation ".$existing->id.
" from ".$existing->owning_lib." to $owner");
- return $e->die_event unless
+ 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);
+ return $e->die_event unless $e->update_actor_workstation($existing);
$e->commit;
return $existing->id;
- } else {
- return OpenILS::Event->new('WORKSTATION_NAME_EXISTS')
- }
- }
-
- my $ws = Fieldmapper::actor::workstation->new;
- $ws->owning_lib($owner);
- $ws->name($name);
- $e->create_actor_workstation($ws) or return $e->die_event;
- $e->commit;
- return $ws->id; # note: editor sets the id on the new object for us
+ } else {
+ return OpenILS::Event->new('WORKSTATION_NAME_EXISTS')
+ }
+ }
+
+ my $ws = Fieldmapper::actor::workstation->new;
+ $ws->owning_lib($owner);
+ $ws->name($name);
+ $e->create_actor_workstation($ws) or return $e->die_event;
+ $e->commit;
+ return $ws->id; # note: editor sets the id on the new object for us
}
__PACKAGE__->register_method(
method => 'workstation_list',
api_name => 'open-ils.actor.workstation.list',
signature => q/
- Returns a list of workstations registered at the given location
- @param authtoken The login session key
- @param ids A list of org_unit.id's for the workstation owners
- /
+ Returns a list of workstations registered at the given location
+ @param authtoken The login session key
+ @param ids A list of org_unit.id's for the workstation owners
+ /
);
sub workstation_list {
- my( $self, $conn, $authtoken, @orgs ) = @_;
+ my( $self, $conn, $authtoken, @orgs ) = @_;
- my $e = new_editor(authtoken=>$authtoken);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken=>$authtoken);
+ return $e->event unless $e->checkauth;
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});
}
api_name => 'open-ils.actor.note.retrieve.all',
authoritative => 1,
signature => q/
- Returns a list of notes for a given user
- Requestor must have VIEW_USER permission if pub==false and
- @param authtoken The login session key
- @param args Hash of params including
- patronid : the patron's id
- pub : true if retrieving only public notes
- /
+ Returns a list of notes for a given user
+ Requestor must have VIEW_USER permission if pub==false and
+ @param authtoken The login session key
+ @param args Hash of params including
+ patronid : the patron's id
+ pub : true if retrieving only public notes
+ /
);
sub fetch_patron_note {
- my( $self, $conn, $authtoken, $args ) = @_;
- my $patronid = $$args{patronid};
-
- my($reqr, $evt) = $U->checkses($authtoken);
- return $evt if $evt;
-
- my $patron;
- ($patron, $evt) = $U->fetch_user($patronid);
- return $evt if $evt;
-
- if($$args{pub}) {
- if( $patronid ne $reqr->id ) {
- $evt = $U->check_perms($reqr->id, $patron->home_ou, 'VIEW_USER');
- return $evt if $evt;
- }
- return $U->cstorereq(
- 'open-ils.cstore.direct.actor.usr_note.search.atomic',
- { usr => $patronid, pub => 't' } );
- }
-
- $evt = $U->check_perms($reqr->id, $patron->home_ou, 'VIEW_USER');
- return $evt if $evt;
-
- return $U->cstorereq(
- 'open-ils.cstore.direct.actor.usr_note.search.atomic', { usr => $patronid } );
+ my( $self, $conn, $authtoken, $args ) = @_;
+ my $patronid = $$args{patronid};
+
+ my($reqr, $evt) = $U->checkses($authtoken);
+ return $evt if $evt;
+
+ my $patron;
+ ($patron, $evt) = $U->fetch_user($patronid);
+ return $evt if $evt;
+
+ if($$args{pub}) {
+ if( $patronid ne $reqr->id ) {
+ $evt = $U->check_perms($reqr->id, $patron->home_ou, 'VIEW_USER');
+ return $evt if $evt;
+ }
+ return $U->cstorereq(
+ 'open-ils.cstore.direct.actor.usr_note.search.atomic',
+ { usr => $patronid, pub => 't' } );
+ }
+
+ $evt = $U->check_perms($reqr->id, $patron->home_ou, 'VIEW_USER');
+ return $evt if $evt;
+
+ return $U->cstorereq(
+ 'open-ils.cstore.direct.actor.usr_note.search.atomic', { usr => $patronid } );
}
__PACKAGE__->register_method(
method => 'create_user_note',
api_name => 'open-ils.actor.note.create',
signature => q/
- Creates a new note for the given user
- @param authtoken The login session key
- @param note The note object
- /
+ Creates a new note for the given user
+ @param authtoken The login session key
+ @param note The note object
+ /
);
sub create_user_note {
- my( $self, $conn, $authtoken, $note ) = @_;
- my $e = new_editor(xact=>1, authtoken=>$authtoken);
- return $e->die_event unless $e->checkauth;
+ my( $self, $conn, $authtoken, $note ) = @_;
+ my $e = new_editor(xact=>1, authtoken=>$authtoken);
+ return $e->die_event unless $e->checkauth;
- my $user = $e->retrieve_actor_user($note->usr)
- or return $e->die_event;
+ my $user = $e->retrieve_actor_user($note->usr)
+ or return $e->die_event;
- return $e->die_event unless
- $e->allowed('UPDATE_USER',$user->home_ou);
+ return $e->die_event unless
+ $e->allowed('UPDATE_USER',$user->home_ou);
- $note->creator($e->requestor->id);
- $e->create_actor_usr_note($note) or return $e->die_event;
- $e->commit;
- return $note->id;
+ $note->creator($e->requestor->id);
+ $e->create_actor_usr_note($note) or return $e->die_event;
+ $e->commit;
+ return $note->id;
}
method => 'delete_user_note',
api_name => 'open-ils.actor.note.delete',
signature => q/
- Deletes a note for the given user
- @param authtoken The login session key
- @param noteid The note id
- /
+ Deletes a note for the given user
+ @param authtoken The login session key
+ @param noteid The note id
+ /
);
sub delete_user_note {
- my( $self, $conn, $authtoken, $noteid ) = @_;
-
- my $e = new_editor(xact=>1, authtoken=>$authtoken);
- return $e->die_event unless $e->checkauth;
- my $note = $e->retrieve_actor_usr_note($noteid)
- or return $e->die_event;
- my $user = $e->retrieve_actor_user($note->usr)
- or return $e->die_event;
- 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;
+ my( $self, $conn, $authtoken, $noteid ) = @_;
+
+ my $e = new_editor(xact=>1, authtoken=>$authtoken);
+ return $e->die_event unless $e->checkauth;
+ my $note = $e->retrieve_actor_usr_note($noteid)
+ or return $e->die_event;
+ my $user = $e->retrieve_actor_user($note->usr)
+ or return $e->die_event;
+ 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;
}
method => 'update_user_note',
api_name => 'open-ils.actor.note.update',
signature => q/
- @param authtoken The login session key
- @param note The note
- /
+ @param authtoken The login session key
+ @param note The note
+ /
);
sub update_user_note {
- my( $self, $conn, $auth, $note ) = @_;
- my $e = new_editor(authtoken=>$auth, xact=>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
- $e->allowed('UPDATE_USER', $patron->home_ou);
- $e->update_actor_user_note($note)
- or return $e->die_event;
- $e->commit;
- return 1;
+ my( $self, $conn, $auth, $note ) = @_;
+ my $e = new_editor(authtoken=>$auth, xact=>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
+ $e->allowed('UPDATE_USER', $patron->home_ou);
+ $e->update_actor_user_note($note)
+ or return $e->die_event;
+ $e->commit;
+ return 1;
}
method => 'create_closed_date',
api_name => 'open-ils.actor.org_unit.closed_date.create',
signature => q/
- Creates a new closing entry for the given org_unit
- @param authtoken The login session key
- @param note The closed_date object
- /
+ Creates a new closing entry for the given org_unit
+ @param authtoken The login session key
+ @param note The closed_date object
+ /
);
sub create_closed_date {
- my( $self, $conn, $authtoken, $cd ) = @_;
+ my( $self, $conn, $authtoken, $cd ) = @_;
- my( $user, $evt ) = $U->checkses($authtoken);
- return $evt if $evt;
+ my( $user, $evt ) = $U->checkses($authtoken);
+ return $evt if $evt;
- $evt = $U->check_perms($user->id, $cd->org_unit, 'CREATE_CLOSEING');
- return $evt if $evt;
+ $evt = $U->check_perms($user->id, $cd->org_unit, 'CREATE_CLOSEING');
+ return $evt if $evt;
- $logger->activity("user ".$user->id." creating library closing for ".$cd->org_unit);
+ $logger->activity("user ".$user->id." creating library closing for ".$cd->org_unit);
- my $id = $U->storagereq(
- 'open-ils.storage.direct.actor.org_unit.closed_date.create', $cd );
- return $U->DB_UPDATE_FAILED($cd) unless $id;
- return $id;
+ my $id = $U->storagereq(
+ 'open-ils.storage.direct.actor.org_unit.closed_date.create', $cd );
+ return $U->DB_UPDATE_FAILED($cd) unless $id;
+ return $id;
}
method => 'delete_closed_date',
api_name => 'open-ils.actor.org_unit.closed_date.delete',
signature => q/
- Deletes a closing entry for the given org_unit
- @param authtoken The login session key
- @param noteid The close_date id
- /
+ Deletes a closing entry for the given org_unit
+ @param authtoken The login session key
+ @param noteid The close_date id
+ /
);
sub delete_closed_date {
- my( $self, $conn, $authtoken, $cd ) = @_;
+ my( $self, $conn, $authtoken, $cd ) = @_;
- my( $user, $evt ) = $U->checkses($authtoken);
- return $evt if $evt;
+ my( $user, $evt ) = $U->checkses($authtoken);
+ return $evt if $evt;
- my $cd_obj;
- ($cd_obj, $evt) = fetch_closed_date($cd);
- return $evt if $evt;
+ my $cd_obj;
+ ($cd_obj, $evt) = fetch_closed_date($cd);
+ return $evt if $evt;
- $evt = $U->check_perms($user->id, $cd->org_unit, 'DELETE_CLOSEING');
- return $evt if $evt;
+ $evt = $U->check_perms($user->id, $cd->org_unit, 'DELETE_CLOSEING');
+ return $evt if $evt;
- $logger->activity("user ".$user->id." deleting library closing for ".$cd->org_unit);
+ $logger->activity("user ".$user->id." deleting library closing for ".$cd->org_unit);
- my $stat = $U->storagereq(
- 'open-ils.storage.direct.actor.org_unit.closed_date.delete', $cd );
- return $U->DB_UPDATE_FAILED($cd) unless $stat;
- return $stat;
+ my $stat = $U->storagereq(
+ 'open-ils.storage.direct.actor.org_unit.closed_date.delete', $cd );
+ return $U->DB_UPDATE_FAILED($cd) unless $stat;
+ return $stat;
}
);
sub usrname_exists {
- my( $self, $conn, $auth, $usrname ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- my $a = $e->search_actor_user({usrname => $usrname}, {idlist=>1});
- return $$a[0] if $a and @$a;
- return undef;
+ my( $self, $conn, $auth, $usrname ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ my $a = $e->search_actor_user({usrname => $usrname}, {idlist=>1});
+ return $$a[0] if $a and @$a;
+ return undef;
}
__PACKAGE__->register_method(
);
sub barcode_exists {
- my( $self, $conn, $auth, $barcode ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- my $card = $e->search_actor_card({barcode => $barcode});
- if (@$card) {
- return 1;
- } else {
- return 0;
- }
- #return undef unless @$card;
- #return $card->[0]->usr;
+ my( $self, $conn, $auth, $barcode ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ my $card = $e->search_actor_card({barcode => $barcode});
+ if (@$card) {
+ return 1;
+ } else {
+ return 0;
+ }
+ #return undef unless @$card;
+ #return $card->[0]->usr;
}
);
sub retrieve_net_levels {
- my( $self, $conn, $auth ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- return $e->retrieve_all_config_net_access_level();
+ my( $self, $conn, $auth ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ return $e->retrieve_all_config_net_access_level();
}
# Retain the old typo API name just in case
api_name => 'open-ils.actor.org_unit.retrieve_by_shortname',
);
sub fetch_org_by_shortname {
- my( $self, $conn, $sname ) = @_;
- my $e = new_editor();
- my $org = $e->search_actor_org_unit({ shortname => uc($sname)})->[0];
- return $e->event unless $org;
- return $org;
+ my( $self, $conn, $sname ) = @_;
+ my $e = new_editor();
+ my $org = $e->search_actor_org_unit({ shortname => uc($sname)})->[0];
+ return $e->event unless $org;
+ return $org;
}
);
sub session_home_lib {
- my( $self, $conn, $auth ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return undef unless $e->checkauth;
- my $org = $e->retrieve_actor_org_unit($e->requestor->home_ou);
- return $org->shortname;
+ my( $self, $conn, $auth ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return undef unless $e->checkauth;
+ my $org = $e->retrieve_actor_org_unit($e->requestor->home_ou);
+ return $org->shortname;
}
__PACKAGE__->register_method(
method => 'session_safe_token',
api_name => 'open-ils.actor.session.safe_token',
signature => q/
- Returns a hashed session ID that is safe for export to the world.
- This safe token will expire after 1 hour of non-use.
- @param auth Active authentication token
- /
+ Returns a hashed session ID that is safe for export to the world.
+ This safe token will expire after 1 hour of non-use.
+ @param auth Active authentication token
+ /
);
sub session_safe_token {
- my( $self, $conn, $auth ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return undef unless $e->checkauth;
+ my( $self, $conn, $auth ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return undef unless $e->checkauth;
- my $safe_token = md5_hex($auth);
+ my $safe_token = md5_hex($auth);
- $cache ||= OpenSRF::Utils::Cache->new("global", 0);
+ $cache ||= OpenSRF::Utils::Cache->new("global", 0);
- # Add more like the following if needed...
- $cache->put_cache(
- "safe-token-home_lib-shortname-$safe_token",
- $e->retrieve_actor_org_unit(
- $e->requestor->home_ou
- )->shortname,
- 60 * 60
- );
+ # Add more like the following if needed...
+ $cache->put_cache(
+ "safe-token-home_lib-shortname-$safe_token",
+ $e->retrieve_actor_org_unit(
+ $e->requestor->home_ou
+ )->shortname,
+ 60 * 60
+ );
- return $safe_token;
+ return $safe_token;
}
method => 'safe_token_home_lib',
api_name => 'open-ils.actor.safe_token.home_lib.shortname',
signature => q/
- Returns the home library shortname from the session
- asscociated with a safe token from generated by
- open-ils.actor.session.safe_token.
- @param safe_token Active safe token
- /
+ Returns the home library shortname from the session
+ asscociated with a safe token from generated by
+ open-ils.actor.session.safe_token.
+ @param safe_token Active safe token
+ /
);
sub safe_token_home_lib {
- my( $self, $conn, $safe_token ) = @_;
+ my( $self, $conn, $safe_token ) = @_;
- $cache ||= OpenSRF::Utils::Cache->new("global", 0);
- return $cache->get_cache( 'safe-token-home_lib-shortname-'. $safe_token );
+ $cache ||= OpenSRF::Utils::Cache->new("global", 0);
+ return $cache->get_cache( 'safe-token-home_lib-shortname-'. $safe_token );
}
);
sub update_penalties {
- my($self, $conn, $auth, $user_id) = @_;
- my $e = new_editor(authtoken=>$auth, xact => 1);
- return $e->die_event unless $e->checkauth;
+ my($self, $conn, $auth, $user_id) = @_;
+ my $e = new_editor(authtoken=>$auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
my $user = $e->retrieve_actor_user($user_id) or return $e->die_event;
return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
my $evt = OpenILS::Utils::Penalty->calculate_penalties($e, $user_id, $e->requestor->ws_ou);
);
sub apply_penalty {
- my($self, $conn, $auth, $penalty) = @_;
+ my($self, $conn, $auth, $penalty) = @_;
- my $e = new_editor(authtoken=>$auth, xact => 1);
- return $e->die_event unless $e->checkauth;
+ my $e = new_editor(authtoken=>$auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
my $user = $e->retrieve_actor_user($penalty->usr) or return $e->die_event;
return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
);
sub remove_penalty {
- my($self, $conn, $auth, $penalty) = @_;
- my $e = new_editor(authtoken=>$auth, xact => 1);
- return $e->die_event unless $e->checkauth;
+ my($self, $conn, $auth, $penalty) = @_;
+ my $e = new_editor(authtoken=>$auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
my $user = $e->retrieve_actor_user($penalty->usr) or return $e->die_event;
return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
);
sub update_penalty_note {
- my($self, $conn, $auth, $penalty_ids, $note) = @_;
- my $e = new_editor(authtoken=>$auth, xact => 1);
- return $e->die_event unless $e->checkauth;
+ my($self, $conn, $auth, $penalty_ids, $note) = @_;
+ my $e = new_editor(authtoken=>$auth, xact => 1);
+ return $e->die_event unless $e->checkauth;
for my $penalty_id (@$penalty_ids) {
my $penalty = $e->search_actor_user_standing_penalty( { id => $penalty_id } )->[0];
if (! $penalty ) { return $e->die_event; }
);
sub ranged_penalty_thresholds {
- my($self, $conn, $auth, $context_org) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
+ my($self, $conn, $auth, $context_org) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('VIEW_GROUP_PENALTY_THRESHOLD', $context_org);
my $list = $e->search_permission_grp_penalty_threshold([
{org_unit => $U->get_org_ancestors($context_org)},
);
sub user_retrieve_fleshed_by_id {
- my( $self, $client, $auth, $user_id, $fields ) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
-
- if( $e->requestor->id != $user_id ) {
- return $e->event unless $e->allowed('VIEW_USER');
- }
-
- $fields ||= [
- "cards",
- "card",
- "standing_penalties",
- "addresses",
- "billing_address",
- "mailing_address",
- "stat_cat_entries",
- "usr_activity" ];
- return new_flesh_user($user_id, $fields, $e);
+ my( $self, $client, $auth, $user_id, $fields ) = @_;
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
+
+ if( $e->requestor->id != $user_id ) {
+ return $e->event unless $e->allowed('VIEW_USER');
+ }
+
+ $fields ||= [
+ "cards",
+ "card",
+ "standing_penalties",
+ "addresses",
+ "billing_address",
+ "mailing_address",
+ "stat_cat_entries",
+ "usr_activity" ];
+ return new_flesh_user($user_id, $fields, $e);
}
sub new_flesh_user {
- my $id = shift;
- my $fields = shift || [];
- my $e = shift;
+ my $id = shift;
+ my $fields = shift || [];
+ my $e = shift;
my $fetch_penalties = 0;
if(grep {$_ eq 'standing_penalties'} @$fields) {
$fetch_usr_act = 1;
}
- my $user = $e->retrieve_actor_user(
- [
- $id,
- {
- "flesh" => 1,
- "flesh_fields" => { "au" => $fields }
- }
- ]
- ) or return $e->die_event;
+ my $user = $e->retrieve_actor_user(
+ [
+ $id,
+ {
+ "flesh" => 1,
+ "flesh_fields" => { "au" => $fields }
+ }
+ ]
+ ) or return $e->die_event;
- if( grep { $_ eq 'addresses' } @$fields ) {
+ if( grep { $_ eq 'addresses' } @$fields ) {
- $user->addresses([]) unless @{$user->addresses};
+ $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 );
- }
- }
- }
+
+ 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 );
+ }
+ }
+ }
if($fetch_penalties) {
# grab the user penalties ranged for this location
);
}
- $e->rollback;
- $user->clear_passwd();
- return $user;
+ $e->rollback;
+ $user->clear_passwd();
+ return $user;
}
);
sub user_retrieve_parts {
- my( $self, $client, $auth, $user_id, $fields ) = @_;
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my( $self, $client, $auth, $user_id, $fields ) = @_;
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
$user_id ||= $e->requestor->id;
- if( $e->requestor->id != $user_id ) {
- return $e->event unless $e->allowed('VIEW_USER');
- }
- my @resp;
- my $user = $e->retrieve_actor_user($user_id) or return $e->event;
- push(@resp, $user->$_()) for(@$fields);
- return \@resp;
+ if( $e->requestor->id != $user_id ) {
+ return $e->event unless $e->allowed('VIEW_USER');
+ }
+ my @resp;
+ my $user = $e->retrieve_actor_user($user_id) or return $e->event;
+ push(@resp, $user->$_()) for(@$fields);
+ return \@resp;
}
# see if we even need to enforce the opt-in value
return 1 unless user_opt_in_enabled($self);
- my $e = new_editor(authtoken => $auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
my $user = $e->retrieve_actor_user($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);
my $ws_org = $e->requestor->ws_ou;
# user is automatically opted-in if they are from the local org
sub create_user_opt_in_at_org {
my($self, $conn, $auth, $user_id, $org_id) = @_;
- my $e = new_editor(authtoken => $auth, xact=>1);
- return $e->die_event unless $e->checkauth;
+ 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 $user = $e->retrieve_actor_user($user_id) or return $e->die_event;
- return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
+ return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
my $opt_in = Fieldmapper::actor::usr_org_unit_opt_in->new;
__PACKAGE__->register_method (
- method => 'retrieve_org_hours',
- api_name => 'open-ils.actor.org_unit.hours_of_operation.retrieve',
- signature => q/
+ method => 'retrieve_org_hours',
+ api_name => 'open-ils.actor.org_unit.hours_of_operation.retrieve',
+ signature => q/
Returns the hours of operation for a specified org unit
- @param authtoken The login session key
- @param org_id The org_unit ID
- /
+ @param authtoken The login session key
+ @param org_id The org_unit ID
+ /
);
sub retrieve_org_hours {
my($self, $conn, $auth, $org_id) = @_;
my $e = new_editor(authtoken => $auth);
- return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->checkauth;
$org_id ||= $e->requestor->ws_ou;
return $e->retrieve_actor_org_unit_hours_of_operation($org_id);
}
__PACKAGE__->register_method (
- method => 'verify_user_password',
- api_name => 'open-ils.actor.verify_user_password',
- signature => q/
+ method => 'verify_user_password',
+ api_name => 'open-ils.actor.verify_user_password',
+ signature => q/
Given a barcode or username and the MD5 encoded password,
returns 1 if the password is correct. Returns 0 otherwise.
- /
+ /
);
sub verify_user_password {
my($self, $conn, $auth, $barcode, $username, $password) = @_;
my $e = new_editor(authtoken => $auth);
- return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->checkauth;
my $user;
my $user_by_barcode;
my $user_by_username;
}
__PACKAGE__->register_method (
- method => 'retrieve_usr_id_via_barcode_or_usrname',
- api_name => "open-ils.actor.user.retrieve_id_by_barcode_or_username",
- signature => q/
+ method => 'retrieve_usr_id_via_barcode_or_usrname',
+ api_name => "open-ils.actor.user.retrieve_id_by_barcode_or_username",
+ signature => q/
Given a barcode or username returns the id for the user or
a failure event.
- /
+ /
);
sub retrieve_usr_id_via_barcode_or_usrname {
my($self, $conn, $auth, $barcode, $username) = @_;
my $e = new_editor(authtoken => $auth);
- return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->checkauth;
my $id_as_barcode= OpenSRF::Utils::SettingsClient->new->config_value(apps => 'open-ils.actor' => app_settings => 'id_as_barcode');
my $user;
my $user_by_barcode;
$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);
+ 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;
}
__PACKAGE__->register_method (
- method => 'merge_users',
- api_name => 'open-ils.actor.user.merge',
- signature => {
+ method => 'merge_users',
+ api_name => 'open-ils.actor.user.merge',
+ 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
sub merge_users {
my($self, $conn, $auth, $master_id, $user_ids, $options) = @_;
my $e = new_editor(xact => 1, authtoken => $auth);
- return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->checkauth;
# disallow the merge if any subordinate accounts are in collections
my $colls = $e->search_money_collections_tracker({usr => $user_ids}, {idlist => 1});
__PACKAGE__->register_method (
- method => 'approve_user_address',
- api_name => 'open-ils.actor.user.pending_address.approve',
- signature => {
+ method => 'approve_user_address',
+ api_name => 'open-ils.actor.user.pending_address.approve',
+ signature => {
desc => q/
/
}
sub approve_user_address {
my($self, $conn, $auth, $addr) = @_;
my $e = new_editor(xact => 1, authtoken => $auth);
- return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->checkauth;
if(ref $addr) {
# if the caller passes an address object, assume they want to
# update it first before approving it
__PACKAGE__->register_method (
- method => 'retrieve_friends',
- api_name => 'open-ils.actor.friends.retrieve',
- signature => {
+ method => 'retrieve_friends',
+ api_name => 'open-ils.actor.friends.retrieve',
+ signature => {
desc => q/
returns { confirmed: [], pending_out: [], pending_in: []}
pending_out are users I'm requesting friendship with
__PACKAGE__->register_method (
- method => 'apply_friend_perms',
- api_name => 'open-ils.actor.friends.perms.apply',
- signature => {
+ method => 'apply_friend_perms',
+ api_name => 'open-ils.actor.friends.perms.apply',
+ signature => {
desc => q/
/
}
__PACKAGE__->register_method (
- method => 'update_user_pending_address',
- api_name => 'open-ils.actor.user.address.pending.cud'
+ method => 'update_user_pending_address',
+ api_name => 'open-ils.actor.user.address.pending.cud'
);
sub update_user_pending_address {
__PACKAGE__->register_method (
- method => 'user_events',
- api_name => 'open-ils.actor.user.events.circ',
+ method => 'user_events',
+ api_name => 'open-ils.actor.user.events.circ',
stream => 1,
);
__PACKAGE__->register_method (
- method => 'user_events',
- api_name => 'open-ils.actor.user.events.ahr',
+ method => 'user_events',
+ api_name => 'open-ils.actor.user.events.ahr',
stream => 1,
);
}
__PACKAGE__->register_method (
- method => 'copy_events',
- api_name => 'open-ils.actor.copy.events.circ',
+ method => 'copy_events',
+ api_name => 'open-ils.actor.copy.events.circ',
stream => 1,
);
__PACKAGE__->register_method (
- method => 'copy_events',
- api_name => 'open-ils.actor.copy.events.ahr',
+ method => 'copy_events',
+ api_name => 'open-ils.actor.copy.events.ahr',
stream => 1,
);
__PACKAGE__->register_method (
- method => 'update_events',
- api_name => 'open-ils.actor.user.event.cancel.batch',
+ method => 'update_events',
+ api_name => 'open-ils.actor.user.event.cancel.batch',
stream => 1,
);
__PACKAGE__->register_method (
- method => 'update_events',
- api_name => 'open-ils.actor.user.event.reset.batch',
+ method => 'update_events',
+ api_name => 'open-ils.actor.user.event.reset.batch',
stream => 1,
);
__PACKAGE__->register_method (
- method => 'really_delete_user',
- api_name => 'open-ils.actor.user.delete.override',
+ method => 'really_delete_user',
+ api_name => 'open-ils.actor.user.delete.override',
signature => q/@see open-ils.actor.user.delete/
);
__PACKAGE__->register_method (
- method => 'really_delete_user',
- api_name => 'open-ils.actor.user.delete',
+ 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 also purges related data from other tables, sometimes by transferring it to a designated destination user.
__PACKAGE__->register_method (
- method => 'user_payments',
- api_name => 'open-ils.actor.user.payments.retrieve',
+ method => 'user_payments',
+ api_name => 'open-ils.actor.user.payments.retrieve',
stream => 1,
signature => q/
Returns all payments for a given user. Default order is newest payments first.
__PACKAGE__->register_method (
- method => 'negative_balance_users',
- api_name => 'open-ils.actor.users.negative_balance',
+ method => 'negative_balance_users',
+ api_name => 'open-ils.actor.users.negative_balance',
stream => 1,
signature => q/
Returns all users that have an overall negative balance
}
__PACKAGE__->register_method(
- method => "request_password_reset",
- api_name => "open-ils.actor.patron.password_reset.request",
- signature => {
+ method => "request_password_reset",
+ api_name => "open-ils.actor.patron.password_reset.request",
+ signature => {
desc => "Generates a UUID token usable with the open-ils.actor.patron.password_reset.commit " .
"method for changing a user's password. The UUID token is distributed via A/T " .
"templates (i.e. email to the user).",
}
__PACKAGE__->register_method(
- method => "commit_password_reset",
- api_name => "open-ils.actor.patron.password_reset.commit",
- signature => {
+ method => "commit_password_reset",
+ api_name => "open-ils.actor.patron.password_reset.commit",
+ signature => {
desc => "Checks a UUID token generated by the open-ils.actor.patron.password_reset.request method for " .
"validity, and if valid, uses it as authorization for changing the associated user's password " .
"with the supplied password.",
);
sub get_barcodes {
- my( $self, $client, $auth, $org_id, $context, $barcode ) = @_;
- my $e = new_editor(authtoken => $auth);
+ my( $self, $client, $auth, $org_id, $context, $barcode ) = @_;
+ my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('STAFF_LOGIN', $org_id);
sub initialize { return 1; }
__PACKAGE__->register_method(
- method => 'fetch_dates',
- api_name => 'open-ils.actor.org_unit.closed.retrieve.all',
- signature => q/
- Retrieves a list of closed date object IDs
- /
+ method => 'fetch_dates',
+ api_name => 'open-ils.actor.org_unit.closed.retrieve.all',
+ signature => q/
+ Retrieves a list of closed date object IDs
+ /
);
sub fetch_dates {
- my( $self, $conn, $auth, $args ) = @_;
+ my( $self, $conn, $auth, $args ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
- my $org = $$args{orgid} || $e->requestor->ws_ou;
- my @date = localtime;
- my $start = $$args{start_date} || #default to today
- ($date[5] + 1900) .'-'. ($date[4] + 1) .'-'. $date[3];
- my $end = $$args{end_date} || '3000-01-01'; # Y3K, here I come..
+ my $org = $$args{orgid} || $e->requestor->ws_ou;
+ my @date = localtime;
+ my $start = $$args{start_date} || #default to today
+ ($date[5] + 1900) .'-'. ($date[4] + 1) .'-'. $date[3];
+ my $end = $$args{end_date} || '3000-01-01'; # Y3K, here I come..
- my $dates = $e->search_actor_org_unit_closed_date(
- {
- close_start => { ">=" => $start },
- close_end => { "<=" => $end },
- org_unit => $org,
- }, { idlist => $$args{idlist} } ) or return $e->event;
+ my $dates = $e->search_actor_org_unit_closed_date(
+ {
+ close_start => { ">=" => $start },
+ close_end => { "<=" => $end },
+ org_unit => $org,
+ }, { idlist => $$args{idlist} } ) or return $e->event;
- if(!$$args{idlist} and @$dates) {
- $dates = [ sort { $a->close_start cmp $b->close_start } @$dates ];
- }
+ if(!$$args{idlist} and @$dates) {
+ $dates = [ sort { $a->close_start cmp $b->close_start } @$dates ];
+ }
- return $dates;
+ return $dates;
}
__PACKAGE__->register_method(
- method => 'fetch_date',
- api_name => 'open-ils.actor.org_unit.closed.retrieve',
- signature => q/
- Retrieves a single date object
- /
+ method => 'fetch_date',
+ api_name => 'open-ils.actor.org_unit.closed.retrieve',
+ signature => q/
+ Retrieves a single date object
+ /
);
sub fetch_date {
- my( $self, $conn, $auth, $id ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- my $date = $e->retrieve_actor_org_unit_closed_date($id) or return $e->event;
- return $date;
+ my( $self, $conn, $auth, $id ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ my $date = $e->retrieve_actor_org_unit_closed_date($id) or return $e->event;
+ return $date;
}
__PACKAGE__->register_method(
- method => 'delete_date',
- api_name => 'open-ils.actor.org_unit.closed.delete',
- signature => q/
- Removes a single date object
- /
+ method => 'delete_date',
+ api_name => 'open-ils.actor.org_unit.closed.delete',
+ signature => q/
+ Removes a single date object
+ /
);
sub delete_date {
- my( $self, $conn, $auth, $id ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- my $date = $e->retrieve_actor_org_unit_closed_date($id) or return $e->event;
- return $e->event unless $e->allowed( # rely on the editor perm eventually
- 'actor.org_unit.closed_date.delete', $date->org_unit);
- $e->delete_actor_org_unit_closed_date($date) or return $e->event;
- return 1;
+ my( $self, $conn, $auth, $id ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ my $date = $e->retrieve_actor_org_unit_closed_date($id) or return $e->event;
+ return $e->event unless $e->allowed( # rely on the editor perm eventually
+ 'actor.org_unit.closed_date.delete', $date->org_unit);
+ $e->delete_actor_org_unit_closed_date($date) or return $e->event;
+ return 1;
}
__PACKAGE__->register_method(
- method => 'create_date',
- api_name => 'open-ils.actor.org_unit.closed.create',
- signature => q/
- Creates a new org closed data
- /
+ method => 'create_date',
+ api_name => 'open-ils.actor.org_unit.closed.create',
+ signature => q/
+ Creates a new org closed data
+ /
);
sub create_date {
- my( $self, $conn, $auth, $date ) = @_;
+ my( $self, $conn, $auth, $date ) = @_;
- my $e = new_editor(authtoken=>$auth, xact =>1);
- return $e->event unless $e->checkauth;
-
- return $e->event unless $e->allowed( # rely on the editor perm eventually
- 'actor.org_unit.closed_date.create', $date->org_unit);
+ my $e = new_editor(authtoken=>$auth, xact =>1);
+ return $e->event unless $e->checkauth;
+
+ return $e->event unless $e->allowed( # rely on the editor perm eventually
+ 'actor.org_unit.closed_date.create', $date->org_unit);
- $e->create_actor_org_unit_closed_date($date) or return $e->event;
+ $e->create_actor_org_unit_closed_date($date) or return $e->event;
- my $newobj = $e->retrieve_actor_org_unit_closed_date($date->id)
- or return $e->event;
+ my $newobj = $e->retrieve_actor_org_unit_closed_date($date->id)
+ or return $e->event;
- $e->commit;
- return $newobj;
+ $e->commit;
+ return $newobj;
}
__PACKAGE__->register_method(
- method => 'edit_date',
- api_name => 'open-ils.actor.org_unit.closed.update',
- signature => q/
- Updates a closed date object
- /
+ method => 'edit_date',
+ api_name => 'open-ils.actor.org_unit.closed.update',
+ signature => q/
+ Updates a closed date object
+ /
);
sub edit_date {
- my( $self, $conn, $auth, $date ) = @_;
- my $e = new_editor(authtoken=>$auth, xact =>1);
- return $e->event unless $e->checkauth;
-
- # First make sure they have the right to update the selected date object
- my $odate = $e->retrieve_actor_org_unit_closed_date($date->id)
- or return $e->event;
+ my( $self, $conn, $auth, $date ) = @_;
+ my $e = new_editor(authtoken=>$auth, xact =>1);
+ return $e->event unless $e->checkauth;
+
+ # First make sure they have the right to update the selected date object
+ my $odate = $e->retrieve_actor_org_unit_closed_date($date->id)
+ or return $e->event;
- return $e->event unless $e->allowed( # rely on the editor perm eventually
- 'actor.org_unit.closed_date.update', $odate->org_unit);
+ return $e->event unless $e->allowed( # rely on the editor perm eventually
+ 'actor.org_unit.closed_date.update', $odate->org_unit);
- $e->update_actor_org_unit_closed_date($date) or return $e->event;
+ $e->update_actor_org_unit_closed_date($date) or return $e->event;
- return 1;
+ return 1;
}
__PACKAGE__->register_method(
- method => 'closed_dates_overlap',
- api_name => 'open-ils.actor.org_unit.closed_date.overlap',
- signature => q/
- Returns an object with 'start' and 'end' fields
- start is the first day the org is open going backwards from
- 'date'. end is the next day the org is open going
- forward from 'date'.
- @param orgid The org unit in question
- @param date The date to search
- /
+ method => 'closed_dates_overlap',
+ api_name => 'open-ils.actor.org_unit.closed_date.overlap',
+ signature => q/
+ Returns an object with 'start' and 'end' fields
+ start is the first day the org is open going backwards from
+ 'date'. end is the next day the org is open going
+ forward from 'date'.
+ @param orgid The org unit in question
+ @param date The date to search
+ /
);
sub closed_dates_overlap {
- my( $self, $conn, $auth, $orgid, $date ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- return $e->request(
- 'open-ils.storage.actor.org_unit.closed_date.overlap', $orgid, $date );
+ my( $self, $conn, $auth, $orgid, $date ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ return $e->request(
+ 'open-ils.storage.actor.org_unit.closed_date.overlap', $orgid, $date );
}
my $event;
sub _sort_buckets {
- my $buckets = shift;
- return $buckets unless ($buckets && $buckets->[0]);
- return [ sort { $a->name cmp $b->name } @$buckets ];
+ my $buckets = shift;
+ return $buckets unless ($buckets && $buckets->[0]);
+ return [ sort { $a->name cmp $b->name } @$buckets ];
}
__PACKAGE__->register_method(
- method => "bucket_retrieve_all",
- api_name => "open-ils.actor.container.all.retrieve_by_user",
+ method => "bucket_retrieve_all",
+ api_name => "open-ils.actor.container.all.retrieve_by_user",
authoritative => 1,
- notes => <<" NOTES");
- Retrieves all un-fleshed buckets assigned to given user
- PARAMS(authtoken, bucketOwnerId)
- If requestor ID is different than bucketOwnerId, requestor must have
- VIEW_CONTAINER permissions.
- NOTES
+ notes => <<" NOTES");
+ Retrieves all un-fleshed buckets assigned to given user
+ PARAMS(authtoken, bucketOwnerId)
+ If requestor ID is different than bucketOwnerId, requestor must have
+ VIEW_CONTAINER permissions.
+ NOTES
sub bucket_retrieve_all {
- my($self, $client, $auth, $user_id) = @_;
+ my($self, $client, $auth, $user_id) = @_;
my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('VIEW_CONTAINER');
}
- my %buckets;
+ my %buckets;
for my $type (keys %ctypes) {
my $meth = "search_" . $ctypes{$type};
- $buckets{$type} = $e->$meth({owner => $user_id});
+ $buckets{$type} = $e->$meth({owner => $user_id});
}
- return \%buckets;
+ return \%buckets;
}
__PACKAGE__->register_method(
- method => "bucket_flesh",
- api_name => "open-ils.actor.container.flesh",
+ method => "bucket_flesh",
+ api_name => "open-ils.actor.container.flesh",
authoritative => 1,
- argc => 3,
+ argc => 3,
);
__PACKAGE__->register_method(
- method => "bucket_flesh_pub",
- api_name => "open-ils.actor.container.public.flesh",
- argc => 3,
+ method => "bucket_flesh_pub",
+ api_name => "open-ils.actor.container.public.flesh",
+ argc => 3,
);
sub bucket_flesh {
- my($self, $conn, $auth, $class, $bucket_id) = @_;
+ my($self, $conn, $auth, $class, $bucket_id) = @_;
my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
return _bucket_flesh($self, $conn, $e, $class, $bucket_id);
}
sub _bucket_flesh {
- my($self, $conn, $e, $class, $bucket_id) = @_;
- my $meth = 'retrieve_' . $ctypes{$class};
+ my($self, $conn, $e, $class, $bucket_id) = @_;
+ my $meth = 'retrieve_' . $ctypes{$class};
my $bkt = $e->$meth($bucket_id) or return $e->event;
- unless($U->is_true($bkt->pub)) {
+ unless($U->is_true($bkt->pub)) {
return undef if $self->api_name =~ /public/;
unless($bkt->owner eq $e->requestor->id) {
my $owner = $e->retrieve_actor_user($bkt->owner)
or return $e->die_event;
return $e->event unless $e->allowed('VIEW_CONTAINER', $owner->home_ou);
}
- }
+ }
my $fmclass = $bkt->class_name . "i";
$meth = 'search_' . $ctypes{$class} . '_item';
- $bkt->items(
+ $bkt->items(
$e->$meth(
{bucket => $bucket_id},
{ order_by => {$fmclass => "pos"},
)
);
- return $bkt;
+ return $bkt;
}
__PACKAGE__->register_method(
- method => "item_note_cud",
- api_name => "open-ils.actor.container.item_note.cud",
+ method => "item_note_cud",
+ api_name => "open-ils.actor.container.item_note.cud",
);
__PACKAGE__->register_method(
- method => "bucket_retrieve_class",
- api_name => "open-ils.actor.container.retrieve_by_class",
- argc => 3,
- authoritative => 1,
- notes => <<" NOTES");
- Retrieves all un-fleshed buckets by class assigned to given user
- PARAMS(authtoken, bucketOwnerId, class [, type])
- class can be one of "biblio", "callnumber", "copy", "user"
- The optional "type" parameter allows you to limit the search by
- bucket type.
- If bucketOwnerId is not defined, the authtoken is used as the
- bucket owner.
- If requestor ID is different than bucketOwnerId, requestor must have
- VIEW_CONTAINER permissions.
- NOTES
+ method => "bucket_retrieve_class",
+ api_name => "open-ils.actor.container.retrieve_by_class",
+ argc => 3,
+ authoritative => 1,
+ notes => <<" NOTES");
+ Retrieves all un-fleshed buckets by class assigned to given user
+ PARAMS(authtoken, bucketOwnerId, class [, type])
+ class can be one of "biblio", "callnumber", "copy", "user"
+ The optional "type" parameter allows you to limit the search by
+ bucket type.
+ If bucketOwnerId is not defined, the authtoken is used as the
+ bucket owner.
+ If requestor ID is different than bucketOwnerId, requestor must have
+ VIEW_CONTAINER permissions.
+ NOTES
sub bucket_retrieve_class {
- my( $self, $client, $authtoken, $userid, $class, $type ) = @_;
+ my( $self, $client, $authtoken, $userid, $class, $type ) = @_;
- my( $staff, $user, $evt ) =
- $apputils->checkses_requestor( $authtoken, $userid, 'VIEW_CONTAINER' );
- return $evt if $evt;
+ my( $staff, $user, $evt ) =
+ $apputils->checkses_requestor( $authtoken, $userid, 'VIEW_CONTAINER' );
+ return $evt if $evt;
- $logger->debug("User " . $staff->id .
- " retrieving buckets for user $userid [class=$class, type=$type]");
+ $logger->debug("User " . $staff->id .
+ " retrieving buckets for user $userid [class=$class, type=$type]");
- my $meth = $types{$class} . ".search.atomic";
- my $buckets;
+ my $meth = $types{$class} . ".search.atomic";
+ my $buckets;
- if( $type ) {
- $buckets = $apputils->simplereq( $svc,
- $meth, { owner => $userid, btype => $type } );
- } else {
- $logger->debug("Grabbing buckets by class $class: $svc : $meth : {owner => $userid}");
- $buckets = $apputils->simplereq( $svc, $meth, { owner => $userid } );
- }
+ if( $type ) {
+ $buckets = $apputils->simplereq( $svc,
+ $meth, { owner => $userid, btype => $type } );
+ } else {
+ $logger->debug("Grabbing buckets by class $class: $svc : $meth : {owner => $userid}");
+ $buckets = $apputils->simplereq( $svc, $meth, { owner => $userid } );
+ }
- return _sort_buckets($buckets);
+ return _sort_buckets($buckets);
}
__PACKAGE__->register_method(
- method => "bucket_create",
- api_name => "open-ils.actor.container.create",
- notes => <<" NOTES");
- Creates a new bucket object. If requestor is different from
- bucketOwner, requestor needs CREATE_CONTAINER permissions
- PARAMS(authtoken, bucketObject);
- Returns the new bucket object
- NOTES
+ method => "bucket_create",
+ api_name => "open-ils.actor.container.create",
+ notes => <<" NOTES");
+ Creates a new bucket object. If requestor is different from
+ bucketOwner, requestor needs CREATE_CONTAINER permissions
+ PARAMS(authtoken, bucketObject);
+ Returns the new bucket object
+ NOTES
sub bucket_create {
- my( $self, $client, $authtoken, $class, $bucket ) = @_;
+ my( $self, $client, $authtoken, $class, $bucket ) = @_;
- my $e = new_editor(xact=>1, authtoken=>$authtoken);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken=>$authtoken);
+ return $e->event unless $e->checkauth;
- if( $bucket->owner ne $e->requestor->id ) {
- return $e->event unless
- $e->allowed('CREATE_CONTAINER');
+ if( $bucket->owner ne $e->requestor->id ) {
+ return $e->event unless
+ $e->allowed('CREATE_CONTAINER');
- } else {
- return $e->event unless
- $e->allowed('CREATE_MY_CONTAINER');
- }
-
- $bucket->clear_id;
+ } else {
+ return $e->event unless
+ $e->allowed('CREATE_MY_CONTAINER');
+ }
+
+ $bucket->clear_id;
my $evt = OpenILS::Event->new('CONTAINER_EXISTS',
payload => [$class, $bucket->owner, $bucket->btype, $bucket->name]);
my $search = {name => $bucket->name, owner => $bucket->owner, btype => $bucket->btype};
- my $obj;
- if( $class eq 'copy' ) {
+ my $obj;
+ if( $class eq 'copy' ) {
return $evt if $e->search_container_copy_bucket($search)->[0];
- return $e->event unless
- $obj = $e->create_container_copy_bucket($bucket);
- }
+ return $e->event unless
+ $obj = $e->create_container_copy_bucket($bucket);
+ }
- if( $class eq 'callnumber' ) {
+ if( $class eq 'callnumber' ) {
return $evt if $e->search_container_call_number_bucket($search)->[0];
- return $e->event unless
- $obj = $e->create_container_call_number_bucket($bucket);
- }
+ return $e->event unless
+ $obj = $e->create_container_call_number_bucket($bucket);
+ }
- if( $class eq 'biblio' ) {
+ if( $class eq 'biblio' ) {
return $evt if $e->search_container_biblio_record_entry_bucket($search)->[0];
- return $e->event unless
- $obj = $e->create_container_biblio_record_entry_bucket($bucket);
- }
+ return $e->event unless
+ $obj = $e->create_container_biblio_record_entry_bucket($bucket);
+ }
- if( $class eq 'user') {
+ if( $class eq 'user') {
return $evt if $e->search_container_user_bucket($search)->[0];
- return $e->event unless
- $obj = $e->create_container_user_bucket($bucket);
- }
+ return $e->event unless
+ $obj = $e->create_container_user_bucket($bucket);
+ }
- $e->commit;
- return $obj->id;
+ $e->commit;
+ return $obj->id;
}
__PACKAGE__->register_method(
- method => "item_create",
- api_name => "open-ils.actor.container.item.create",
+ method => "item_create",
+ api_name => "open-ils.actor.container.item.create",
signature => {
desc => q/
Adds one or more items to an existing container
/,
params => [
- {desc => 'Authentication token', type => 'string'},
- {desc => 'Container class. Can be "copy", "callnumber", "biblio", or "user"', type => 'string'},
- {desc => 'Item or items. Can either be a single container item object, or an array of them', type => 'object'},
+ {desc => 'Authentication token', type => 'string'},
+ {desc => 'Container class. Can be "copy", "callnumber", "biblio", or "user"', type => 'string'},
+ {desc => 'Item or items. Can either be a single container item object, or an array of them', type => 'object'},
],
return => {
desc => 'The ID of the newly created item(s). In batch context, an array of IDs is returned'
sub item_create {
- my( $self, $client, $authtoken, $class, $item ) = @_;
+ my( $self, $client, $authtoken, $class, $item ) = @_;
- my $e = new_editor(xact=>1, authtoken=>$authtoken);
- return $e->die_event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken=>$authtoken);
+ return $e->die_event unless $e->checkauth;
my $items = (ref $item eq 'ARRAY') ? $item : [$item];
- my ( $bucket, $evt ) = $apputils->fetch_container_e($e, $item->bucket, $class);
- return $evt if $evt;
+ my ( $bucket, $evt ) = $apputils->fetch_container_e($e, $item->bucket, $class);
+ return $evt if $evt;
- if( $bucket->owner ne $e->requestor->id ) {
- return $e->die_event unless
- $e->allowed('CREATE_CONTAINER_ITEM');
+ if( $bucket->owner ne $e->requestor->id ) {
+ return $e->die_event unless
+ $e->allowed('CREATE_CONTAINER_ITEM');
- } else {
-# return $e->event unless
-# $e->allowed('CREATE_CONTAINER_ITEM'); # new perm here?
- }
-
+ } else {
+# return $e->event unless
+# $e->allowed('CREATE_CONTAINER_ITEM'); # new perm here?
+ }
+
for my $one_item (@$items) {
$one_item->clear_id;
}
}
- $e->commit;
+ $e->commit;
# CStoreEeditor inserts the id (pkey) on newly created objects
return [ map { $_->id } @$items ] if ref $item eq 'ARRAY';
- return $item->id;
+ return $item->id;
}
__PACKAGE__->register_method(
- method => "item_delete",
- api_name => "open-ils.actor.container.item.delete",
- notes => <<" NOTES");
- PARAMS(authtoken, class, itemId)
- NOTES
+ method => "item_delete",
+ api_name => "open-ils.actor.container.item.delete",
+ notes => <<" NOTES");
+ PARAMS(authtoken, class, itemId)
+ NOTES
sub item_delete {
- my( $self, $client, $authtoken, $class, $itemid ) = @_;
+ my( $self, $client, $authtoken, $class, $itemid ) = @_;
- my $e = new_editor(xact=>1, authtoken=>$authtoken);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken=>$authtoken);
+ return $e->event unless $e->checkauth;
- my $ret = __item_delete($e, $class, $itemid);
- $e->commit unless $U->event_code($ret);
- return $ret;
+ my $ret = __item_delete($e, $class, $itemid);
+ $e->commit unless $U->event_code($ret);
+ return $ret;
}
sub __item_delete {
- my( $e, $class, $itemid ) = @_;
- my( $bucket, $item, $evt);
+ my( $e, $class, $itemid ) = @_;
+ my( $bucket, $item, $evt);
- ( $item, $evt ) = $U->fetch_container_item_e( $e, $itemid, $class );
- return $evt if $evt;
+ ( $item, $evt ) = $U->fetch_container_item_e( $e, $itemid, $class );
+ return $evt if $evt;
- ( $bucket, $evt ) = $U->fetch_container_e($e, $item->bucket, $class);
- return $evt if $evt;
+ ( $bucket, $evt ) = $U->fetch_container_e($e, $item->bucket, $class);
+ return $evt if $evt;
- if( $bucket->owner ne $e->requestor->id ) {
+ if( $bucket->owner ne $e->requestor->id ) {
my $owner = $e->retrieve_actor_user($bucket->owner)
or return $e->die_event;
- return $e->event unless $e->allowed('DELETE_CONTAINER_ITEM', $owner->home_ou);
- }
+ return $e->event unless $e->allowed('DELETE_CONTAINER_ITEM', $owner->home_ou);
+ }
- my $stat;
- if( $class eq 'copy' ) {
+ my $stat;
+ if( $class eq 'copy' ) {
for my $note (@{$e->search_container_copy_bucket_item_note({item => $item->id})}) {
return $e->event unless
$e->delete_container_copy_bucket_item_note($note);
}
- return $e->event unless
- $stat = $e->delete_container_copy_bucket_item($item);
- }
+ return $e->event unless
+ $stat = $e->delete_container_copy_bucket_item($item);
+ }
- if( $class eq 'callnumber' ) {
+ if( $class eq 'callnumber' ) {
for my $note (@{$e->search_container_call_number_bucket_item_note({item => $item->id})}) {
return $e->event unless
$e->delete_container_call_number_bucket_item_note($note);
}
- return $e->event unless
- $stat = $e->delete_container_call_number_bucket_item($item);
- }
+ return $e->event unless
+ $stat = $e->delete_container_call_number_bucket_item($item);
+ }
- if( $class eq 'biblio' ) {
+ if( $class eq 'biblio' ) {
for my $note (@{$e->search_container_biblio_record_entry_bucket_item_note({item => $item->id})}) {
return $e->event unless
$e->delete_container_biblio_record_entry_bucket_item_note($note);
}
- return $e->event unless
- $stat = $e->delete_container_biblio_record_entry_bucket_item($item);
- }
+ return $e->event unless
+ $stat = $e->delete_container_biblio_record_entry_bucket_item($item);
+ }
- if( $class eq 'user') {
+ if( $class eq 'user') {
for my $note (@{$e->search_container_user_bucket_item_note({item => $item->id})}) {
return $e->event unless
$e->delete_container_user_bucket_item_note($note);
}
- return $e->event unless
- $stat = $e->delete_container_user_bucket_item($item);
- }
+ return $e->event unless
+ $stat = $e->delete_container_user_bucket_item($item);
+ }
- return $stat;
+ return $stat;
}
__PACKAGE__->register_method(
- method => 'full_delete',
- api_name => 'open-ils.actor.container.full_delete',
- notes => "Complety removes a container including all attached items",
-);
+ method => 'full_delete',
+ api_name => 'open-ils.actor.container.full_delete',
+ notes => "Complety removes a container including all attached items",
+);
sub full_delete {
- my( $self, $client, $authtoken, $class, $containerId ) = @_;
- my( $container, $evt);
+ my( $self, $client, $authtoken, $class, $containerId ) = @_;
+ my( $container, $evt);
- my $e = new_editor(xact=>1, authtoken=>$authtoken);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken=>$authtoken);
+ return $e->event unless $e->checkauth;
- ( $container, $evt ) = $apputils->fetch_container_e($e, $containerId, $class);
- return $evt if $evt;
+ ( $container, $evt ) = $apputils->fetch_container_e($e, $containerId, $class);
+ return $evt if $evt;
- if( $container->owner ne $e->requestor->id ) {
+ if( $container->owner ne $e->requestor->id ) {
my $owner = $e->retrieve_actor_user($container->owner)
or return $e->die_event;
- return $e->event unless $e->allowed('DELETE_CONTAINER', $owner->home_ou);
- }
+ return $e->event unless $e->allowed('DELETE_CONTAINER', $owner->home_ou);
+ }
- my $items;
+ my $items;
- my @s = ({bucket => $containerId}, {idlist=>1});
+ my @s = ({bucket => $containerId}, {idlist=>1});
- if( $class eq 'copy' ) {
- $items = $e->search_container_copy_bucket_item(@s);
- }
+ if( $class eq 'copy' ) {
+ $items = $e->search_container_copy_bucket_item(@s);
+ }
- if( $class eq 'callnumber' ) {
- $items = $e->search_container_call_number_bucket_item(@s);
- }
+ if( $class eq 'callnumber' ) {
+ $items = $e->search_container_call_number_bucket_item(@s);
+ }
- if( $class eq 'biblio' ) {
- $items = $e->search_container_biblio_record_entry_bucket_item(@s);
- }
+ if( $class eq 'biblio' ) {
+ $items = $e->search_container_biblio_record_entry_bucket_item(@s);
+ }
- if( $class eq 'user') {
- $items = $e->search_container_user_bucket_item(@s);
- }
+ if( $class eq 'user') {
+ $items = $e->search_container_user_bucket_item(@s);
+ }
- __item_delete($e, $class, $_) for @$items;
+ __item_delete($e, $class, $_) for @$items;
- my $stat;
- if( $class eq 'copy' ) {
- return $e->event unless
- $stat = $e->delete_container_copy_bucket($container);
- }
+ my $stat;
+ if( $class eq 'copy' ) {
+ return $e->event unless
+ $stat = $e->delete_container_copy_bucket($container);
+ }
- if( $class eq 'callnumber' ) {
- return $e->event unless
- $stat = $e->delete_container_call_number_bucket($container);
- }
+ if( $class eq 'callnumber' ) {
+ return $e->event unless
+ $stat = $e->delete_container_call_number_bucket($container);
+ }
- if( $class eq 'biblio' ) {
- return $e->event unless
- $stat = $e->delete_container_biblio_record_entry_bucket($container);
- }
+ if( $class eq 'biblio' ) {
+ return $e->event unless
+ $stat = $e->delete_container_biblio_record_entry_bucket($container);
+ }
- if( $class eq 'user') {
- return $e->event unless
- $stat = $e->delete_container_user_bucket($container);
- }
+ if( $class eq 'user') {
+ return $e->event unless
+ $stat = $e->delete_container_user_bucket($container);
+ }
- $e->commit;
- return $stat;
+ $e->commit;
+ return $stat;
}
__PACKAGE__->register_method(
- method => 'container_update',
- api_name => 'open-ils.actor.container.update',
- signature => q/
- Updates the given container item.
- @param authtoken The login session key
- @param class The container class
- @param container The container item
- @return true on success, 0 on no update, Event on error
- /
+ method => 'container_update',
+ api_name => 'open-ils.actor.container.update',
+ signature => q/
+ Updates the given container item.
+ @param authtoken The login session key
+ @param class The container class
+ @param container The container item
+ @return true on success, 0 on no update, Event on error
+ /
);
sub container_update {
- my( $self, $conn, $authtoken, $class, $container ) = @_;
+ my( $self, $conn, $authtoken, $class, $container ) = @_;
- my $e = new_editor(xact=>1, authtoken=>$authtoken);
- return $e->event unless $e->checkauth;
+ my $e = new_editor(xact=>1, authtoken=>$authtoken);
+ return $e->event unless $e->checkauth;
- my ( $dbcontainer, $evt ) = $U->fetch_container_e($e, $container->id, $class);
- return $evt if $evt;
+ my ( $dbcontainer, $evt ) = $U->fetch_container_e($e, $container->id, $class);
+ return $evt if $evt;
- if( $e->requestor->id ne $container->owner ) {
- return $e->event unless $e->allowed('UPDATE_CONTAINER');
- }
+ if( $e->requestor->id ne $container->owner ) {
+ return $e->event unless $e->allowed('UPDATE_CONTAINER');
+ }
- my $stat;
- if( $class eq 'copy' ) {
- return $e->event unless
- $stat = $e->update_container_copy_bucket($container);
- }
+ my $stat;
+ if( $class eq 'copy' ) {
+ return $e->event unless
+ $stat = $e->update_container_copy_bucket($container);
+ }
- if( $class eq 'callnumber' ) {
- return $e->event unless
- $stat = $e->update_container_call_number_bucket($container);
- }
+ if( $class eq 'callnumber' ) {
+ return $e->event unless
+ $stat = $e->update_container_call_number_bucket($container);
+ }
- if( $class eq 'biblio' ) {
- return $e->event unless
- $stat = $e->update_container_biblio_record_entry_bucket($container);
- }
+ if( $class eq 'biblio' ) {
+ return $e->event unless
+ $stat = $e->update_container_biblio_record_entry_bucket($container);
+ }
- if( $class eq 'user') {
- return $e->event unless
- $stat = $e->update_container_user_bucket($container);
- }
+ if( $class eq 'user') {
+ return $e->event unless
+ $stat = $e->update_container_user_bucket($container);
+ }
- $e->commit;
- return $stat;
+ $e->commit;
+ return $stat;
}
__PACKAGE__->register_method(
- method => "anon_cache",
- api_name => "open-ils.actor.anon_cache.set_value",
+ method => "anon_cache",
+ api_name => "open-ils.actor.anon_cache.set_value",
signature => {
desc => q/
Sets a value in the anon web cache. If the session key is
undefined, one will be automatically generated.
/,
params => [
- {desc => 'Session key', type => 'string'},
+ {desc => 'Session key', type => 'string'},
{
desc => q/Field name. The name of the field in this cache session whose value to set/,
type => 'string'
);
__PACKAGE__->register_method(
- method => "anon_cache",
- api_name => "open-ils.actor.anon_cache.get_value",
+ method => "anon_cache",
+ api_name => "open-ils.actor.anon_cache.get_value",
signature => {
desc => q/
Returns the cached data at the specified field within the specified cache session.
/,
params => [
- {desc => 'Session key', type => 'string'},
+ {desc => 'Session key', type => 'string'},
{
desc => q/Field name. The name of the field in this cache session whose value to set/,
type => 'string'
);
__PACKAGE__->register_method(
- method => "anon_cache",
- api_name => "open-ils.actor.anon_cache.delete_session",
+ method => "anon_cache",
+ api_name => "open-ils.actor.anon_cache.delete_session",
signature => {
desc => q/
Deletes a cache session.
/,
params => [
- {desc => 'Session key', type => 'string'},
+ {desc => 'Session key', type => 'string'},
],
return => {
desc => 'Session key',
my($self, $conn, $ses_key, $field_key, $value) = @_;
my $sc = OpenSRF::Utils::SettingsClient->new;
- my $cache = OpenSRF::Utils::Cache->new('anon');
+ my $cache = OpenSRF::Utils::Cache->new('anon');
my $cache_timeout = $sc->config_value(cache => anon => 'max_cache_time') || 1800; # 30 minutes
my $cache_size = $sc->config_value(cache => anon => 'max_cache_size') || 102400; # 100k
__PACKAGE__->register_method (
- method => 'create_user_stage',
- api_name => 'open-ils.actor.user.stage.create',
+ method => 'create_user_stage',
+ api_name => 'open-ils.actor.user.stage.create',
signature => {
desc => q/
Creates a new pending user account including addresses and statcats.
Users are added to staging tables pending staff review.
/,
params => [
- {desc => 'user', type => 'object', class => 'stgu'},
- {desc => 'Mailing address. Optional', type => 'object', class => 'stgma'},
- {desc => 'Billing address. Optional', type => 'object', class => 'stgba'},
- {desc => 'Statcats. Optional. This is an array of "stgsc" objects', type => 'array'},
+ {desc => 'user', type => 'object', class => 'stgu'},
+ {desc => 'Mailing address. Optional', type => 'object', class => 'stgma'},
+ {desc => 'Billing address. Optional', type => 'object', class => 'stgba'},
+ {desc => 'Statcats. Optional. This is an array of "stgsc" objects', type => 'array'},
],
return => {
desc => 'username on success, Event on error',
}
__PACKAGE__->register_method (
- method => 'user_stage_by_org',
- api_name => 'open-ils.actor.user.stage.retrieve.by_org',
+ method => 'user_stage_by_org',
+ api_name => 'open-ils.actor.user.stage.retrieve.by_org',
stream => 1
);
__PACKAGE__->register_method (
- method => 'user_stage_by_uname',
- api_name => 'open-ils.actor.user.stage.retrieve.by_username',
+ method => 'user_stage_by_uname',
+ api_name => 'open-ils.actor.user.stage.retrieve.by_username',
);
sub user_stage_by_uname {
__PACKAGE__->register_method (
- method => 'delete_user_stage',
- api_name => 'open-ils.actor.user.stage.delete',
+ method => 'delete_user_stage',
+ api_name => 'open-ils.actor.user.stage.delete',
);
sub delete_user_stage {
__PACKAGE__->register_method(
- method => 'group_money_summary',
- api_name => 'open-ils.actor.usergroup.members.balance_owed',
+ method => 'group_money_summary',
+ api_name => 'open-ils.actor.usergroup.members.balance_owed',
authoritative => 1,
- signature => q/
- /
+ signature => q/
+ /
);
sub group_money_summary {
- my($self, $conn, $auth, $group_id) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- return $e->event unless $e->allowed('VIEW_USER');
+ my($self, $conn, $auth, $group_id) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ return $e->event unless $e->allowed('VIEW_USER');
- my $users = $e->search_actor_user({usrgroup => $group_id}, {idlist => 1});
+ my $users = $e->search_actor_user({usrgroup => $group_id}, {idlist => 1});
my @mous;
for my $uid ( @$users ) {
__PACKAGE__->register_method(
- method => 'get_users_from_usergroup',
- api_name => 'open-ils.actor.usergroup.members.retrieve',
+ method => 'get_users_from_usergroup',
+ api_name => 'open-ils.actor.usergroup.members.retrieve',
authoritative => 1,
- signature => q/
- Returns a list of ids for users that are in the given usergroup
- /
+ signature => q/
+ Returns a list of ids for users that are in the given usergroup
+ /
);
sub get_users_from_usergroup {
- my( $self, $conn, $auth, $usergroup ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- return $e->event unless $e->allowed('VIEW_USER'); # XXX reley on editor perm
- return $e->search_actor_user({usrgroup => $usergroup}, {idlist => 1});
+ my( $self, $conn, $auth, $usergroup ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ return $e->event unless $e->allowed('VIEW_USER'); # XXX reley on editor perm
+ return $e->search_actor_user({usrgroup => $usergroup}, {idlist => 1});
}
__PACKAGE__->register_method(
- method => 'get_leaders_from_usergroup',
- api_name => 'open-ils.actor.usergroup.leaders.retrieve',
- signature => q/
- Returns a list of ids for users that are leaders of the given usergroup
- /
+ method => 'get_leaders_from_usergroup',
+ api_name => 'open-ils.actor.usergroup.leaders.retrieve',
+ signature => q/
+ Returns a list of ids for users that are leaders of the given usergroup
+ /
);
sub get_leaders_from_usergroup {
- my( $self, $conn, $auth, $usergroup ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- return $e->event unless $e->allowed('VIEW_USER'); # XXX reley on editor perm
- my $users = $e->search_actor_user({usrgroup => $usergroup})
- or return $e->event;
-
- my @res;
- for my $u (@$users) {
- push( @res, $u->id ) if $u->master_account;
- }
-
- return \@res;
+ my( $self, $conn, $auth, $usergroup ) = @_;
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ return $e->event unless $e->allowed('VIEW_USER'); # XXX reley on editor perm
+ my $users = $e->search_actor_user({usrgroup => $usergroup})
+ or return $e->event;
+
+ my @res;
+ for my $u (@$users) {
+ push( @res, $u->id ) if $u->master_account;
+ }
+
+ return \@res;
}
__PACKAGE__->register_method(
- method => 'get_address_members',
- api_name => 'open-ils.actor.address.members',
- signature => q/
- Returns a list of ids for users that link to the given address
- @param auth
- @param addrid The address id
- /
+ method => 'get_address_members',
+ api_name => 'open-ils.actor.address.members',
+ signature => q/
+ Returns a list of ids for users that link to the given address
+ @param auth
+ @param addrid The address id
+ /
);
sub get_address_members {
- my( $self, $conn, $auth, $addrid ) = @_;
+ my( $self, $conn, $auth, $addrid ) = @_;
- my $e = new_editor(authtoken=>$auth);
- return $e->event unless $e->checkauth;
- return $e->event unless $e->allowed('VIEW_USER'); # XXX reley on editor perm
+ my $e = new_editor(authtoken=>$auth);
+ return $e->event unless $e->checkauth;
+ return $e->event unless $e->allowed('VIEW_USER'); # XXX reley on editor perm
- my $ad = $e->retrieve_actor_user_address($addrid) or return $e->event;
- my $ma = $e->search_actor_user({mailing_address => $addrid}, {idlist => 1});
- my $ba = $e->search_actor_user({billing_address => $addrid}, {idlist => 1});
+ my $ad = $e->retrieve_actor_user_address($addrid) or return $e->event;
+ my $ma = $e->search_actor_user({mailing_address => $addrid}, {idlist => 1});
+ my $ba = $e->search_actor_user({billing_address => $addrid}, {idlist => 1});
- my @list = (@$ma, @$ba, $ad->usr);
- my %dedup = map { $_ => 1 } @list;
- return [ keys %dedup ];
+ my @list = (@$ma, @$ba, $ad->usr);
+ my %dedup = map { $_ => 1 } @list;
+ return [ keys %dedup ];
}
__PACKAGE__->register_method(
- method => 'reset_group',
- api_name => 'open-ils.actor.usergroup.new',
- signature => q/
- Gives the requested user a new empty usergroup.
- @param auth The auth token
- @param userid The id of the user who needs the new usergroup
- @param leader If true, this user will be marked as the group leader
- /
+ method => 'reset_group',
+ api_name => 'open-ils.actor.usergroup.new',
+ signature => q/
+ Gives the requested user a new empty usergroup.
+ @param auth The auth token
+ @param userid The id of the user who needs the new usergroup
+ @param leader If true, this user will be marked as the group leader
+ /
);
sub reset_group {
- my( $self, $conn, $auth, $userid, $leader ) = @_;
+ my( $self, $conn, $auth, $userid, $leader ) = @_;
- my $e = new_editor(authtoken=>$auth, xact=>1);
- return $e->die_event unless $e->checkauth;
- return $e->die_event unless $e->allowed('UPDATE_USER'); # XXX reley on editor perm
+ my $e = new_editor(authtoken=>$auth, xact=>1);
+ return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->allowed('UPDATE_USER'); # XXX reley on editor perm
- my $user = $e->retrieve_actor_user($userid) or return $e->die_event;
+ my $user = $e->retrieve_actor_user($userid) or return $e->die_event;
- # ask for a new group id
- my $groupid = $U->storagereq('open-ils.storage.actor.user.group_id.new');
+ # ask for a new group id
+ my $groupid = $U->storagereq('open-ils.storage.actor.user.group_id.new');
- $user->usrgroup($groupid);
- $user->master_account('t') if $leader;
+ $user->usrgroup($groupid);
+ $user->master_account('t') if $leader;
- $e->update_actor_user($user) or return $e->die_event;
- $e->commit;
- return $groupid;
+ $e->update_actor_user($user) or return $e->die_event;
+ $e->commit;
+ return $groupid;
}
# ---------------------------------------------------------------------------
sub start_db_session {
- my $self = shift;
- my $session = OpenSRF::AppSession->connect( "open-ils.storage" );
- my $trans_req = $session->request( "open-ils.storage.transaction.begin" );
-
- my $trans_resp = $trans_req->recv();
- if(ref($trans_resp) and UNIVERSAL::isa($trans_resp,"Error")) { throw $trans_resp; }
- if( ! $trans_resp->content() ) {
- throw OpenSRF::ERROR
- ("Unable to Begin Transaction with database" );
- }
- $trans_req->finish();
+ my $self = shift;
+ my $session = OpenSRF::AppSession->connect( "open-ils.storage" );
+ my $trans_req = $session->request( "open-ils.storage.transaction.begin" );
+
+ my $trans_resp = $trans_req->recv();
+ if(ref($trans_resp) and UNIVERSAL::isa($trans_resp,"Error")) { throw $trans_resp; }
+ if( ! $trans_resp->content() ) {
+ throw OpenSRF::ERROR
+ ("Unable to Begin Transaction with database" );
+ }
+ $trans_req->finish();
- $logger->debug("Setting global storage session to ".
- "session: " . $session->session_id . " : " . $session->app );
+ $logger->debug("Setting global storage session to ".
+ "session: " . $session->session_id . " : " . $session->app );
- return $session;
+ return $session;
}
sub set_audit_info {
- my $self = shift;
- my $session = shift;
- my $authtoken = shift;
- my $user_id = shift;
- my $ws_id = shift;
-
- my $audit_req = $session->request( "open-ils.storage.set_audit_info", $authtoken, $user_id, $ws_id );
- my $audit_resp = $audit_req->recv();
- $audit_req->finish();
+ my $self = shift;
+ my $session = shift;
+ my $authtoken = shift;
+ my $user_id = shift;
+ my $ws_id = shift;
+
+ my $audit_req = $session->request( "open-ils.storage.set_audit_info", $authtoken, $user_id, $ws_id );
+ my $audit_resp = $audit_req->recv();
+ $audit_req->finish();
}
my $PERM_QUERY = {
# returns undef if user has all of the perms provided
# returns the first failed perm on failure
sub check_user_perms {
- my($self, $user_id, $org_id, @perm_types ) = @_;
- $logger->debug("Checking perms with user : $user_id , org: $org_id, @perm_types");
+ my($self, $user_id, $org_id, @perm_types ) = @_;
+ $logger->debug("Checking perms with user : $user_id , org: $org_id, @perm_types");
- for my $type (@perm_types) {
- $PERM_QUERY->{select}->{au}->[0]->{params} = [$type, $org_id];
- $PERM_QUERY->{where}->{id} = $user_id;
- return $type unless $self->is_true(OpenILS::Utils::CStoreEditor->new->json_query($PERM_QUERY)->[0]->{has_perm});
- }
- return undef;
+ for my $type (@perm_types) {
+ $PERM_QUERY->{select}->{au}->[0]->{params} = [$type, $org_id];
+ $PERM_QUERY->{where}->{id} = $user_id;
+ return $type unless $self->is_true(OpenILS::Utils::CStoreEditor->new->json_query($PERM_QUERY)->[0]->{has_perm});
+ }
+ return undef;
}
# checks the list of user perms. The first one that fails returns a new
sub check_perms {
- my( $self, $user_id, $org_id, @perm_types ) = @_;
- my $t = $self->check_user_perms( $user_id, $org_id, @perm_types );
- return OpenILS::Event->new('PERM_FAILURE', ilsperm => $t, ilspermloc => $org_id ) if $t;
- return undef;
+ my( $self, $user_id, $org_id, @perm_types ) = @_;
+ my $t = $self->check_user_perms( $user_id, $org_id, @perm_types );
+ return OpenILS::Event->new('PERM_FAILURE', ilsperm => $t, ilspermloc => $org_id ) if $t;
+ return undef;
}
# commits and destroys the session
# ---------------------------------------------------------------------------
sub commit_db_session {
- my( $self, $session ) = @_;
+ my( $self, $session ) = @_;
- my $req = $session->request( "open-ils.storage.transaction.commit" );
- my $resp = $req->recv();
+ my $req = $session->request( "open-ils.storage.transaction.commit" );
+ my $resp = $req->recv();
- if(!$resp) {
- throw OpenSRF::EX::ERROR ("Unable to commit db session");
- }
+ if(!$resp) {
+ throw OpenSRF::EX::ERROR ("Unable to commit db session");
+ }
- if(UNIVERSAL::isa($resp,"Error")) {
- throw $resp ($resp->stringify);
- }
+ if(UNIVERSAL::isa($resp,"Error")) {
+ throw $resp ($resp->stringify);
+ }
- if(!$resp->content) {
- throw OpenSRF::EX::ERROR ("Unable to commit db session");
- }
+ if(!$resp->content) {
+ throw OpenSRF::EX::ERROR ("Unable to commit db session");
+ }
- $session->finish();
- $session->disconnect();
- $session->kill_me();
+ $session->finish();
+ $session->disconnect();
+ $session->kill_me();
}
sub rollback_db_session {
- my( $self, $session ) = @_;
+ my( $self, $session ) = @_;
- my $req = $session->request("open-ils.storage.transaction.rollback");
- my $resp = $req->recv();
- if(UNIVERSAL::isa($resp,"Error")) { throw $resp; }
+ my $req = $session->request("open-ils.storage.transaction.rollback");
+ my $resp = $req->recv();
+ if(UNIVERSAL::isa($resp,"Error")) { throw $resp; }
- $session->finish();
- $session->disconnect();
- $session->kill_me();
+ $session->finish();
+ $session->disconnect();
+ $session->kill_me();
}
# returns undef it the event is not an ILS event
# returns the event code otherwise
sub event_code {
- my( $self, $evt ) = @_;
- return $evt->{ilsevent} if $self->is_event($evt);
- return undef;
+ my( $self, $evt ) = @_;
+ return $evt->{ilsevent} if $self->is_event($evt);
+ return undef;
}
# some events, in particular auto-generated events, don't have an
# ilsevent key. treat hashes with a 'textcode' key as events.
sub is_event {
- my ($self, $evt) = @_;
- return (
- ref($evt) eq 'HASH' and (
- defined $evt->{ilsevent} or
- defined $evt->{textcode}
- )
- );
+ my ($self, $evt) = @_;
+ return (
+ ref($evt) eq 'HASH' and (
+ defined $evt->{ilsevent} or
+ defined $evt->{textcode}
+ )
+ );
}
# ---------------------------------------------------------------------------
# throws an exception on error.
# ---------------------------------------------------------------------------
sub check_user_session {
- my( $self, $user_session ) = @_;
+ my( $self, $user_session ) = @_;
- my $content = $self->simplereq(
- 'open-ils.auth',
- 'open-ils.auth.session.retrieve', $user_session);
+ my $content = $self->simplereq(
+ 'open-ils.auth',
+ 'open-ils.auth.session.retrieve', $user_session);
return undef if (!$content) or $self->event_code($content);
- return $content;
+ return $content;
}
# generic simple request returning a scalar value
sub simplereq {
- my($self, $service, $method, @params) = @_;
- return $self->simple_scalar_request($service, $method, @params);
+ my($self, $service, $method, @params) = @_;
+ return $self->simple_scalar_request($service, $method, @params);
}
sub simple_scalar_request {
- my($self, $service, $method, @params) = @_;
+ my($self, $service, $method, @params) = @_;
- my $session = OpenSRF::AppSession->create( $service );
+ my $session = OpenSRF::AppSession->create( $service );
- my $request = $session->request( $method, @params );
+ my $request = $session->request( $method, @params );
- my $val;
- my $err;
- try {
+ my $val;
+ my $err;
+ try {
- $val = $request->gather(1);
+ $val = $request->gather(1);
- } catch Error with {
- $err = shift;
- };
+ } catch Error with {
+ $err = shift;
+ };
- if( $err ) {
- warn "received error : service=$service : method=$method : params=".Dumper(\@params) . "\n $err";
- throw $err ("Call to $service for method $method \n failed with exception: $err : " );
- }
+ if( $err ) {
+ warn "received error : service=$service : method=$method : params=".Dumper(\@params) . "\n $err";
+ throw $err ("Call to $service for method $method \n failed with exception: $err : " );
+ }
- return $val;
+ return $val;
}
sub build_org_tree {
- my( $self, $orglist ) = @_;
+ my( $self, $orglist ) = @_;
- return $orglist unless ref $orglist;
+ return $orglist unless ref $orglist;
return $$orglist[0] if @$orglist == 1;
- my @list = sort {
- $a->ou_type <=> $b->ou_type ||
- $a->name cmp $b->name } @$orglist;
+ my @list = sort {
+ $a->ou_type <=> $b->ou_type ||
+ $a->name cmp $b->name } @$orglist;
- for my $org (@list) {
+ for my $org (@list) {
- next unless ($org);
+ next unless ($org);
next if (!defined($org->parent_ou) || $org->parent_ou eq "");
- my ($parent) = grep { $_->id == $org->parent_ou } @list;
- next unless $parent;
- $parent->children([]) unless defined($parent->children);
- push( @{$parent->children}, $org );
- }
+ my ($parent) = grep { $_->id == $org->parent_ou } @list;
+ next unless $parent;
+ $parent->children([]) unless defined($parent->children);
+ push( @{$parent->children}, $org );
+ }
- return $list[0];
+ return $list[0];
}
sub fetch_closed_date {
- my( $self, $cd ) = @_;
- my $evt;
-
- $logger->debug("Fetching closed_date $cd from cstore");
+ my( $self, $cd ) = @_;
+ my $evt;
+
+ $logger->debug("Fetching closed_date $cd from cstore");
- my $cd_obj = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.actor.org_unit.closed_date.retrieve', $cd );
+ my $cd_obj = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.actor.org_unit.closed_date.retrieve', $cd );
- if(!$cd_obj) {
- $logger->info("closed_date $cd not found in the db");
- $evt = OpenILS::Event->new('ACTOR_USER_NOT_FOUND');
- }
+ if(!$cd_obj) {
+ $logger->info("closed_date $cd not found in the db");
+ $evt = OpenILS::Event->new('ACTOR_USER_NOT_FOUND');
+ }
- return ($cd_obj, $evt);
+ return ($cd_obj, $evt);
}
sub fetch_user {
- my( $self, $userid ) = @_;
- my( $user, $evt );
-
- $logger->debug("Fetching user $userid from cstore");
+ my( $self, $userid ) = @_;
+ my( $user, $evt );
+
+ $logger->debug("Fetching user $userid from cstore");
- $user = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.actor.user.retrieve', $userid );
+ $user = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.actor.user.retrieve', $userid );
- if(!$user) {
- $logger->info("User $userid not found in the db");
- $evt = OpenILS::Event->new('ACTOR_USER_NOT_FOUND');
- }
+ if(!$user) {
+ $logger->info("User $userid not found in the db");
+ $evt = OpenILS::Event->new('ACTOR_USER_NOT_FOUND');
+ }
- return ($user, $evt);
+ return ($user, $evt);
}
sub checkses {
- my( $self, $session ) = @_;
- my $user = $self->check_user_session($session) or
+ my( $self, $session ) = @_;
+ my $user = $self->check_user_session($session) or
return (undef, OpenILS::Event->new('NO_SESSION'));
return ($user);
}
# verifiese the session and checks the permissions agains the
# session user and the user's home_ou as the org id
sub checksesperm {
- my( $self, $session, @perms ) = @_;
- my $user; my $evt; my $e;
- $logger->debug("Checking user session $session and perms @perms");
- ($user, $evt) = $self->checkses($session);
- return (undef, $evt) if $evt;
- $evt = $self->check_perms($user->id, $user->home_ou, @perms);
- return ($user, $evt);
+ my( $self, $session, @perms ) = @_;
+ my $user; my $evt; my $e;
+ $logger->debug("Checking user session $session and perms @perms");
+ ($user, $evt) = $self->checkses($session);
+ return (undef, $evt) if $evt;
+ $evt = $self->check_perms($user->id, $user->home_ou, @perms);
+ return ($user, $evt);
}
sub checkrequestor {
- my( $self, $staffobj, $userid, @perms ) = @_;
- my $user; my $evt;
- $userid = $staffobj->id unless defined $userid;
+ my( $self, $staffobj, $userid, @perms ) = @_;
+ my $user; my $evt;
+ $userid = $staffobj->id unless defined $userid;
- $logger->debug("checkrequestor(): requestor => " . $staffobj->id . ", target => $userid");
+ $logger->debug("checkrequestor(): requestor => " . $staffobj->id . ", target => $userid");
- if( $userid ne $staffobj->id ) {
- ($user, $evt) = $self->fetch_user($userid);
- return (undef, $evt) if $evt;
- $evt = $self->check_perms( $staffobj->id, $user->home_ou, @perms );
+ if( $userid ne $staffobj->id ) {
+ ($user, $evt) = $self->fetch_user($userid);
+ return (undef, $evt) if $evt;
+ $evt = $self->check_perms( $staffobj->id, $user->home_ou, @perms );
- } else {
- $user = $staffobj;
- }
+ } else {
+ $user = $staffobj;
+ }
- return ($user, $evt);
+ return ($user, $evt);
}
sub checkses_requestor {
- my( $self, $authtoken, $targetid, @perms ) = @_;
- my( $requestor, $target, $evt );
+ my( $self, $authtoken, $targetid, @perms ) = @_;
+ my( $requestor, $target, $evt );
- ($requestor, $evt) = $self->checkses($authtoken);
- return (undef, undef, $evt) if $evt;
+ ($requestor, $evt) = $self->checkses($authtoken);
+ return (undef, undef, $evt) if $evt;
- ($target, $evt) = $self->checkrequestor( $requestor, $targetid, @perms );
- return( $requestor, $target, $evt);
+ ($target, $evt) = $self->checkrequestor( $requestor, $targetid, @perms );
+ return( $requestor, $target, $evt);
}
sub fetch_copy {
- my( $self, $copyid ) = @_;
- my( $copy, $evt );
+ my( $self, $copyid ) = @_;
+ my( $copy, $evt );
- $logger->debug("Fetching copy $copyid from cstore");
+ $logger->debug("Fetching copy $copyid from cstore");
- $copy = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.asset.copy.retrieve', $copyid );
+ $copy = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.asset.copy.retrieve', $copyid );
- if(!$copy) { $evt = OpenILS::Event->new('ASSET_COPY_NOT_FOUND'); }
+ if(!$copy) { $evt = OpenILS::Event->new('ASSET_COPY_NOT_FOUND'); }
- return( $copy, $evt );
+ return( $copy, $evt );
}
# retrieves a circ object by id
sub fetch_circulation {
- my( $self, $circid ) = @_;
- my $circ; my $evt;
-
- $logger->debug("Fetching circ $circid from cstore");
+ my( $self, $circid ) = @_;
+ my $circ; my $evt;
+
+ $logger->debug("Fetching circ $circid from cstore");
- $circ = $self->simplereq(
- 'open-ils.cstore',
- "open-ils.cstore.direct.action.circulation.retrieve", $circid );
+ $circ = $self->simplereq(
+ 'open-ils.cstore',
+ "open-ils.cstore.direct.action.circulation.retrieve", $circid );
- if(!$circ) {
- $evt = OpenILS::Event->new('ACTION_CIRCULATION_NOT_FOUND', circid => $circid );
- }
+ if(!$circ) {
+ $evt = OpenILS::Event->new('ACTION_CIRCULATION_NOT_FOUND', circid => $circid );
+ }
- return ( $circ, $evt );
+ return ( $circ, $evt );
}
sub fetch_record_by_copy {
- my( $self, $copyid ) = @_;
- my( $record, $evt );
-
- $logger->debug("Fetching record by copy $copyid from cstore");
-
- $record = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.asset.copy.retrieve', $copyid,
- { flesh => 3,
- flesh_fields => { bre => [ 'fixed_fields' ],
- acn => [ 'record' ],
- acp => [ 'call_number' ],
- }
- }
- );
+ my( $self, $copyid ) = @_;
+ my( $record, $evt );
+
+ $logger->debug("Fetching record by copy $copyid from cstore");
+
+ $record = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.asset.copy.retrieve', $copyid,
+ { flesh => 3,
+ flesh_fields => { bre => [ 'fixed_fields' ],
+ acn => [ 'record' ],
+ acp => [ 'call_number' ],
+ }
+ }
+ );
- if(!$record) {
- $evt = OpenILS::Event->new('BIBLIO_RECORD_ENTRY_NOT_FOUND');
- } else {
- $record = $record->call_number->record;
- }
+ if(!$record) {
+ $evt = OpenILS::Event->new('BIBLIO_RECORD_ENTRY_NOT_FOUND');
+ } else {
+ $record = $record->call_number->record;
+ }
- return ($record, $evt);
+ return ($record, $evt);
}
# turns a record object into an mvr (mods) object
sub record_to_mvr {
- my( $self, $record ) = @_;
- return undef unless $record and $record->marc;
- my $u = OpenILS::Utils::ModsParser->new();
- $u->start_mods_batch( $record->marc );
- my $mods = $u->finish_mods_batch();
- $mods->doc_id($record->id);
+ my( $self, $record ) = @_;
+ return undef unless $record and $record->marc;
+ my $u = OpenILS::Utils::ModsParser->new();
+ $u->start_mods_batch( $record->marc );
+ my $mods = $u->finish_mods_batch();
+ $mods->doc_id($record->id);
$mods->tcn($record->tcn_value);
- return $mods;
+ return $mods;
}
sub fetch_hold {
- my( $self, $holdid ) = @_;
- my( $hold, $evt );
+ my( $self, $holdid ) = @_;
+ my( $hold, $evt );
- $logger->debug("Fetching hold $holdid from cstore");
+ $logger->debug("Fetching hold $holdid from cstore");
- $hold = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.action.hold_request.retrieve', $holdid);
+ $hold = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.action.hold_request.retrieve', $holdid);
- $evt = OpenILS::Event->new('ACTION_HOLD_REQUEST_NOT_FOUND', holdid => $holdid) unless $hold;
+ $evt = OpenILS::Event->new('ACTION_HOLD_REQUEST_NOT_FOUND', holdid => $holdid) unless $hold;
- return ($hold, $evt);
+ return ($hold, $evt);
}
sub fetch_hold_transit_by_hold {
- my( $self, $holdid ) = @_;
- my( $transit, $evt );
+ my( $self, $holdid ) = @_;
+ my( $transit, $evt );
- $logger->debug("Fetching transit by hold $holdid from cstore");
+ $logger->debug("Fetching transit by hold $holdid from cstore");
- $transit = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.action.hold_transit_copy.search', { hold => $holdid } );
+ $transit = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.action.hold_transit_copy.search', { hold => $holdid } );
- $evt = OpenILS::Event->new('ACTION_HOLD_TRANSIT_COPY_NOT_FOUND', holdid => $holdid) unless $transit;
+ $evt = OpenILS::Event->new('ACTION_HOLD_TRANSIT_COPY_NOT_FOUND', holdid => $holdid) unless $transit;
- return ($transit, $evt );
+ return ($transit, $evt );
}
# fetches the captured, but not fulfilled hold attached to a given copy
sub fetch_open_hold_by_copy {
- my( $self, $copyid ) = @_;
- $logger->debug("Searching for active hold for copy $copyid");
- my( $hold, $evt );
+ my( $self, $copyid ) = @_;
+ $logger->debug("Searching for active hold for copy $copyid");
+ my( $hold, $evt );
- $hold = $self->cstorereq(
- 'open-ils.cstore.direct.action.hold_request.search',
- {
- current_copy => $copyid ,
- capture_time => { "!=" => undef },
- fulfillment_time => undef,
- cancel_time => undef,
- } );
+ $hold = $self->cstorereq(
+ 'open-ils.cstore.direct.action.hold_request.search',
+ {
+ current_copy => $copyid ,
+ capture_time => { "!=" => undef },
+ fulfillment_time => undef,
+ cancel_time => undef,
+ } );
- $evt = OpenILS::Event->new('ACTION_HOLD_REQUEST_NOT_FOUND', copyid => $copyid) unless $hold;
- return ($hold, $evt);
+ $evt = OpenILS::Event->new('ACTION_HOLD_REQUEST_NOT_FOUND', copyid => $copyid) unless $hold;
+ return ($hold, $evt);
}
sub fetch_hold_transit {
- my( $self, $transid ) = @_;
- my( $htransit, $evt );
- $logger->debug("Fetching hold transit with hold id $transid");
- $htransit = $self->cstorereq(
- 'open-ils.cstore.direct.action.hold_transit_copy.retrieve', $transid );
- $evt = OpenILS::Event->new('ACTION_HOLD_TRANSIT_COPY_NOT_FOUND', id => $transid) unless $htransit;
- return ($htransit, $evt);
+ my( $self, $transid ) = @_;
+ my( $htransit, $evt );
+ $logger->debug("Fetching hold transit with hold id $transid");
+ $htransit = $self->cstorereq(
+ 'open-ils.cstore.direct.action.hold_transit_copy.retrieve', $transid );
+ $evt = OpenILS::Event->new('ACTION_HOLD_TRANSIT_COPY_NOT_FOUND', id => $transid) unless $htransit;
+ return ($htransit, $evt);
}
sub fetch_copy_by_barcode {
- my( $self, $barcode ) = @_;
- my( $copy, $evt );
+ my( $self, $barcode ) = @_;
+ my( $copy, $evt );
- $logger->debug("Fetching copy by barcode $barcode from cstore");
+ $logger->debug("Fetching copy by barcode $barcode from cstore");
- $copy = $self->simplereq( 'open-ils.cstore',
- 'open-ils.cstore.direct.asset.copy.search', { barcode => $barcode, deleted => 'f'} );
- #'open-ils.storage.direct.asset.copy.search.barcode', $barcode );
+ $copy = $self->simplereq( 'open-ils.cstore',
+ 'open-ils.cstore.direct.asset.copy.search', { barcode => $barcode, deleted => 'f'} );
+ #'open-ils.storage.direct.asset.copy.search.barcode', $barcode );
- $evt = OpenILS::Event->new('ASSET_COPY_NOT_FOUND', barcode => $barcode) unless $copy;
+ $evt = OpenILS::Event->new('ASSET_COPY_NOT_FOUND', barcode => $barcode) unless $copy;
- return ($copy, $evt);
+ return ($copy, $evt);
}
sub fetch_open_billable_transaction {
- my( $self, $transid ) = @_;
- my( $transaction, $evt );
+ my( $self, $transid ) = @_;
+ my( $transaction, $evt );
- $logger->debug("Fetching open billable transaction $transid from cstore");
+ $logger->debug("Fetching open billable transaction $transid from cstore");
- $transaction = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.money.open_billable_transaction_summary.retrieve', $transid);
+ $transaction = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.money.open_billable_transaction_summary.retrieve', $transid);
- $evt = OpenILS::Event->new(
- 'MONEY_OPEN_BILLABLE_TRANSACTION_SUMMARY_NOT_FOUND', transid => $transid ) unless $transaction;
+ $evt = OpenILS::Event->new(
+ 'MONEY_OPEN_BILLABLE_TRANSACTION_SUMMARY_NOT_FOUND', transid => $transid ) unless $transaction;
- return ($transaction, $evt);
+ return ($transaction, $evt);
}
$buckets{'user'} = 'user_bucket';
sub fetch_container {
- my( $self, $id, $type ) = @_;
- my( $bucket, $evt );
+ my( $self, $id, $type ) = @_;
+ my( $bucket, $evt );
- $logger->debug("Fetching container $id with type $type");
+ $logger->debug("Fetching container $id with type $type");
- my $e = 'CONTAINER_CALL_NUMBER_BUCKET_NOT_FOUND';
- $e = 'CONTAINER_BIBLIO_RECORD_ENTRY_BUCKET_NOT_FOUND' if $type eq 'biblio';
- $e = 'CONTAINER_USER_BUCKET_NOT_FOUND' if $type eq 'user';
- $e = 'CONTAINER_COPY_BUCKET_NOT_FOUND' if $type eq 'copy';
+ my $e = 'CONTAINER_CALL_NUMBER_BUCKET_NOT_FOUND';
+ $e = 'CONTAINER_BIBLIO_RECORD_ENTRY_BUCKET_NOT_FOUND' if $type eq 'biblio';
+ $e = 'CONTAINER_USER_BUCKET_NOT_FOUND' if $type eq 'user';
+ $e = 'CONTAINER_COPY_BUCKET_NOT_FOUND' if $type eq 'copy';
- my $meth = $buckets{$type};
- $bucket = $self->simplereq(
- 'open-ils.cstore',
- "open-ils.cstore.direct.container.$meth.retrieve", $id );
+ my $meth = $buckets{$type};
+ $bucket = $self->simplereq(
+ 'open-ils.cstore',
+ "open-ils.cstore.direct.container.$meth.retrieve", $id );
- $evt = OpenILS::Event->new(
- $e, container => $id, container_type => $type ) unless $bucket;
+ $evt = OpenILS::Event->new(
+ $e, container => $id, container_type => $type ) unless $bucket;
- return ($bucket, $evt);
+ return ($bucket, $evt);
}
sub fetch_container_e {
- my( $self, $editor, $id, $type ) = @_;
+ my( $self, $editor, $id, $type ) = @_;
- my( $bucket, $evt );
- $bucket = $editor->retrieve_container_copy_bucket($id) if $type eq 'copy';
- $bucket = $editor->retrieve_container_call_number_bucket($id) if $type eq 'callnumber';
- $bucket = $editor->retrieve_container_biblio_record_entry_bucket($id) if $type eq 'biblio';
- $bucket = $editor->retrieve_container_user_bucket($id) if $type eq 'user';
+ my( $bucket, $evt );
+ $bucket = $editor->retrieve_container_copy_bucket($id) if $type eq 'copy';
+ $bucket = $editor->retrieve_container_call_number_bucket($id) if $type eq 'callnumber';
+ $bucket = $editor->retrieve_container_biblio_record_entry_bucket($id) if $type eq 'biblio';
+ $bucket = $editor->retrieve_container_user_bucket($id) if $type eq 'user';
- $evt = $editor->event unless $bucket;
- return ($bucket, $evt);
+ $evt = $editor->event unless $bucket;
+ return ($bucket, $evt);
}
sub fetch_container_item_e {
- my( $self, $editor, $id, $type ) = @_;
+ my( $self, $editor, $id, $type ) = @_;
- my( $bucket, $evt );
- $bucket = $editor->retrieve_container_copy_bucket_item($id) if $type eq 'copy';
- $bucket = $editor->retrieve_container_call_number_bucket_item($id) if $type eq 'callnumber';
- $bucket = $editor->retrieve_container_biblio_record_entry_bucket_item($id) if $type eq 'biblio';
- $bucket = $editor->retrieve_container_user_bucket_item($id) if $type eq 'user';
+ my( $bucket, $evt );
+ $bucket = $editor->retrieve_container_copy_bucket_item($id) if $type eq 'copy';
+ $bucket = $editor->retrieve_container_call_number_bucket_item($id) if $type eq 'callnumber';
+ $bucket = $editor->retrieve_container_biblio_record_entry_bucket_item($id) if $type eq 'biblio';
+ $bucket = $editor->retrieve_container_user_bucket_item($id) if $type eq 'user';
- $evt = $editor->event unless $bucket;
- return ($bucket, $evt);
+ $evt = $editor->event unless $bucket;
+ return ($bucket, $evt);
}
sub fetch_container_item {
- my( $self, $id, $type ) = @_;
- my( $bucket, $evt );
+ my( $self, $id, $type ) = @_;
+ my( $bucket, $evt );
- $logger->debug("Fetching container item $id with type $type");
+ $logger->debug("Fetching container item $id with type $type");
- my $meth = $buckets{$type} . "_item";
+ my $meth = $buckets{$type} . "_item";
- $bucket = $self->simplereq(
- 'open-ils.cstore',
- "open-ils.cstore.direct.container.$meth.retrieve", $id );
+ $bucket = $self->simplereq(
+ 'open-ils.cstore',
+ "open-ils.cstore.direct.container.$meth.retrieve", $id );
- my $e = 'CONTAINER_CALL_NUMBER_BUCKET_ITEM_NOT_FOUND';
- $e = 'CONTAINER_BIBLIO_RECORD_ENTRY_BUCKET_ITEM_NOT_FOUND' if $type eq 'biblio';
- $e = 'CONTAINER_USER_BUCKET_ITEM_NOT_FOUND' if $type eq 'user';
- $e = 'CONTAINER_COPY_BUCKET_ITEM_NOT_FOUND' if $type eq 'copy';
+ my $e = 'CONTAINER_CALL_NUMBER_BUCKET_ITEM_NOT_FOUND';
+ $e = 'CONTAINER_BIBLIO_RECORD_ENTRY_BUCKET_ITEM_NOT_FOUND' if $type eq 'biblio';
+ $e = 'CONTAINER_USER_BUCKET_ITEM_NOT_FOUND' if $type eq 'user';
+ $e = 'CONTAINER_COPY_BUCKET_ITEM_NOT_FOUND' if $type eq 'copy';
- $evt = OpenILS::Event->new(
- $e, itemid => $id, container_type => $type ) unless $bucket;
+ $evt = OpenILS::Event->new(
+ $e, itemid => $id, container_type => $type ) unless $bucket;
- return ($bucket, $evt);
+ return ($bucket, $evt);
}
sub fetch_patron_standings {
- my $self = shift;
- $logger->debug("Fetching patron standings");
- return $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.config.standing.search.atomic', { id => { '!=' => undef } });
+ my $self = shift;
+ $logger->debug("Fetching patron standings");
+ return $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.config.standing.search.atomic', { id => { '!=' => undef } });
}
sub fetch_permission_group_tree {
- my $self = shift;
- $logger->debug("Fetching patron profiles");
- return $self->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.groups.tree.retrieve' );
+ my $self = shift;
+ $logger->debug("Fetching patron profiles");
+ return $self->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.groups.tree.retrieve' );
}
sub fetch_permission_group_descendants {
}
sub fetch_patron_circ_summary {
- my( $self, $userid ) = @_;
- $logger->debug("Fetching patron summary for $userid");
- my $summary = $self->simplereq(
- 'open-ils.storage',
- "open-ils.storage.action.circulation.patron_summary", $userid );
-
- if( $summary ) {
- $summary->[0] ||= 0;
- $summary->[1] ||= 0.0;
- return $summary;
- }
- return undef;
+ my( $self, $userid ) = @_;
+ $logger->debug("Fetching patron summary for $userid");
+ my $summary = $self->simplereq(
+ 'open-ils.storage',
+ "open-ils.storage.action.circulation.patron_summary", $userid );
+
+ if( $summary ) {
+ $summary->[0] ||= 0;
+ $summary->[1] ||= 0.0;
+ return $summary;
+ }
+ return undef;
}
sub fetch_copy_statuses {
- my( $self ) = @_;
- $logger->debug("Fetching copy statuses");
- return $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.config.copy_status.search.atomic', { id => { '!=' => undef } });
+ my( $self ) = @_;
+ $logger->debug("Fetching copy statuses");
+ return $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.config.copy_status.search.atomic', { id => { '!=' => undef } });
}
sub fetch_copy_location {
- my( $self, $id ) = @_;
- my $evt;
- my $cl = $self->cstorereq(
- 'open-ils.cstore.direct.asset.copy_location.retrieve', $id );
- $evt = OpenILS::Event->new('ASSET_COPY_LOCATION_NOT_FOUND') unless $cl;
- return ($cl, $evt);
+ my( $self, $id ) = @_;
+ my $evt;
+ my $cl = $self->cstorereq(
+ 'open-ils.cstore.direct.asset.copy_location.retrieve', $id );
+ $evt = OpenILS::Event->new('ASSET_COPY_LOCATION_NOT_FOUND') unless $cl;
+ return ($cl, $evt);
}
sub fetch_copy_locations {
- my $self = shift;
- return $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.asset.copy_location.search.atomic', { id => { '!=' => undef } });
+ my $self = shift;
+ return $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.asset.copy_location.search.atomic', { id => { '!=' => undef } });
}
sub fetch_copy_location_by_name {
- my( $self, $name, $org ) = @_;
- my $evt;
- my $cl = $self->cstorereq(
- 'open-ils.cstore.direct.asset.copy_location.search',
- { name => $name, owning_lib => $org } );
- $evt = OpenILS::Event->new('ASSET_COPY_LOCATION_NOT_FOUND') unless $cl;
- return ($cl, $evt);
+ my( $self, $name, $org ) = @_;
+ my $evt;
+ my $cl = $self->cstorereq(
+ 'open-ils.cstore.direct.asset.copy_location.search',
+ { name => $name, owning_lib => $org } );
+ $evt = OpenILS::Event->new('ASSET_COPY_LOCATION_NOT_FOUND') unless $cl;
+ return ($cl, $evt);
}
sub fetch_callnumber {
- my( $self, $id, $flesh, $e ) = @_;
+ my( $self, $id, $flesh, $e ) = @_;
- $e ||= OpenILS::Utils::CStoreEditor->new;
+ $e ||= OpenILS::Utils::CStoreEditor->new;
- my $evt = OpenILS::Event->new( 'ASSET_CALL_NUMBER_NOT_FOUND', id => $id );
- return( undef, $evt ) unless $id;
+ my $evt = OpenILS::Event->new( 'ASSET_CALL_NUMBER_NOT_FOUND', id => $id );
+ return( undef, $evt ) unless $id;
- $logger->debug("Fetching callnumber $id");
+ $logger->debug("Fetching callnumber $id");
my $cn = $e->retrieve_asset_call_number([
$id,
{ flesh => $flesh, flesh_fields => { acn => [ 'prefix', 'suffix', 'label_class' ] } },
]);
- return ( $cn, $e->event );
+ return ( $cn, $e->event );
}
my %ORG_CACHE; # - these rarely change, so cache them..
sub fetch_org_unit {
- my( $self, $id ) = @_;
- return undef unless $id;
- return $id if( ref($id) eq 'Fieldmapper::actor::org_unit' );
- return $ORG_CACHE{$id} if $ORG_CACHE{$id};
- $logger->debug("Fetching org unit $id");
- my $evt = undef;
-
- my $org = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.actor.org_unit.retrieve', $id );
- $evt = OpenILS::Event->new( 'ACTOR_ORG_UNIT_NOT_FOUND', id => $id ) unless $org;
- $ORG_CACHE{$id} = $org;
+ my( $self, $id ) = @_;
+ return undef unless $id;
+ return $id if( ref($id) eq 'Fieldmapper::actor::org_unit' );
+ return $ORG_CACHE{$id} if $ORG_CACHE{$id};
+ $logger->debug("Fetching org unit $id");
+ my $evt = undef;
+
+ my $org = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.actor.org_unit.retrieve', $id );
+ $evt = OpenILS::Event->new( 'ACTOR_ORG_UNIT_NOT_FOUND', id => $id ) unless $org;
+ $ORG_CACHE{$id} = $org;
- return ($org, $evt);
+ return ($org, $evt);
}
sub fetch_stat_cat {
- my( $self, $type, $id ) = @_;
- my( $cat, $evt );
- $logger->debug("Fetching $type stat cat: $id");
- $cat = $self->simplereq(
- 'open-ils.cstore',
- "open-ils.cstore.direct.$type.stat_cat.retrieve", $id );
+ my( $self, $type, $id ) = @_;
+ my( $cat, $evt );
+ $logger->debug("Fetching $type stat cat: $id");
+ $cat = $self->simplereq(
+ 'open-ils.cstore',
+ "open-ils.cstore.direct.$type.stat_cat.retrieve", $id );
- my $e = 'ASSET_STAT_CAT_NOT_FOUND';
- $e = 'ACTOR_STAT_CAT_NOT_FOUND' if $type eq 'actor';
+ my $e = 'ASSET_STAT_CAT_NOT_FOUND';
+ $e = 'ACTOR_STAT_CAT_NOT_FOUND' if $type eq 'actor';
- $evt = OpenILS::Event->new( $e, id => $id ) unless $cat;
- return ( $cat, $evt );
+ $evt = OpenILS::Event->new( $e, id => $id ) unless $cat;
+ return ( $cat, $evt );
}
sub fetch_stat_cat_entry {
- my( $self, $type, $id ) = @_;
- my( $entry, $evt );
- $logger->debug("Fetching $type stat cat entry: $id");
- $entry = $self->simplereq(
- 'open-ils.cstore',
- "open-ils.cstore.direct.$type.stat_cat_entry.retrieve", $id );
+ my( $self, $type, $id ) = @_;
+ my( $entry, $evt );
+ $logger->debug("Fetching $type stat cat entry: $id");
+ $entry = $self->simplereq(
+ 'open-ils.cstore',
+ "open-ils.cstore.direct.$type.stat_cat_entry.retrieve", $id );
- my $e = 'ASSET_STAT_CAT_ENTRY_NOT_FOUND';
- $e = 'ACTOR_STAT_CAT_ENTRY_NOT_FOUND' if $type eq 'actor';
+ my $e = 'ASSET_STAT_CAT_ENTRY_NOT_FOUND';
+ $e = 'ACTOR_STAT_CAT_ENTRY_NOT_FOUND' if $type eq 'actor';
- $evt = OpenILS::Event->new( $e, id => $id ) unless $entry;
- return ( $entry, $evt );
+ $evt = OpenILS::Event->new( $e, id => $id ) unless $entry;
+ return ( $entry, $evt );
}
sub fetch_stat_cat_entry_default {
}
sub find_org {
- my( $self, $org_tree, $orgid ) = @_;
+ my( $self, $org_tree, $orgid ) = @_;
return undef unless $org_tree and defined $orgid;
- return $org_tree if ( $org_tree->id eq $orgid );
- return undef unless ref($org_tree->children);
- for my $c (@{$org_tree->children}) {
- my $o = $self->find_org($c, $orgid);
- return $o if $o;
- }
- return undef;
+ return $org_tree if ( $org_tree->id eq $orgid );
+ return undef unless ref($org_tree->children);
+ for my $c (@{$org_tree->children}) {
+ my $o = $self->find_org($c, $orgid);
+ return $o if $o;
+ }
+ return undef;
}
sub fetch_non_cat_type_by_name_and_org {
- my( $self, $name, $orgId ) = @_;
- $logger->debug("Fetching non cat type $name at org $orgId");
- my $types = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.config.non_cataloged_type.search.atomic',
- { name => $name, owning_lib => $orgId } );
- return ($types->[0], undef) if($types and @$types);
- return (undef, OpenILS::Event->new('CONFIG_NON_CATALOGED_TYPE_NOT_FOUND') );
+ my( $self, $name, $orgId ) = @_;
+ $logger->debug("Fetching non cat type $name at org $orgId");
+ my $types = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.config.non_cataloged_type.search.atomic',
+ { name => $name, owning_lib => $orgId } );
+ return ($types->[0], undef) if($types and @$types);
+ return (undef, OpenILS::Event->new('CONFIG_NON_CATALOGED_TYPE_NOT_FOUND') );
}
sub fetch_non_cat_type {
- my( $self, $id ) = @_;
- $logger->debug("Fetching non cat type $id");
- my( $type, $evt );
- $type = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.config.non_cataloged_type.retrieve', $id );
- $evt = OpenILS::Event->new('CONFIG_NON_CATALOGED_TYPE_NOT_FOUND') unless $type;
- return ($type, $evt);
+ my( $self, $id ) = @_;
+ $logger->debug("Fetching non cat type $id");
+ my( $type, $evt );
+ $type = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.config.non_cataloged_type.retrieve', $id );
+ $evt = OpenILS::Event->new('CONFIG_NON_CATALOGED_TYPE_NOT_FOUND') unless $type;
+ return ($type, $evt);
}
sub DB_UPDATE_FAILED {
- my( $self, $payload ) = @_;
- return OpenILS::Event->new('DATABASE_UPDATE_FAILED',
- payload => ($payload) ? $payload : undef );
+ my( $self, $payload ) = @_;
+ return OpenILS::Event->new('DATABASE_UPDATE_FAILED',
+ payload => ($payload) ? $payload : undef );
}
sub fetch_booking_reservation {
- my( $self, $id ) = @_;
- my( $res, $evt );
-
- $res = $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.booking.reservation.retrieve', $id
- );
-
- # simplereq doesn't know how to flesh so ...
- if ($res) {
- $res->usr(
- $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.actor.user.retrieve', $res->usr
- )
- );
-
- $res->target_resource_type(
- $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.booking.resource_type.retrieve', $res->target_resource_type
- )
- );
-
- if ($res->current_resource) {
- $res->current_resource(
- $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.booking.resource.retrieve', $res->current_resource
- )
- );
-
- if ($self->is_true( $res->target_resource_type->catalog_item )) {
- $res->current_resource->catalog_item( $self->fetch_copy_by_barcode( $res->current_resource->barcode ) );
- }
- }
-
- if ($res->target_resource) {
- $res->target_resource(
- $self->simplereq(
- 'open-ils.cstore',
- 'open-ils.cstore.direct.booking.resource.retrieve', $res->target_resource
- )
- );
-
- if ($self->is_true( $res->target_resource_type->catalog_item )) {
- $res->target_resource->catalog_item( $self->fetch_copy_by_barcode( $res->target_resource->barcode ) );
- }
- }
-
- } else {
- $evt = OpenILS::Event->new('RESERVATION_NOT_FOUND');
- }
-
- return ($res, $evt);
+ my( $self, $id ) = @_;
+ my( $res, $evt );
+
+ $res = $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.booking.reservation.retrieve', $id
+ );
+
+ # simplereq doesn't know how to flesh so ...
+ if ($res) {
+ $res->usr(
+ $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.actor.user.retrieve', $res->usr
+ )
+ );
+
+ $res->target_resource_type(
+ $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.booking.resource_type.retrieve', $res->target_resource_type
+ )
+ );
+
+ if ($res->current_resource) {
+ $res->current_resource(
+ $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.booking.resource.retrieve', $res->current_resource
+ )
+ );
+
+ if ($self->is_true( $res->target_resource_type->catalog_item )) {
+ $res->current_resource->catalog_item( $self->fetch_copy_by_barcode( $res->current_resource->barcode ) );
+ }
+ }
+
+ if ($res->target_resource) {
+ $res->target_resource(
+ $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.booking.resource.retrieve', $res->target_resource
+ )
+ );
+
+ if ($self->is_true( $res->target_resource_type->catalog_item )) {
+ $res->target_resource->catalog_item( $self->fetch_copy_by_barcode( $res->target_resource->barcode ) );
+ }
+ }
+
+ } else {
+ $evt = OpenILS::Event->new('RESERVATION_NOT_FOUND');
+ }
+
+ return ($res, $evt);
}
sub fetch_circ_duration_by_name {
- my( $self, $name ) = @_;
- my( $dur, $evt );
- $dur = $self->simplereq(
- &nbs