diff options
| author | michael pereira | 2011-03-04 03:21:32 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-04 03:21:32 +0100 |
| commit | e2db1dc442e9f28fe666537a8af024c810912bb4 (patch) | |
| tree | de16d36dff50a950dd963788689e18576a6db02f | |
| parent | Inserted deleteForm (diff) | |
| parent | Änderungen an den Filtern (diff) | |
| download | pbs2-e2db1dc442e9f28fe666537a8af024c810912bb4.tar.gz pbs2-e2db1dc442e9f28fe666537a8af024c810912bb4.tar.xz pbs2-e2db1dc442e9f28fe666537a8af024c810912bb4.zip | |
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Conflicts:
.zfproject.xml
| -rw-r--r-- | .zfproject.xml | 13 | ||||
| -rw-r--r-- | application/configs/application.ini | 2 | ||||
| -rw-r--r-- | application/controllers/AuthController.php | 70 | ||||
| -rw-r--r-- | application/controllers/FilterController.php | 75 | ||||
| -rw-r--r-- | application/forms/FilterAdd.php | 19 | ||||
| -rw-r--r-- | application/views/scripts/auth/delete.phtml | 5 | ||||
| -rw-r--r-- | application/views/scripts/filter/editfilter.phtml | 1 | ||||
| -rw-r--r-- | application/views/scripts/filter/index.phtml | 10 | ||||
| -rw-r--r-- | application/views/scripts/filter/removefilter.phtml | 1 | ||||
| -rw-r--r-- | createDefaultMapper/mappertemplate | 13 | ||||
| -rw-r--r-- | simonFilterSqlTests.sql | 6 |
11 files changed, 171 insertions, 44 deletions
diff --git a/.zfproject.xml b/.zfproject.xml index be15633..ad4a683 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -25,6 +25,9 @@ </controllerFile> <controllerFile controllerName="Filter"> <actionMethod actionName="index"/> + <actionMethod actionName="addfilter"/> + <actionMethod actionName="removefilter"/> + <actionMethod actionName="editfilter"/> </controllerFile> </controllersDirectory> <formsDirectory> @@ -33,6 +36,7 @@ <formFile formName="PersonRegister"/> <formFile formName="FilterCreate"/> <formFile formName="AuthDelete"/> + <formFile formName="FilterAdd"/> </formsDirectory> <layoutsDirectory enabled="false"/> <modelsDirectory> @@ -138,6 +142,15 @@ <viewControllerScriptsDirectory forControllerName="Filter"> <viewScriptFile forActionName="index"/> </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="addfilter"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="removefilter"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Filter"> + <viewScriptFile forActionName="editfilter"/> + </viewControllerScriptsDirectory> </viewScriptsDirectory> <viewHelpersDirectory/> <viewFiltersDirectory enabled="false"/> diff --git a/application/configs/application.ini b/application/configs/application.ini index 9bfaec2..6970da3 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -10,7 +10,7 @@ resources.frontController.params.displayExceptions = 0 resources.db.adapter = PDO_MYSQL resources.db.params.host = localhost resources.db.params.username = root -resources.db.params.password = 123456 +resources.db.params.password = lsfks resources.db.params.dbname = pbs resources.db.isDefaultTableAdapter = true diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php index 4264e7b..fd30d82 100644 --- a/application/controllers/AuthController.php +++ b/application/controllers/AuthController.php @@ -3,10 +3,14 @@ class AuthController extends Zend_Controller_Action { - public function loginAction() + public function init() { - $db = Zend_Db_Table::getDefaultAdapter(); - + $db = Zend_Db_Table::getDefaultAdapter(); + + } + + public function loginAction() + { if (!isset($_POST["login"])){ $loginForm = new Application_Form_AuthLogin(); } else { @@ -31,14 +35,12 @@ class AuthController extends Zend_Controller_Action $result = $auth->authenticate($adapter); // TODO: erweiterte fehlerbeschreibung des Users - // siehe http://framework.zend.com/manual/en/zend.auth.introduction.html if ($result->isValid()) { - #$this->_helper->FlashMessenger('Erfolgreich angemeldet'); $this->_redirect('/'); return; } else { - //$this->_helper->FlashMessenger('E-Mail oder Passwort falsch'); + echo "Falsche Email oder Passwort"; } } } @@ -47,25 +49,35 @@ class AuthController extends Zend_Controller_Action } public function registerAction() - { - $db = Zend_Db_Table::getDefaultAdapter(); - + { if (!isset($_POST["register"])){ $registerForm = new Application_Form_AuthRegister(); } else { $registerForm = new Application_Form_AuthRegister($_POST); - + if ($registerForm->isValid($_POST)) { + $person = new Application_Model_Person($_POST); - if ($person != null) { - echo "Erfolgreich registriert"; - var_dump($person); - //$this->_redirect('/auth/login'); - return; - } else { - echo "Die angegebene Email-Adresse existiert bereits"; - } - } + $personmapper = new Application_Model_PersonMapper(); + + $date = new DateTime(); + $person->setRegisterdate($date->getTimestamp()); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + + try { + $personmapper->save($person); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Adresse bereits vorhanden."; + return; + } + echo "Erfolgreich registriert. <br/>"; + echo "Weiter zum Login: <a href=\""."/auth/login"."\">Login</a>"; + return; + } } $this->view->registerForm = $registerForm; @@ -81,9 +93,25 @@ class AuthController extends Zend_Controller_Action // action body } - public function deleteAccountAction() + public function deleteAction() { - // action body + if (!isset($_POST["delete"])){ + $deleteForm = new Application_Form_AuthDelete(); + } else { + $deleteForm = new Application_Form_AuthDelete($_POST); + + if ($deleteForm->isValid($_POST)) { + + $person = new Application_Model_Person($_POST); + $personmapper = new Application_Model_PersonMapper(); + + + $personmapper->delete($person); + } + } + + $this->view->deleteForm = $deleteForm; + } diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index da8e404..d066c53 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -8,31 +8,70 @@ class 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"; - } - /* Initialize action controller here */ + $this->_filtermapper = new Application_Model_FilterMapper(); + }catch (Zend_Exception $e) { + echo "Error message 1: " . $e->getMessage() . "\n"; + } } public function indexAction() { try{ - $this->_filtermapper = new Application_Model_FilterMapper(); - $this->view->filters = $this->_filtermapper->fetchAll(); - - }catch (Zend_Exception $e) { + $this->_filtermapper = new Application_Model_FilterMapper(); + $this->view->filters = $this->_filtermapper->fetchAll(); + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + public function addfilterAction() + { + $db = Zend_Db_Table::getDefaultAdapter(); + if (!isset($_POST["add"])){ + $addfilterform = new Application_Form_FilterAdd(); + $this->view->addfilterform = $addfilterform; + }else { + $addfilterform = new Application_Form_FilterAdd($_POST); + if ($addfilterform->isValid($_POST)) { + try{ + $newfilter = new Application_Model_Filter(); + $newfilter->setTitle($_POST['title']); + $newfilter->setCreated(time()); + $newfilter->setDescription($_POST['description']); + $newfilter->setPriority($_POST['priority']); + + // TODO: Ändere mit ACL + $newfilter->setGroupID('1'); + $newfilter->setMembershipID('1'); + $newfilter->setBootmenuID('1'); + + + + $newfilter2 = new Application_Model_FilterMapper(); + $newfilter2->save($newfilter); + + $this->_redirect('/filter'); + return; + }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; } + } + } } - public function addfilterAction() - { - $db = Zend_Db_Table::getDefaultAdapter(); - - $addfilterform = new Application_Form_FilterAdd(); - - $this->view->addfilterform = $addfilterform; + public function removefilterAction() + { + $filterID = $_GET['filterID']; + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($filterID)){ + // TODO: lösche den aktuellen eintrag + } + // action body + } + + public function editfilterAction() + { + // action body } @@ -40,3 +79,7 @@ class FilterController extends Zend_Controller_Action + + + + diff --git a/application/forms/FilterAdd.php b/application/forms/FilterAdd.php index 969f07b..825d3f2 100644 --- a/application/forms/FilterAdd.php +++ b/application/forms/FilterAdd.php @@ -5,7 +5,7 @@ class Application_Form_FilterAdd extends Zend_Form public function init() { - $this->setName("Register"); + $this->setName("Add Filter"); $this->setMethod('post'); $this->addElement('text', 'title', array( @@ -16,10 +16,23 @@ class Application_Form_FilterAdd extends Zend_Form 'required' => true, 'label' => 'Title:', )); - $this->addElement('submit', 'register', array( + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'required' => true, + 'label' => 'Description:', + )); + $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' => 'Login', + 'label' => 'Add Filter', )); } diff --git a/application/views/scripts/auth/delete.phtml b/application/views/scripts/auth/delete.phtml index 3b7085d..8f269a0 100644 --- a/application/views/scripts/auth/delete.phtml +++ b/application/views/scripts/auth/delete.phtml @@ -1 +1,4 @@ -<br /><br /><center>View script for controller <b>Auth</b> and script/action name <b>deleteAccount</b></center>
\ No newline at end of file +<?php +$this->deleteForm->setAction($this->url()); +echo $this->deleteForm; +?> diff --git a/application/views/scripts/filter/editfilter.phtml b/application/views/scripts/filter/editfilter.phtml new file mode 100644 index 0000000..452a096 --- /dev/null +++ b/application/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/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml index 0f9b51e..33043dc 100644 --- a/application/views/scripts/filter/index.phtml +++ b/application/views/scripts/filter/index.phtml @@ -13,10 +13,20 @@ <table border=1> <tr> <th>filterid</th> + <th>filterID</th> </tr> <?php foreach ($this->filters as $filter): ?> <tr> + <td><?php echo $this->escape($filter->getID()) ?></td> <td><?php echo $this->escape($filter->title) ?></td> + <td><a href="<?php echo $this->url( + array( + 'controller' => 'filter', + 'action' => 'editfilter', + 'filterID' => $filter->getID() + ), + 'default', + true) ?>">edit filter</a></td> </tr> <?php endforeach ?> diff --git a/application/views/scripts/filter/removefilter.phtml b/application/views/scripts/filter/removefilter.phtml new file mode 100644 index 0000000..a46f9ec --- /dev/null +++ b/application/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/createDefaultMapper/mappertemplate b/createDefaultMapper/mappertemplate index 62de1eb..c7c857e 100644 --- a/createDefaultMapper/mappertemplate +++ b/createDefaultMapper/mappertemplate @@ -35,10 +35,19 @@ class Application_Model_MAPPER $data = array(SAVEDATA); if (null === ($id = $MVAR->getID()) ) { - unset($data['id']); + unset($data['MVARID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('MVARID = ?' => $id)); + } + } + + public function delete(Application_Model_MODEL $MVAR) + { + if (null === ($id = $MVAR->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('MVARID = ?' => $id)); } } diff --git a/simonFilterSqlTests.sql b/simonFilterSqlTests.sql new file mode 100644 index 0000000..95d15ab --- /dev/null +++ b/simonFilterSqlTests.sql @@ -0,0 +1,6 @@ +INSERT INTO `pbs`.`pbs_group` (`groupID` ,`title` ,`description`)VALUES (NULL , 'testgruppe1', NULL); +INSERT INTO `pbs`.`pbs_person` (`personID`, `title`, `name`, `firstname`, `street`, `housenumber`, `city`, `postalcode`, `logindate`, `registerdate`, `email`, `login`, `password`, `password_salt`) VALUES (NULL, 'Mr.Test', 'te', 'st', NULL, NULL, NULL, NULL, NULL, '', '', 'test', '', ''); +INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`) VALUES (NULL, '1', 'Testrolle', NULL); +INSERT INTO `pbs`.`pbs_membership` (`membershipID`, `groupID`, `roleID`, `personID`) VALUES (NULL, '1', '1', '1'); +INSERT INTO `pbs`.`pbs_bootmenu` (`bootmenuID`, `membershipID`, `title`, `time`) VALUES (NULL, '1', 'TestBootMenu', ''); +INSERT INTO `pbs`.`pbs_filter` (`filterID`, `membershipID`, `groupID`, `bootmenuID`, `title`, `description`, `created`, `priority`) VALUES (NULL, '1', '1', '1', 'TestFilter', NULL, '', '1'); |
