From b99d7a884edabd9e5d297c8117ee7552ca702b96 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 16 Mar 2011 13:01:28 +0100 Subject: Arbeiten am Clientcontroller, Membership in Auth gesetzt --- application/modules/dev/layouts/dev.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/modules/dev') diff --git a/application/modules/dev/layouts/dev.phtml b/application/modules/dev/layouts/dev.phtml index 2c7f6f0..b911944 100644 --- a/application/modules/dev/layouts/dev.phtml +++ b/application/modules/dev/layouts/dev.phtml @@ -22,7 +22,7 @@ echo $this->headScript()."\n";
| ID | +GroupID | MAC | Hardwarehash | Actions | @@ -14,6 +15,7 @@ clients as $client): ?>||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| escape($client->getID()) ?> | +escape($client->getGroupID()) ?> | escape($client->getMacadress()) ?> | escape($client->getHardwarehash()) ?> | Not allowed to delete this";
+ break;
+ case "ok":
+ echo " Delete sucessful ";
+ break;
+ case "error":
+ echo "There was an error deleting ";
+ break;
+ }
+ $clientMapper = new Application_Model_ClientMapper();
+ $clientsInGroup = $clientMapper->findBy('groupID',$this->membership->getGroupID());
+ # print_a($clientsInGroup);
+
+ $this->view->clients = $clientsInGroup;
}
@@ -34,6 +43,23 @@ class User_ClientController extends Zend_Controller_Action
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/result/ok');
+ }
+ else{
+ $this->_redirect('/user/client/index/result/forbidden');
+ }
+ }
+ $this->_redirect('/user/client/index/result/error');
// action body
}
diff --git a/application/modules/user/views/scripts/client/index.phtml b/application/modules/user/views/scripts/client/index.phtml
index 4f0e6ec..e79b208 100644
--- a/application/modules/user/views/scripts/client/index.phtml
+++ b/application/modules/user/views/scripts/client/index.phtml
@@ -1 +1,41 @@
-Clients+formButton('createbootos', 'Create Client', array( + 'onclick' => 'self.location="/user/client/addclient"', + 'class' => 'addbutton'))?> + +clients): ?> +
There are no clients to display. + diff --git a/application/modules/user/views/scripts/index/index.phtml b/application/modules/user/views/scripts/index/index.phtml index 77e0720..a6e84a7 100644 --- a/application/modules/user/views/scripts/index/index.phtml +++ b/application/modules/user/views/scripts/index/index.phtml @@ -1,9 +1,9 @@Welcome-text;?>
-text;?>
-text;?>
-text;?>
+infobox: text;?>
+okbox: text;?>
+warningbox: text;?>
+errorbox: text;?>
links);?>
links)>0 && is_array($this->links)): ?>
diff --git a/library/Pbs/PbsNotifier.php b/library/Pbs/PbsNotifier.php
new file mode 100644
index 0000000..b079f2d
--- /dev/null
+++ b/library/Pbs/PbsNotifier.php
@@ -0,0 +1,27 @@
+
diff --git a/pbs-newdata.sql b/pbs-newdata.sql
index 7f4b958..c309a54 100644
--- a/pbs-newdata.sql
+++ b/pbs-newdata.sql
@@ -20,17 +20,17 @@ INSERT INTO `pbs`.`pbs_membership` (`membershipID`, `groupID`, `roleID`, `person
INSERT INTO `pbs`.`pbs_membership` (`membershipID`, `groupID`, `roleID`, `personID`) VALUES (2, '1', '2', '2');
-- Adding clients
-INSERT INTO `pbs_client` (`clientID`, `macadress`, `hardwarehash`) VALUES
-(1, '00:00:00:00:00:10', 'ea9b82d9de911bc2d3cd23f53a6cab48'),
-(2, '00:00:00:00:10:00', '1e2b1599710fbbef0dc789e8cfe12455'),
-(3, '00:00:00:10:10:00', '8f6209ca3d6b35e223a11c249d1b69fc'),
-(4, '00:00:10:00:00:00', 'e17ab09f3586464f19629e2e8b1e9a9d'),
-(5, '00:10:00:00:00:00', '9bf70279d283b85440c2031c19bb6812'),
-(6, '10:00:00:00:00:00', 'ad3bce4464a6267441ec144744439c7e'),
-(7, '00:55:00:55:00:55', 'e8d7e80d79f224771b7a3a0af4e02748'),
-(8, '66:00:66:00:66:00', 'ded66ce272f384e9e386c1b57ded3e4d'),
-(9, '00:ff:ff:ff:ff:ff', '695610ee509c060b1fca9c8011529af4'),
-(10, '00:22:00:22:00:22', 'a3562c8cad2a4fa4fc11656025dc911b');
+INSERT INTO `pbs_client` (`clientID`, `groupID`,`macadress`, `hardwarehash`) VALUES
+(1, 1, '00:00:00:00:00:10', 'ea9b82d9de911bc2d3cd23f53a6cab48'),
+(2, 1, '00:00:00:00:10:00', '1e2b1599710fbbef0dc789e8cfe12455'),
+(3, 1, '00:00:00:10:10:00', '8f6209ca3d6b35e223a11c249d1b69fc'),
+(4, 1, '00:00:10:00:00:00', 'e17ab09f3586464f19629e2e8b1e9a9d'),
+(5, 1, '00:10:00:00:00:00', '9bf70279d283b85440c2031c19bb6812'),
+(6, 1, '10:00:00:00:00:00', 'ad3bce4464a6267441ec144744439c7e'),
+(7, 1, '00:55:00:55:00:55', 'e8d7e80d79f224771b7a3a0af4e02748'),
+(8, 1, '66:00:66:00:66:00', 'ded66ce272f384e9e386c1b57ded3e4d'),
+(9, 1, '00:ff:ff:ff:ff:ff', '695610ee509c060b1fca9c8011529af4'),
+(10, 1, '00:22:00:22:00:22', 'a3562c8cad2a4fa4fc11656025dc911b');
-- Adding config
INSERT INTO `pbs_config` (`configID`, `title`, `groupID`, `membershipID`, `shellscript`, `created`) VALUES
diff --git a/pbs.sql b/pbs.sql
index 4373267..12e00f6 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -208,6 +208,9 @@ CREATE TABLE IF NOT EXISTS `pbs_client` (
`hardwarehash` varchar(32),
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 CONSTRAINT `pbs_client_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;
CREATE TABLE IF NOT EXISTS `pbs_session` (
`sessionID` int(11) NOT NULL AUTO_INCREMENT,
@@ -225,6 +228,7 @@ ALTER TABLE `pbs_session` ADD `alphasessionID` VARCHAR( 16 ) NOT NULL AFTER `ses
ALTER TABLE `pbs_session` ADD `bootmenuentryID` INT AFTER `clientID` ;
ALTER TABLE `pbs_session` ADD `membershipID` INT NULL AFTER `bootisoID` ;
+
ALTER TABLE `pbs_session`
ADD CONSTRAINT `pbs_session_ibfk_1` FOREIGN KEY (`clientID`) REFERENCES `pbs_client` (`clientID`) ON DELETE CASCADE,
ADD CONSTRAINT `pbs_session_ibfk_2` FOREIGN KEY (`bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE CASCADE,
diff --git a/public/media/css/style.css b/public/media/css/style.css
index 57b3552..8390fb2 100644
--- a/public/media/css/style.css
+++ b/public/media/css/style.css
@@ -237,7 +237,7 @@ td.action img{border:none;}
.footer{text-align:right;font-size:10px;font-family:Verdana, Arial;padding:10px 0px 10px 0px;}
/* boxes */
-.checkbox, .warningbox, .errorbox, .infobox {
+.okbox, .warningbox, .errorbox, .infobox {
margin:10px 0px;
padding:10px 10px 10px 40px;
border-width:1px;
@@ -259,7 +259,7 @@ td.action img{border:none;}
background: #FF9999 url('/media/img/box_error.png') no-repeat;
background-position:10px center;
}
-.checkbox{
+.okbox{
border:1px solid #339933;
background: #BBFFBB url('/media/img/box_check.png') no-repeat;
background-position:10px center;
--
cgit v1.2.3-55-g7522
From 7bb045fa152dec51a75f1ba8c45c016ba96c587c Mon Sep 17 00:00:00 2001
From: Simon Franz
Date: Wed, 16 Mar 2011 16:19:28 +0100
Subject: ClientController geändert, Forms können in FBGui und User nicht
benutzt werden
---
.zfproject.xml | 1 +
application/Bootstrap.php | 3 +-
.../modules/dev/controllers/ClientController.php | 2 +-
.../modules/user/controllers/ClientController.php | 55 +++++++++++++++-------
application/modules/user/forms/Client.php | 46 ++++++++++++++++++
.../user/views/scripts/client/addclient.phtml | 4 +-
.../user/views/scripts/client/editclient.phtml | 4 +-
.../modules/user/views/scripts/client/index.phtml | 1 +
library/Pbs/Notifier.php | 54 +++++++++++++++++++++
9 files changed, 147 insertions(+), 23 deletions(-)
create mode 100644 application/modules/user/forms/Client.php
create mode 100644 library/Pbs/Notifier.php
(limited to 'application/modules/dev')
diff --git a/.zfproject.xml b/.zfproject.xml
index 5724941..c0eba40 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -264,6 +264,7 @@
Not allowed to delete this ";
- break;
- case "ok":
- echo "Delete sucessful ";
- break;
- case "error":
- echo "There was an error deleting ";
- break;
+ $result = $this->_request->getParam('deleteresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('delete',$result);
}
$clientMapper = new Application_Model_ClientMapper();
$clientsInGroup = $clientMapper->findBy('groupID',$this->membership->getGroupID());
@@ -53,19 +46,45 @@ class User_ClientController extends Zend_Controller_Action
if($client->getGroupID() == $this->membership->getGroupID()){
$clientMapper = new Application_Model_ClientMapper();
$clientMapper->delete($client);
- $this->_redirect('/user/client/index/result/ok');
+ $this->_redirect('/user/client/index/deleteresult/ok');
}
else{
- $this->_redirect('/user/client/index/result/forbidden');
+ $this->_redirect('/user/client/index/deleteresult/forbidden');
}
}
- $this->_redirect('/user/client/index/result/error');
- // action body
+ $this->_redirect('/user/client/index/deleteresult/error');
}
- public function editclientAction()
- {
- // action body
+ public function editclientAction(){
+
+ 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()){
+ # print_a($this);die();
+ $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','groups'=>$groups),$_POST);
+ if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) {
+ $client = new Application_Model_Client($_POST);
+ $client->setID($this->_request->getParam('clientID'));
+ $clientmapper = new Application_Model_ClientMapper();
+ $clientmapper->save($client);
+ print_a('updated');
+ $this->_redirect('/dev/client');
+ }
+ $this->view->editclient = $editclient;
+ }
}
diff --git a/application/modules/user/forms/Client.php b/application/modules/user/forms/Client.php
new file mode 100644
index 0000000..a79ede1
--- /dev/null
+++ b/application/modules/user/forms/Client.php
@@ -0,0 +1,46 @@
+setName("pool");
+ $this->setMethod('post');
+
+ $this->addElement('text', 'macadress', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'MacAdress:',
+ ));
+ $this->addElement('text', 'hardwarehash', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Hardwarehash:',
+ ));
+
+ $this->addElement('submit', 'add', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => $this->buttontext,
+ ));
+
+ $this->addElement('button', 'Cancel', array(
+ 'onclick' => 'self.location="/user/client"'
+ ));
+ }
+ private $buttontext = 'Save';
+ private $groups;
+ function setButtontext($v){
+ $this->buttontext = $v;
+ }
+
+
+}
+
diff --git a/application/modules/user/views/scripts/client/addclient.phtml b/application/modules/user/views/scripts/client/addclient.phtml
index 9d1c04e..13511fb 100644
--- a/application/modules/user/views/scripts/client/addclient.phtml
+++ b/application/modules/user/views/scripts/client/addclient.phtml
@@ -1 +1,3 @@
-Clients+notification != ''){echo $this->notification;} ?> formButton('createbootos', 'Create Client', array( 'onclick' => 'self.location="/user/client/addclient"', 'class' => 'addbutton'))?> diff --git a/library/Pbs/Notifier.php b/library/Pbs/Notifier.php new file mode 100644 index 0000000..f2f889b --- /dev/null +++ b/library/Pbs/Notifier.php @@ -0,0 +1,54 @@ +Not allowed to delete this"; + break; + case "ok": + $result = "Delete sucessful ";
+ break;
+ case "error":
+ $result = "Delete failed ";
+ break;
+ }
+ break;
+ case "modify":
+ switch($result){
+ case "forbidden":
+ $result = "Not allowed to modify this ";
+ break;
+ case "ok":
+ $result = "Modify sucessful ";
+ break;
+ case "error":
+ $result = "Modify failed ";
+ break;
+ }
+ break;
+ case "create":
+ switch($result){
+ case "forbidden":
+ $result = "Not allowed to create this ";
+ break;
+ case "ok":
+ $result = "Creation sucessful ";
+ break;
+ case "error":
+ $result = "Creation failed ";
+ break;
+ }
+ break;
+ }
+ return $result;
+
+ }
+}
+
+?>
--
cgit v1.2.3-55-g7522
| ||||||||