diff options
| author | michael pereira | 2011-04-20 18:49:49 +0200 |
|---|---|---|
| committer | michael pereira | 2011-04-20 18:49:49 +0200 |
| commit | cc3660add480ac1dc217d7f853b325db7d6ec7d0 (patch) | |
| tree | 8056c87777d806c613a607c3f479ce07475b5db6 /application/modules/fbgui | |
| parent | API + Fixes (diff) | |
| parent | Url für Config gekürzt (diff) | |
| download | pbs2-cc3660add480ac1dc217d7f853b325db7d6ec7d0.tar.gz pbs2-cc3660add480ac1dc217d7f853b325db7d6ec7d0.tar.xz pbs2-cc3660add480ac1dc217d7f853b325db7d6ec7d0.zip | |
merges
Diffstat (limited to 'application/modules/fbgui')
7 files changed, 267 insertions, 148 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 fb8282a..d2b21be 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -13,65 +13,75 @@ class Fbgui_IndexController extends Zend_Controller_Action { protected $membership; - - public function init() - { - /* Initialize action controller here */ - $membershipMapper = new Application_Model_MembershipMapper(); + + 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'); + public function errorAction() + { + $result = $this->_request->getParam('serialresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('serial',$result); - } - } - - public function indexAction() - { + } + } + + public function indexAction() + { $mySession = new Zend_Session_Namespace('pbs'); - - if(count($mySession->postdata)<=0) + + 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(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']); + $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'])){ + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + + if(!isset($_SESSION['alphasessionID'])){ $session = new Application_Model_Session(); $session->setBootisoID($bootiso->getID()); $session->setClientID($clientID); @@ -79,18 +89,18 @@ class Fbgui_IndexController extends Zend_Controller_Action if($this->membership->getID() != ''){ $session->setMembershipID($this->membership->getID()); } - $session->setIp($_SERVER['REMOTE_ADDR']); + $session->setIp($_SERVER['REMOTE_ADDR']); $session = $n->createSession($session); - $_SESSION['alphasessionID'] = $session->getAlphasessionID(); + $_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() != ''){ + if($this->membership->getID() != '' && $session->getMembershipID() == ''){ $session->setMembershipID($this->membership->getID()); - $session->save(); + $sessionMapper->save($session); } } // Request Bootmenu @@ -98,74 +108,70 @@ class Fbgui_IndexController extends Zend_Controller_Action $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); - + // 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; - #print_a(Zend_Auth::getInstance()->hasIdentity(),$bm->MembershipID ,$this->membership->getID()); - if (!Zend_Auth::getInstance()->hasIdentity()) { - # $pbsNotifier = new Pbs_Notifier(); - # $this->view->notification = $pbsNotifier->notify("This is not your Bootmenu. You have to login to get your own Bootmenu.<br />Click here to <a href='/fbgui/auth/login/'>login</a>",'info'); + + if (!Zend_Auth::getInstance()->hasIdentity()) { $this->view->loginmenu = true; } - if(Zend_Auth::getInstance()->hasIdentity()){ + + 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'); + $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'); } } } 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'); - - $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'); - + // 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'); + $this->view->nobootmenu = true; } } else{ - #$this->_redirect('/fbgui/index/error/serialresult/noserial'); - } - - } + #$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_k = $sessionMapper->findBy(array('alphasessionID' => $a),true); + + $session = new Application_Model_Session(); $session->setOptions($session_k[0]); $session->setID($session_k[0]['sessionID']); - #print_a($bootmenuentry); + $session->setBootmenuentryID($bootmenuntryID); $session->setBootosID($bootmenuentry->getBootosID()); $sessionMapper->save($session); - - + + $this->view->host = '132.230.4.27'; - $this->view->alphasessionID = $a; + $this->view->alphasessionID = $a; } } diff --git a/application/modules/fbgui/controllers/PersonController.php b/application/modules/fbgui/controllers/PersonController.php index 7bb82aa..b884a28 100644 --- a/application/modules/fbgui/controllers/PersonController.php +++ b/application/modules/fbgui/controllers/PersonController.php @@ -42,7 +42,15 @@ class Fbgui_PersonController extends Zend_Controller_Action if(isset($userIDsNamespace['membershipID'])) { $this->_redirect('/fbgui/'); } else { - if(count($this->memberships) > 0) { + 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']; @@ -70,7 +78,7 @@ class Fbgui_PersonController extends Zend_Controller_Action $this->view->membershipSelectForm = $membershipSelectForm; } } else { - $this->_redirect('/fbgui/'); + $this->_redirect('/fbgui/index/index/notify/nomember'); } } } diff --git a/application/modules/fbgui/forms/Login.php b/application/modules/fbgui/forms/Login.php index ee8846f..896b555 100644 --- a/application/modules/fbgui/forms/Login.php +++ b/application/modules/fbgui/forms/Login.php @@ -25,7 +25,7 @@ class fbgui_Form_Login extends Zend_Form ), 'required' => true, 'id' => 'email', - 'class' => '', + 'class' => 'keyboardInput', 'label' => 'E-Mail:', )); @@ -36,12 +36,13 @@ class fbgui_Form_Login extends Zend_Form ), 'required' => true, 'id' => 'pass', - 'class' => '', + 'class' => 'keyboardInput', 'label' => 'Password:', )); $this->addElement('submit', 'login', array( 'required' => false, + 'id' => 'submit', 'ignore' => true, 'label' => 'Login', )); diff --git a/application/modules/fbgui/layouts/rz.phtml b/application/modules/fbgui/layouts/rz.phtml index 5945695..cecf38e 100644 --- a/application/modules/fbgui/layouts/rz.phtml +++ b/application/modules/fbgui/layouts/rz.phtml @@ -17,26 +17,9 @@ echo $this->headScript()."\n"; <script src='/media/js/jquery-ui.min.js'></script> <script src='/media/js/script.js'></script> -<script src='/media/js/jquery.mousewheel.js'></script> -<script src='/media/js/jquery.keyboard.js'></script> -<script src='/media/js/jquery.keyboard.extension-typing.js'></script> +<script src='/media/js/keyboard.js'></script> <link href="/media/css/keyboard.css" media="screen" rel="stylesheet" type="text/css" /> -<script type="text/javascript"> -function toggleKeyboard(onoff){ - if($('#email').hasClass('qwerty') == false){ - $('#email').addClass('qwerty'); - $('#pass').addClass('qwerty'); - $('.qwerty').keyboard({ layout: 'qwerty' }).addTyping(); - } - else{ - $('#email').removeClass('qwerty ui-keyboard-input ui-widget-content ui-corner-all').unbind(); - $('#pass').removeClass('qwerty ui-keyboard-input ui-widget-content ui-corner-all').unbind(); - } -} - -</script> - </head> <body> <div id='sidepannel'> @@ -72,6 +55,7 @@ function toggleKeyboard(onoff){ </div> <div id="footer" class="footer flexbox flex"> + <div style='float:left;padding-left:5px;'><button onclick='fbgui.shutDown();'>Shutdown</button></div> <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> // diff --git a/application/modules/fbgui/views/scripts/auth/login.phtml b/application/modules/fbgui/views/scripts/auth/login.phtml index 09724d4..330b34f 100644 --- a/application/modules/fbgui/views/scripts/auth/login.phtml +++ b/application/modules/fbgui/views/scripts/auth/login.phtml @@ -3,9 +3,15 @@ $this->loginForm->setAction($this->url()); echo $this->loginForm; ?> -<button class='keyboardbutton' onclick='toggleKeyboard();return false;'>Show/Hide on-screen keyboard</button> + <script> $(document).ready(function(){ $("#email").focus(); + $('input').keypress(function(e) { + if(e.which == 13) { + $(this).blur(); + $('#login').focus().click(); + } + }); }); </script> diff --git a/application/modules/fbgui/views/scripts/index/index.phtml b/application/modules/fbgui/views/scripts/index/index.phtml index a141add..8a5f0e6 100644 --- a/application/modules/fbgui/views/scripts/index/index.phtml +++ b/application/modules/fbgui/views/scripts/index/index.phtml @@ -1,20 +1,114 @@ <?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).click(function(){ + abortStartcount = true; + }) + $(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(); + } + abortStartcount = true; + }); + }); + decreaseDown(); + }); + function decreaseDown(){ + var act = parseInt($('.startcounter').html()); + if(act == 0){ + start(); + return; + } + var next = act-1; + $('.startcounter').html(next); + if(next == 0){ + start(); + } + if(next > 0 && abortStartcount == false){ + setTimeout('decreaseDown()',1000); + } + if(abortStartcount == true){ + $('.startcounter').parent().fadeOut(); + } + } + 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; + var abortStartcount = false; $(document).ready(function(){ $('.selectswitch').click(function(){ $('.selectswitch').removeClass('selected'); $(this).addClass('selected'); $("#selectedBootOs").val($(this).find('.id').val()); - $("#startbutton").focus(); + $("#startbutton").focus(); }); $('.bootmenu .selectswitch').eq(activeElement).click(); $('#startbutton').focus(); @@ -27,6 +121,9 @@ }); $(function() { + $(document).click(function(){ + abortStartcount = true; + }) $(document).keyup(function (event) { if (event.keyCode == 38) { // up @@ -42,14 +139,37 @@ // Down $('#startbutton').click(); } + abortStartcount = true; }); }); - + <?php if(count($this->entries) > 0): ?> + decreaseDown() + <?php endif; ?> }); + function decreaseDown(){ + var act = parseInt($('.startcounter').html()); + if(act == 0){ + start(); + return; + } + var next = act-1; + $('.startcounter').html(next); + if(next == 0){ + start(); + } + if(next > 0 && abortStartcount == false){ + setTimeout('decreaseDown()',1000); + } + if(abortStartcount == true){ + $('.startcounter').parent().fadeOut(); + } + } function start(){ 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(); } @@ -60,6 +180,9 @@ } </script> <h1><?php echo $this->title;?></h1> + <?php if(count($this->entries) > 0): ?> + <div style='padding:5px;float:right;'>Starting in <span class='startcounter'><?php echo $this->startcounter; ?></span> seconds</div> + <?php endif; ?> <div class='bootmenu'> <?php $first = true; ?> @@ -77,14 +200,10 @@ <input type="hidden" class="id" value="<?php echo $entry->getID();?>"/> </div> <?php endforeach; ?> - </div> + </div> <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;'> Start System </button> - <div class='clear'></div> - <?php if($this->notificationbot != ''){echo $this->notificationbot;} ?> - - - + <div class='clear'></div> <?php endif;?> |
