}
-
-__PACKAGE__->register_method(
- method => 'slim_tree',
- api_name => "open-ils.actor.org_tree.slim_hash.retrieve",
-);
-sub slim_tree {
- my $tree = new_editor()->search_actor_org_unit(
- [
- {"parent_ou" => undef },
- {
- flesh => -1,
- flesh_fields => { aou => ['children'] },
- order_by => { aou => 'name'},
- select => { aou => ["id","shortname", "name"]},
- }
- ]
- )->[0];
-
- return trim_tree($tree);
-}
-
-
-sub trim_tree {
- my $tree = shift;
- return undef unless $tree;
- my $htree = {
- code => $tree->shortname,
- name => $tree->name,
- };
- if( $tree->children and @{$tree->children} ) {
- $htree->{children} = [];
- for my $c (@{$tree->children}) {
- push( @{$htree->{children}}, trim_tree($c) );
- }
- }
-
- return $htree;
-}
-
-
__PACKAGE__->register_method(
method => "update_penalties",
api_name => "open-ils.actor.user.penalties.update"
return $val;
}
-
-
-
-
-my $tree = undef;
-my $orglist = undef;
-my $org_typelist = undef;
-my $org_typelist_hash = {};
-
-sub __get_org_tree {
-
- # can we throw this version away??
-
- my $self = shift;
- if($tree) { return $tree; }
-
- # see if it's in the cache
- $tree = $cache_client->new()->get_cache('_orgtree');
- if($tree) { return $tree; }
-
- if(!$orglist) {
- warn "Retrieving Org Tree\n";
- $orglist = $self->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.actor.org_unit.search.atomic",
- { id => { '!=' => undef } }
- );
- }
-
- if( ! $org_typelist ) {
- warn "Retrieving org types\n";
- $org_typelist = $self->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.actor.org_unit_type.search.atomic",
- { id => { '!=' => undef } }
- );
- $self->build_org_type($org_typelist);
- }
-
- $tree = $self->build_org_tree($orglist,1);
- $cache_client->new()->put_cache('_orgtree', $tree);
- return $tree;
-
-}
-
-my $slimtree = undef;
-sub get_slim_org_tree {
-
- my $self = shift;
- if($slimtree) { return $slimtree; }
-
- # see if it's in the cache
- $slimtree = $cache_client->new()->get_cache('slimorgtree');
- if($slimtree) { return $slimtree; }
-
- if(!$orglist) {
- warn "Retrieving Org Tree\n";
- $orglist = $self->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.actor.org_unit.search.atomic",
- { id => { '!=' => undef } }
- );
- }
-
- $slimtree = $self->build_org_tree($orglist);
- $cache_client->new->put_cache('slimorgtree', $slimtree);
- return $slimtree;
-
-}
-
-
-sub build_org_type {
- my($self, $org_typelist) = @_;
- for my $type (@$org_typelist) {
- $org_typelist_hash->{$type->id()} = $type;
- }
-}
-
-
-
sub build_org_tree {
-
- my( $self, $orglist, $add_types ) = @_;
+ my( $self, $orglist ) = @_;
return $orglist unless ref $orglist;
return $$orglist[0] if @$orglist == 1;
for my $org (@list) {
next unless ($org);
-
- if(!ref($org->ou_type()) and $add_types) {
- $org->ou_type( $org_typelist_hash->{$org->ou_type()});
- }
-
next if (!defined($org->parent_ou) || $org->parent_ou eq "");
my ($parent) = grep { $_->id == $org->parent_ou } @list;
return($bill, $evt);
}
-my $ORG_TREE;
-sub fetch_org_tree {
- my $self = shift;
- return $ORG_TREE if $ORG_TREE;
- return $ORG_TREE = OpenILS::Utils::CStoreEditor->new->search_actor_org_unit(
- [
- {"parent_ou" => undef },
- {
- flesh => -1,
- flesh_fields => { aou => ['children'] },
- order_by => { aou => 'name'}
- }
- ]
- )->[0];
-}
-
sub walk_org_tree {
my( $self, $node, $callback ) = @_;
return unless $node;
return $org_types = OpenILS::Utils::CStoreEditor->new->retrieve_all_actor_org_unit_type();
}
+my %ORG_TREE;
sub get_org_tree {
my $self = shift;
my $locale = shift || '';
my $cache = OpenSRF::Utils::Cache->new("global", 0);
- my $tree = $cache->get_cache("orgtree.$locale");
+ my $tree = $ORG_TREE{$locale} || $cache->get_cache("orgtree.$locale");
return $tree if $tree;
my $ses = OpenILS::Utils::CStoreEditor->new;
]
)->[0];
+ $ORG_TREE{$locale} = $tree;
$cache->put_cache("orgtree.$locale", $tree);
return $tree;
}
my($self, $conn, $auth, $org_id, $carrier, $number, $target_ids) = @_;
my $sms_enable = $U->ou_ancestor_setting_value(
- $org_id || $U->fetch_org_tree->id,
+ $org_id || $U->get_org_tree->id,
'sms.enable'
);
# We could maybe make a Validator for this on the templates
}
my $disable_auth = $U->ou_ancestor_setting_value(
- $org_id || $U->fetch_org_tree->id,
+ $org_id || $U->get_org_tree->id,
'sms.disable_authentication_requirement.callnumbers'
);