summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon2011-04-14 13:39:56 +0200
committerSimon2011-04-14 13:39:56 +0200
commit4ef5ef67e07245296fe73d3948d9526338bced63 (patch)
tree9317e60083f3279397c9f48aabc421ad65660457
parentEs werden keine Sessions mehr angelegt wenn ein Admin die Bootmenuentries tes... (diff)
downloadpbs2-4ef5ef67e07245296fe73d3948d9526338bced63.tar.gz
pbs2-4ef5ef67e07245296fe73d3948d9526338bced63.tar.xz
pbs2-4ef5ef67e07245296fe73d3948d9526338bced63.zip
Ticket #207 - Graph wird beim verlinken angezeigt
-rw-r--r--application/controllers/StatsController.php5
-rw-r--r--application/modules/user/controllers/GroupController.php28
-rw-r--r--application/modules/user/forms/GroupLink.php25
-rw-r--r--application/modules/user/views/scripts/group/link.phtml13
-rw-r--r--library/Pbs/Graph.php11
5 files changed, 67 insertions, 15 deletions
diff --git a/application/controllers/StatsController.php b/application/controllers/StatsController.php
index 74eb2db..51114f4 100644
--- a/application/controllers/StatsController.php
+++ b/application/controllers/StatsController.php
@@ -29,6 +29,11 @@ class StatsController extends Zend_Controller_Action
$groupID = $group;
}
+ $child = $this->_request->getParam('child');
+ if(Pbs_Acl::checkRight('glk') && $child != ''){
+ $n->newChild($child);
+ }
+
echo $n->graph($groupID);
}
}
diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php
index 4bebc52..39053ae 100644
--- a/application/modules/user/controllers/GroupController.php
+++ b/application/modules/user/controllers/GroupController.php
@@ -285,17 +285,39 @@ class User_GroupController extends Zend_Controller_Action
{
if(!Pbs_Acl::checkRight('glk'))
$this->_redirect('/user');
+
+ $linkableGroups = $this->groupList;
+ $groupGroupsMapper = new Application_Model_GroupGroupsMapper();
+ $childs = array();
+ $parents = array();
+ $childs = $groupGroupsMapper->getChildGroups($this->membership->getGroupID());
+ $parents = $groupGroupsMapper->getParentGroups($this->membership->getGroupID());
+ #print_a($childs,$parents);
+ foreach($linkableGroups as $i => $group){
+ #print_a($group->getID());
+ if(isset($childs[1]) && in_array($group->getID(),$childs[1])){
+ unset($linkableGroups[$i]);
+ }
+ if(count($parents) > 0){
+ foreach($parents as $d){
+ if(in_array($group->getID(),$d)){
+ unset($linkableGroups[$i]);
+ }
+ }
+ }
+ }
+ #print_a($linkableGroups);
if (!isset($_POST["link"])){
- $linkForm = new user_Form_GroupLink(array('grouplist' => $this->groupList));
+ $linkForm = new user_Form_GroupLink(array('grouplist' => $linkableGroups));
} else {
- $linkForm = new user_Form_GroupLink(array('grouplist' => $this->groupList),$_POST);
+ $linkForm = new user_Form_GroupLink(array('grouplist' => $linkableGroups),$_POST);
if ($linkForm->isValid($_POST)) {
$groupgroups = new Application_Model_GroupGroups();
if($_POST['superordinatedGroupID'] == $_POST['groupID'] || $_POST['groupID'] == 1) {
$this->_redirect('/user/group/index/page/'.$this->page.'/addresult/forbidden');
}
- $groupgroups->setParentID($_POST['superordinatedGroupID']);
+ $groupgroups->setParentID($this->membership->getGroupID());
$groupgroups->setGroupID($_POST['groupID']);
try {
$this->groupGroupsMapper->save($groupgroups);
diff --git a/application/modules/user/forms/GroupLink.php b/application/modules/user/forms/GroupLink.php
index 9bddb19..9aba5a4 100644
--- a/application/modules/user/forms/GroupLink.php
+++ b/application/modules/user/forms/GroupLink.php
@@ -13,28 +13,31 @@ class user_Form_GroupLink extends Zend_Form
{
$this->setName("GroupLink");
$this->setMethod('post');
-
- $groupfield = $this->createElement('select','groupID');
- $groupfield ->setLabel('Group:');
+
+/*
+ $groupfield1 = $this->createElement('select','superordinatedGroupID');
+ $groupfield1 ->setLabel('Parent Group:');
if(count($this->grouplist)>0){
foreach($this->grouplist as $group => $g){
- $groupfield->addMultiOption($g->getID(), $g->getTitle());
+ $groupfield1->addMultiOption($g->getID(), $g->getTitle());
}
}
- $groupfield->setRegisterInArrayValidator(false);
- $this->addElement($groupfield);
+ $groupfield1->setRegisterInArrayValidator(false);
+ $this->addElement($groupfield1);
+ */
- $groupfield1 = $this->createElement('select','superordinatedGroupID');
- $groupfield1 ->setLabel('superordinated Group:');
+ $groupfield = $this->createElement('select','groupID');
+ $groupfield ->setLabel('Group:');
+ $groupfield->setAttrib('onchange', "reloadGraph();");
if(count($this->grouplist)>0){
foreach($this->grouplist as $group => $g){
- $groupfield1->addMultiOption($g->getID(), $g->getTitle());
+ $groupfield->addMultiOption($g->getID(), $g->getTitle());
}
}
- $groupfield1->setRegisterInArrayValidator(false);
- $this->addElement($groupfield1);
+ $groupfield->setRegisterInArrayValidator(false);
+ $this->addElement($groupfield);
$this->addElement('submit', 'link', array(
'required' => false,
diff --git a/application/modules/user/views/scripts/group/link.phtml b/application/modules/user/views/scripts/group/link.phtml
index 5bb2a9d..1f3fbfa 100644
--- a/application/modules/user/views/scripts/group/link.phtml
+++ b/application/modules/user/views/scripts/group/link.phtml
@@ -2,4 +2,15 @@
<?php
$this->linkForm->setAction($this->url());
echo $this->linkForm;
-?> \ No newline at end of file
+?>
+<div class='bottomimg'><img id='depthimg' /></div>
+
+<script type="text/javascript">
+ $(document).ready(function(){
+ reloadGraph();
+ });
+ function reloadGraph(){
+ i = $("#groupID option:selected").val();
+ $('#depthimg').attr('src','/stats/graphgroup/child/' + i);
+ }
+</script>
diff --git a/library/Pbs/Graph.php b/library/Pbs/Graph.php
index e42b9d4..664c078 100644
--- a/library/Pbs/Graph.php
+++ b/library/Pbs/Graph.php
@@ -8,6 +8,7 @@ class Pbs_Graph{
private $level;
private $edges;
private $crawledNodes;
+ private $childs = array();
public function graph($groupID)
{
@@ -25,6 +26,13 @@ class Pbs_Graph{
node [ style=filled fillcolor="#ffffffff" ];
"'.$this->getGroupTitle($groupID).'" [ fontcolor="#ffffffff", style=filled, fillcolor="#004A99FF"];
';
+ if(count($this->childs) >=1){
+ foreach($this->childs as $childID){
+ $this->edges[$groupID][$childID] = 1;
+ $this->graphstring .= '"'.$this->getGroupTitle($groupID).'" -> "'.$this->getGroupTitle($childID).'";'."\n";
+ $this->getChildGroups($childID);
+ }
+ }
$this->getParentGroups($groupID);
$this->getChildGroups($groupID);
$this->graphstring .= '}';
@@ -73,6 +81,9 @@ class Pbs_Graph{
$groupmapper->find($groupID,$group);
return $group->getTitle();
}
+ public function newChild($id){
+ $this->childs[] = $id;
+ }
private function getParentGroups($groupID, $level=1) {
if($this->crawledNodes['parent'][$groupID] == 1)