From debe4607bc71ad3160ccc3bdb27853071b3d78cd Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 1 Mar 2018 19:23:03 -0800 Subject: [PATCH] add Parent and Parents functions --- web/includes/Group.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web/includes/Group.php b/web/includes/Group.php index f8836ebca..d6edba7ca 100644 --- a/web/includes/Group.php +++ b/web/includes/Group.php @@ -288,6 +288,23 @@ $group_options[$Group->Id()] = str_repeat( ' ', $depth ) . $Group->Name(); return $monitor_id; } +public function Parent( ) { + if ( $this->{'ParentId'} ) { + return new Group($this->{'ParentId'}); + } + return null; +} + +public function Parents() { + $Parents = array(); + $Parent = $this->Parent(); + while( $Parent ) { + array_unshift($Parents, $Parent); + $Parent = $Parent->Parent(); + } + return $Parents; +} + } # end class Group