summaryrefslogtreecommitdiffstats
path: root/application/modules/fbgui
diff options
context:
space:
mode:
authormichael pereira2011-03-29 11:01:35 +0200
committermichael pereira2011-03-29 11:01:35 +0200
commitecb5c8d8c31ad70bb24e0ea1cfb6110bcd0a96bb (patch)
tree4b40a4178c2dc3bd3fe21730a29dd07bb8742790 /application/modules/fbgui
parentPreboot User Controller fertig, ACL fehlt noch (diff)
parentselectmembership von auth zu person verschoben fbgui module (diff)
downloadpbs2-ecb5c8d8c31ad70bb24e0ea1cfb6110bcd0a96bb.tar.gz
pbs2-ecb5c8d8c31ad70bb24e0ea1cfb6110bcd0a96bb.tar.xz
pbs2-ecb5c8d8c31ad70bb24e0ea1cfb6110bcd0a96bb.zip
zfconf
Diffstat (limited to 'application/modules/fbgui')
-rw-r--r--application/modules/fbgui/controllers/AuthController.php89
-rw-r--r--application/modules/fbgui/controllers/IndexController.php2
-rw-r--r--application/modules/fbgui/controllers/PersonController.php76
-rw-r--r--application/modules/fbgui/forms/MembershipSelect.php42
-rw-r--r--application/modules/fbgui/layouts/fbgui.phtml17
-rw-r--r--application/modules/fbgui/views/scripts/auth/login.phtml4
-rw-r--r--application/modules/fbgui/views/scripts/person/selectmembership.phtml5
7 files changed, 181 insertions, 54 deletions
diff --git a/application/modules/fbgui/controllers/AuthController.php b/application/modules/fbgui/controllers/AuthController.php
index e9b6666..1b7b5fe 100644
--- a/application/modules/fbgui/controllers/AuthController.php
+++ b/application/modules/fbgui/controllers/AuthController.php
@@ -3,27 +3,27 @@
class Fbgui_AuthController extends Zend_Controller_Action
{
- public function init()
- {
+ public function init()
+ {
$this->db = Zend_Db_Table::getDefaultAdapter();
$this->personmapper = new Application_Model_PersonMapper();
- }
+ }
- public function indexAction()
- {
+ public function indexAction()
+ {
$this->_helper-> viewRenderer-> setNoRender();
$this->_helper->redirector('login', 'auth');
- }
+ }
- public function loginAction()
- {
+ public function loginAction()
+ {
if (Zend_Auth::getInstance()->hasIdentity()) {
- $this->_redirect('/user/');
+ $this->_redirect('/fbgui/');
} else {
if (!isset($_POST["login"])){
- $loginForm = new user_Form_Login();
+ $loginForm = new fbgui_Form_Login();
} else {
- $loginForm = new user_Form_Login($_POST);
+ $loginForm = new fbgui_Form_Login($_POST);
if ($loginForm->isValid($_POST)) {
@@ -31,51 +31,54 @@ class Fbgui_AuthController extends Zend_Controller_Action
$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->_helper->redirector('selectmembership', 'person');
- return;
- } else {
- echo "Wrong Email or Password.";
- }
+ '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->_helper->redirector('selectmembership', 'person');
+ return;
+ } else {
+ echo "Wrong Email or Password.";
+ }
}
}
$this->view->loginForm = $loginForm;
}
- }
+ }
- public function logoutAction()
- {
+ public function logoutAction()
+ {
$this->_helper-> viewRenderer-> setNoRender();
$auth = Zend_Auth::getInstance();
$auth->clearIdentity();
Zend_Session::namespaceUnset('userIDs');
+ Zend_Session::forgetMe();
$this->_helper->redirector('login', 'auth');
return;
- }
+ }
+}
+
+
-}
diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php
index 809ecae..c70386f 100644
--- a/application/modules/fbgui/controllers/IndexController.php
+++ b/application/modules/fbgui/controllers/IndexController.php
@@ -76,7 +76,7 @@ class Fbgui_IndexController extends Zend_Controller_Action
}
}
else{
- echo "<h1>Not Welcome</h1>";
+ echo "<h1>Not Welcome</h1>";
}
}
diff --git a/application/modules/fbgui/controllers/PersonController.php b/application/modules/fbgui/controllers/PersonController.php
new file mode 100644
index 0000000..06076c5
--- /dev/null
+++ b/application/modules/fbgui/controllers/PersonController.php
@@ -0,0 +1,76 @@
+<?php
+
+class Fbgui_PersonController extends Zend_Controller_Action
+{
+ protected $person;
+ protected $personmapper;
+ protected $membershipMapper;
+ protected $memberships;
+
+ public function init()
+ {
+ if (Zend_Auth::getInstance()->hasIdentity()) {
+ $this->personmapper = new Application_Model_PersonMapper();
+ $result = $this->personmapper->findBy('email', Zend_Auth::getInstance()->getIdentity());
+ $this->person = new Application_Model_Person($result[0]);
+ $this->person->setID($result[0]['personID']);
+ $this->membershipMapper = new Application_Model_MembershipMapper();
+ $this->memberships = $this->membershipMapper->findBy("personID",$this->person->getID());
+ } else {
+ $this->_helper->redirector('login', 'auth');
+ }
+ }
+
+ public function indexAction()
+ {
+ $this->_helper->redirector('selectmembership', 'person');
+ }
+
+ public function selectmembershipAction()
+ {
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+ if(isset($userIDsNamespace['membershipID'])) {
+ $this->_redirect('/fbgui/');
+ } else {
+ if(count($this->memberships) > 0) {
+ if(isset($_POST['selectmembership'])) {
+ $roleSession = new Zend_Session_Namespace('userIDs');
+ $roleSession->membershipID = $_POST['membershipID'];
+ $roleSession->personID = $this->person->getID();
+ $membership = $this->membershipMapper->find($_POST['membershipID']);
+ $roleSession->groupID = $membership->getGroupID();
+ $roleSession->roleID = $membership->getRoleID();
+ $this->_redirect('/fbgui/');
+ return;
+ } else {
+ $groupMapper = new Application_Model_GroupMapper();
+ $roleMapper = new Application_Model_RoleMapper();
+ if(isset($this->memberships)) {
+ foreach($this->memberships as $membership) {
+ $group = $groupMapper->find($membership['groupID']);
+ $role = $roleMapper->find($membership['roleID']);
+ $membershipList[] = array(
+ 'membershipID' => $membership['membershipID'],
+ 'group' => $group->getTitle(),
+ 'role' => $role->getTitle()
+ );
+ }
+ }
+ $membershipSelectForm = new fbgui_Form_MembershipSelect(array('membershiplist' => $membershipList));
+ $this->view->membershipSelectForm = $membershipSelectForm;
+ }
+ } else {
+ $this->_redirect('/fbgui/');
+ }
+ }
+ }
+
+ public function changemembershipAction()
+ {
+ $this->_helper-> viewRenderer-> setNoRender();
+ Zend_Session::namespaceUnset('userIDs');
+ $this->_helper->redirector('selectmembership', 'person');
+ return;
+ }
+}
+
diff --git a/application/modules/fbgui/forms/MembershipSelect.php b/application/modules/fbgui/forms/MembershipSelect.php
new file mode 100644
index 0000000..6e03f7d
--- /dev/null
+++ b/application/modules/fbgui/forms/MembershipSelect.php
@@ -0,0 +1,42 @@
+<?php
+
+class fbgui_Form_MembershipSelect extends Zend_Form
+{
+ private $membershiplist;
+
+ public function setMembershiplist($membershiplist){
+ $this->membershiplist = $membershiplist;
+
+ }
+
+ public function getMembershiplist(){
+ return $this->membershiplist;
+ }
+
+ public function init()
+ {
+ $this->setName("MembershipSelect");
+ $this->setMethod('post');
+
+ $membershipfield = $this->createElement('select','membershipID');
+ $membershipfield ->setLabel('Membership:');
+
+ if(count($this->membershiplist)>0){
+ foreach($this->membershiplist as $membership => $m){
+ $membershipfield->addMultiOption($m['membershipID'], $m['group'] . ' - ' . $m['role']);
+ }
+ }
+
+ $membershipfield->setRegisterInArrayValidator(false);
+ $this->addElement($membershipfield);
+
+ $this->addElement('submit', 'selectmembership', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Select',
+ ));
+ }
+
+
+}
+
diff --git a/application/modules/fbgui/layouts/fbgui.phtml b/application/modules/fbgui/layouts/fbgui.phtml
index 7bb59fa..09f2f9d 100644
--- a/application/modules/fbgui/layouts/fbgui.phtml
+++ b/application/modules/fbgui/layouts/fbgui.phtml
@@ -49,15 +49,16 @@ echo $this->headScript()."\n";
<div id="content">
<?php echo $this->layout()->content; ?>
</div>
+
+ <div id="footer" class="footer flexbox flex">
+ <div style='padding:5px;'>
+ <a onclick="$('#debug .v1').toggle();$('#debug .v2').toggle();">display Debug</a> //
+ <i>last edit: <?php echo date("m\/Y",filectime('index.php'));?></i> //
+ <i>version: 0.1.1</i>
+ </div>
+ </div>
</div>
-
-<div id="footer" class="footer flexbox flex">
- <div style='padding:5px;'>
- <a onclick="$('#debug .v1').toggle();$('#debug .v2').toggle();">display Debug</a> //
- <i>last edit: <?php echo date("m\/Y",filectime('index.php'));?></i> //
- <i>version: 0.1.1</i>
- </div>
-</div>
+
<div id='debug'>
<div class='v1'>
<a onclick="$('#debug .v1').toggle();$('#debug .v2').toggle();">
diff --git a/application/modules/fbgui/views/scripts/auth/login.phtml b/application/modules/fbgui/views/scripts/auth/login.phtml
index d68d2af..9742c35 100644
--- a/application/modules/fbgui/views/scripts/auth/login.phtml
+++ b/application/modules/fbgui/views/scripts/auth/login.phtml
@@ -1,5 +1,5 @@
+<h1>Login</h1>
<?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
+?> \ No newline at end of file
diff --git a/application/modules/fbgui/views/scripts/person/selectmembership.phtml b/application/modules/fbgui/views/scripts/person/selectmembership.phtml
new file mode 100644
index 0000000..5f7e5bf
--- /dev/null
+++ b/application/modules/fbgui/views/scripts/person/selectmembership.phtml
@@ -0,0 +1,5 @@
+<h1>Select Membership</h1>
+<?php
+$this->membershipSelectForm->setAction($this->url());
+echo $this->membershipSelectForm;
+?> \ No newline at end of file