summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon2011-03-07 13:57:04 +0100
committerSimon2011-03-07 13:57:04 +0100
commit5688b750744f8568414dc745961747e5629bd194 (patch)
treed8821314ada6f422d3d362666e7060af502709a3
parentview variable in application.ini hinzugefügt (diff)
downloadpbs2-5688b750744f8568414dc745961747e5629bd194.tar.gz
pbs2-5688b750744f8568414dc745961747e5629bd194.tar.xz
pbs2-5688b750744f8568414dc745961747e5629bd194.zip
Pool actions zum bearbeiten von Pools hinzugefügt
-rw-r--r--.zfproject.xml9
-rw-r--r--application/controllers/PoolController.php84
-rw-r--r--application/forms/Pool.php44
-rw-r--r--application/models/PoolEntries.php11
-rw-r--r--application/models/PoolEntriesMapper.php12
-rw-r--r--application/models/PoolMapper.php7
-rw-r--r--application/views/scripts/pool/createpool.phtml3
-rw-r--r--application/views/scripts/pool/editpool.phtml5
-rw-r--r--application/views/scripts/pool/index.phtml28
-rw-r--r--application/views/scripts/pool/linkclient.phtml1
-rw-r--r--application/views/scripts/pool/unlinkclient.phtml1
-rw-r--r--pbs.sql1
12 files changed, 190 insertions, 16 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index 69a753a..b36ab70 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -64,6 +64,8 @@
<actionMethod actionName="createpool"/>
<actionMethod actionName="deletepool"/>
<actionMethod actionName="editpool"/>
+ <actionMethod actionName="linkclient"/>
+ <actionMethod actionName="unlinkclient"/>
</controllerFile>
<controllerFile controllerName="Bootiso">
<actionMethod actionName="index"/>
@@ -88,6 +90,7 @@
<formFile formName="BootmenuEntriesEdit"/>
<formFile formName="BootisoCreate"/>
<formFile formName="BootisoEdit"/>
+ <formFile formName="Pool"/>
</formsDirectory>
<layoutsDirectory enabled="false"/>
<modelsDirectory>
@@ -271,6 +274,12 @@
<viewControllerScriptsDirectory forControllerName="Bootiso">
<viewScriptFile forActionName="editbootiso"/>
</viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Pool">
+ <viewScriptFile forActionName="linkclient"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Pool">
+ <viewScriptFile forActionName="unlinkclient"/>
+ </viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php
index f9e54be..27e81a3 100644
--- a/application/controllers/PoolController.php
+++ b/application/controllers/PoolController.php
@@ -11,24 +11,98 @@ class PoolController extends Zend_Controller_Action
public function indexAction()
{
$poolMapper = new Application_Model_PoolMapper();
- $this->view->pools = $poolMapper->fetchAll();
+ $this->view->pools = $poolMapper->fetchAll();
}
public function createpoolAction()
{
- // action body
+ if (!isset($_POST["add"])){
+ $addfilterform = new Application_Form_Pool();
+ $this->view->addpool = $addfilterform;
+ }else {
+ $addpoolform = new Application_Form_Pool($_POST);
+ if ($addpoolform->isValid($_POST)) {
+ try{
+ $pool = new Application_Model_Pool($_POST);
+ $poolmapper = new Application_Model_PoolMapper();
+ $poolmapper->save($pool);
+ $this->_redirect('/pool');
+ return;
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
+ }
}
public function deletepoolAction()
{
- // action body
+ $poolID = $this->_request->getParam('poolID');
+ // TODO: ACL implementieren ob er den pool löschen darf
+ if(is_numeric($poolID)){
+ $deletepool = new Application_Model_Pool();
+ $deletepool->setID($poolID);
+ $poolmapper = new Application_Model_PoolMapper();
+ $poolmapper->delete($deletepool);
+ }
+ $this->_redirect('/pool');
}
public function editpoolAction()
{
+ if (!isset($_POST["add"])){
+ $poolID = $this->_request->getParam('poolID');
+
+ $pool = new Application_Model_Pool();
+ $poolmapper = new Application_Model_PoolMapper();
+ $poolmapper->find($poolID,$pool);
+ $poolArray = $pool->toArray();
+
+ $editpool = new Application_Form_Pool();
+ $editpool->populate($poolArray);
+ $this->view->editpoolform = $editpool;
+
+ }else {
+ $addpoolform = new Application_Form_Pool($_POST);
+ if ($addpoolform->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('/pool');
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
+ }
+ }
+
+ public function linkclientAction()
+ {
// action body
}
+ public function unlinkclientAction()
+ {
+ $poolentriesID = $this->_request->getParam('poolentriesID');
+
+ // TODO: ACL implementieren ob er den filter löschen darf
+ if(is_numeric($poolentriesID)){
+ $deletepoolentries = new Application_Model_PoolEntries();
+ $deletepoolentries->setID($poolentriesID);
+ echo "<pre style='border:1px solid black;background-color:#F5B800'>";
+ print_r($deletepoolentries);
+ echo "</pre>";
+
+ $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper();
+ $deletepoolentriesmapper->delete($deletepoolentries);
+ echo "ok";
+ }
+# echo "ready";
+ $this->_redirect('/pool');
+ }
+
}
@@ -38,3 +112,7 @@ class PoolController extends Zend_Controller_Action
+
+
+
+
diff --git a/application/forms/Pool.php b/application/forms/Pool.php
new file mode 100644
index 0000000..0cef533
--- /dev/null
+++ b/application/forms/Pool.php
@@ -0,0 +1,44 @@
+<?php
+
+class Application_Form_Pool extends Zend_Form
+{
+
+ public function init()
+ {
+ $this->setName("pool");
+ $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:',
+ ));
+ // TODO: Add target of Filter
+
+ $this->addElement('text', 'location', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Location:',
+ ));
+
+ $this->addElement('submit', 'add', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Save',
+ ));
+ }
+
+
+}
+
diff --git a/application/models/PoolEntries.php b/application/models/PoolEntries.php
index 31caf5f..102dc9d 100644
--- a/application/models/PoolEntries.php
+++ b/application/models/PoolEntries.php
@@ -2,6 +2,7 @@
class Application_Model_PoolEntries
{
+ protected $_poolentriesID;
protected $_poolID;
protected $_clientID;
@@ -42,7 +43,15 @@ class Application_Model_PoolEntries
return $this;
}
-
+ public function getID()
+ {
+ return $this->_poolentriesID;
+ }
+ public function setID($_poolentriesID)
+ {
+ $this->_poolentriesID = $_poolentriesID;
+ return $this;
+ }
public function getPoolID()
{
return $this->_poolID;
diff --git a/application/models/PoolEntriesMapper.php b/application/models/PoolEntriesMapper.php
index 5d92f4c..d730fb8 100644
--- a/application/models/PoolEntriesMapper.php
+++ b/application/models/PoolEntriesMapper.php
@@ -32,13 +32,13 @@ class Application_Model_PoolEntriesMapper
public function save(Application_Model_PoolEntries $polentries)
{
- $data = array('poolID'=> $polentries->getPoolID() ,'clientID'=> $polentries->getClientID() );
+ $data = array('poolentriesID' => $polentries->getID(), 'poolID'=> $polentries->getPoolID() ,'clientID'=> $polentries->getClientID() );
if (null === ($id = $polentries->getID()) ) {
- unset($data['polentriesID']);
+ unset($data['poolentriesID']);
$this->getDbTable()->insert($data);
} else {
- $this->getDbTable()->update($data, array('polentriesID = ?' => $id));
+ $this->getDbTable()->update($data, array('poolentriesID = ?' => $id));
}
}
@@ -47,7 +47,7 @@ class Application_Model_PoolEntriesMapper
if (null === ($id = $polentries->getID()) ) {
return;
} else {
- $this->getDbTable()->delete(array('polentriesID = ?' => $id));
+ $this->getDbTable()->delete(array('poolentriesID = ?' => $id));
}
}
@@ -60,7 +60,7 @@ class Application_Model_PoolEntriesMapper
$row = $result->current();
- $polentries->setPoolID($row->poolID)->setClientID($row->clientID);
+ $polentries->setID($row->poolentriesID)->setPoolID($row->poolID)->setClientID($row->clientID);
}
public function fetchAll()
@@ -70,7 +70,7 @@ class Application_Model_PoolEntriesMapper
foreach ($resultSet as $row) {
$entry = new Application_Model_PoolEntries();
- $entry->setPoolID($row->poolID)->setClientID($row->clientID);
+ $entry->setID($row->poolentriesID)->setPoolID($row->poolID)->setClientID($row->clientID);
$entries[] = $entry;
}
diff --git a/application/models/PoolMapper.php b/application/models/PoolMapper.php
index e2d351a..be096b7 100644
--- a/application/models/PoolMapper.php
+++ b/application/models/PoolMapper.php
@@ -31,7 +31,7 @@ class Application_Model_PoolMapper
public function save(Application_Model_Pool $pol)
{
-
+ print_a($pol);
$data = array('poolID'=> $pol->getID() ,
'title'=> $pol->getTitle() ,
'description'=> $pol->getDescription() ,
@@ -63,7 +63,10 @@ class Application_Model_PoolMapper
$row = $result->current();
- $pol->setID($row->poolID)->setTitle($row->title)->setDescription($row->description)->setLocation($row->location);
+ $pol->setID($row->poolID)
+ ->setTitle($row->title)
+ ->setDescription($row->description)
+ ->setLocation($row->location);
}
public function fetchAll()
diff --git a/application/views/scripts/pool/createpool.phtml b/application/views/scripts/pool/createpool.phtml
index 3d7f8ca..305b36e 100644
--- a/application/views/scripts/pool/createpool.phtml
+++ b/application/views/scripts/pool/createpool.phtml
@@ -1 +1,2 @@
-<br /><br /><center>View script for controller <b>Pool</b> and script/action name <b>createpool</b></center> \ No newline at end of file
+<?php
+echo $this->addpool;
diff --git a/application/views/scripts/pool/editpool.phtml b/application/views/scripts/pool/editpool.phtml
index c70464e..359a5f9 100644
--- a/application/views/scripts/pool/editpool.phtml
+++ b/application/views/scripts/pool/editpool.phtml
@@ -1 +1,4 @@
-<br /><br /><center>View script for controller <b>Pool</b> and script/action name <b>editpool</b></center> \ No newline at end of file
+<h1>Edit Pool</h1>
+<?php
+
+echo $this->editpoolform;
diff --git a/application/views/scripts/pool/index.phtml b/application/views/scripts/pool/index.phtml
index 989cf41..1bee0fe 100644
--- a/application/views/scripts/pool/index.phtml
+++ b/application/views/scripts/pool/index.phtml
@@ -1,5 +1,13 @@
<h1>Pools</h1>
+<a href="<?php echo $this->url(
+ array(
+ 'controller' => 'pool',
+ 'action' => 'createpool'
+ ),
+ 'default',
+ true) ?>">create pool</a>
+
<?php if ($this->pools): ?>
<!-- A table of filters. -->
@@ -19,11 +27,27 @@
<td><a href="<?php echo $this->url(
array(
'controller' => 'pool',
- 'action' => 'removepool',
+ 'action' => 'editpool',
+ 'poolID' => $pool->getID()
+ ),
+ 'default',
+ true) ?>">edit pool</a></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'pool',
+ 'action' => 'deletepool',
+ 'poolID' => $pool->getID()
+ ),
+ 'default',
+ true) ?>">delete pool</a></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'pool',
+ 'action' => 'linkclient',
'poolID' => $pool->getID()
),
'default',
- true) ?>">remove pool</a></td>
+ true) ?>">link client</a></td>
</tr>
<?php endforeach ?>
</table>
diff --git a/application/views/scripts/pool/linkclient.phtml b/application/views/scripts/pool/linkclient.phtml
new file mode 100644
index 0000000..1cc06e4
--- /dev/null
+++ b/application/views/scripts/pool/linkclient.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Pool</b> and script/action name <b>linkclient</b></center> \ No newline at end of file
diff --git a/application/views/scripts/pool/unlinkclient.phtml b/application/views/scripts/pool/unlinkclient.phtml
new file mode 100644
index 0000000..35aa9c5
--- /dev/null
+++ b/application/views/scripts/pool/unlinkclient.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Pool</b> and script/action name <b>unlinkclient</b></center> \ No newline at end of file
diff --git a/pbs.sql b/pbs.sql
index aa2d14c..7ec6eaa 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -230,6 +230,7 @@ CREATE TABLE IF NOT EXISTS `pbs_poolentries` (
KEY `poolID` (`poolID`),
KEY `clientID` (`clientID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
+ALTER TABLE `pbs_poolentries` ADD `poolentriesID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
ALTER TABLE `pbs_poolentries`
ADD CONSTRAINT `pbs_poolentries_ibfk_1` FOREIGN KEY (`poolID`) REFERENCES `pbs_pool` (`poolID`) ON DELETE CASCADE,