diff options
author | michael pereira | 2011-03-30 13:17:49 +0200 |
---|---|---|
committer | michael pereira | 2011-03-30 13:17:49 +0200 |
commit | f1654848b7e19f2ffdc8bd7e295526e1e1106ce8 (patch) | |
tree | a984c4f7401c83eddb42fc7faa9c50231459c472 /application | |
parent | Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff) | |
download | pbs2-f1654848b7e19f2ffdc8bd7e295526e1e1106ce8.tar.gz pbs2-f1654848b7e19f2ffdc8bd7e295526e1e1106ce8.tar.xz pbs2-f1654848b7e19f2ffdc8bd7e295526e1e1106ce8.zip |
findBy Methode angepasst
Diffstat (limited to 'application')
-rw-r--r-- | application/models/BootIsoMapper.php | 19 | ||||
-rw-r--r-- | application/models/BootOsMapper.php | 9 | ||||
-rw-r--r-- | application/modules/fbgui/controllers/IndexController.php | 2 | ||||
-rw-r--r-- | application/modules/user/controllers/BootosController.php | 76 |
4 files changed, 83 insertions, 23 deletions
diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php index 52849b2..c8c4b41 100644 --- a/application/models/BootIsoMapper.php +++ b/application/models/BootIsoMapper.php @@ -5,7 +5,7 @@ class Application_Model_BootIsoMapper protected $_dbTable; - public function findBy($criteria, $value) + public function findBy($criteria, $value, $array=false) { try{ $db = Zend_Db_Table::getDefaultAdapter(); @@ -15,14 +15,17 @@ class Application_Model_BootIsoMapper $stmt = $select->query(); $result = $stmt->fetchAll(); - $entries = array(); - foreach ($result as $row) { - $entry = new Application_Model_BootIso($row); - $entry->setID($row['bootisoID']); - $entries[] = $entry; + if(!$array){ + $entries = array(); + foreach ($result as $row) { + $entry = new Application_Model_BootIso($row); + $entry->setID($row['bootisoID']); + $entries[] = $entry; + } + return $entries; + }else{ + return $result; } - - return $entries; }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php index dda5f68..74fced0 100644 --- a/application/models/BootOsMapper.php +++ b/application/models/BootOsMapper.php @@ -15,7 +15,14 @@ class Application_Model_BootOsMapper $stmt = $select->query(); $result = $stmt->fetchAll(); - return $result; + $entries = array(); + foreach ($result as $row) { + $entry = new Application_Model_BootOs($row); + $entry->setID($row['bootosID']); + $entries[] = $entry; + } + + return $entries; }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index c70386f..505c68b 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -26,7 +26,7 @@ class Fbgui_IndexController extends Zend_Controller_Action $groupID = $bootiso->getGroupID(); } elseif(isset($_POST['serialnumber'])){ - $results = $bootisomapper->findBy('serialnumber',$_POST['serialnumber']); + $results = $bootisomapper->findBy('serialnumber',$_POST['serialnumber'],true); if(count($results) == 0){ echo 'Your serialnumber is not known by the system'; } diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index 81ddda3..8daa96c 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -3,30 +3,75 @@ class user_BootosController extends Zend_Controller_Action { + protected $bootosMapper; + protected $membershipMapper; + protected $membership; + public function init() { - $db = Zend_Db_Table::getDefaultAdapter(); + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] ==''){ + $this->_redirect('/user/index'); + } + + $this->bootosMapper = new Application_Model_BootOsMapper(); + + $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(); + } else { + $this->_helper->redirector('login', 'auth'); + } } public function indexAction() { + $result = $this->_request->getParam('addresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create',$result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete',$result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify',$result); + } + $result = $this->_request->getParam('updateresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('update',$result); + } - $bootosmapper = new Application_Model_BootOsMapper(); + $groupMapper = new Application_Model_GroupMapper(); + $personMapper = new Application_Model_PersonMapper(); - $groupmapper = new Application_Model_GroupMapper(); - $membershipmapper = new Application_Model_MembershipMapper(); - $personmapper = new Application_Model_PersonMapper(); - $configmapper = new Application_Model_ConfigMapper(); + $groupID = $this->membership->getGroupID(); + + //TODO ACL Darf er BootOsMenu sehen? + if(false) + $this->_redirect('/user/index'); + + $configMapper = new Application_Model_ConfigMapper(); - $this->view->bootoslist = $bootosmapper->fetchAll(); + $this->view->bootoslist = $this->bootosMapper->findBy("groupID", $groupID); $this->view->update = array(); + $update = $this->_request->getParam('checkupdate'); + if(count($this->view->bootoslist)>0){ foreach ($this->view->bootoslist as $bootos){ - $this->view->update[$bootos->getID()] = $this->checkupdateAction($bootos); - $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupmapper->find($bootos->getGroupID())->getTitle()); - $bootos->setMembershipID("[".$bootos->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootos->getMembershipID())->getPersonID())->getFirstname()); - $bootos->setConfigID("[".$bootos->getConfigID()."] ".$configmapper->find($bootos->getConfigID())->getTitle()); + $this->view->update[$bootos->getID()] = $update && $this->checkupdateAction($bootos); + $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); + $bootos->setMembershipID("[".$bootos->getMembershipID()."] ".$personMapper->find($this->membershipMapper->find($bootos->getMembershipID())->getPersonID())->getFirstname()); + $bootos->setConfigID("[".$bootos->getConfigID()."] ".$configMapper->find($bootos->getConfigID())->getTitle()); } } @@ -35,8 +80,13 @@ class user_BootosController extends Zend_Controller_Action public function createbootosAction() { - $groupmapper = new Application_Model_GroupMapper(); - $configmapper = new Application_Model_ConfigMapper(); + + //TODO ACL Darf er BootISOs erstellen? + if(false) + $this->_redirect('/user/bootiso/index/addresult/forbidden'); + + $groupMapper = new Application_Model_GroupMapper(); + $configMapper = new Application_Model_ConfigMapper(); if (!isset($_POST["createbootos"])){ try{ |