From 57053f41cd6cc755ecccef8d32080f6a34addbe9 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 19 Mar 2011 20:16:16 +0100 Subject: Filterentry Formular geändert, selectboxen für Client, Membership etc fehlen noch --- application/modules/user/forms/FilterEntry.php | 166 +++++++++++++++++++++++-- 1 file changed, 157 insertions(+), 9 deletions(-) (limited to 'application/modules/user/forms') diff --git a/application/modules/user/forms/FilterEntry.php b/application/modules/user/forms/FilterEntry.php index 21ceb93..24f1861 100644 --- a/application/modules/user/forms/FilterEntry.php +++ b/application/modules/user/forms/FilterEntry.php @@ -33,70 +33,218 @@ class user_Form_FilterEntry extends Zend_Form $desc = "Select the filtertype"; $label1 = 'Value 1:'; $label2 = 'Value 2:'; + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'id' => 'val2' + )); break; case "1": $desc = "You can set one IP or an IP-Range"; $label1 = 'Start:'; $label2 = 'End:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'validators' => array( + array( + 'regex', + false, + array( + '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", + Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'validators' => array( + array( + 'regex', + false, + array( + '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", + Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val2' + )); break; case "2": $desc = "You can set one Mac-Adress or an Mac-Range"; $label1 = 'Start:'; $label2 = 'End:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'validators' => array( + array( + 'regex', + false, + array( + '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", + Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'validators' => array( + array( + 'regex', + false, + array( + '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", + Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val2' + )); break; case "3": $desc = "Select your Pool"; $label1 = 'PoolID:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); break; case "4": $desc = "Select your BootIso"; $label1 = 'BootIsoID:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); break; case "5": $desc = "Select a Membership"; $label1 = 'Membership:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); break; case "6": $desc = "Select a Group"; $label1 = 'Group:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); break; case "7": $desc = "Specify a time-range"; $label1 = 'Start:'; $label2 = 'End:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'required' => true, + 'id' => 'val2' + )); break; case "8": $desc = "Select a Client"; $label1 = 'Client:'; + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); break; case "9": $desc = "Define a Hardwarehash"; $label1 = 'Hardwarehash:'; + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(32, 32)), + ), + 'required' => true, + 'id' => 'val1' + )); break; case "10": $desc = "Specify the Weekday (Monday:1, Tuesday:2 ... Sunday:7) or a range"; $label1 = 'Start Day:'; $label2 = 'End Day:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'required' => true, + 'id' => 'val2' + )); break; case "11": $desc = "Specify the date or a day range of the filter"; $label1 = 'Start Date:'; $label2 = 'End Date:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'required' => true, + 'id' => 'val2' + )); break; } $filtertypes->setDescription($desc); $this->addElement($filtertypes); - $this->addElement('text', 'filtervalue', array( - 'label' => $label1, - 'id' => 'val1' - )); - if(!in_array($filterentryID,array(3,4,5,6,8,9))){ - $this->addElement('text', 'filtervalue2', array( - 'label' => $label2, - 'id' => 'val2' - )); + + $this->addElement($filtervalue1); + if(isset($filtervalue2 )){ + $this->addElement($filtervalue2); } $this->addElement('submit', 'add', array( -- cgit v1.2.3-55-g7522 From 8b7d22a01d141e437312c81b208942f749bc3e62 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 19 Mar 2011 20:50:50 +0100 Subject: Selectboxen in Filterentry, Gruppen-Selectbox fehlt noch --- .../modules/user/controllers/FilterController.php | 61 +++++++++++++---- application/modules/user/forms/FilterEntry.php | 80 ++++++++++++++-------- 2 files changed, 100 insertions(+), 41 deletions(-) (limited to 'application/modules/user/forms') diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php index a94d5b3..88c7668 100644 --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -174,6 +174,30 @@ class User_FilterController extends Zend_Controller_Action } } } + + private function prepareFormData(){ + $poolMapper = new Application_Model_PoolMapper(); + $pools = $poolMapper->findBY('groupID',$this->membership->getGroupID()); + + $bootisoMapper = new Application_Model_BootIsoMapper(); + $bootisos = $bootisoMapper->findBY('groupID',$this->membership->getGroupID()); + + $membershipMapper = new Application_Model_MembershipMapper(); + $memberships = $membershipMapper->findBY('groupID',$this->membership->getGroupID()); + + // TODO: get all child groups + $grouppMapper = new Application_Model_GroupMapper(); + $groups = $grouppMapper->findBY('groupID',$this->membership->getGroupID()); + + $clientMapper = new Application_Model_ClientMapper(); + $clients = $clientMapper->findBY('groupID',$this->membership->getGroupID()); + + return array ( 'clients' => $clients, + 'memberships' => $memberships, + 'bootisos' => $bootisos, + 'pools' => $pools); + + } public function addfilterentryAction() { @@ -183,14 +207,16 @@ class User_FilterController extends Zend_Controller_Action $filter = new Application_Model_Filter(); $filterMapper->find($filterID,$filter); + $selectData = $this->prepareFormData(); + if($filter->getGroupID() == $this->membership->getGroupID()){ if (!isset($_POST["add"])){ try{ - $addform = new user_Form_FilterEntry( - array( 'buttontext' => 'Add Filterentry', - 'filterID' => $filterID, - 'data' => $_POST - )); + $addform = new user_Form_FilterEntry(array( 'buttontext' => 'Add Filterentry', + 'filterID' => $filterID, + 'selectData' => $selectData, + 'data' => $_POST + )); $addform->populate($_POST); $this->view->addform = $addform; }catch (Zend_Exception $e) { @@ -198,7 +224,10 @@ class User_FilterController extends Zend_Controller_Action $this->_redirect('/user/filter/index/addresult/error'); } } else{ - $addform = new user_Form_FilterEntry(array('buttontext' => 'Add Filterentry', 'data'=>$_POST)); + $addform = new user_Form_FilterEntry(array('buttontext' => 'Add Filterentry', + 'selectData' => $selectData, + 'data'=>$_POST + )); if ($addform->isValid($_POST)) { print_a('valid'); $newfilterenty = new Application_Model_FilterEntries(); @@ -215,12 +244,14 @@ class User_FilterController extends Zend_Controller_Action } else{ $newfilterenty->setFiltervalue($_POST['filtervalue']); - $newfilterenty->setFiltervalue2($_POST['filtervalue2']); + if(isset($_POST['filtervalue2'])){ + $newfilterenty->setFiltervalue2($_POST['filtervalue2']); + } } $newfilter2 = new Application_Model_FilterEntriesMapper(); $newfilter2->save($newfilterenty); - #$this->_redirect('/user/filter/index/addresult/ok'); + $this->_redirect('/user/filter/index/addresult/ok'); } $this->view->addform = $addform; } @@ -233,6 +264,7 @@ class User_FilterController extends Zend_Controller_Action public function editfilterentryAction() { //TODO: ACL: is he allowed to edit filterentrys ? + $selectData = $this->prepareFormData(); if (!isset($_POST["add"])){ try{ $filterentriesID = $this->_request->getParam('filterentriesID'); @@ -249,9 +281,10 @@ class User_FilterController extends Zend_Controller_Action $filterentry->setFiltertypeID($_POST['filtertypeID']) ; } $data = $filterentry->toArray(); - $editfilterform = new user_Form_FilterEntry( - array('buttontext' => 'Edit Filterentry', - 'data' => $data)); + $editfilterform = new user_Form_FilterEntry(array('buttontext' => 'Edit Filterentry', + 'selectData' => $selectData, + 'data' => $data + )); $editfilterform->populate($filterentry->toArray()); $this->view->editfilterform = $editfilterform; @@ -266,7 +299,10 @@ class User_FilterController extends Zend_Controller_Action } else{ try{ $filterentriesID = $this->_request->getParam('filterentriesID'); - $editfilterform = new user_Form_FilterEntry(array('buttontext' => 'Edit Filterentry','data' => $_POST),$_POST); + $editfilterform = new user_Form_FilterEntry(array('buttontext' => 'Edit Filterentry', + 'selectData' => $selectData, + 'data' => $_POST + )); if ($editfilterform->isValid($_POST)) { $filterentry = new Application_Model_FilterEntries(); $filterentriesmapper = new Application_Model_FilterEntriesMapper(); @@ -297,7 +333,6 @@ class User_FilterController extends Zend_Controller_Action // check if it's the last groupID filterentry $allFilters = $filterentriesmapper->findBy('filterID',$filterentry->getFilterID()); - #print_a($allFilters); $lastfilter = true; foreach($allFilters as $thisFilterentry){ if($thisFilterentry['filtertypeID'] == 6 && $thisFilterentry['filterentriesID'] != $filterentriesID){ diff --git a/application/modules/user/forms/FilterEntry.php b/application/modules/user/forms/FilterEntry.php index 24f1861..55941c0 100644 --- a/application/modules/user/forms/FilterEntry.php +++ b/application/modules/user/forms/FilterEntry.php @@ -11,7 +11,7 @@ class user_Form_FilterEntry extends Zend_Form $this->setMethod('post'); $this->setAttrib('id','filterentryform'); #print_a($this->data); - + print_a($this->selectData); try{ $filtertypemapper = new Application_Model_FilterTypeMapper(); $filtertype = $filtertypemapper->fetchAll(); @@ -128,43 +128,59 @@ class user_Form_FilterEntry extends Zend_Form break; case "3": $desc = "Select your Pool"; - $label1 = 'PoolID:'; + $label1 = 'PoolID:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'required' => true, - 'id' => 'val1' - )); + $filtervalue1 = $this->createElement('select','filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['pools'])>0){ + foreach($this->selectData['pools'] as $id => $g){ + $filtervalue1->addMultiOption($g['poolID'], $g['title']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); break; case "4": $desc = "Select your BootIso"; $label1 = 'BootIsoID:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'required' => true, - 'id' => 'val1' - )); + $filtervalue1 = $this->createElement('select','filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['bootisos'])>0){ + foreach($this->selectData['bootisos'] as $id => $g){ + $filtervalue1->addMultiOption($g['bootisoID'], $g['title']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); break; case "5": $desc = "Select a Membership"; $label1 = 'Membership:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'required' => true, - 'id' => 'val1' - )); + $filtervalue1 = $this->createElement('select','filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['memberships'])>0){ + $personMapper = new Application_Model_PersonMapper(); + foreach($this->selectData['memberships'] as $id => $g){ + // Display full name of Person + $person = new Application_Model_Person(); + $personMapper->find($g['personID'],$person); + $filtervalue1->addMultiOption($g['membershipID'], $person->getName().", ".$person->getFirstname()); + } + } + $filtervalue1->setRegisterInArrayValidator(false); break; case "6": $desc = "Select a Group"; $label1 = 'Group:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'required' => true, - 'id' => 'val1' - )); + // TODO: insert the child Groups + $filtervalue1 = $this->createElement('select','filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['groups'])>0){ + foreach($this->selectData['groups'] as $id => $g){ + $filtervalue1->addMultiOption($g['groupID'], $g['title']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); break; case "7": $desc = "Specify a time-range"; @@ -185,11 +201,15 @@ class user_Form_FilterEntry extends Zend_Form case "8": $desc = "Select a Client"; $label1 = 'Client:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'required' => true, - 'id' => 'val1' - )); + + $filtervalue1 = $this->createElement('select','filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['clients'])>0){ + foreach($this->selectData['clients'] as $id => $g){ + $filtervalue1->addMultiOption($g['clientID'], $g['macadress']." - ".$g['hardwarehash']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); break; case "9": $desc = "Define a Hardwarehash"; @@ -275,6 +295,10 @@ class user_Form_FilterEntry extends Zend_Form function setFilterID($v){ $this->filterID = $v; } + private $selectData; + function setSelectData($v){ + $this->selectData = $v; + } } ?> -- cgit v1.2.3-55-g7522 From e4d3c4db0929770ebf70fd0d943821c5ca128519 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Mon, 21 Mar 2011 10:06:49 +0100 Subject: Login in User Module --- .zfproject.xml | 717 +++++++++++---------- .../modules/user/controllers/AuthController.php | 196 +++++- application/modules/user/forms/Login.php | 27 +- application/modules/user/forms/RecoverPassword.php | 28 + application/modules/user/forms/Register.php | 105 +++ .../modules/user/views/scripts/auth/login.phtml | 5 + .../user/views/scripts/auth/recoverpassword.phtml | 4 + .../modules/user/views/scripts/auth/register.phtml | 4 + 8 files changed, 718 insertions(+), 368 deletions(-) create mode 100644 application/modules/user/forms/RecoverPassword.php create mode 100644 application/modules/user/forms/Register.php create mode 100644 application/modules/user/views/scripts/auth/login.phtml create mode 100644 application/modules/user/views/scripts/auth/recoverpassword.phtml create mode 100644 application/modules/user/views/scripts/auth/register.phtml (limited to 'application/modules/user/forms') diff --git a/.zfproject.xml b/.zfproject.xml index 539aaa9..523e667 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -12,135 +12,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -222,6 +95,11 @@ + + + + + @@ -275,6 +153,9 @@ + + + @@ -360,10 +241,23 @@ + + + + + + + + + + + + + @@ -387,238 +281,369 @@ + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php index 80a411d..ff5893f 100644 --- a/application/modules/user/controllers/AuthController.php +++ b/application/modules/user/controllers/AuthController.php @@ -3,25 +3,179 @@ class User_AuthController extends Zend_Controller_Action { - public function init() - { - /* Initialize action controller here */ - } - - public function indexAction() - { - // action body - $membershipID = $this->_request->getParam('membershipID'); - if($membershipID == ''){ - $_SESSION['membershipID'] = 1; - } - else{ - $_SESSION['membershipID'] = $membershipID; - } - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify("membershipID is set to ".$_SESSION['membershipID'],'ok'); - } - - -} + protected $personmapper = null; + private $db = null; + + public function init() + { + $this->db = Zend_Db_Table::getDefaultAdapter(); + $this->personmapper = new Application_Model_PersonMapper(); + } + + public function indexAction() + { + // action body + $membershipID = $this->_request->getParam('membershipID'); + if($membershipID == ''){ + $_SESSION['membershipID'] = 1; + } + else{ + $_SESSION['membershipID'] = $membershipID; + } + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify("membershipID is set to ".$_SESSION['membershipID'],'ok'); + } + + public function loginAction() + { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->_redirect('/user/'); + } else { + if (!isset($_POST["login"])){ + $loginForm = new user_Form_Login(); + } else { + $loginForm = new user_Form_Login($_POST); + + if ($loginForm->isValid($_POST)) { + + $auth = Zend_Auth::getInstance(); + + $adapter = new Zend_Auth_Adapter_DbTable( + $this->db, + 'pbs_person', + 'email', + 'password', + 'MD5(CONCAT(?, password_salt))' + ); + + + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); + + $result = $auth->authenticate($adapter); + + // TODO: erweiterte fehlerbeschreibung des Users + + if ($result->isValid()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy('email', Zend_Auth::getInstance()->getIdentity()); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $date = new DateTime(); + $person->setLogindate($date->getTimestamp()); + $this->personmapper->save($person); + $this->_redirect('/user/'); + return; + } else { + echo "Wrong Email or Password."; + } + } + } + $this->view->loginForm = $loginForm; + } + } + + public function logoutAction() + { + $this->_helper-> viewRenderer-> setNoRender(); + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + $this->_helper->redirector('login', 'auth'); + return; + } + + public function registerAction() + { + if (Zend_Auth::getInstance()->hasIdentity()) { + print_a('Already logged in.'); + } else { + if (!isset($_POST["register"])){ + $registerForm = new user_Form_Register(); + } else { + $registerForm = new user_Form_Register($_POST); + + if ($registerForm->isValid($_POST)) { + + $person = new Application_Model_Person($_POST); + $this->personmapper = new Application_Model_PersonMapper(); + + $date = new DateTime(); + $person->setRegisterdate($date->getTimestamp()); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + print_a($person); + try { + $this->personmapper->save($person); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + echo "Email Address already existing.."; + return; + } + echo "Successfully registered.
"; + echo "Continue to Login: Login"; + $this->_helper->redirector('login', 'auth'); + return; + } + } + $this->view->registerForm = $registerForm; + } + } + + public function deleteAction() + { + $this->_helper-> viewRenderer-> setNoRender(); + $result = $this->personmapper->findBy('email', Zend_Auth::getInstance()->getIdentity()); + $person = $result[0]; + $personID = $person["personID"]; + if (isset($personID)){ + $this->personmapper = new Application_Model_PersonMapper(); + $person = $this->personmapper->find($personID); + try { + $this->personmapper->delete($person); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + return; + } + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + $this->_helper->redirector('login', 'auth'); + return; + } + } + + public function recoverpasswordAction() + { + if (!isset($_POST["recoverPassword"])){ + $recoverPasswordForm = new user_Form_RecoverPassword(); + } else { + $recoverPasswordForm = new user_Form_RecoverPassword($_POST); + # Wiederherstellung funktioniert noch nicht!!! + /*if ($recoverPasswordForm->isValid($_POST)) { + $recoverPasswordForm->getView()->url(); + $person = new Application_Model_Person($_POST); + $this->personmapper = new Application_Model_PersonMapper(); + + $result = $this->personmapper->findBy('email', $_POST['email']); + $email = $result[0]['email']; + $name = $result[0]['firstname'] . ' ' . $result[0]['name']; + $url = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->view->url(); + $recoverid = $this->random(100); + $mailbody = 'Um das Passwort zu ändern klicken Sie auf folgenden Link

Passwort ändern'; + $mail = new Zend_Mail(); + $mail->setBodyHtml($mailbody, 'utf8'); + $mail->getBodyHtml()->getContent(); + $mail->setFrom('admin@local', 'Admin'); + $mail->addTo($email, $name); + $mail->setSubject('Password Wiederherstellung Preboot Server'); + $mail->send(); + } + */ + } + $this->view->recoverPasswordForm = $recoverPasswordForm; + } +} \ No newline at end of file diff --git a/application/modules/user/forms/Login.php b/application/modules/user/forms/Login.php index 58c5cc9..342e0b2 100644 --- a/application/modules/user/forms/Login.php +++ b/application/modules/user/forms/Login.php @@ -5,7 +5,32 @@ class user_Form_Login extends Zend_Form public function init() { - /* Form Elements & Other Definitions Here ... */ + $this->setName("Login"); + $this->setMethod('post'); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'E-Mail:', + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'login', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Login', + )); } diff --git a/application/modules/user/forms/RecoverPassword.php b/application/modules/user/forms/RecoverPassword.php new file mode 100644 index 0000000..90feb87 --- /dev/null +++ b/application/modules/user/forms/RecoverPassword.php @@ -0,0 +1,28 @@ +setName("RecoverPassword"); + $this->setMethod('post'); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 30)), + ), + 'required' => true, + 'label' => 'Email:', + )); + $this->addElement('submit', 'recoverPassword', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Recover Password', + )); + } + + +} + diff --git a/application/modules/user/forms/Register.php b/application/modules/user/forms/Register.php new file mode 100644 index 0000000..9c2a42d --- /dev/null +++ b/application/modules/user/forms/Register.php @@ -0,0 +1,105 @@ +setName("Register"); + $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('text', 'name', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Name:', + )); + + $this->addElement('text', 'firstname', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Firstname:', + )); + + $this->addElement('text', 'street', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Street:', + )); + + $this->addElement('text', 'housenumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Housenumber:', + )); + + $this->addElement('text', 'city', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'City:', + )); + + $this->addElement('text', 'postalcode', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Postalcode:', + )); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Email:', + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'register', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Register', + )); + + + } + + + +} + diff --git a/application/modules/user/views/scripts/auth/login.phtml b/application/modules/user/views/scripts/auth/login.phtml new file mode 100644 index 0000000..d68d2af --- /dev/null +++ b/application/modules/user/views/scripts/auth/login.phtml @@ -0,0 +1,5 @@ +loginForm->setAction($this->url()); +echo $this->loginForm; +?> +
\ No newline at end of file diff --git a/application/modules/user/views/scripts/auth/recoverpassword.phtml b/application/modules/user/views/scripts/auth/recoverpassword.phtml new file mode 100644 index 0000000..881e00e --- /dev/null +++ b/application/modules/user/views/scripts/auth/recoverpassword.phtml @@ -0,0 +1,4 @@ +recoverPasswordForm->setAction($this->url()); +echo $this->recoverPasswordForm; +?> diff --git a/application/modules/user/views/scripts/auth/register.phtml b/application/modules/user/views/scripts/auth/register.phtml new file mode 100644 index 0000000..2033b04 --- /dev/null +++ b/application/modules/user/views/scripts/auth/register.phtml @@ -0,0 +1,4 @@ +registerForm->setAction($this->url()); +echo $this->registerForm; +?> \ No newline at end of file -- cgit v1.2.3-55-g7522