summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-25 15:11:49 +0100
committerJonathan Bauer2011-03-25 15:11:49 +0100
commit1c6075cfa2314b70c5e9db39f2d5d05436a10ae6 (patch)
tree2f9f5304ec2ebc4659657d361a1a1ea80134296a /library
parentbla (diff)
parentSession war im Filter nicht gesetzt (diff)
downloadpbs2-1c6075cfa2314b70c5e9db39f2d5d05436a10ae6.tar.gz
pbs2-1c6075cfa2314b70c5e9db39f2d5d05436a10ae6.tar.xz
pbs2-1c6075cfa2314b70c5e9db39f2d5d05436a10ae6.zip
Merge branch 'master' of git.openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'library')
-rw-r--r--library/Pbs/Filter.php6
-rw-r--r--library/Pbs/Graph.php59
2 files changed, 63 insertions, 2 deletions
diff --git a/library/Pbs/Filter.php b/library/Pbs/Filter.php
index ade53a3..93f595b 100644
--- a/library/Pbs/Filter.php
+++ b/library/Pbs/Filter.php
@@ -11,10 +11,12 @@ class Pbs_Filter{
$db = $this->db;
$debuglevel = 3;
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+
$membershipMapper = new Application_Model_MembershipMapper();
$this->membership = new Application_Model_Membership();
- if(isset($_SESSION['membershipID'])){
- $membershipMapper->find($_SESSION['membershipID'],$this->membership);
+ if(isset($userIDsNamespace['membershipID'])){
+ $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership);
}
else{
$this->membership->setID(null);
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);
+ }
+ }
+}