From 75965675618c0d59ff97ed6cc8a1286d69ba1b8d Mon Sep 17 00:00:00 2001
From: Simon
Date: Fri, 18 Mar 2011 11:26:43 +0100
Subject: PoolController fertig
---
.../modules/user/controllers/ClientController.php | 147 +++++++++++----------
.../modules/user/controllers/PoolController.php | 135 ++++++++++++++++---
application/modules/user/forms/PoolClient.php | 30 +++++
.../modules/user/views/scripts/pool/index.phtml | 7 +-
.../user/views/scripts/pool/linkclient.phtml | 3 +-
5 files changed, 231 insertions(+), 91 deletions(-)
create mode 100644 application/modules/user/forms/PoolClient.php
(limited to 'application/modules')
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php
index bf64102..d40e1b1 100644
--- a/application/modules/user/controllers/ClientController.php
+++ b/application/modules/user/controllers/ClientController.php
@@ -46,88 +46,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/PoolController.php b/application/modules/user/controllers/PoolController.php
index 01b5a2a..7ff4da1 100644
--- a/application/modules/user/controllers/PoolController.php
+++ b/application/modules/user/controllers/PoolController.php
@@ -29,7 +29,16 @@ 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();
@@ -70,7 +79,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 +104,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 +154,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/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 @@
+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/pool/index.phtml b/application/modules/user/views/scripts/pool/index.phtml
index 05b880a..8ebabe8 100644
--- a/application/modules/user/views/scripts/pool/index.phtml
+++ b/application/modules/user/views/scripts/pool/index.phtml
@@ -1,4 +1,5 @@
- | escape($pool->getID()) ?> |
+
escape($pool->getTitle()) ?> |
escape($pool->getDescription()) ?> |
escape($pool->getLocation()) ?> |
@@ -56,7 +57,7 @@
- | ClientID |
+
Mac |
Hardwarehash |
Actions |
@@ -64,7 +65,7 @@
- |
+
View script for controller Pool and script/action name linkpool
\ No newline at end of file
+poolclient;
--
cgit v1.2.3-55-g7522
From 01fb4ed21df32100b28f63bc37b76c4083582ffd Mon Sep 17 00:00:00 2001
From: Simon
Date: Fri, 18 Mar 2011 12:03:50 +0100
Subject: Ansicht von Pools geändert
---
application/modules/user/views/scripts/pool/index.phtml | 3 +++
public/media/css/style.css | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
(limited to 'application/modules')
diff --git a/application/modules/user/views/scripts/pool/index.phtml b/application/modules/user/views/scripts/pool/index.phtml
index 8ebabe8..e1c0d7c 100644
--- a/application/modules/user/views/scripts/pool/index.phtml
+++ b/application/modules/user/views/scripts/pool/index.phtml
@@ -90,6 +90,8 @@
+
+freeclients)>0): ?>
Free clients
@@ -124,6 +126,7 @@ foreach ($this->freeclients as $client): ?>
+
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
+}
--
cgit v1.2.3-55-g7522
From 5139008cee049b2ab24b870a263996fe9043adeb Mon Sep 17 00:00:00 2001
From: Simon
Date: Fri, 18 Mar 2011 18:49:30 +0100
Subject: User-Oberfläche, FBGui-Oberfläche legt Session&Clients an - für
Kiosk-System apache-default zum ersetzen, damit server von außen erreichbar
ist FilterController weitergearbeitet
---
.zfproject.xml | 25 +++++
apache-default | 36 ++++++
application/controllers/IndexController.php | 11 ++
.../modules/dev/controllers/FilterController.php | 11 +-
.../modules/fbgui/controllers/IndexController.php | 49 ++++++--
.../modules/user/controllers/ClientController.php | 4 +
.../modules/user/controllers/FilterController.php | 103 ++++++++++++++++-
.../modules/user/controllers/PoolController.php | 14 ++-
application/modules/user/forms/Filter.php | 68 +++++++++++
.../user/views/scripts/filter/addfilter.phtml | 2 +
.../user/views/scripts/filter/addfilterentry.phtml | 1 +
.../user/views/scripts/filter/editfilter.phtml | 1 +
.../views/scripts/filter/editfilterentry.phtml | 1 +
.../modules/user/views/scripts/filter/index.phtml | 124 ++++++++++++++++++++-
.../user/views/scripts/filter/removefilter.phtml | 1 +
.../views/scripts/filter/removefilterentry.phtml | 1 +
library/Pbs/Notifier.php | 14 +++
library/Pbs/Session.php | 14 ++-
pbs-newdata.sql | 6 +-
pbs.sql | 1 +
20 files changed, 462 insertions(+), 25 deletions(-)
create mode 100644 apache-default
create mode 100644 application/modules/user/forms/Filter.php
create mode 100644 application/modules/user/views/scripts/filter/addfilter.phtml
create mode 100644 application/modules/user/views/scripts/filter/addfilterentry.phtml
create mode 100644 application/modules/user/views/scripts/filter/editfilter.phtml
create mode 100644 application/modules/user/views/scripts/filter/editfilterentry.phtml
create mode 100644 application/modules/user/views/scripts/filter/removefilter.phtml
create mode 100644 application/modules/user/views/scripts/filter/removefilterentry.phtml
(limited to 'application/modules')
diff --git a/.zfproject.xml b/.zfproject.xml
index 22ccca6..90d4d20 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -252,6 +252,12 @@
+
+
+
+
+
+
@@ -267,6 +273,7 @@
+
@@ -334,6 +341,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apache-default b/apache-default
new file mode 100644
index 0000000..95d0580
--- /dev/null
+++ b/apache-default
@@ -0,0 +1,36 @@
+
+ ServerAdmin webmaster@localhost
+
+DocumentRoot /tmp/pbs2/public
+
+ Options FollowSymLinks
+ AllowOverride All
+
+
+
+ ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
+
+ AllowOverride None
+ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
+ Order allow,deny
+ Allow from all
+
+
+ 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/"
+
+ Options Indexes MultiViews FollowSymLinks
+ AllowOverride None
+ Order deny,allow
+ Deny from all
+ Allow from 127.0.0.0/255.0.0.0 ::1/128
+
+
+
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 "Welcome";
+ print_a('Session is now set','Your alphasessionID is '.$session->getAlphasessionID());
+ $this->_redirect('/dev/bootmenu/index/bootmenuid/1');
+ }
+ else{
+ echo "Not Welcome";
+ print_a($_POST);
+ }
+ die();
}
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php
index d40e1b1..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();
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 7ff4da1..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);
@@ -41,7 +46,14 @@ class User_PoolController extends Zend_Controller_Action
}
$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();
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 @@
+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/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 @@
+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 @@
+
View script for controller Filter and script/action name addfilterentry
\ 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 @@
+
View script for controller Filter and script/action name editfilter
\ 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 @@
+
View script for controller Filter and script/action name editfilterentry
\ 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 @@
-
View script for controller Filter and script/action name index
\ No newline at end of file
+Filters
+notification != ''){echo $this->notification;} ?>
+formButton('createconfig', 'Create Filter', array(
+ 'onclick' => 'self.location="/user/filter/addfilter"',
+ 'class' => 'addbutton'))?>
+
+filters): ?>
+
+
+ | ID |
+ Title |
+ Description |
+ Priority |
+ TargetBootMenu |
+ Actions |
+
+ filters as $filter): ?>
+
+ | escape($filter->getID()) ?> |
+ escape($filter->title) ?> |
+ escape($filter->Description) ?> |
+ escape($filter->priority) ?> |
+ escape($filter->bootmenuID) ?> |
+  |
+  |
+  |
+
+ findBy('filterID',$filter->getID()));
+ $erg = $fe->findBy('filterID',$filter->getID());
+ ?>
+ 0): ?>
+
+ | ↳ |
+
+
+
+
+ | Filtertype |
+ Value |
+ Value2 |
+ Actions |
+
+
+
+
+ | find($filterentry['filtertypeID'],$erg);
+ //name zur ID finden
+ echo "[".$filterentry['filtertypeID']."] ";
+ echo $erg->getFiltertypename();
+
+
+ ?> |
+ |
+ |
+
+ |
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+ There are no filters to display.
+
+
+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 @@
+
View script for controller Filter and script/action name removefilter
\ 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 @@
+
View script for controller Filter and script/action name removefilterentry
\ No newline at end of file
diff --git a/library/Pbs/Notifier.php b/library/Pbs/Notifier.php
index 23fec57..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 = "$action ";
+ break;
case "delete":
switch($result){
case "forbidden":
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 a412195..1490fd5 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`, `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
diff --git a/pbs.sql b/pbs.sql
index 58c21b2..76bfc9c 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -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;
--
cgit v1.2.3-55-g7522
|