summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael pereira2011-03-25 17:24:17 +0100
committermichael pereira2011-03-25 17:24:17 +0100
commit9615b25b5afd08263a09ae9ef71daeb9e545b6e5 (patch)
tree98ccbd71450ca558bb4ebddeef5845b562e53fd8
parentfixes (diff)
parentgruppengraph nach einloggen in /user/ (diff)
downloadpbs2-9615b25b5afd08263a09ae9ef71daeb9e545b6e5.tar.gz
pbs2-9615b25b5afd08263a09ae9ef71daeb9e545b6e5.tar.xz
pbs2-9615b25b5afd08263a09ae9ef71daeb9e545b6e5.zip
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
-rw-r--r--.zfproject.xml7
-rw-r--r--application/controllers/IndexController.php7
-rw-r--r--application/controllers/StatsController.php28
-rw-r--r--application/modules/dev/forms/FilterEvaluate.php2
-rw-r--r--application/modules/fbgui/controllers/IndexController.php3
-rw-r--r--application/modules/user/views/scripts/index/index.phtml2
-rw-r--r--library/Pbs/Filter.php6
-rw-r--r--library/Pbs/Graph.php59
-rw-r--r--send-post.html12
-rw-r--r--tests/application/controllers/StatsControllerTest.php20
10 files changed, 132 insertions, 14 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index eda876f..70ccd1c 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -15,6 +15,9 @@
<controllerFile controllerName="Auth">
<actionMethod actionName="index"/>
</controllerFile>
+ <controllerFile controllerName="Stats">
+ <actionMethod actionName="index"/>
+ </controllerFile>
</controllersDirectory>
<formsDirectory enabled="false"/>
<layoutsDirectory enabled="false"/>
@@ -689,6 +692,9 @@
<viewControllerScriptsDirectory forControllerName="Auth">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Stats">
+ <viewScriptFile forActionName="index"/>
+ </viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewScriptsDirectory/>
<viewHelpersDirectory/>
@@ -753,6 +759,7 @@
<testApplicationControllerFile filesystemName="PrebootControllerTest.php"/>
<testApplicationControllerFile filesystemName="AuthControllerTest.php"/>
<testApplicationControllerFile filesystemName="AuthControllerTest.php"/>
+ <testApplicationControllerFile filesystemName="StatsControllerTest.php"/>
</testApplicationControllerDirectory>
</testApplicationDirectory>
<testLibraryDirectory>
diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php
index d26f8d4..cf6673c 100644
--- a/application/controllers/IndexController.php
+++ b/application/controllers/IndexController.php
@@ -14,12 +14,13 @@ class IndexController extends Zend_Controller_Action
$_SESSION['postdata'] = $_POST;
$this->_redirect('/fbgui/index/index');
}
-
-
+
// action body
- }
+
+ }
+
}
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 @@
+<?php
+
+class StatsController extends Zend_Controller_Action
+{
+
+ public function init()
+ {
+ $this->_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/dev/forms/FilterEvaluate.php b/application/modules/dev/forms/FilterEvaluate.php
index 9922f2b..7fd16c3 100644
--- a/application/modules/dev/forms/FilterEvaluate.php
+++ b/application/modules/dev/forms/FilterEvaluate.php
@@ -12,7 +12,7 @@ class dev_Form_FilterEvaluate extends Zend_Form
{
$this->setName("Test Filter");
$this->setMethod('post');
- $this->setAction('/filter/evaluate');
+ $this->setAction('/dev/filter/evaluate');
$this->addElement('text', 'ip', array(
'filters' => array('StringTrim'),
diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php
index bc94db5..91d045d 100644
--- a/application/modules/fbgui/controllers/IndexController.php
+++ b/application/modules/fbgui/controllers/IndexController.php
@@ -30,6 +30,7 @@ class Fbgui_IndexController extends Zend_Controller_Action
elseif(isset($_POST['serialnumber'])){
$results = $bootisomapper->findBy('serialnumber',$_POST['serialnumber']);
+ print_a($results);
$bootiso->setOptions($results[0]);
$bootiso->setID($results[0]['bootisoID']);
$groupID = $bootiso->getGroupID();
@@ -44,7 +45,7 @@ class Fbgui_IndexController extends Zend_Controller_Action
$clientID = $client->getID();
$session = new Application_Model_Session();
- $session->setBootisoID($_POST['bootisoID']);
+ $session->setBootisoID($bootiso->getID());
$session->setClientID($clientID);
$session->setTime(time());
$session->setIp($_SERVER['REMOTE_ADDR']);
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 @@
<?php endforeach ?>
</ul>
-
+<img src='/stats/graphgroup/' />
<?php endif ?>
diff --git a/library/Pbs/Filter.php b/library/Pbs/Filter.php
index 1759412..5b5e523 100644
--- a/library/Pbs/Filter.php
+++ b/library/Pbs/Filter.php
@@ -11,10 +11,12 @@ class Pbs_Filter{
$db = $this->db;
$debuglevel = 0;
+ $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..7711dce
--- /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="5,5";';
+ $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);
+ }
+ }
+}
diff --git a/send-post.html b/send-post.html
index 080e73a..6cad8c8 100644
--- a/send-post.html
+++ b/send-post.html
@@ -9,8 +9,8 @@
<fieldset>
<legend>http://132.230.4.27/</legend>
<form action='http://132.230.4.27/' method='post'>
- <label>BootisoID</label>
- <input type='text' name='bootisoID' value='1'></br>
+ <label>serialnumber</label>
+ <input type='text' name='serialnumber' value='10-20-30-40-50'></br>
<label>Mac</label>
<input type='text' name='mac' value='00:0c:29:01:63:88'></br>
<label>Hardwarehash</label>
@@ -21,8 +21,8 @@
<fieldset>
<legend>http://pbs2.local/</legend>
<form action='http://pbs2.local/' method='post'>
- <label>BootisoID</label>
- <input type='text' name='bootisoID' value='1'></br>
+ <label>serialnumber</label>
+ <input type='text' name='serialnumber' value='10-20-30-40-50'></br>
<label>Mac</label>
<input type='text' name='mac' value='00:0c:29:01:63:88'></br>
<label>Hardwarehash</label>
@@ -33,8 +33,8 @@
<fieldset>
<legend>http://localhost:81/</legend>
<form action='http://localhost:81/' method='post'>
- <label>BootisoID</label>
- <input type='text' name='bootisoID' value='1'></br>
+ <label>serialnumber</label>
+ <input type='text' name='serialnumber' value='10-20-30-40-50'></br>
<label>Mac</label>
<input type='text' name='mac' value='00:0c:29:01:63:88'></br>
<label>Hardwarehash</label>
diff --git a/tests/application/controllers/StatsControllerTest.php b/tests/application/controllers/StatsControllerTest.php
new file mode 100644
index 0000000..d130e2e
--- /dev/null
+++ b/tests/application/controllers/StatsControllerTest.php
@@ -0,0 +1,20 @@
+<?php
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+class StatsControllerTest extends PHPUnit_Framework_TestCase
+{
+
+ public function setUp()
+ {
+ /* Setup Routine */
+ }
+
+ public function tearDown()
+ {
+ /* Tear Down Routine */
+ }
+
+
+}
+