summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/controllers/AuthController.php37
-rw-r--r--application/controllers/PersonController.php28
-rw-r--r--application/views/scripts/person/selectmembership.phtml6
3 files changed, 55 insertions, 16 deletions
diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php
index 0de5d67..c5cb46f 100644
--- a/application/controllers/AuthController.php
+++ b/application/controllers/AuthController.php
@@ -51,12 +51,30 @@ class AuthController extends Zend_Controller_Action
$success = sprintf("%s", $login->success);
if ($success === "true") {
$personid = sprintf("%s", $login->personid);
+ $membershipSession = new Zend_Session_Namespace('user');
+ foreach($login->membershiplist->membership as $membershipXML)
+ {
+ $membership['membershipID'] = sprintf("%s", $membershipXML->id);
+ $membership['personID'] = sprintf("%s", $membershipXML->personid);
+ $membership['groupID'] = sprintf("%s", $membershipXML->groupid);
+ $membership['apikey'] = sprintf("%s", $membershipXML->apikey);
+ $membershipSession->memberships[] = $membership;
+ }
$this->personmapper = new Application_Model_PersonMapper();
$person = $this->personmapper->find($personid);
- print_a('case1',$person);
+ $person->setEmail($loginForm->getValue('email'));
+ $person->setPassword($loginForm->getValue('password'));
+ $person->setSuspend(0);
$date = new DateTime();
$person->setLogindate($date->getTimestamp());
- $this->personmapper->save($person);
+ try {
+ $this->personmapper->save($person);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
$authSession = new Zend_Session_Namespace('auth');
$authSession->storage = $person->getEmail();
$this->_helper->redirector('selectmembership', 'person');
@@ -67,6 +85,20 @@ class AuthController extends Zend_Controller_Action
$poolctrlNotifier = new Poolctrl_Notifier();
$this->view->notification = $poolctrlNotifier->notify('Wrong Email or Password', 'error');
} else if($error == "person suspended") {
+ $personid = sprintf("%s", $login->personid);
+ $this->personmapper = new Application_Model_PersonMapper();
+ $person = $this->personmapper->find($personid);
+ $person->setEmail($loginForm->getValue('email'));
+ $person->setPassword($loginForm->getValue('password'));
+ $person->setSuspend(1);
+ try {
+ $this->personmapper->save($person);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
$poolctrlNotifier = new Poolctrl_Notifier();
$this->view->notification = $poolctrlNotifier->notify('Your Account is suspended', 'error');
}
@@ -84,6 +116,7 @@ class AuthController extends Zend_Controller_Action
$auth = Zend_Auth::getInstance();
$auth->clearIdentity();
Zend_Session::namespaceUnset('userIDs');
+ Zend_Session::namespaceUnset('user');
Zend_Session::forgetMe();
$this->_helper->redirector('login', 'auth');
return;
diff --git a/application/controllers/PersonController.php b/application/controllers/PersonController.php
index 2a97fac..04a9bfc 100644
--- a/application/controllers/PersonController.php
+++ b/application/controllers/PersonController.php
@@ -35,7 +35,10 @@ class PersonController extends Zend_Controller_Action
}
$this->groupMapper = new Application_Model_GroupMapper();
$this->membershipMapper = new Application_Model_MembershipMapper();
- $this->memberships = $this->membershipMapper->findBy(array("personID" => $this->person->getID()),true);
+
+ $membershipNamespace = Zend_Session::namespaceGet('user');
+
+ $this->memberships = $membershipNamespace['memberships'];
$this->view->apikeys = array();
@@ -71,20 +74,20 @@ class PersonController extends Zend_Controller_Action
} else {
if(count($this->memberships) == 1) {
$myMembership = $this->memberships[0];
- $roleSession = new Zend_Session_Namespace('userIDs');
- $roleSession->membershipID = $myMembership['membershipID'];
- $roleSession->personID = $myMembership['personID'];
- $roleSession->groupID = $myMembership['groupID'];
- $roleSession->apikey = $myMembership['apikey'];
+ $userSession = new Zend_Session_Namespace('userIDs');
+ $userSession->membershipID = $myMembership['membershipID'];
+ $userSession->personID = $myMembership['personID'];
+ $userSession->groupID = $myMembership['groupID'];
+ $userSession->apikey = $myMembership['apikey'];
$this->_redirect('/');
} elseif(count($this->memberships) > 1) {
if(isset($_POST['selectmembership'])) {
- $roleSession = new Zend_Session_Namespace('userIDs');
- $roleSession->membershipID = $_POST['membershipID'];
- $roleSession->personID = $this->person->getID();
+ $userSession = new Zend_Session_Namespace('userIDs');
+ $userSession->membershipID = $_POST['membershipID'];
+ $userSession->personID = $this->person->getID();
$membership = $this->membershipMapper->find($_POST['membershipID']);
- $roleSession->groupID = $membership->getGroupID();
- $roleSession->apikey = $membership->getApikey();
+ $userSession->groupID = $membership->getGroupID();
+ $userSession->apikey = $membership->getApikey();
$this->_redirect('/');
return;
} else {
@@ -116,7 +119,8 @@ class PersonController extends Zend_Controller_Action
$this->view->membershipSelectForm = $membershipSelectForm;
}
} else {
- $this->_helper->redirector('request', 'person');
+ $poolNotifier = new Poolctrl_Notifier();
+ $this->view->notification = $poolNotifier->notify("Currently you are not member of a group", 'error' );
}
}
}
diff --git a/application/views/scripts/person/selectmembership.phtml b/application/views/scripts/person/selectmembership.phtml
index f5c18a3..4ac4ab4 100644
--- a/application/views/scripts/person/selectmembership.phtml
+++ b/application/views/scripts/person/selectmembership.phtml
@@ -2,6 +2,8 @@
<?php if($this->notification != ''){echo $this->notification;} ?>
<?php
-$this->membershipSelectForm->setAction($this->url());
-echo $this->membershipSelectForm;
+if(isset($this->membershipSelectForm)) {
+ $this->membershipSelectForm->setAction($this->url());
+ echo $this->membershipSelectForm;
+}
?>