summaryrefslogtreecommitdiffstats
path: root/application/modules
diff options
context:
space:
mode:
authormichael pereira2011-03-21 10:52:51 +0100
committermichael pereira2011-03-21 10:52:51 +0100
commit3a59301fdf10fcc0ecc3a56db18f3a36cc0c1aac (patch)
treed70593ed8261f466b41d21731421dfb6489d7dfa /application/modules
parentPreboot Controller eingerichtet (diff)
parentLogin in User Module (diff)
downloadpbs2-3a59301fdf10fcc0ecc3a56db18f3a36cc0c1aac.tar.gz
pbs2-3a59301fdf10fcc0ecc3a56db18f3a36cc0c1aac.tar.xz
pbs2-3a59301fdf10fcc0ecc3a56db18f3a36cc0c1aac.zip
zfproject
Diffstat (limited to 'application/modules')
-rw-r--r--application/modules/user/controllers/AuthController.php196
-rw-r--r--application/modules/user/controllers/FilterController.php196
-rw-r--r--application/modules/user/forms/FilterEntry.php194
-rw-r--r--application/modules/user/forms/Login.php27
-rw-r--r--application/modules/user/forms/RecoverPassword.php28
-rw-r--r--application/modules/user/forms/Register.php105
-rw-r--r--application/modules/user/views/scripts/auth/login.phtml5
-rw-r--r--application/modules/user/views/scripts/auth/recoverpassword.phtml4
-rw-r--r--application/modules/user/views/scripts/auth/register.phtml4
9 files changed, 675 insertions, 84 deletions
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) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ echo "Email Address already existing..";
+ return;
+ }
+ echo "Successfully registered. <br/>";
+ echo "Continue to Login: <a href=\""."/dev/auth/login"."\">Login</a>";
+ $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) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ 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<br /><br /><a href="'. $url . '/auth/recoverpassword/?recoverid='. $recoverid . '">Passwort ändern</a>';
+ $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/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php
index 3a14865..444a33a 100644
--- a/application/modules/user/controllers/FilterController.php
+++ b/application/modules/user/controllers/FilterController.php
@@ -74,7 +74,15 @@ class User_FilterController extends Zend_Controller_Action
$newfilter->setGroupID($this->membership->getGroupID());
$newfilter->setMembershipID($this->membership->getID());
$newfilter2 = new Application_Model_FilterMapper();
- $newfilter2->save($newfilter);
+ $id = $newfilter2->save($newfilter);
+
+ $filterentriesMapper = new Application_Model_FilterEntriesMapper();
+ $filterentry = new Application_Model_FilterEntries();
+ $filterentry->setFilterID($id);
+ $filterentry->setFiltertypeID(6);
+ $filterentry->setFiltervalue($this->membership->getGroupID());
+ $filterentriesMapper->save($filterentry);
+
$this->_redirect('/user/filter/index/addresult/ok');
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
@@ -166,6 +174,49 @@ class User_FilterController extends Zend_Controller_Action
}
}
}
+
+ // $parent is the parent of the children we want to see
+ // $level is increased when we go deeper into the tree
+ private function display_children($parent, $level, &$data) {
+ // retrieve all children of $parent
+ $result = mysql_query('SELECT groupID FROM pbs_groupgroups '.
+ 'WHERE parentID="'.$parent.'";');
+
+ // display each child
+ while ($row = mysql_fetch_array($result)) {
+ // indent and display the title of this child
+ $data[$level][] = str_repeat(' ',$level).$row['title'];
+
+ // call this function again to display this
+ // child's children
+ $data = display_children($row['title'], $level+1,$data);
+ }
+ return $data;
+ }
+
+ 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()
{
@@ -175,14 +226,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) {
@@ -190,20 +243,29 @@ class User_FilterController extends Zend_Controller_Action
$this->_redirect('/user/filter/index/addresult/error');
}
} else{
- $addform = new user_Form_FilterEntry(array('buttontext' => 'Add Filterentry'),$_POST);
-
- if ($addform->isValid($_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();
$newfilterenty->setFilterID($filterID);
$newfilterenty->setFiltertypeID($_POST['filtertypeID']);
if($_POST['filtertypeID'] == 1){
- $newfilterenty->setFiltervalue($this->fillIP($_POST['filtervalue']));
- $newfilterenty->setFiltervalue2($this->fillIP($_POST['filtervalue2']));
+ $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.'));
+ $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.'));
+ }
+ elseif($_POST['filtertypeID'] == 2){
+ $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,':'));
+ $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':'));
}
else{
$newfilterenty->setFiltervalue($_POST['filtervalue']);
- $newfilterenty->setFiltervalue2($_POST['filtervalue2']);
+ if(isset($_POST['filtervalue2'])){
+ $newfilterenty->setFiltervalue2($_POST['filtervalue2']);
+ }
}
$newfilter2 = new Application_Model_FilterEntriesMapper();
@@ -221,6 +283,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');
@@ -237,10 +300,10 @@ class User_FilterController extends Zend_Controller_Action
$filterentry->setFiltertypeID($_POST['filtertypeID']) ;
}
$data = $filterentry->toArray();
- # print_a($data);
- $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;
@@ -255,7 +318,10 @@ class User_FilterController extends Zend_Controller_Action
} else{
try{
$filterentriesID = $this->_request->getParam('filterentriesID');
- $editfilterform = new user_Form_FilterEntry(array('buttontext' => 'Edit Filterentry'),$_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();
@@ -265,22 +331,47 @@ class User_FilterController extends Zend_Controller_Action
$filter = new Application_Model_Filter();
$filterMapper->find($filterentry->getFilterID(),$filter);
- if($filter->getGroupID() == $this->membership->getGroupID()){
+ if($filter->getGroupID() == $this->membership->getGroupID()){
if($_POST['filterID'] == '')
unset($_POST['filterID']);
+
$newfilterenty = new Application_Model_FilterEntries($_POST);
$newfilterenty->setID($filterentriesID);
- if($_POST['filtertypeID'] == 1){
- $newfilterenty->setFiltervalue($this->fillIP($_POST['filtervalue']));
- $newfilterenty->setFiltervalue2($this->fillIP($_POST['filtervalue2']));
+ if($_POST['filtertypeID'] == 1){
+ $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.'));
+ $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.'));
+ }
+ elseif($_POST['filtertypeID'] == 2){
+ $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,';'));
+ $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':'));
}
else{
$newfilterenty->setFiltervalue($_POST['filtervalue']);
$newfilterenty->setFiltervalue2($_POST['filtervalue2']);
}
- $newfilter2 = new Application_Model_FilterEntriesMapper();
- $newfilter2->save($newfilterenty);
- $this->_redirect('/user/filter/index/modifyresult/ok');
+
+ // check if it's the last groupID filterentry
+ $allFilters = $filterentriesmapper->findBy('filterID',$filterentry->getFilterID());
+ $lastfilter = true;
+ foreach($allFilters as $thisFilterentry){
+ if($thisFilterentry['filtertypeID'] == 6 && $thisFilterentry['filterentriesID'] != $filterentriesID){
+ // one other filter with a groupID exists
+ $lastfilter = false;
+ }
+ if($newfilterenty->getFiltertypeID() == 6){
+ // this filter will be a GroupFilter
+ $lastfilter = false;
+ }
+ }
+ if($lastfilter){
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('You cannot modify the last GroupFilter','forbidden');
+ }
+ else{
+ $newfilter2 = new Application_Model_FilterEntriesMapper();
+ $newfilter2->save($newfilterenty);
+ $this->_redirect('/user/filter/index/modifyresult/ok');
+ }
}
else{
$this->_redirect('/user/filter/index/modifyresult/forbidden');
@@ -309,14 +400,31 @@ class User_FilterController extends Zend_Controller_Action
$filterMapper->find($filterID,$filter);
if($filter->getGroupID() == $this->membership->getGroupID()){
- try{
+ try{
$deletefilterentry = new Application_Model_FilterEntries();
$deletefilterentry->setID($filterentriesID);
-
- $filterentriesmapper = new Application_Model_FilterEntriesMapper();
- $filterentriesmapper->delete($deletefilterentry);
- $this->_redirect('/user/filter/index/deleteresult/ok');
-
+
+ // check if it's the last groupID filterentry
+ $allFilters = $filterentriesmapper->findBy('filterID',$filterID);
+ $lastfilter = true;
+ foreach($allFilters as $thisFilterentry){
+ if($thisFilterentry['filtertypeID'] == 6 && $thisFilterentry['filterentriesID'] != $filterentriesID){
+ // one other filter with a groupID exists
+ $lastfilter = false;
+ }
+ if($deletefilterentry->getFiltertypeID() == 6){
+ // this filter will be a GroupFilter
+ $lastfilter = false;
+ }
+ }
+ if($lastfilter){
+ $this->_redirect('/user/filter/index/deleteresult/forbidden');
+ }
+ else{
+ $filterentriesmapper = new Application_Model_FilterEntriesMapper();
+ $filterentriesmapper->delete($deletefilterentry);
+ $this->_redirect('/user/filter/index/deleteresult/ok');
+ }
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
$this->_redirect('/user/filter/index/deleteresult/error');
@@ -330,28 +438,14 @@ class User_FilterController extends Zend_Controller_Action
$this->_redirect('/user/filter/index/deleteresult/error');
}
}
-
- private function fillIP($ip)
- {
- $ar = explode(".",$ip);
- $representation = array();
- foreach($ar as $part){
- $representation[] = sprintf("%03s",$part);
- }
- return implode(".",$representation);
- }
-
- private function fillMac($ip)
- {
- $ar = explode(":",$ip);
- $representation = array();
- foreach($ar as $part){
- $representation[] = sprintf("%02s",$part);
- }
- return implode(":",$representation);
+ private function fillup($string, $length, $seperator=':',$sign='0'){
+ $ar = explode($seperator,$string);
+ $representation = array();
+ foreach($ar as $part){
+ $representation[] = sprintf("%".$sign.$length."s",$part);
+ }
+ return implode($seperator,$representation);
}
-
-
}
diff --git a/application/modules/user/forms/FilterEntry.php b/application/modules/user/forms/FilterEntry.php
index 21ceb93..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();
@@ -33,70 +33,238 @@ 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:';
+ $label1 = 'PoolID:';
+
+ $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('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('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:';
+ // 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";
$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('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";
$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(
@@ -127,6 +295,10 @@ class user_Form_FilterEntry extends Zend_Form
function setFilterID($v){
$this->filterID = $v;
}
+ private $selectData;
+ function setSelectData($v){
+ $this->selectData = $v;
+ }
}
?>
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 @@
+<?php
+
+class user_Form_RecoverPassword extends Zend_Form
+{
+
+ public function init()
+ {
+ $this->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 @@
+<?php
+
+class user_Form_Register extends Zend_Form
+{
+
+ public function init()
+ {
+ $this->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 @@
+<?php
+$this->loginForm->setAction($this->url());
+echo $this->loginForm;
+?>
+<div><button onclick="location.href='/user/auth/recoverpassword'">Recover Password</button></div> \ 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 @@
+<?php
+$this->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 @@
+<?php
+$this->registerForm->setAction($this->url());
+echo $this->registerForm;
+?> \ No newline at end of file