From 4ef5ef67e07245296fe73d3948d9526338bced63 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 14 Apr 2011 13:39:56 +0200 Subject: Ticket #207 - Graph wird beim verlinken angezeigt --- .../modules/user/controllers/GroupController.php | 28 +++++++++++++++++++--- application/modules/user/forms/GroupLink.php | 25 ++++++++++--------- .../modules/user/views/scripts/group/link.phtml | 13 +++++++++- 3 files changed, 51 insertions(+), 15 deletions(-) (limited to 'application/modules') 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 @@ linkForm->setAction($this->url()); echo $this->linkForm; -?> \ No newline at end of file +?> +
+ + -- cgit v1.2.3-55-g7522