custom org tree : tpac
authorBill Erickson <berick@esilibrary.com>
Mon, 19 Mar 2012 20:31:08 +0000 (16:31 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 21 Mar 2012 18:19:36 +0000 (14:19 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm

index e672eac..a39fb35 100644 (file)
@@ -122,6 +122,30 @@ sub init_ro_object_cache {
         return [ values %{$cache{map}{aou}} ];
     };
 
+    $ro_object_subs->{aouct_tree} = sub {
+
+        # fetch the org unit tree
+        unless(exists $cache{aouct_tree}) {
+            $cache{aouct_tree} = undef;
+
+            my $tree_id = $e->json_querysearch_actor_org_unit_custom_tree([
+                {purpose => 'opac', active => 't'},
+                {idlist => 1}
+            ])->[0];
+
+            if ($tree_id) {
+                $cache{aouct_tree} = $e->search_actor_org_unit_custom_tree_node([
+                               {   parent => undef, tree => $tree_id}, 
+                    {   flesh        => -1,
+                                       flesh_fields => {aou    =>  ['children']},
+                                       order_by     => {aouctn => 'sibling_order'}
+                               }
+                       ])->[0];
+            }
+        }
+
+        return $cache{aouct_tree};
+    };
 
     # turns an ISO date into something TT can understand
     $ro_object_subs->{parse_datetime} = sub {