summaryrefslogtreecommitdiffstats
path: root/application/modules/dev/controllers/GroupController.php
diff options
context:
space:
mode:
authorSimon2011-03-14 16:09:03 +0100
committerSimon2011-03-14 16:09:03 +0100
commitb5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c (patch)
treefcef50ad1ddf831f457d6aecd83e7fdc63297a1c /application/modules/dev/controllers/GroupController.php
parentfooter bleibt am fensterbottom (diff)
downloadpbs2-b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c.tar.gz
pbs2-b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c.tar.xz
pbs2-b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c.zip
Application in 3 Modules gesplittet, Dev = unsere entwicklungsumgebung, user = die weboberfläche fr anwender mit acl etc, fbgui = für die fbgui truppe - links in dev müssen noch angepasst werden
Diffstat (limited to 'application/modules/dev/controllers/GroupController.php')
-rw-r--r--application/modules/dev/controllers/GroupController.php242
1 files changed, 242 insertions, 0 deletions
diff --git a/application/modules/dev/controllers/GroupController.php b/application/modules/dev/controllers/GroupController.php
new file mode 100644
index 0000000..fbc7943
--- /dev/null
+++ b/application/modules/dev/controllers/GroupController.php
@@ -0,0 +1,242 @@
+<?php
+
+class GroupController extends Zend_Controller_Action
+{
+ protected $groupMapper;
+ protected $groupGroupsMapper;
+ protected $membershipMapper;
+ protected $groupRequestMapper;
+ protected $personmapper;
+ protected $rolemapper;
+ protected $groupList;
+
+ public function init()
+ {
+ if (Zend_Auth::getInstance()->hasIdentity()) {
+ $this->groupMapper = new Application_Model_GroupMapper();
+ $this->groupGroupsMapper = new Application_Model_GroupGroupsMapper();
+ $this->membershipMapper = new Application_Model_MembershipMapper();
+ $this->groupRequestMapper = new Application_Model_GroupRequestMapper();
+ $this->personmapper = new Application_Model_PersonMapper();
+ $this->rolemapper = new Application_Model_RoleMapper();
+ $this->groupList = $this->groupMapper->fetchAll();
+ } else {
+ $this->_helper->redirector('login', 'auth');
+ }
+ }
+
+ public function indexAction()
+ {
+ $this->view->groupList = $this->groupList;
+ }
+
+ public function addAction()
+ {
+ if (!isset($_POST["add"])){
+ $addForm = new Application_Form_GroupAdd(array('grouplist' => $this->groupList));
+ } else {
+ $addForm = new Application_Form_GroupAdd(array('grouplist' => $this->groupList),$_POST);
+
+ if ($addForm->isValid($_POST)) {
+ $group = new Application_Model_Group($_POST);
+ try {
+ $this->groupMapper->save($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ if($_POST['superordinatedGroupID'] != -1) {
+ $lastID = $this->groupMapper->getDbTable()->getDefaultAdapter()->lastInsertId();
+ $groupgroups = new Application_Model_GroupGroups();
+ $groupgroups->setParentID($_POST['superordinatedGroupID']);
+ $groupgroups->setGroupID($lastID);
+ try {
+ $this->groupGroupsMapper->save($groupgroups);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+
+ }
+ echo "Group successfully added. <br/>";
+ }
+ }
+
+ $this->view->addForm = $addForm;
+ }
+
+ public function editAction()
+ {
+ if(!isset($_POST['groupID'])) {
+ $addForm = new Application_Form_GroupAdd(array('grouplist' => $this->groupList));
+ $this->view->addForm = $addForm;
+ return;
+ }
+ if (!isset($_POST["save"])){
+ $group = $this->groupMapper->find($_POST['groupID']);
+ $_POST['title'] = $group->getTitle();
+ $_POST['description'] = $group->getDescription();
+ $editForm = new Application_Form_GroupEdit();
+ } else {
+ $editForm = new Application_Form_GroupEdit($_POST);
+ if ($editForm->isValid($_POST)) {
+ $group = new Application_Model_Group($_POST);
+ try {
+ $this->groupMapper->save($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Email Address already existing.";
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Successfully saved. <br/>";
+ }
+ }
+
+ $this->view->editForm = $editForm;
+ }
+
+ public function showAction()
+ {
+ if($_POST['groupID']) {
+ $groupRequests = $this->groupRequestMapper->findBy('groupID', $_POST['groupID']);
+ if(isset($groupRequests)) {
+ foreach($groupRequests as $groupRequest) {
+ $person = $this->personmapper->find($groupRequest['personID']);
+ $groupRequestList[] = array(
+ 'grouprequestID' => $groupRequest['grouprequestID'],
+ 'person' => $person
+ );
+ }
+ $this->view->groupRequestList = $groupRequestList;
+ $this->view->roleList = $this->rolemapper->findBy('groupID', $_POST['groupID']);
+ }
+ $members = $this->membershipMapper->findBy('groupID', $_POST['groupID']);
+ if(isset($members)) {
+ foreach($members as $member) {
+ $person = $this->personmapper->find($member['personID']);
+ $membersList[] = array(
+ 'membershipID' => $member['membershipID'],
+ 'person' => $person
+ );
+ }
+ $this->view->memberslist = $membersList;
+ }
+ $groupgroups = $this->groupGroupsMapper->findBy('groupID', $_POST['groupID']);
+ if(is_object($groupgroups)) {
+ $parentGroup = $this->groupMapper->find($groupgroups->getParentID());
+ $this->view->$parentGroup = $parentGroup;
+ }
+ $group = $this->groupMapper->find($_POST['groupID']);
+ $this->view->group = $group;
+ }
+ }
+
+ public function linkAction()
+ {
+ if (!isset($_POST["link"])){
+ $linkForm = new Application_Form_GroupLink(array('grouplist' => $this->groupList));
+ } else {
+ $linkForm = new Application_Form_GroupLink(array('grouplist' => $this->groupList),$_POST);
+
+ if ($linkForm->isValid($_POST)) {
+ $groupgroups = new Application_Model_GroupGroups();
+ $groupgroups->setParentID($_POST['superordinatedGroupID']);
+ $groupgroups->setGroupID($_POST['groupID']);
+ try {
+ $this->groupGroupsMapper->save($groupgroups);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Groups successfully linked. <br/>";
+ }
+ }
+
+ $this->view->linkForm = $linkForm;
+ }
+
+ public function deleteAction()
+ {
+ if (isset($_POST["groupID"])){
+ $group = $this->groupMapper->find($_POST["groupID"]);
+ try {
+ $this->groupMapper->delete($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Group successfully deleted. <br/>";
+ }
+ }
+
+ public function grantpersonAction()
+ {
+ if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) {
+ $groupRequest = $this->groupRequestMapper->find($_POST['grouprequestID']);
+ try {
+ $this->groupRequestMapper->delete($groupRequest);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ $membership = new Application_Model_Membership();
+ $membership->setGroupID($groupRequest->getGroupID());
+ $membership->setPersonID($groupRequest->getPersonID());
+ $membership->setRoleID($_POST['roleID']);
+ try {
+ $this->membershipMapper->save($membership);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Chosen Person has been successfully added to the chosen group. <br />";
+ }
+ }
+
+ public function revokepersonAction()
+ {
+ if(isset($_POST['membershipID'])) {
+ $membership = $this->membershipMapper->find($_POST['membershipID']);
+ if(isset($membership)) {
+ try {
+ $this->membershipMapper->delete($membership);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Chosen Person has been successfully removed from the chosen group. <br />";
+ }
+
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+