diff options
| author | michael pereira | 2011-03-18 19:27:33 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-18 19:27:33 +0100 |
| commit | 87b3b1d9c0cecf76d1eb39cf2548072607de59ea (patch) | |
| tree | 5d07af0d68e20a38422a72864b3ca68b1a1b07be | |
| parent | BootOs Update implementiert, BootISO anlegen und some fixes (diff) | |
| parent | User-Oberfläche, FBGui-Oberfläche legt Session&Clients an - für Kiosk-System (diff) | |
| download | pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.tar.gz pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.tar.xz pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.zip | |
newsql geaendert
26 files changed, 729 insertions, 118 deletions
diff --git a/.zfproject.xml b/.zfproject.xml index 4a6e73f..90d4d20 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -252,6 +252,12 @@ </controllerFile> <controllerFile controllerName="Filter"> <actionMethod actionName="index"/> + <actionMethod actionName="addfilter"/> + <actionMethod actionName="removefilter"/> + <actionMethod actionName="editfilter"/> + <actionMethod actionName="addfilterentry"/> + <actionMethod actionName="editfilterentry"/> + <actionMethod actionName="removefilterentry"/> </controllerFile> <controllerFile controllerName="Pool"> <actionMethod actionName="index"/> @@ -266,6 +272,8 @@ <formFile formName="Login"/> <formFile formName="Client"/> <formFile formName="Pool"/> + <formFile formName="PoolClient"/> + <formFile formName="Filter"/> </formsDirectory> <layoutsDirectory enabled="false"/> <modelsDirectory> @@ -333,6 +341,24 @@ <viewControllerScriptsDirectory forControllerName="Pool"> <viewScriptFile forActionName="unlinkclient"/> </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="addfilter"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="removefilter"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="editfilter"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="addfilterentry"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="editfilterentry"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="removefilterentry"/> + </viewControllerScriptsDirectory> </viewScriptsDirectory> <viewHelpersDirectory/> <viewFiltersDirectory/> diff --git a/apache-default b/apache-default new file mode 100644 index 0000000..95d0580 --- /dev/null +++ b/apache-default @@ -0,0 +1,36 @@ +<VirtualHost *:80> + ServerAdmin webmaster@localhost + +DocumentRoot /tmp/pbs2/public + <Directory /tmp/pbs2/public > + Options FollowSymLinks + AllowOverride All + </Directory> + + + ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ + <Directory "/usr/lib/cgi-bin"> + AllowOverride None + Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch + Order allow,deny + Allow from all + </Directory> + + ErrorLog /var/log/apache2/error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog /var/log/apache2/access.log combined + + Alias /doc/ "/usr/share/doc/" + <Directory "/usr/share/doc/"> + Options Indexes MultiViews FollowSymLinks + AllowOverride None + Order deny,allow + Deny from all + Allow from 127.0.0.0/255.0.0.0 ::1/128 + </Directory> + +</VirtualHost> diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index df2f91c..9a65853 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -6,6 +6,17 @@ class IndexController extends Zend_Controller_Action public function init() { /* Initialize action controller here */ + if(stristr($_SERVER['HTTP_USER_AGENT'],'prebootGUI')){ + $redirector = $this->_helper->getHelper('Redirector'); + $redirector->gotoSimple('index', + 'Index', + 'fbgui', + array('keys' => array_keys($_POST), + 'post' => $_POST + ) + ); + + } } public function indexAction() diff --git a/application/modules/dev/controllers/FilterController.php b/application/modules/dev/controllers/FilterController.php index b346810..53900b3 100644 --- a/application/modules/dev/controllers/FilterController.php +++ b/application/modules/dev/controllers/FilterController.php @@ -10,12 +10,11 @@ class dev_FilterController extends Zend_Controller_Action public function init() { try{ - - $this->_filtermapper = new Application_Model_FilterMapper(); - }catch (Zend_Exception $e) { - echo "Error message 1: " . $e->getMessage() . "\n"; - } - $this->db = Zend_Db_Table::getDefaultAdapter(); + $this->_filtermapper = new Application_Model_FilterMapper(); + }catch (Zend_Exception $e) { + echo "Error message 1: " . $e->getMessage() . "\n"; + } + $this->db = Zend_Db_Table::getDefaultAdapter(); } public function indexAction() diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index 685feaa..238edb7 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -9,17 +9,44 @@ class Fbgui_IndexController extends Zend_Controller_Action } public function indexAction() - { - // action body - - // Call this Procedure after Login to create a session and save the alphasessionID to session - $n = new Pbs_Session(); - $session = new Application_Model_Session(); - $session->setBootisoID(1); - $session->setTime(time()); - $session->setIp($_SERVER['REMOTE_ADDR']); - $session = $n->createsession($session); - $_SESSION['alphasessionID'] = $session->getAlphasessionID(); + { + if(isset($this->_request->getParam('post')) && $this->_request->getParam('keys')){ + $data = $this->_request->getParam('post'); + $keys = $this->_request->getParam('keys'); + $_POST = array_combine ( $keys , $data ); + } + if(isset($_POST['bootisoID'])){ + // Create a session + $n = new Pbs_Session(); + + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso = new Application_Model_BootIso(); + $bootisomapper->find($_POST['bootisoID'],$bootiso); + $groupID = $bootiso->getGroupID(); + + $client = new Application_Model_Client(); + $client->setMacadress($_POST['mac']); + $client->setHardwarehash($_POST['hardwarehash']); + $client->setGroupID($groupID); + $client = $n->createClient($client); + $clientID = $client->getID(); + + $session = new Application_Model_Session(); + $session->setBootisoID($_POST['bootisoID']); + $session->setClientID($clientID); + $session->setTime(time()); + $session->setIp($_SERVER['REMOTE_ADDR']); + $session = $n->createSession($session); + $_SESSION['alphasessionID'] = $session->getAlphasessionID(); + echo "<h1>Welcome</h1>"; + print_a('Session is now set','Your alphasessionID is '.$session->getAlphasessionID()); + $this->_redirect('/dev/bootmenu/index/bootmenuid/1'); + } + else{ + echo "<h1>Not Welcome</h1>"; + print_a($_POST); + } + die(); } diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index bf64102..4bb2b35 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -5,6 +5,10 @@ class User_ClientController extends Zend_Controller_Action private $membership; public function init() { + if($_SESSION['membershipID'] ==''){ + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set','forbidden'); + } /* Initialize action controller here */ $membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); @@ -46,88 +50,99 @@ class User_ClientController extends Zend_Controller_Action $hh = $this->_request->getParam('hh'); // TODO: ACL: is he authorized to create new clients? - if (!isset($_POST["add"])){ - $addclient = new user_Form_Client(array('buttontext' => 'Create Client')); - $this->view->addclient = $addclient; - } - else{ - $addclient = new user_Form_Client(array('buttontext' => 'Create Client'),$_POST); - print_a($_POST); - if ($addclient->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $mac = ($mac!='')?$mac:$_POST['macadress']; - $hh = ($hh!='')?$hh:$_POST['hardwarehash']; - $client->setMacadress($mac); - $client->setHardwarehash($hh); - $client->setGroupID($this->membership->getGroupID()); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->save($client); - $this->_redirect('/user/client/addresult/ok'); - } - $this->view->addclient = $addclient; - } + #if( he is allowed){ + if (!isset($_POST["add"])){ + $addclient = new user_Form_Client(array('buttontext' => 'Create Client')); + $this->view->addclient = $addclient; + } + else{ + $addclient = new user_Form_Client(array('buttontext' => 'Create Client'),$_POST); + print_a($_POST); + if ($addclient->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $mac = ($mac!='')?$mac:$_POST['macadress']; + $hh = ($hh!='')?$hh:$_POST['hardwarehash']; + $client->setMacadress($mac); + $client->setHardwarehash($hh); + $client->setGroupID($this->membership->getGroupID()); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + $this->_redirect('/user/client/addresult/ok'); + } + $this->view->addclient = $addclient; + } + #}else{ + # $this->_redirect('/user/'); + #} } public function removeclientAction() { $clientID = $this->_request->getParam('clientID'); // TODO: ACL: is he authorized to delete clients? - $clientMapper = new Application_Model_ClientMapper(); - if(is_numeric($clientID)){ - $client = new Application_Model_Client(); - $clientMapper->find($clientID,$client); - // TODO: ACL: Is He authorized to delete - if($client->getGroupID() == $this->membership->getGroupID()){ - $clientMapper = new Application_Model_ClientMapper(); - $clientMapper->delete($client); - $this->_redirect('/user/client/index/deleteresult/ok'); - } - else{ - $this->_redirect('/user/client/index/deleteresult/forbidden'); + #if( he is allowed){ + $clientMapper = new Application_Model_ClientMapper(); + if(is_numeric($clientID)){ + $client = new Application_Model_Client(); + $clientMapper->find($clientID,$client); + if($client->getGroupID() == $this->membership->getGroupID()){ + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->delete($client); + $this->_redirect('/user/client/index/deleteresult/ok'); + } + else{ + $this->_redirect('/user/client/index/deleteresult/forbidden'); + } } - } - $this->_redirect('/user/client/index/deleteresult/error'); + $this->_redirect('/user/client/index/deleteresult/error'); + #}else{ + # $this->_redirect('/user/'); + #} } public function editclientAction(){ - // TODO: ACL: Is he authorized to edit clients ? - if (!isset($_POST["add"])){ - $clientID = $this->_request->getParam('clientID'); - $client = new Application_Model_Client(); - $mapper = new Application_Model_ClientMapper(); - $mapper->find($clientID,$client); + // TODO: ACL: Is he authorized to edit clients ? + #if( he is allowed){ + 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')); - $editclient->populate($client->toArray()); - $this->view->editclient = $editclient; - } - else{ - $this->_redirect('/user/client/index/modifyresult/error'); - } - } - else{ - $editclient = new user_Form_Client(array('buttontext' => 'Edit Client'),$_POST); - if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $client->setID($this->_request->getParam('clientID')); + if($client->getGroupID() == $this->membership->getGroupID()){ + $editclient = new user_Form_Client(array('buttontext' => 'Edit Client')); + $editclient->populate($client->toArray()); + $this->view->editclient = $editclient; + } + else{ + $this->_redirect('/user/client/index/modifyresult/error'); + } + } + else{ + $editclient = new user_Form_Client(array('buttontext' => 'Edit Client'),$_POST); + if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $client->setID($this->_request->getParam('clientID')); - $dbclient = new Application_Model_Client(); - $clientMapper = new Application_Model_ClientMapper(); - $clientMapper->find($this->_request->getParam('clientID'),$dbclient); + $dbclient = new Application_Model_Client(); + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->find($this->_request->getParam('clientID'),$dbclient); - if($dbclient->getGroupID() == $this->membership->getGroupID()){ - $client->setGroupID($this->membership->getGroupID()); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->save($client); - $this->_redirect('/user/client/index/modifyresult/ok'); - } - else{ - $this->_redirect('/user/client/index/modifyresult/error'); + if($dbclient->getGroupID() == $this->membership->getGroupID()){ + $client->setGroupID($this->membership->getGroupID()); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + $this->_redirect('/user/client/index/modifyresult/ok'); + } + else{ + $this->_redirect('/user/client/index/modifyresult/error'); + } } - } - $this->view->editclient = $editclient; - } + $this->view->editclient = $editclient; + } + #}else{ + # $this->_redirect('/user/'); + #} } diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php index 2704309..8ceefe3 100644 --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -2,13 +2,100 @@ class User_FilterController extends Zend_Controller_Action { - + protected $filterMapper; + protected $membershipMapper; public function init() { - /* Initialize action controller here */ + if($_SESSION['membershipID'] ==''){ + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set','forbidden'); + } + $this->filterMapper = new Application_Model_FilterMapper(); + + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($_SESSION['membershipID'],$this->membership); + + $this->db = Zend_Db_Table::getDefaultAdapter(); } public function indexAction() + { + // TODO: ACL: is he authorized to see this? + + $result = $this->_request->getParam('addresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create',$result); + } + + $filters = $this->filterMapper->findBy('groupID',$this->membership->getGroupID()); + foreach($filters as $filter){ + $ff = new Application_Model_Filter(); + $ff->setOptions($filter); + $ff->setID($filter['filterID']); + $allFilter[] = $ff; + } + $this->view->filters = $allFilter; + } + + public function addfilterAction() + { + // TODO: ACL: is he authorized to add a filter? + $bmmapper = new Application_Model_BootMenuMapper(); + $result = $bmmapper->findBy('groupID',$this->membership->getGroupID()); + foreach($result as $rr){ + $bm = new Application_Model_BootMenu(); + $bm->setOptions($rr); + $bm->setID($rr['bootmenuID']); + $bootmenus[] = $bm; + } + $this->view->bootmenus = $bootmenus; + + if (!isset($_POST["add"])){ + $addfilterform = new user_Form_Filter(array('buttontext' => 'Create Filter','bootmenus'=>$bootmenus)); + $this->view->addfilterform = $addfilterform; + }else { + $addfilterform = new user_Form_Filter(array('buttontext' => 'Create Filter','bootmenus'=>$bootmenus),$_POST); + if ($addfilterform->isValid($_POST)) { + try{ + $newfilter = new Application_Model_Filter($_POST); + $newfilter->setCreated(time()); + $newfilter->setGroupID($this->membership->getGroupID()); + $newfilter->setMembershipID($this->membership->getID()); + $newfilter2 = new Application_Model_FilterMapper(); + $newfilter2->save($newfilter); + $this->_redirect('/user/filter/index/addresult/ok'); + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/filter/index/addresult/error'); + } + } + $this->view->addfilterform = $addfilterform; + } + } + + public function removefilterAction() + { + // action body + } + + public function editfilterAction() + { + // action body + } + + public function addfilterentryAction() + { + // action body + } + + public function editfilterentryAction() + { + // action body + } + + public function removefilterentryAction() { // action body } @@ -16,3 +103,15 @@ class User_FilterController extends Zend_Controller_Action } + + + + + + + + + + + + diff --git a/application/modules/user/controllers/PoolController.php b/application/modules/user/controllers/PoolController.php index 01b5a2a..f786aa8 100644 --- a/application/modules/user/controllers/PoolController.php +++ b/application/modules/user/controllers/PoolController.php @@ -5,6 +5,11 @@ class User_PoolController extends Zend_Controller_Action private $membership; public function init() { + if($_SESSION['membershipID'] ==''){ + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set','forbidden'); + } + $membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); $membershipMapper->find($_SESSION['membershipID'],$this->membership); @@ -29,10 +34,26 @@ class User_PoolController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('create',$result); } - + $result = $this->_request->getParam('linkresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('link',$result); + } + $result = $this->_request->getParam('unlinkresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('unlink',$result); + } $poolMapper = new Application_Model_PoolMapper(); - $this->view->pools = $poolMapper->fetchAll(); + $pools = $poolMapper->findBy('groupID',$this->membership->getGroupID()); + foreach($pools as $pool){ + $ff = new Application_Model_Pool(); + $ff->setOptions($pool); + $ff->setID($pool['poolID']); + $yourpools[] = $ff; + } + $this->view->pools = $yourpools; $clientmapper = new Application_Model_ClientMapper(); $clients = $clientmapper->fetchAll(); @@ -70,7 +91,7 @@ class User_PoolController extends Zend_Controller_Action $this->_redirect('/dev/pool/index/addresult/error'); } } - $this->view->addpool = $addfilterform; + $this->view->addpool = $addpoolform; } } @@ -95,36 +116,49 @@ class User_PoolController extends Zend_Controller_Action } $this->_redirect('/user/pool/index/deleteresult/error'); #}else{ - # $this->_redirect('/user/pool/index/deleteresult/forbidden'); + # $this->_redirect('/user/'); #} } public function editpoolAction() { // TODO: ACL: is he allowed to edit a pool? - // TODO: is he allowed to edit this pool? if (!isset($_POST["add"])){ - $poolID = $this->_request->getParam('poolID'); + $poolID = $this->_request->getParam('poolID'); $pool = new Application_Model_Pool(); $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->find($poolID,$pool); - $poolArray = $pool->toArray(); - $editpool = new user_Form_Pool(array('buttontext' => 'Edit Pool')); - $editpool->populate($poolArray); - $this->view->editpool = $editpool; - + $poolmapper->find($poolID,$pool); + if($pool->getGroupID() == $this->membership->getGroupID()){ + $poolArray = $pool->toArray(); + $editpool = new user_Form_Pool(array('buttontext' => 'Edit Pool')); + $editpool->populate($poolArray); + $this->view->editpool = $editpool; + } + else{ + $this->_redirect('/user/pool/index/modifyresult/forbidden'); + } }else { $editpoolform = new user_Form_Pool(array('buttontext' => 'Edit Pool'),$_POST); if ($editpoolform->isValid($_POST)) { try{ - $pool = new Application_Model_Pool($_POST); - $pool->setID($this->_request->getParam('poolID')); $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->save($pool); - $this->_redirect('/dev/pool/index/modifyresult/ok'); + $poolID = $this->_request->getParam('poolID'); + $pooldb = new Application_Model_Pool(); + $poolmapper->find($poolID,$pooldb); + print_a($pooldb->getGroupID(), $this->membership->getGroupID()); + if($pooldb->getGroupID() == $this->membership->getGroupID()){ + $pool = new Application_Model_Pool($_POST); + $pool->setID($poolID); + $pool->setGroupID($this->membership->getGroupID()); + $poolmapper->save($pool); + $this->_redirect('/user/pool/index/modifyresult/ok'); + } + else{ + $this->_redirect('/user/pool/index/modifyresult/forbidden'); + } }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/dev/pool/index/modifyresult/error'); + $this->_redirect('/user/pool/index/modifyresult/error'); } } $this->view->editpool = $editpoolform; @@ -132,13 +166,88 @@ class User_PoolController extends Zend_Controller_Action } public function linkclientAction() - { - // action body + { + $clientID = $this->_request->getParam('clientID'); + $poolID = $this->_request->getParam('poolID'); + + // TODO: ACL: Is he allowed to link clients to pools? + if(!isset($_POST['clientID']) && ($clientID == '')){ + $clientmapper = new Application_Model_ClientMapper(); + $clients = $clientmapper->findBy('groupID',$this->membership->getGroupID()); + $assignedclientmapper = new Application_Model_PoolEntriesMapper(); + $assignedclients = $assignedclientmapper->fetchAll(); + foreach($assignedclients as $c){ + $assignedclientsArray[] = $c->toArray(); + } + $freeclients = $this->arrayDiff($clients,$assignedclientsArray); + + $poolclient = new user_Form_PoolClient(array('buttontext' => 'Link Client','clients'=> $freeclients)); + $this->view->poolclient = $poolclient; + }else { + $poolclient = new dev_Form_PoolClient(array('buttontext' => 'Link Client'),$_POST); + try{ + $poolID = $this->_request->getParam('poolID'); + $poolmapper = new Application_Model_PoolMapper(); + $pooldb = new Application_Model_Pool(); + $poolmapper->find($poolID,$pooldb); + $clientmapper = new Application_Model_ClientMapper(); + $clientdb = new Application_Model_Client(); + $clientmapper->find($clientID,$clientdb); + + if($pooldb->getGroupID() == $this->membership->getGroupID() && $clientdb->getGroupID() == $this->membership->getGroupID()){ + $poolentriesmapper = new Application_Model_PoolEntriesMapper(); + $poolentry = new Application_Model_PoolEntries($_POST); + $poolentry->setPoolID($poolID); + if($poolentry->getClientID() == ''){ + $poolentry->setClientID($clientID); + } + $poolentriesmapper->save($poolentry); + $this->_redirect('/user/pool/index/linkresult/ok'); + } + else{ + $this->_redirect('/user/pool/index/linkresult/forbidden'); + } + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/pool/index/linkresult/error'); + } + $this->view->poolclient = $poolclient; + } } public function unlinkclientAction() { - // action body + $poolentriesID = $this->_request->getParam('poolentriesID'); + + // TODO: ACL: Is he allowed to unlink clients from pools? + if(is_numeric($poolentriesID)){ + $poolentriesMapper = new Application_Model_PoolEntriesMapper(); + $poolentry = new Application_Model_PoolEntries(); + $poolentriesMapper->find($poolentriesID,$poolentry); + $clientMapper = new Application_Model_ClientMapper(); + $client = new Application_Model_Client(); + + $poolMapper = new Application_Model_PoolMapper(); + $pool = new Application_Model_Pool(); + + $clientMapper->find($poolentry->getClientID(),$client); + $poolMapper->find($poolentry->getPoolID(),$pool); + + + if($pool->getGroupID() == $this->membership->getGroupID() && $client->getGroupID() == $this->membership->getGroupID()){ + $deletepoolentries = new Application_Model_PoolEntries(); + $deletepoolentries->setID($poolentriesID); + $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper(); + $deletepoolentriesmapper->delete($deletepoolentries); + $this->_redirect('/user/pool/index/unlinkresult/ok'); + } + else{ + $this->_redirect('/user/pool/index/unlinkresult/forbidden'); + } + } + else{ + $this->_redirect('/user/pool/index/unlinkresult/error'); + } } // creates an array of two arrays diff --git a/application/modules/user/forms/Filter.php b/application/modules/user/forms/Filter.php new file mode 100644 index 0000000..69aaf4b --- /dev/null +++ b/application/modules/user/forms/Filter.php @@ -0,0 +1,68 @@ +<?php + +class user_Form_Filter extends Zend_Form +{ + + private $bootmenus; + + public function init() + { + $this->setName("Add Filter"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'required' => false, + 'label' => 'Description:', + )); + + $bootmenufield = $this->createElement('select','bootmenuID'); + $bootmenufield ->setLabel('Bootmenu:'); + + if(count($this->bootmenus)>0){ + foreach($this->bootmenus as $id => $g){ + $bootmenufield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $bootmenufield->setRegisterInArrayValidator(false); + $this->addElement($bootmenufield); + + $this->addElement('text', 'priority', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Priority:', + )); + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/filter"' + )); + } + function setBootmenus($val){ + $this->bootmenus = $val; + return; + } + private $buttontext = 'Save'; + function setButtontext($v){ + $this->buttontext = $v; + } + + + +} + diff --git a/application/modules/user/forms/PoolClient.php b/application/modules/user/forms/PoolClient.php new file mode 100644 index 0000000..52ba7d8 --- /dev/null +++ b/application/modules/user/forms/PoolClient.php @@ -0,0 +1,30 @@ +<?php + +class user_Form_PoolClient extends Zend_Form +{ + private $clients; + + public function init() + { + $this->setName("addClientToPool"); + $this->setMethod('post'); + + $clientfield = $this->createElement('select','clientID'); + $clientfield ->setLabel('Client:'); + foreach($this->clients as $c){ + $clientfield->addMultiOption($c['clientID'],$c['macadress']." - ".$c['hardwarehash']); + } + $this->addElement($clientfield); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + } + public function setClients($clients){ + $this->clients = $clients; + return $this; + } +} + diff --git a/application/modules/user/views/scripts/filter/addfilter.phtml b/application/modules/user/views/scripts/filter/addfilter.phtml new file mode 100644 index 0000000..3c7eb9f --- /dev/null +++ b/application/modules/user/views/scripts/filter/addfilter.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->addfilterform; diff --git a/application/modules/user/views/scripts/filter/addfilterentry.phtml b/application/modules/user/views/scripts/filter/addfilterentry.phtml new file mode 100644 index 0000000..f7240c8 --- /dev/null +++ b/application/modules/user/views/scripts/filter/addfilterentry.phtml @@ -0,0 +1 @@ +<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>addfilterentry</b></center>
\ No newline at end of file diff --git a/application/modules/user/views/scripts/filter/editfilter.phtml b/application/modules/user/views/scripts/filter/editfilter.phtml new file mode 100644 index 0000000..452a096 --- /dev/null +++ b/application/modules/user/views/scripts/filter/editfilter.phtml @@ -0,0 +1 @@ +<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>editfilter</b></center>
\ No newline at end of file diff --git a/application/modules/user/views/scripts/filter/editfilterentry.phtml b/application/modules/user/views/scripts/filter/editfilterentry.phtml new file mode 100644 index 0000000..60a1f6f --- /dev/null +++ b/application/modules/user/views/scripts/filter/editfilterentry.phtml @@ -0,0 +1 @@ +<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>editfilterentry</b></center>
\ No newline at end of file diff --git a/application/modules/user/views/scripts/filter/index.phtml b/application/modules/user/views/scripts/filter/index.phtml index bace90f..94d77d7 100644 --- a/application/modules/user/views/scripts/filter/index.phtml +++ b/application/modules/user/views/scripts/filter/index.phtml @@ -1 +1,123 @@ -<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>index</b></center>
\ No newline at end of file +<h1>Filters</h1> +<?php if($this->notification != ''){echo $this->notification;} ?> +<?php echo $this->formButton('createconfig', 'Create Filter', array( + 'onclick' => 'self.location="/user/filter/addfilter"', + 'class' => 'addbutton'))?> + +<?php if ($this->filters): ?> + <table> + <tr> + <th>ID</th> + <th>Title</th> + <th>Description</th> + <th>Priority</th> + <th>TargetBootMenu</th> + <th colspan=3>Actions</th> + </tr> + <?php foreach ($this->filters as $filter): ?> + <tr class='entry'> + <td><?php echo $this->escape($filter->getID()) ?></td> + <td><?php echo $this->escape($filter->title) ?></td> + <td><?php echo $this->escape($filter->Description) ?></td> + <td><?php echo $this->escape($filter->priority) ?></td> + <td><?php echo $this->escape($filter->bootmenuID) ?></td> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'filter', + 'action' => 'editfilter', + 'filterID' => $filter->getID() + ), + 'default', + true) ?>"><img src='/media/img/edit.png' alt='Edit Filter'/></a></td> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'filter', + 'action' => 'removefilter', + 'filterID' => $filter->getID() + ), + 'default', + true) ?>"><img src='/media/img/delete.png' alt='Delete Filter'/></a></td> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'filter', + 'action' => 'addfilterentry', + 'filterID' => $filter->getID() + ), + 'default', + true) ?>"><img src='/media/img/add.png' alt='Add Filterentry'/></a></td> + </tr> + <?php + $fe = new Application_Model_FilterEntriesMapper(); + # print_a($erg = $fe->findBy('filterID',$filter->getID())); + $erg = $fe->findBy('filterID',$filter->getID()); + ?> + <?php if (count($erg)>0): ?> + <tr class=detail> + <td class=arrowtop>↳</td> + <td colspan=7> + <?php + + ?> + <table> + <tr> + <th>Filtertype</th> + <th>Value</th> + <th>Value2</th> + <th colspan=2>Actions</th> + </tr> + <?php foreach ($erg as $filterentry): ?> + + <tr> + <td><?php + + $filter2 = new Application_Model_FilterTypeMapper(); + $erg = new Application_Model_FilterType(); + $filter2->find($filterentry['filtertypeID'],$erg); + //name zur ID finden + echo "[".$filterentry['filtertypeID']."] "; + echo $erg->getFiltertypename(); + + + ?></td> + <td><?php echo $filterentry['filtervalue'];?></td> + <td><?php echo $filterentry['filtervalue2'];?></td> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'filter', + 'action' => 'editfilterentry', + 'filterentriesID' => $filterentry['filterentriesID'] + ), + 'default', + true) ?>"><img src='/media/img/edit.png' alt='Edit Filterentry'/></a> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'filter', + 'action' => 'removefilterentry', + 'filterentriesID' => $filterentry['filterentriesID'] + ), + 'default', + true) ?>"><img src='/media/img/delete.png' alt='Delete Filterentry'/></a> + </tr> + + <?php endforeach ?> + </table> + </td> + </tr> + <?php endif;?> + <?php endforeach ?> + </table> + + +<?php else: ?> + + <p>There are no filters to display.</p> + +<?php endif;?> +<?php echo $this->formButton('createconfig', 'Test Filters', array( + 'onclick' => 'self.location="/user/filter/testevaluate"', + 'class' => 'addbutton'))?> diff --git a/application/modules/user/views/scripts/filter/removefilter.phtml b/application/modules/user/views/scripts/filter/removefilter.phtml new file mode 100644 index 0000000..a46f9ec --- /dev/null +++ b/application/modules/user/views/scripts/filter/removefilter.phtml @@ -0,0 +1 @@ +<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>removefilter</b></center>
\ No newline at end of file diff --git a/application/modules/user/views/scripts/filter/removefilterentry.phtml b/application/modules/user/views/scripts/filter/removefilterentry.phtml new file mode 100644 index 0000000..dc7189d --- /dev/null +++ b/application/modules/user/views/scripts/filter/removefilterentry.phtml @@ -0,0 +1 @@ +<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>removefilterentry</b></center>
\ No newline at end of file diff --git a/application/modules/user/views/scripts/pool/index.phtml b/application/modules/user/views/scripts/pool/index.phtml index 05b880a..e1c0d7c 100644 --- a/application/modules/user/views/scripts/pool/index.phtml +++ b/application/modules/user/views/scripts/pool/index.phtml @@ -1,4 +1,5 @@ <h1>Pools</h1> +<?php if($this->notification != ''){echo $this->notification;} ?> <?php echo $this->formButton('createconfig', 'Create Pool', array( 'onclick' => 'self.location="/user/pool/createpool"', 'class' => 'addbutton'))?> @@ -14,7 +15,7 @@ </tr> <?php foreach ($this->pools as $pool): ?> <tr class=entry> - <td><?php echo $this->escape($pool->getID()) ?></td> + <!--<td><?php echo $this->escape($pool->getID()) ?></td>--> <td><?php echo $this->escape($pool->getTitle()) ?></td> <td><?php echo $this->escape($pool->getDescription()) ?></td> <td><?php echo $this->escape($pool->getLocation()) ?></td> @@ -56,7 +57,7 @@ <td colspan=6> <table> <tr> - <th>ClientID</th> + <!-- <th>ClientID</th> --> <th>Mac</th> <th>Hardwarehash</th> <th>Actions</th> @@ -64,7 +65,7 @@ <?php foreach ($clients as $client): ?> <tr> - <td><?php echo $client['clientID'];?></td> + <!-- <td><?php echo $client['clientID'];?></td> --> <?php $cli = new Application_Model_Client(); $clientMapper = new Application_Model_ClientMapper(); @@ -89,6 +90,8 @@ <?php endif;?> <?php endforeach ?> </table> + +<?php if (count($this->freeclients)>0): ?> <h2>Free clients</h2> <table > <tr> @@ -123,6 +126,7 @@ foreach ($this->freeclients as $client): ?> </tr> <?php endforeach ?> </table> +<?php endif;?> <?php else: ?> diff --git a/application/modules/user/views/scripts/pool/linkclient.phtml b/application/modules/user/views/scripts/pool/linkclient.phtml index a2f9a6c..eebe111 100644 --- a/application/modules/user/views/scripts/pool/linkclient.phtml +++ b/application/modules/user/views/scripts/pool/linkclient.phtml @@ -1 +1,2 @@ -<br /><br /><center>View script for controller <b>Pool</b> and script/action name <b>linkpool</b></center>
\ No newline at end of file +<?php +echo $this->poolclient; diff --git a/library/Pbs/Notifier.php b/library/Pbs/Notifier.php index 256aea4..1c7dfca 100644 --- a/library/Pbs/Notifier.php +++ b/library/Pbs/Notifier.php @@ -6,6 +6,20 @@ class Pbs_Notifier{ public function notify($action,$result){ switch($action){ + default: + switch($result){ + case "forbidden": + $result = "errorbox"; + break; + case "ok": + $result = "okbox"; + break; + case "error": + $result = "warningbox"; + break; + } + $result = "<div class='$result'>$action</div>"; + break; case "delete": switch($result){ case "forbidden": @@ -45,6 +59,32 @@ class Pbs_Notifier{ break; } break; + case "link": + switch($result){ + case "forbidden": + $result = "<div class='errorbox'>Not allowed to link this</div>"; + break; + case "ok": + $result = "<div class='okbox'>Link sucessful</div>"; + break; + case "error": + $result = "<div class='warningbox'>Link failed</div>"; + break; + } + break; + case "unlink": + switch($result){ + case "forbidden": + $result = "<div class='errorbox'>Not allowed to unlink this</div>"; + break; + case "ok": + $result = "<div class='okbox'>Unlink sucessful</div>"; + break; + case "error": + $result = "<div class='warningbox'>Unlink failed</div>"; + break; + } + break; } return $result; diff --git a/library/Pbs/Session.php b/library/Pbs/Session.php index 592b89c..eb7c927 100644 --- a/library/Pbs/Session.php +++ b/library/Pbs/Session.php @@ -2,7 +2,7 @@ class Pbs_Session{ - public function createsession(Application_Model_Session $session){ + public function CreateSession(Application_Model_Session $session){ $sessionmapper = new Application_Model_SessionMapper(); $uniqid = $this->getUniqueCode(10); @@ -16,6 +16,18 @@ class Pbs_Session{ $sessionmapper->find($id, $session); return $session; } + public function createClient(Application_Model_Client $client){ + $clientmapper = new Application_Model_ClientMapper(); + $result = $clientmapper->findBy('macadress',$client->getMacadress()); + if(($result)>0){ + $client->setOptions($result); + } + else{ + $id = $clientmapper->save($client); + $clientmapper->find($id, $client); + } + return $client; + } private function getUniqueCode($length = "") { $code = md5(uniqid(rand(), true)); diff --git a/pbs-newdata.sql b/pbs-newdata.sql index 9dd4624..e2e20f8 100644 --- a/pbs-newdata.sql +++ b/pbs-newdata.sql @@ -55,9 +55,9 @@ INSERT INTO `pbs_bootos` (`bootosID`, `configID`, `groupID`, `membershipID`, `ti -- Adding bootiso INSERT INTO `pbs_bootiso` (`bootisoID`, `title`, `membershipID`, `groupID`, `path_fbgui`, `serialnumber`, `created`, `expires`, `public`) VALUES -(1, 'BootIso 1', 1, 1, 'Path 1', 123456789, '1299693879', '2012-03-09', 0), -(2, 'BootIso 2', 1, 1, 'Path 2', 2147483647, '1299693899', '2012-03-09', 0), -(3, 'BootIso 3', 1, 1, 'Path 3', 2147483647, '1299693899', '2012-03-09', 0); +(1, 'BootIso 1', 1, 1, 'Path 1', 123456789, '123', '2012-03-09', 0), +(2, 'BootIso 2', 1, 1, 'Path 2', 2147483647, '456', '2012-03-09', 0), +(3, 'BootIso 3', 1, 1, 'Path 3', 2147483647, '789', '2012-03-09', 0); -- Adding Pools INSERT INTO `pbs_pool` (`poolID`, `groupID`, `title`, `description`, `location`) VALUES @@ -209,6 +209,7 @@ CREATE TABLE IF NOT EXISTS `pbs_client` ( PRIMARY KEY (`clientID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1; ALTER TABLE `pbs_client` ADD `groupID` INT NOT NULL AFTER `clientID` ; +ALTER TABLE `pbs_client` ADD UNIQUE (`macadress`); ALTER TABLE `pbs_client` ADD CONSTRAINT `pbs_client_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE; diff --git a/public/media/css/style.css b/public/media/css/style.css index 103ab3d..c9ad7e8 100644 --- a/public/media/css/style.css +++ b/public/media/css/style.css @@ -201,7 +201,7 @@ th { td { font-size: 12px; - border: 1px solid #CCC; + border: 1px solid #CCC; } .addbutton { @@ -249,6 +249,9 @@ dl.zend_form dd * { tr.entry { background-color: #FFF5CC; } +tr.entry td{ + padding-left: 3px; +} tr.detail>td { border: none; @@ -261,6 +264,7 @@ td.arrowtop { tr.detail table tr td { background-color: #E2EFE1; + padding-left: 3px; } tr td.action { @@ -326,4 +330,4 @@ td.action img { background: #FFFFFF url('/media/img/box_info.png') no-repeat; background-position: 10px center; color: #777; -}
\ No newline at end of file +} diff --git a/public/media/img/save.png b/public/media/img/save.png Binary files differindex 5cb71bd..b288a4c 100644 --- a/public/media/img/save.png +++ b/public/media/img/save.png diff --git a/public/media/img/show.png b/public/media/img/show.png Binary files differindex 2a29102..6a0dd1d 100644 --- a/public/media/img/show.png +++ b/public/media/img/show.png |
