diff options
Diffstat (limited to 'application/modules/fbgui')
| -rw-r--r-- | application/modules/fbgui/Bootstrap.php | 20 | ||||
| -rw-r--r-- | application/modules/fbgui/controllers/AuthController.php | 153 | ||||
| -rw-r--r-- | application/modules/fbgui/controllers/IndexController.php | 378 | ||||
| -rw-r--r-- | application/modules/fbgui/controllers/PersonController.php | 167 | ||||
| -rw-r--r-- | application/modules/fbgui/forms/Login.php | 92 | ||||
| -rw-r--r-- | application/modules/fbgui/forms/MembershipSelect.php | 92 |
6 files changed, 440 insertions, 462 deletions
diff --git a/application/modules/fbgui/Bootstrap.php b/application/modules/fbgui/Bootstrap.php index 60e2a7b..75c3df3 100644 --- a/application/modules/fbgui/Bootstrap.php +++ b/application/modules/fbgui/Bootstrap.php @@ -1,4 +1,4 @@ -<?php +<? php /* * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg * This program is free software distributed under the GPL version 2. @@ -9,14 +9,12 @@ * * General information about OpenSLX can be found at http://openslx.org/ */ -class fbgui_Bootstrap extends Zend_Application_Module_Bootstrap -{ - function _initViewHelpers() - { - $this->bootstrap('layout'); - - $layout = $this->getResource('layout'); - $view = $layout->getView(); - $view->headLink()->appendStylesheet('/media/css/fbgui.css'); - } +class fbgui_Bootstrap extends Zend_Application_Module_Bootstrap { + function _initViewHelpers() { + $this->bootstrap('layout'); + + $layout = $this->getResource('layout'); + $view = $layout->getView(); + $view->headLink()->appendStylesheet('/media/css/fbgui.css'); + } } diff --git a/application/modules/fbgui/controllers/AuthController.php b/application/modules/fbgui/controllers/AuthController.php index 936aa61..f51d89f 100644 --- a/application/modules/fbgui/controllers/AuthController.php +++ b/application/modules/fbgui/controllers/AuthController.php @@ -1,84 +1,79 @@ -<?php +<? php /* * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg - * This program is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your suggestions, praise, or complaints to feedback@openslx.org - * - * General information about OpenSLX can be found at http://openslx.org/ - */ - -class Fbgui_AuthController extends Zend_Controller_Action -{ - - public function init() - { - $this->db = Zend_Db_Table::getDefaultAdapter(); - $this->personmapper = new Application_Model_PersonMapper(); - } - - public function indexAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $this->_helper->redirector('login', 'auth'); - } - - public function loginAction() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->_redirect('/fbgui/'); - } else { - if (!isset($_POST["login"])){ - $loginForm = new fbgui_Form_Login(); - } else { - $loginForm = new fbgui_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(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $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() - { - $this->_helper-> viewRenderer-> setNoRender(); - $auth = Zend_Auth::getInstance(); - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_redirect('/fbgui/index'); -# $this->_helper->redirector('fbgui', 'index'); - return; - } +* This program is free software distributed under the GPL version 2. +* See http://gpl.openslx.org/ +* +* If you have any feedback please consult http://feedback.openslx.org/ and +* send your suggestions, praise, or complaints to feedback@openslx.org +* +* General information about OpenSLX can be found at http://openslx.org/ +*/ + +class Fbgui_AuthController extends Zend_Controller_Action { + + public function init() { + $this->db = Zend_Db_Table::getDefaultAdapter(); + $this->personmapper = new Application_Model_PersonMapper(); + } + + public function indexAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $this->_helper->redirector('login', 'auth'); + } + + public function loginAction() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->_redirect('/fbgui/'); + } else { + if (!isset($_POST["login"])) { + $loginForm = new fbgui_Form_Login(); + } else { + $loginForm = new fbgui_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(array('email' => Zend_Auth::getInstance()->getIdentity()), true); + $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() { + $this->_helper-> viewRenderer-> setNoRender(); + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_redirect('/fbgui/index'); +# $this->_helper->redirector('fbgui', 'index'); + return; + } } diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index e5f8abd..9e2856e 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -1,197 +1,189 @@ -<?php +<? php /* * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg - * This program is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your suggestions, praise, or complaints to feedback@openslx.org - * - * General information about OpenSLX can be found at http://openslx.org/ - */ - -class Fbgui_IndexController extends Zend_Controller_Action -{ - protected $membership; - - public function init() - { - /* Initialize action controller here */ - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - - $membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - } - - public function errorAction() - { - $result = $this->_request->getParam('serialresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('serial',$result); - } - } - - public function indexAction() - { - $mySession = new Zend_Session_Namespace('pbs'); - $this->view->notification = array(); - - - if(count($mySession->postdata)<=0){ - $mySession->postdata = $_POST; - } - - $result = $this->_request->getParam('notify'); - if($result == 'nomember'){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification[] = $pbsNotifier->notify('You have no membership, therefore you have no own BootMenu','info'); - } - - $d = new Pbs_Debug(); - $d->debug(array('FBGuiIndexController',$_SERVER['REMOTE_ADDR'],implode("\t",$mySession->postdata))); - - if(isset($mySession->postdata['bootisoID']) || isset($mySession->postdata['serialnumber'])){ - // Create a session - $n = new Pbs_Session(); - - $bootisomapper = new Application_Model_BootIsoMapper(); - $bootiso = new Application_Model_BootIso(); - if(isset($mySession->postdata['bootisoID'])){ - $bootisomapper->find($mySession->postdata['bootisoID'],$bootiso); - $groupID = $bootiso->getGroupID(); - } - elseif(isset($mySession->postdata['serialnumber'])){ - $results = $bootisomapper->findBy(array('serialnumber' => $mySession->postdata['serialnumber']),true); - if(count($results) == 0){ - $this->_redirect('/fbgui/index/error/serialresult/noserial2'); - } - $bootiso->setOptions($results[0]); - $bootiso->setID($results[0]['bootisoID']); - $groupID = $bootiso->getGroupID(); - - } - - $client = new Application_Model_Client(); - $client->setMacadress($mySession->postdata['mac']); - $client->setHardwarehash($mySession->postdata['hardwarehash']); - $client->setGroupID($groupID); - $client->setCreated(time()); - $client = $n->createClient($client); - $clientID = $client->getID(); - - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - - if(!isset($_SESSION['alphasessionID'])){ - $session = new Application_Model_Session(); - $session->setBootisoID($bootiso->getID()); - $session->setClientID($clientID); - $session->setTime(time()); - if($this->membership->getID() != ''){ - $session->setMembershipID($this->membership->getID()); - } - $session->setIp($_SERVER['REMOTE_ADDR']); - $session = $n->createSession($session); - $_SESSION['alphasessionID'] = $session->getAlphasessionID(); - } - else{ - $session = new Application_Model_Session(); - $sessionMapper = new Application_Model_SessionMapper(); - $sessions = $sessionMapper->findBy(array('alphasessionID'=>$_SESSION['alphasessionID'])); - $session = $sessions[0]; - if($this->membership->getID() != '' && $session->getMembershipID() == ''){ - $session->setMembershipID($this->membership->getID()); - $sessionMapper->save($session); - } - } - // Request Bootmenu - $pbsFilter = new Pbs_Filter(); - $bootmenuID = $pbsFilter->evaluate(); - if($bootmenuID != null){ - $this->view->alphasessionID = $_SESSION['alphasessionID']; - // print_a('Debug Output', - // 'Session is now set', - // 'Your sessionID is '.$session->getID(), - // 'Your alphasessionID is '.$session->getAlphasessionID(), - // 'Your client is '.$session->getClientID(), - // 'goto bootmenu '.$bootmenuID); - - $bootmenuMapper = new Application_Model_BootMenuMapper(); - $bm = $bootmenuMapper->find($bootmenuID); - $this->view->title = $bm->getTitle(); - $this->view->startcounter = $bm->getStartcounter(); - - $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); - $this->view->entries = $res; - - if (!Zend_Auth::getInstance()->hasIdentity()) { - $this->view->loginmenu = true; - } - - if(Zend_Auth::getInstance()->hasIdentity()){ - if($bm->MembershipID != '' && $bm->MembershipID == $this->membership->getID()){} - else{ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification[] = $pbsNotifier->notify("This is not your Bootmenu. There is currently a BootMenu with a higher priority active.",'info'); - } - } - - if(count($res) == 0){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification[] = $pbsNotifier->notify("There are no entries in the bootmenu.",'info'); - $this->view->nobootmenu = true; - unset($this->view->entries); - } - - - } - else{ - // print_a('Debug Output', - // 'Session is now set', - // 'Your sessionID is '.$session->getID(), - // 'Your alphasessionID is '.$session->getAlphasessionID(), - // 'Your client is '.$session->getClientID(), - // 'there is no bootmenu for you'); - if (!Zend_Auth::getInstance()->hasIdentity()) { - $this->view->loginmenu = true; - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification[] = $pbsNotifier->notify("There is no default BootMenu, please Login to get your BootMenu.",'info'); - } - else{ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification[] = $pbsNotifier->notify("You have no BootMenu.",'info'); - } - $this->view->nobootmenu = true; - } - } - else{ - #$this->_redirect('/fbgui/index/error/serialresult/noserial'); - } - - } - public function startAction(){ - $bootmenuntryID = $this->_request->getParam('bme'); - $a = $_SESSION['alphasessionID']; - $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentriesMapper->find($bootmenuntryID,$bootmenuentry); - - $sessionMapper = new Application_Model_SessionMapper(); - $session_k = $sessionMapper->findBy(array('alphasessionID' => $a),true); - - $session = new Application_Model_Session(); - $session->setOptions($session_k[0]); - $session->setID($session_k[0]['sessionID']); - - $session->setBootmenuentryID($bootmenuntryID); - $session->setBootosID($bootmenuentry->getBootosID()); - $sessionMapper->save($session); - - - $this->view->host = 'pbs2.mp.openslx.org'; - $this->view->alphasessionID = $a; - } +* This program is free software distributed under the GPL version 2. +* See http://gpl.openslx.org/ +* +* If you have any feedback please consult http://feedback.openslx.org/ and +* send your suggestions, praise, or complaints to feedback@openslx.org +* +* General information about OpenSLX can be found at http://openslx.org/ +*/ + +class Fbgui_IndexController extends Zend_Controller_Action { + protected $membership; + + public function init() { + /* Initialize action controller here */ + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + } + + public function errorAction() { + $result = $this->_request->getParam('serialresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('serial', $result); + } + } + + public function indexAction() { + $mySession = new Zend_Session_Namespace('pbs'); + $this->view->notification = array(); + + + if(count($mySession->postdata) <= 0) { + $mySession->postdata = $_POST; + } + + $result = $this->_request->getParam('notify'); + if($result == 'nomember') { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification[] = $pbsNotifier->notify('You have no membership, therefore you have no own BootMenu', 'info'); + } + + $d = new Pbs_Debug(); + $d->debug(array('FBGuiIndexController', $_SERVER['REMOTE_ADDR'], implode("\t", $mySession->postdata))); + + if(isset($mySession->postdata['bootisoID']) || isset($mySession->postdata['serialnumber'])) { + // Create a session + $n = new Pbs_Session(); + + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso = new Application_Model_BootIso(); + if(isset($mySession->postdata['bootisoID'])) { + $bootisomapper->find($mySession->postdata['bootisoID'], $bootiso); + $groupID = $bootiso->getGroupID(); + } + elseif(isset($mySession->postdata['serialnumber'])) { + $results = $bootisomapper->findBy(array('serialnumber' => $mySession->postdata['serialnumber']), true); + if(count($results) == 0) { + $this->_redirect('/fbgui/index/error/serialresult/noserial2'); + } + $bootiso->setOptions($results[0]); + $bootiso->setID($results[0]['bootisoID']); + $groupID = $bootiso->getGroupID(); + + } + + $client = new Application_Model_Client(); + $client->setMacadress($mySession->postdata['mac']); + $client->setHardwarehash($mySession->postdata['hardwarehash']); + $client->setGroupID($groupID); + $client->setCreated(time()); + $client = $n->createClient($client); + $clientID = $client->getID(); + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + + if(!isset($_SESSION['alphasessionID'])) { + $session = new Application_Model_Session(); + $session->setBootisoID($bootiso->getID()); + $session->setClientID($clientID); + $session->setTime(time()); + if($this->membership->getID() != '') { + $session->setMembershipID($this->membership->getID()); + } + $session->setIp($_SERVER['REMOTE_ADDR']); + $session = $n->createSession($session); + $_SESSION['alphasessionID'] = $session->getAlphasessionID(); + } else { + $session = new Application_Model_Session(); + $sessionMapper = new Application_Model_SessionMapper(); + $sessions = $sessionMapper->findBy(array('alphasessionID' => $_SESSION['alphasessionID'])); + $session = $sessions[0]; + if($this->membership->getID() != '' && $session->getMembershipID() == '') { + $session->setMembershipID($this->membership->getID()); + $sessionMapper->save($session); + } + } + // Request Bootmenu + $pbsFilter = new Pbs_Filter(); + $bootmenuID = $pbsFilter->evaluate(); + if($bootmenuID != null) { + $this->view->alphasessionID = $_SESSION['alphasessionID']; + // print_a('Debug Output', + // 'Session is now set', + // 'Your sessionID is '.$session->getID(), + // 'Your alphasessionID is '.$session->getAlphasessionID(), + // 'Your client is '.$session->getClientID(), + // 'goto bootmenu '.$bootmenuID); + + $bootmenuMapper = new Application_Model_BootMenuMapper(); + $bm = $bootmenuMapper->find($bootmenuID); + $this->view->title = $bm->getTitle(); + $this->view->startcounter = $bm->getStartcounter(); + + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID), false); + $this->view->entries = $res; + + if (!Zend_Auth::getInstance()->hasIdentity()) { + $this->view->loginmenu = true; + } + + if(Zend_Auth::getInstance()->hasIdentity()) { + if($bm->MembershipID != '' && $bm->MembershipID == $this->membership->getID()) { + } else { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification[] = $pbsNotifier->notify("This is not your Bootmenu. There is currently a BootMenu with a higher priority active.", 'info'); + } + } + + if(count($res) == 0) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification[] = $pbsNotifier->notify("There are no entries in the bootmenu.", 'info'); + $this->view->nobootmenu = true; + unset($this->view->entries); + } + + + } else { + // print_a('Debug Output', + // 'Session is now set', + // 'Your sessionID is '.$session->getID(), + // 'Your alphasessionID is '.$session->getAlphasessionID(), + // 'Your client is '.$session->getClientID(), + // 'there is no bootmenu for you'); + if (!Zend_Auth::getInstance()->hasIdentity()) { + $this->view->loginmenu = true; + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification[] = $pbsNotifier->notify("There is no default BootMenu, please Login to get your BootMenu.", 'info'); + } else { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification[] = $pbsNotifier->notify("You have no BootMenu.", 'info'); + } + $this->view->nobootmenu = true; + } + } else { +#$this->_redirect('/fbgui/index/error/serialresult/noserial'); + } + + } + public function startAction() { + $bootmenuntryID = $this->_request->getParam('bme'); + $a = $_SESSION['alphasessionID']; + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentriesMapper->find($bootmenuntryID, $bootmenuentry); + + $sessionMapper = new Application_Model_SessionMapper(); + $session_k = $sessionMapper->findBy(array('alphasessionID' => $a), true); + + $session = new Application_Model_Session(); + $session->setOptions($session_k[0]); + $session->setID($session_k[0]['sessionID']); + + $session->setBootmenuentryID($bootmenuntryID); + $session->setBootosID($bootmenuentry->getBootosID()); + $sessionMapper->save($session); + + + $this->view->host = 'pbs2.mp.openslx.org'; + $this->view->alphasessionID = $a; + } } diff --git a/application/modules/fbgui/controllers/PersonController.php b/application/modules/fbgui/controllers/PersonController.php index b884a28..0e3ab14 100644 --- a/application/modules/fbgui/controllers/PersonController.php +++ b/application/modules/fbgui/controllers/PersonController.php @@ -1,94 +1,91 @@ -<?php +<? php /* * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg - * This program is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your suggestions, praise, or complaints to feedback@openslx.org - * - * General information about OpenSLX can be found at http://openslx.org/ - */ +* This program is free software distributed under the GPL version 2. +* See http://gpl.openslx.org/ +* +* If you have any feedback please consult http://feedback.openslx.org/ and +* send your suggestions, praise, or complaints to feedback@openslx.org +* +* General information about OpenSLX can be found at http://openslx.org/ +*/ -class Fbgui_PersonController extends Zend_Controller_Action -{ - protected $person; - protected $personmapper; - protected $membershipMapper; - protected $memberships; +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(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $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(array("personID" => $this->person->getID()),true); - } else { - $this->_helper->redirector('login', 'auth'); - } - } + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()), true); + $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(array("personID" => $this->person->getID()), true); + } else { + $this->_helper->redirector('login', 'auth'); + } + } - public function indexAction() - { - $this->_helper->redirector('selectmembership', 'person'); - } + 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) == 1) { - $myMembership = $this->memberships[0]; - $roleSession = new Zend_Session_Namespace('userIDs'); - $roleSession->membershipID = $myMembership['membershipID']; - $roleSession->personID = $myMembership['personID']; - $roleSession->groupID = $myMembership['groupID']; - $roleSession->roleID = $myMembership['roleID']; - $this->_redirect('/fbgui/'); - } elseif(count($this->memberships) > 1) { - 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/index/index/notify/nomember'); - } - } - } + public function selectmembershipAction() { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if(isset($userIDsNamespace['membershipID'])) { + $this->_redirect('/fbgui/'); + } 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->roleID = $myMembership['roleID']; + $this->_redirect('/fbgui/'); + } + elseif(count($this->memberships) > 1) { + 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/index/index/notify/nomember'); + } + } + } - public function changemembershipAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - Zend_Session::namespaceUnset('userIDs'); - $this->_helper->redirector('selectmembership', 'person'); - return; - } + public function changemembershipAction() { + $this->_helper-> viewRenderer-> setNoRender(); + Zend_Session::namespaceUnset('userIDs'); + $this->_helper->redirector('selectmembership', 'person'); + return; + } } diff --git a/application/modules/fbgui/forms/Login.php b/application/modules/fbgui/forms/Login.php index 896b555..759f53e 100644 --- a/application/modules/fbgui/forms/Login.php +++ b/application/modules/fbgui/forms/Login.php @@ -1,52 +1,50 @@ -<?php +<? php /* * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg - * This program is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your suggestions, praise, or complaints to feedback@openslx.org - * - * General information about OpenSLX can be found at http://openslx.org/ - */ - -class fbgui_Form_Login extends Zend_Form -{ - - public function init() - { - $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, - 'id' => 'email', - 'class' => 'keyboardInput', - 'label' => 'E-Mail:', - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'id' => 'pass', - 'class' => 'keyboardInput', - 'label' => 'Password:', - )); - - $this->addElement('submit', 'login', array( - 'required' => false, - 'id' => 'submit', - 'ignore' => true, - 'label' => 'Login', - )); - } +* This program is free software distributed under the GPL version 2. +* See http://gpl.openslx.org/ +* +* If you have any feedback please consult http://feedback.openslx.org/ and +* send your suggestions, praise, or complaints to feedback@openslx.org +* +* General information about OpenSLX can be found at http://openslx.org/ +*/ + +class fbgui_Form_Login extends Zend_Form { + + public function init() { + $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, + 'id' => 'email', + 'class' => 'keyboardInput', + 'label' => 'E-Mail:', + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'id' => 'pass', + 'class' => 'keyboardInput', + 'label' => 'Password:', + )); + + $this->addElement('submit', 'login', array( + 'required' => false, + 'id' => 'submit', + 'ignore' => true, + 'label' => 'Login', + )); + } } diff --git a/application/modules/fbgui/forms/MembershipSelect.php b/application/modules/fbgui/forms/MembershipSelect.php index d59a6d8..d75a5bf 100644 --- a/application/modules/fbgui/forms/MembershipSelect.php +++ b/application/modules/fbgui/forms/MembershipSelect.php @@ -1,52 +1,50 @@ -<?php +<? php /* * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg - * This program is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your suggestions, praise, or complaints to feedback@openslx.org - * - * General information about OpenSLX can be found at http://openslx.org/ - */ - -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, - 'id' => 'submit', - 'ignore' => true, - 'label' => 'Select', - )); - } +* This program is free software distributed under the GPL version 2. +* See http://gpl.openslx.org/ +* +* If you have any feedback please consult http://feedback.openslx.org/ and +* send your suggestions, praise, or complaints to feedback@openslx.org +* +* General information about OpenSLX can be found at http://openslx.org/ +*/ + +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, + 'id' => 'submit', + 'ignore' => true, + 'label' => 'Select', + )); + } } |
