summaryrefslogtreecommitdiffstats
path: root/library/Pbs/Graph.php
diff options
context:
space:
mode:
authorSimon2011-03-25 15:09:25 +0100
committerSimon2011-03-25 15:09:25 +0100
commit9b6cf6612354e6bfec6ee817874e54e1b85ccc1e (patch)
treebbb57b263668d485d5911e1734a30a91c0085a00 /library/Pbs/Graph.php
parentfix serialnumber in fbgui Index (diff)
downloadpbs2-9b6cf6612354e6bfec6ee817874e54e1b85ccc1e.tar.gz
pbs2-9b6cf6612354e6bfec6ee817874e54e1b85ccc1e.tar.xz
pbs2-9b6cf6612354e6bfec6ee817874e54e1b85ccc1e.zip
Session war im Filter nicht gesetzt
Diffstat (limited to 'library/Pbs/Graph.php')
-rw-r--r--library/Pbs/Graph.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/library/Pbs/Graph.php b/library/Pbs/Graph.php
new file mode 100644
index 0000000..13bbe3a
--- /dev/null
+++ b/library/Pbs/Graph.php
@@ -0,0 +1,59 @@
+<?php
+
+class Pbs_Graph{
+
+ private $db = null;
+ private $membership;
+ private $graphstring;
+
+ public function graph($groupID)
+ {
+ $this->db = Zend_Db_Table::getDefaultAdapter();
+ $db = $this->db;
+
+
+
+ $this->graphstring = 'digraph groups {
+ size="6,6";';
+ $this->getParentGroups($groupID);
+ $this->getChildGroups($groupID);
+ $this->graphstring .= '}';
+ $this->graphstring = str_replace(array("\t","\n"),"",$this->graphstring);
+ return str_replace('"','\"',$this->graphstring);
+ }
+ private function getGroupTitle($groupID){
+ $group = new Application_Model_Group();
+ $groupmapper = new Application_Model_GroupMapper();
+ $groupmapper->find($groupID,$group);
+ return $group->getTitle();
+ }
+
+ private function getParentGroups($groupID, $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'];
+ $this->graphstring .= '"'.$this->getGroupTitle($row['parentID']).'" -> "'.$this->getGroupTitle($groupID).'";'."\n";
+ // get the function recursive an increase the level
+ $this->getParentGroups($row['parentID'], $level+1);
+ }
+ }
+
+ // Gets all childs-groups from a given group
+ private function getChildGroups($groupID, $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'];
+ $this->graphstring .= '"'.$this->getGroupTitle($groupID).'" -> "'.$this->getGroupTitle($row['groupID']).'";'."\n";
+ // get the function recursive an increase the level
+ $this->getChildGroups($row['groupID'], $level+1);
+ }
+ }
+}