diff options
Diffstat (limited to 'application/modules/user/controllers/ClientController.php')
| -rw-r--r-- | application/modules/user/controllers/ClientController.php | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index cbb114a..589fcdc 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -14,7 +14,7 @@ class User_ClientController extends Zend_Controller_Action { private $membership; protected $page; - + public function init() { if (Zend_Auth::getInstance()->hasIdentity()) { @@ -30,14 +30,14 @@ class User_ClientController extends Zend_Controller_Action } else { $this->_helper->redirector('login', 'auth'); } - $this->page = $this->_request->getParam('page'); + $this->page = $this->_request->getParam('page'); } public function indexAction() { // ACL: is he authorized to see this ? if(!Pbs_Acl::checkRight('clo')) - $this->_redirect('/user'); + $this->_redirect('/user'); // Get the Clients which booted with a bootiso of this group $result = $this->_request->getParam('deleteresult'); @@ -58,27 +58,32 @@ class User_ClientController extends Zend_Controller_Action $clientMapper = new Application_Model_ClientMapper(); $clientsInGroup = $clientMapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - + // Search $search = $this->_request->getParam('search'); $mySearch = new Pbs_Search(); $mySearch->setSearchTerm($search); $mySearch->setModule('client'); if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $clientsInGroup = $mySearch->search($clientsInGroup); + $this->view->search = $mySearch->getSearchTerm(); + $clientsInGroup = $mySearch->search($clientsInGroup); } $this->view->searchform = $mySearch->searchForm(); + // Format Time-String + foreach($clientsInGroup as $k=>$cig){ + $clientsInGroup[$k]['created'] = date(Zend_Registry::get('dateformat'),$cig['created']); + } + // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($clientsInGroup); - $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setRequestPage($this->_request->getParam('page')); $pagination->setPageUrl('/user/client/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $clientsInGroup = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination($pageurl); + $clientsInGroup = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); $this->view->clients = $clientsInGroup; @@ -94,7 +99,7 @@ class User_ClientController extends Zend_Controller_Action // ACL: is he authorized to create new clients? if(!Pbs_Acl::checkRight('cla')) - $this->_redirect('/user'); + $this->_redirect('/user'); if (!isset($_POST["add"])){ $addclient = new user_Form_Client(array( @@ -102,7 +107,7 @@ class User_ClientController extends Zend_Controller_Action 'page' => $this->page)); $this->view->addclient = $addclient; } - else{ + else{ $addclient = new user_Form_Client(array( 'buttontext' => 'Create Client', 'page' => $this->page),$_POST); @@ -111,7 +116,8 @@ class User_ClientController extends Zend_Controller_Action $mac = ($mac!='')?$mac:$_POST['macadress']; $hh = ($hh!='')?$hh:$_POST['hardwarehash']; $client->setMacadress($mac); - $client->setHardwarehash($hh); + $client->setHardwarehash($hh); + $client->setCreated(time()); $client->setGroupID($this->membership->getGroupID()); $clientmapper = new Application_Model_ClientMapper(); $clientmapper->save($client); @@ -124,11 +130,11 @@ class User_ClientController extends Zend_Controller_Action public function removeclientAction() { $clientID = $this->_request->getParam('clientID'); - + // ACL: is he authorized to delete clients? if(!Pbs_Acl::checkRight('cld')) - $this->_redirect('/user'); - + $this->_redirect('/user'); + $clientMapper = new Application_Model_ClientMapper(); if(is_numeric($clientID)){ $client = new Application_Model_Client(); @@ -148,14 +154,14 @@ class User_ClientController extends Zend_Controller_Action public function editclientAction(){ // ACL: Is he authorized to edit clients ? if(!Pbs_Acl::checkRight('cle')) - $this->_redirect('/user'); + $this->_redirect('/user'); if (!isset($_POST["add"])){ $clientID = $this->_request->getParam('clientID'); $client = new Application_Model_Client(); $mapper = new Application_Model_ClientMapper(); $mapper->find($clientID,$client); - + if($client->getGroupID() == $this->membership->getGroupID()){ $editclient = new user_Form_Client(array( 'buttontext' => 'Edit Client', @@ -173,11 +179,13 @@ class User_ClientController extends Zend_Controller_Action 'page' => $this->page),$_POST); if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { $client = new Application_Model_Client($_POST); - $client->setID($this->_request->getParam('clientID')); + $client->setID($this->_request->getParam('clientID')); $dbclient = new Application_Model_Client(); $clientMapper = new Application_Model_ClientMapper(); $clientMapper->find($this->_request->getParam('clientID'),$dbclient); + + $client->setCreated($dbclient->getCreated()); if($dbclient->getGroupID() == $this->membership->getGroupID()){ $client->setGroupID($this->membership->getGroupID()); |
