From 10a6fbc649a84558641872d0d58b7684f3a542cd Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 14 Aug 2006 16:43:48 +0000 Subject: [PATCH] added some org/session methods git-svn-id: svn://svn.open-ils.org/ILS/trunk@5489 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Actor.pm | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 5781ca67fb..1a506938cc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -2411,6 +2411,44 @@ sub session_home_lib { +__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 => 2, + 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; +} + 1; -- 2.11.0