diff options
author | Simon | 2011-03-22 11:26:03 +0100 |
---|---|---|
committer | Simon | 2011-03-22 11:26:03 +0100 |
commit | 21fd2681fd6916154a2047c75fabb0e1b5bd09ba (patch) | |
tree | a69e5a0a7e133c05e09842faa5cee5f0ae8aca0c /application | |
parent | fbgui oberfläche angepasst (diff) | |
download | pbs2-21fd2681fd6916154a2047c75fabb0e1b5bd09ba.tar.gz pbs2-21fd2681fd6916154a2047c75fabb0e1b5bd09ba.tar.xz pbs2-21fd2681fd6916154a2047c75fabb0e1b5bd09ba.zip |
Alle ParentGroups und alle ChildGroups einer Gruppe herausfinden
Diffstat (limited to 'application')
-rw-r--r-- | application/models/GroupGroupsMapper.php | 32 | ||||
-rw-r--r-- | application/modules/user/controllers/FilterController.php | 23 | ||||
-rw-r--r-- | application/modules/user/controllers/IndexController.php | 4 |
3 files changed, 38 insertions, 21 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; + } + diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php index 307c40d..d604aba 100644 --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -173,27 +173,8 @@ class User_FilterController extends Zend_Controller_Action $this->_redirect('/user/filter/index/modifyresult/error'); } } - } - - // $parent is the parent of the children we want to see - // $level is increased when we go deeper into the tree - private function display_children($parent, $level, &$data) { - // retrieve all children of $parent - $result = mysql_query('SELECT groupID FROM pbs_groupgroups '. - 'WHERE parentID="'.$parent.'";'); - - // display each child - while ($row = mysql_fetch_array($result)) { - // indent and display the title of this child - $data[$level][] = str_repeat(' ',$level).$row['title']; - - // call this function again to display this - // child's children - $data = display_children($row['title'], $level+1,$data); - } - return $data; - } - + } + private function prepareFormData(){ $poolMapper = new Application_Model_PoolMapper(); $pools = $poolMapper->findBY('groupID',$this->membership->getGroupID()); diff --git a/application/modules/user/controllers/IndexController.php b/application/modules/user/controllers/IndexController.php index 8b295e0..74e1da7 100644 --- a/application/modules/user/controllers/IndexController.php +++ b/application/modules/user/controllers/IndexController.php @@ -22,6 +22,10 @@ class User_IndexController extends Zend_Controller_Action ); } $this->view->links = $links; + + $ggMapper = new Application_Model_GroupGroupsMapper(); + print_a('Your Parent Groups', $ggMapper->getParentGroups($_SESSION['membershipID'])); + print_a('Your Child Groups',$ggMapper->getChildGroups($_SESSION['membershipID'])); } } |