diff options
| author | Simon | 2011-04-19 17:25:09 +0200 |
|---|---|---|
| committer | Simon | 2011-04-19 17:25:09 +0200 |
| commit | 4223800a7a62eaa6148d7e96e87593e8913150cf (patch) | |
| tree | f4394fd043ceeaf664500d05b90ab9dcec7ad743 | |
| parent | Ticket #215 - Shutdown Button hinzugefügt (diff) | |
| download | pbs2-4223800a7a62eaa6148d7e96e87593e8913150cf.tar.gz pbs2-4223800a7a62eaa6148d7e96e87593e8913150cf.tar.xz pbs2-4223800a7a62eaa6148d7e96e87593e8913150cf.zip | |
Logout in der FBGui eingebaut
3 files changed, 106 insertions, 43 deletions
diff --git a/application/modules/fbgui/controllers/AuthController.php b/application/modules/fbgui/controllers/AuthController.php index c811b06..936aa61 100644 --- a/application/modules/fbgui/controllers/AuthController.php +++ b/application/modules/fbgui/controllers/AuthController.php @@ -39,35 +39,29 @@ class Fbgui_AuthController extends Zend_Controller_Action $auth = Zend_Auth::getInstance(); - $adapter = new Zend_Auth_Adapter_DbTable( - $this->db, - 'pbs_person', - 'email', - 'password', - 'MD5(CONCAT(?, password_salt))' - ); + $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."; - } + $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; @@ -81,7 +75,8 @@ class Fbgui_AuthController extends Zend_Controller_Action $auth->clearIdentity(); Zend_Session::namespaceUnset('userIDs'); Zend_Session::forgetMe(); - $this->_helper->redirector('login', 'auth'); + $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 26f12fb..ab146d3 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -135,9 +135,9 @@ class Fbgui_IndexController extends Zend_Controller_Action // 'Your alphasessionID is '.$session->getAlphasessionID(), // 'Your client is '.$session->getClientID(), // 'there is no bootmenu for you'); - - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify("There is no BootMenu to show. Please log in to get your BootMenu.<br />Click here to <a href='/fbgui/auth/login/'>login</a>",'error'); + $this->view->nobootmenu = true; + #$pbsNotifier = new Pbs_Notifier(); + #$this->view->notification = $pbsNotifier->notify("There is no BootMenu to show. Please log in to get your BootMenu.<br />Click here to <a href='/fbgui/auth/login/'>login</a>",'error'); } } diff --git a/application/modules/fbgui/views/scripts/index/index.phtml b/application/modules/fbgui/views/scripts/index/index.phtml index a141add..2454d45 100644 --- a/application/modules/fbgui/views/scripts/index/index.phtml +++ b/application/modules/fbgui/views/scripts/index/index.phtml @@ -1,12 +1,82 @@ <?php if($this->notification != ''){echo $this->notification;} ?> -<?php if($this->loginmenu):?> -<div class="fbguilogin selectswitch" style=''> - <div style='font-size:16px;font-weight:bold;margin-bottom:5px;'>Login</div> - <i>This is not your Bootmenu. Select this to get your own Bootmenu.</i> - <input type="hidden" class="id" value="login"/> -</div> + +<?php if($this->nobootmenu === true):?> + <div class="fbguilogin selectswitch" style=''> + <div style='font-size:16px;font-weight:bold;margin-bottom:5px;'>Login</div> + <i>There is no BootMenu to show. Please login to get your BootMenu.</i> + <input type="hidden" class="id" value="login"/> + </div> + <script type="text/javascript"> + var activeElement = 0; + $(document).ready(function(){ + $('.selectswitch').click(function(){ + $('.selectswitch').removeClass('selected'); + $(this).addClass('selected'); + $("#selectedBootOs").val($(this).find('.id').val()); + $("#startbutton").focus(); + }); + $('.selectswitch').click(); + $('#startbutton').focus(); + $('.selectswitch').dblclick(function(){ + $('.selectswitch').removeClass('selected'); + $(this).addClass('selected'); + $("#selectedBootOs").val($(this).find('.id').val()); + $("#startbutton").focus(); + start(); + }); + + $(function() { + $(document).keyup(function (event) { + if (event.keyCode == 38) { + // up + if(activeElement >=1) + activeElement = activeElement-1; + $('.selectswitch').eq(activeElement).click(); + } else if (event.keyCode == 40) { + // Down + if(activeElement < $('.selectswitch').length-1 ) + activeElement = activeElement+1; + $('.selectswitch').eq(activeElement).click(); + } else if (event.keyCode == 13) { + // Down + $('#startbutton').click(); + } + }); + }); + }); + function start(){ + if($('#selectedBootOs').val() != ''){ + if($('#selectedBootOs').val() == 'login'){ + window.location='/fbgui/auth/login/' + } else{ + window.location='/fbgui/index/start/bme/'+$('#selectedBootOs').val(); + } + } + else{ + alert('You have to select a BootOs'); + } + } + </script> + <input style="display:none;" type='text' id="selectedBootOs" /> + <button onClick="start();" id='startbutton' class="fbguistart" style='font-size:16px;font-weight:bold;margin-bottom:5px;'> + Login + </button> + <div class='clear'></div> <?php endif; ?> <?php if(isset($this->entries)):?> + <?php if($this->loginmenu):?> + <div class="fbguilogin selectswitch" style=''> + <div style='font-size:16px;font-weight:bold;margin-bottom:5px;'>Login</div> + <i>This is not your Bootmenu. Select this to get your own Bootmenu.</i> + <input type="hidden" class="id" value="login"/> + </div> + <?php else:?> + <div class="fbguilogin selectswitch" style=''> + <div style='font-size:16px;font-weight:bold;margin-bottom:5px;'>Logout</div> + <i>Select this to logout and get to the default BootMenu.</i> + <input type="hidden" class="id" value="logout"/> + </div> + <?php endif;?> <script type="text/javascript"> var activeElement = 0; $(document).ready(function(){ @@ -14,7 +84,7 @@ $('.selectswitch').removeClass('selected'); $(this).addClass('selected'); $("#selectedBootOs").val($(this).find('.id').val()); - $("#startbutton").focus(); + $("#startbutton").focus(); }); $('.bootmenu .selectswitch').eq(activeElement).click(); $('#startbutton').focus(); @@ -50,6 +120,8 @@ if($('#selectedBootOs').val() != ''){ if($('#selectedBootOs').val() == 'login'){ window.location='/fbgui/auth/login/' + }else if($('#selectedBootOs').val() == 'logout'){ + window.location='/fbgui/auth/logout/' } else{ window.location='/fbgui/index/start/bme/'+$('#selectedBootOs').val(); } @@ -82,9 +154,5 @@ <button onClick="start();" id='startbutton' class="fbguistart" style='font-size:16px;font-weight:bold;margin-bottom:5px;'> Start System </button> - <div class='clear'></div> - <?php if($this->notificationbot != ''){echo $this->notificationbot;} ?> - - - + <div class='clear'></div> <?php endif;?> |
