diff options
| author | Simon | 2011-03-14 16:09:03 +0100 |
|---|---|---|
| committer | Simon | 2011-03-14 16:09:03 +0100 |
| commit | b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c (patch) | |
| tree | fcef50ad1ddf831f457d6aecd83e7fdc63297a1c /application/modules/dev/controllers/ConfigController.php | |
| parent | footer bleibt am fensterbottom (diff) | |
| download | pbs2-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/ConfigController.php')
| -rw-r--r-- | application/modules/dev/controllers/ConfigController.php | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/application/modules/dev/controllers/ConfigController.php b/application/modules/dev/controllers/ConfigController.php new file mode 100644 index 0000000..3eff0cc --- /dev/null +++ b/application/modules/dev/controllers/ConfigController.php @@ -0,0 +1,126 @@ +<?php + +class ConfigController extends Zend_Controller_Action +{ + + public function init() + { + $db = Zend_Db_Table::getDefaultAdapter(); + } + + public function indexAction() + { + $configmapper = new Application_Model_ConfigMapper(); + + $groupmapper = new Application_Model_GroupMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $personmapper = new Application_Model_PersonMapper(); + + $this->view->configlist = $configmapper->fetchAll(); + + foreach ($this->view->configlist as $config){ + $config->setGroupID("[".$config->getGroupID()."] ".$groupmapper->find($config->getGroupID())->getTitle()); + $config->setMembershipID("[".$config->getMembershipID()."] ".$personmapper->find($membershipmapper->find($config->getMembershipID())->getPersonID())->getFirstname()); + } + + } + + public function createconfigAction() + { + $groupmapper = new Application_Model_GroupMapper(); + if (!isset($_POST["createconfig"])){ + $createconfigForm = new Application_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll())); + } else { + + $createconfigForm = new Application_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll()),$_POST); + + if ($createconfigForm->isValid($_POST)) { + + $config = new Application_Model_Config($_POST); + $config->setCreated(time()); + $config->setMembershipID('1'); + + $configmapper = new Application_Model_ConfigMapper(); + + try { + $configmapper->save($config); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/config'); + } + } + + $this->view->createconfigForm = $createconfigForm; + } + + public function editconfigAction() + { + $configID = $this->_request->getParam('configID'); + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["editconfig"])){ + $configID = $this->_request->getParam('configID'); + if (!isset($configID) || !is_numeric($configID)){ + $this->_redirect('/config'); + } else { + $config = new Application_Model_Config(); + $configmapper = new Application_Model_ConfigMapper(); + $config = $configmapper->find($configID); + + $editconfigForm = new Application_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll())); + $editconfigForm->populate($config->toArray()); + } + }else{ + $editconfigForm = new Application_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll()),$_POST); + + if ($editconfigForm->isValid($_POST)) { + + $config = new Application_Model_Config($_POST); + $configmapper = new Application_Model_ConfigMapper(); + $config->setCreated(time()); + $config->setMembershipID('1'); + $config->setID($configID); + + try { + $configmapper->save($config); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/config'); + } + + } + + $this->view->editconfigForm = $editconfigForm; + } + + public function deleteconfigAction() + { + $configID = $this->_request->getParam('configID'); + if (!isset($configID)){ + $this->_redirect('/config'); + } else { + $config = new Application_Model_Config(); + $config->setID($configID); + $configmapper = new Application_Model_ConfigMapper(); + $configmapper->delete($config); + } + $this->_redirect('/config'); + } + + +} + + + + + + + |
