diff options
Diffstat (limited to 'application/modules/user/controllers/ConfigController.php')
| -rw-r--r-- | application/modules/user/controllers/ConfigController.php | 380 |
1 files changed, 190 insertions, 190 deletions
diff --git a/application/modules/user/controllers/ConfigController.php b/application/modules/user/controllers/ConfigController.php index 7f752a8..aba51f7 100644 --- a/application/modules/user/controllers/ConfigController.php +++ b/application/modules/user/controllers/ConfigController.php @@ -19,33 +19,33 @@ class user_ConfigController extends Zend_Controller_Action protected $page; protected $config; protected $type; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { + + public function init() + { + if (Zend_Auth::getInstance()->hasIdentity()) { $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); if($userIDsNamespace['membershipID'] ==''){ $this->_redirect('/user/index'); } - + $this->configMapper = new Application_Model_ConfigMapper(); - + $this->membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); $this->db = Zend_Db_Table::getDefaultAdapter(); - + $this->type = $this->_request->getParam('type'); } else { $this->_helper->redirector('login', 'auth'); } - $this->page = $this->_request->getParam('page'); - } + $this->page = $this->_request->getParam('page'); + } - public function indexAction() - { - $result = $this->_request->getParam('addresult'); + public function indexAction() + { + $result = $this->_request->getParam('addresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('create',$result); @@ -60,200 +60,200 @@ class user_ConfigController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('modify',$result); } - - $groupID = $this->membership->getGroupID(); - + + $groupID = $this->membership->getGroupID(); + //ACL Darf er Configs sehen? - if(!Pbs_Acl::checkRight('csai') && !Pbs_Acl::checkRight('csui')) - $this->_redirect('/user/index'); - - $this->configMapper = new Application_Model_ConfigMapper(); - - if($this->type =='own' && Pbs_Acl::checkRight('csui')){ - $this->view->type = 'own'; - $this->view->configlist = $this->configMapper->findBy(array('membershipID' => $this->membership->getID())); - }else{ - $this->view->type = 'group'; - $this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID())); - } - - foreach ($this->view->configlist as $config){ - $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated())); - } - - // Search + if(!Pbs_Acl::checkRight('csai') && !Pbs_Acl::checkRight('csui')) + $this->_redirect('/user/index'); + + $this->configMapper = new Application_Model_ConfigMapper(); + + if($this->type =='own' && Pbs_Acl::checkRight('csui')){ + $this->view->type = 'own'; + $this->view->configlist = $this->configMapper->findBy(array('membershipID' => $this->membership->getID())); + }else{ + $this->view->type = 'group'; + $this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID())); + } + + foreach ($this->view->configlist as $config){ + $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated())); + } + + // Search $search = $this->_request->getParam('search'); $mySearch = new Pbs_Search(); $mySearch->setSearchTerm($search); $mySearch->setType($this->type); $mySearch->setModule('config'); if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->configlist = $mySearch->search($this->view->configlist); + $this->view->search = $mySearch->getSearchTerm(); + $this->view->configlist = $mySearch->search($this->view->configlist); } $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($this->view->configlist); - $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setRequestPage($this->_request->getParam('page')); $pagination->setPageUrl('/user/config/index/type/'.$this->type.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $this->view->configlist = $pagination->getElements(); - + $this->view->configlist = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); - - } - - public function searchAction(){ + + } + + public function searchAction(){ $this->_redirect('/user/config/index/type/'.$this->type.'/search/'.($_GET['search'])); } - public function createconfigAction() - { - //ACL Darf er Configs erstellen? - if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); - - if (!isset($_POST["createconfig"])){ - $configForm = new user_Form_Config(array('action' => 'createconfig','page'=>$this->page, 'type'=>$this->type)); - } else { - $configForm = new user_Form_Config(array('action' => 'createconfig','page'=>$this->page, 'type'=>$this->type),$_POST); - - if ($configForm->isValid($_POST)) { - - $config = new Application_Model_Config($_POST); - $config->setCreated(time()); - - if(Pbs_Acl::checkRight('cc') && $this->_request->getParam('type') == 'group') - $config->setGroupID($this->membership->getGroupID()); - elseif(Pbs_Acl::checkRight('cco') && $this->_request->getParam('type') == 'own') - $config->setMembershipID($this->membership->getID()); - else - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); - - try { - $this->configMapper->save($config); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); - } - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); - } - } - - $this->view->configForm = $configForm; - } - - public function addUserAction(){ - - } - - public function editconfigAction() - { - //ACL Darf er Configs editieren? - if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - - $configID = $this->_request->getParam('configID'); - if (!is_numeric($configID)) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $groupID = $this->membership->getGroupID(); - - $config = new Application_Model_Config(); - $this->configMapper->find($configID, $config); - - if($config->getMembershipID() != null){ - if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem'))) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - } - - if (!isset($_POST["editconfig"])){ - - $configForm = new user_Form_Config(array('action' => 'editconfig','page'=>$this->page, 'type'=>$this->type)); - $configForm->populate($config->toArray()); - - }else{ - $configForm = new user_Form_Config(array('action' => 'editconfig','page'=>$this->page, 'type'=>$this->type),$_POST); - - if ($configForm->isValid($_POST)) { - - $configold = $config; - - $config = new Application_Model_Config($_POST); - $config->setCreated(time()); - - if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null) - $config->setGroupID($this->membership->getGroupID()); - elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null) - $config->setMembershipID($this->membership->getID()); - else - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $config->setID($configID); - - if($configold->getShellscript() != $config->getShellscript()){ - //ACL Is he allowed to edit other than Metadata? - if(!Pbs_Acl::checkRight('ce')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - } - - - try { - $this->configMapper->save($config); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - } - - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); - } - - } - - $this->view->configForm = $configForm; - } - - public function deleteconfigAction() - { - //ACL Darf er Configs löschen? - if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - - try{ - $configID = $this->_request->getParam('configID'); - if (!is_numeric($configID)) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); - - $config = new Application_Model_Config(); - $this->configMapper->find($configID,$config); - - if($config->getMembershipID() != null){ - if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - } - - $this->configMapper->delete($config); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); - } + public function createconfigAction() + { + //ACL Darf er Configs erstellen? + if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco')) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); + + if (!isset($_POST["createconfig"])){ + $configForm = new user_Form_Config(array('action' => 'createconfig','page'=>$this->page, 'type'=>$this->type)); + } else { + $configForm = new user_Form_Config(array('action' => 'createconfig','page'=>$this->page, 'type'=>$this->type),$_POST); + + if ($configForm->isValid($_POST)) { + + $config = new Application_Model_Config($_POST); + $config->setCreated(time()); + + if(Pbs_Acl::checkRight('cc') && $this->_request->getParam('type') == 'group') + $config->setGroupID($this->membership->getGroupID()); + elseif(Pbs_Acl::checkRight('cco') && $this->_request->getParam('type') == 'own') + $config->setMembershipID($this->membership->getID()); + else + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); + + try { + $this->configMapper->save($config); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); + } + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->configForm = $configForm; + } + + public function addUserAction(){ + + } + + public function editconfigAction() + { + //ACL Darf er Configs editieren? + if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo')) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); + + $configID = $this->_request->getParam('configID'); + if (!is_numeric($configID)) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + + $groupID = $this->membership->getGroupID(); + + $config = new Application_Model_Config(); + $this->configMapper->find($configID, $config); + + if($config->getMembershipID() != null){ + if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo')) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); + }else{ + if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem'))) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); + } + + if (!isset($_POST["editconfig"])){ + + $configForm = new user_Form_Config(array('action' => 'editconfig','page'=>$this->page, 'type'=>$this->type)); + $configForm->populate($config->toArray()); + + }else{ + $configForm = new user_Form_Config(array('action' => 'editconfig','page'=>$this->page, 'type'=>$this->type),$_POST); + + if ($configForm->isValid($_POST)) { + + $configold = $config; + + $config = new Application_Model_Config($_POST); + $config->setCreated(time()); + + if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null) + $config->setGroupID($this->membership->getGroupID()); + elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null) + $config->setMembershipID($this->membership->getID()); + else + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + + $config->setID($configID); + + if($configold->getShellscript() != $config->getShellscript()){ + //ACL Is he allowed to edit other than Metadata? + if(!Pbs_Acl::checkRight('ce')) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); + } + + + try { + $this->configMapper->save($config); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + } + + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); + } + + } + + $this->view->configForm = $configForm; + } + + public function deleteconfigAction() + { + //ACL Darf er Configs löschen? + if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo')) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); + + try{ + $configID = $this->_request->getParam('configID'); + if (!is_numeric($configID)) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); + + $config = new Application_Model_Config(); + $this->configMapper->find($configID,$config); + + if($config->getMembershipID() != null){ + if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo')) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); + }else{ + if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd')) + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); + } + + $this->configMapper->delete($config); + + }catch(Zend_Exception $e){ + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); + } + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); + } } |
