From 9b6cf6612354e6bfec6ee817874e54e1b85ccc1e Mon Sep 17 00:00:00 2001
From: Simon
Date: Fri, 25 Mar 2011 15:09:25 +0100
Subject: Session war im Filter nicht gesetzt
---
library/Pbs/Graph.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 library/Pbs/Graph.php
(limited to 'library/Pbs/Graph.php')
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 @@
+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);
+ }
+ }
+}
--
cgit v1.2.3-55-g7522
From fe944ac09029d3e173b629f99e0b8ef4d8212d0b Mon Sep 17 00:00:00 2001
From: Simon
Date: Fri, 25 Mar 2011 15:51:56 +0100
Subject: gruppengraph nach einloggen in /user/
---
.zfproject.xml | 7 ++++++
application/controllers/IndexController.php | 9 ++++---
application/controllers/StatsController.php | 28 ++++++++++++++++++++++
.../modules/user/views/scripts/index/index.phtml | 2 +-
library/Pbs/Graph.php | 2 +-
send-post.html | 8 ++-----
.../controllers/StatsControllerTest.php | 20 ++++++++++++++++
7 files changed, 63 insertions(+), 13 deletions(-)
create mode 100644 application/controllers/StatsController.php
create mode 100644 tests/application/controllers/StatsControllerTest.php
(limited to 'library/Pbs/Graph.php')
diff --git a/.zfproject.xml b/.zfproject.xml
index eda876f..70ccd1c 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -15,6 +15,9 @@
+
+
+
@@ -689,6 +692,9 @@
+
+
+
@@ -753,6 +759,7 @@
+
diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php
index 2c53550..cf6673c 100644
--- a/application/controllers/IndexController.php
+++ b/application/controllers/IndexController.php
@@ -14,12 +14,11 @@ class IndexController extends Zend_Controller_Action
$_SESSION['postdata'] = $_POST;
$this->_redirect('/fbgui/index/index');
}
-
- echo 'tesT';
+
// action body
- $n = new Pbs_Graph();
- print_a($n->graph(2));
- }
+
+
+ }
}
diff --git a/application/controllers/StatsController.php b/application/controllers/StatsController.php
new file mode 100644
index 0000000..024eacd
--- /dev/null
+++ b/application/controllers/StatsController.php
@@ -0,0 +1,28 @@
+_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+ }
+
+ public function graphgroupAction(){
+
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+
+ if($userIDsNamespace['groupID'] !=''){
+ header("Content-Type: image/png");
+
+ $n = new Pbs_Graph();
+ $str = 'echo "';
+ $str .= $n->graph($userIDsNamespace['groupID']);
+ $str .= '" | dot -Tpng ';
+
+ passthru($str);
+ }
+ }
+}
+
diff --git a/application/modules/user/views/scripts/index/index.phtml b/application/modules/user/views/scripts/index/index.phtml
index a6e84a7..0f1fab5 100644
--- a/application/modules/user/views/scripts/index/index.phtml
+++ b/application/modules/user/views/scripts/index/index.phtml
@@ -13,6 +13,6 @@
-
+
diff --git a/library/Pbs/Graph.php b/library/Pbs/Graph.php
index 13bbe3a..7711dce 100644
--- a/library/Pbs/Graph.php
+++ b/library/Pbs/Graph.php
@@ -14,7 +14,7 @@ class Pbs_Graph{
$this->graphstring = 'digraph groups {
- size="6,6";';
+ size="5,5";';
$this->getParentGroups($groupID);
$this->getChildGroups($groupID);
$this->graphstring .= '}';
diff --git a/send-post.html b/send-post.html
index 6e04b1f..6cad8c8 100644
--- a/send-post.html
+++ b/send-post.html
@@ -9,8 +9,6 @@