diff options
Diffstat (limited to 'application/models/GroupGroupsMapper.php')
| -rw-r--r-- | application/models/GroupGroupsMapper.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/application/models/GroupGroupsMapper.php b/application/models/GroupGroupsMapper.php index 181d12d..0ea5e5f 100644 --- a/application/models/GroupGroupsMapper.php +++ b/application/models/GroupGroupsMapper.php @@ -87,6 +87,38 @@ class Application_Model_GroupGroupsMapper } return $entries; } + // Gets All groupIDs of the parent groups begins with the + public function getParentGroups($groupID, &$data=null, $level=1) { + $db = Zend_Db_Table::getDefaultAdapter(); + $query = 'SELECT parentID FROM pbs_groupgroups WHERE groupID="'.$groupID.'"'; + $stmt = $db->query($query); + $result = $stmt->fetchAll(); + foreach($result as $row){ + // save the current groupID in level-list + $data[$level][] = $row['parentID']; + + // get the function recursive an increase the level + $data = $this->getParentGroups($row['parentID'], $data, $level+1); + } + return $data; + } + + // Gets all childs-groups from a given group + public function getChildGroups($groupID, &$data=null, $level=1) { + $db = Zend_Db_Table::getDefaultAdapter(); + $query = 'SELECT groupID FROM pbs_groupgroups WHERE parentID="'.$groupID.'"'; + $stmt = $db->query($query); + $result = $stmt->fetchAll(); + foreach($result as $row){ + // save the current groupID in level-list + $data[$level][] = $row['groupID']; + + // get the function recursive an increase the level + $data = $this->getChildGroups($row['groupID'], $data, $level+1); + } + return $data; + } + |
