summaryrefslogtreecommitdiffstats
path: root/library/Pbs/Session.php
diff options
context:
space:
mode:
authorSebastian Schmelzer2012-01-11 14:36:35 +0100
committerSebastian Schmelzer2012-01-11 14:36:35 +0100
commitfca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e (patch)
tree6e6aaf749f34db8c7c7153c23ef85c57187430bb /library/Pbs/Session.php
parentAPI: mit addBootos kann man nun auch editieren (diff)
downloadpbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.gz
pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.xz
pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.zip
format source files
Diffstat (limited to 'library/Pbs/Session.php')
-rw-r--r--library/Pbs/Session.php70
1 files changed, 34 insertions, 36 deletions
diff --git a/library/Pbs/Session.php b/library/Pbs/Session.php
index 12e6738..bc4587e 100644
--- a/library/Pbs/Session.php
+++ b/library/Pbs/Session.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.
@@ -10,41 +10,39 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
-class Pbs_Session{
+class Pbs_Session {
- public function createSession(Application_Model_Session $session){
- $sessionmapper = new Application_Model_SessionMapper();
- $uniqid = $this->getUniqueCode(10);
- $sm = new Application_Model_SessionMapper();
- while(count($sm->findBy(array('alphasessionID' => $uniqid),true))>0){
- $uniqid = $this->getUniqueCode(16);
- }
-
- $session->setAlphasessionID($uniqid);
-
- $id = $sessionmapper->save($session);
- $sessionmapper->find($id, $session);
- return $session;
- }
- public function createClient(Application_Model_Client $client){
- $clientmapper = new Application_Model_ClientMapper();
- $result = $clientmapper->findBy(array('macadress' => $client->getMacadress(),'groupID'=>$client->getGroupID()),true);
- if(count($result)>0){
- $client->setOptions($result[0]);
- $client->setID($result[0]['clientID']);
- }
- else{
- $id = $clientmapper->save($client);
- $clientmapper->find($id, $client);
- }
- return $client;
- }
- private function getUniqueCode($length = "")
- {
- $code = md5(uniqid(rand(), true));
- if ($length != "") return substr($code, 0, $length);
- else return $code;
- }
+ public function createSession(Application_Model_Session $session) {
+ $sessionmapper = new Application_Model_SessionMapper();
+ $uniqid = $this->getUniqueCode(10);
+ $sm = new Application_Model_SessionMapper();
+ while(count($sm->findBy(array('alphasessionID' => $uniqid), true)) > 0) {
+ $uniqid = $this->getUniqueCode(16);
+ }
+
+ $session->setAlphasessionID($uniqid);
+
+ $id = $sessionmapper->save($session);
+ $sessionmapper->find($id, $session);
+ return $session;
+ }
+ public function createClient(Application_Model_Client $client) {
+ $clientmapper = new Application_Model_ClientMapper();
+ $result = $clientmapper->findBy(array('macadress' => $client->getMacadress(), 'groupID' => $client->getGroupID()), true);
+ if(count($result) > 0) {
+ $client->setOptions($result[0]);
+ $client->setID($result[0]['clientID']);
+ } else {
+ $id = $clientmapper->save($client);
+ $clientmapper->find($id, $client);
+ }
+ return $client;
+ }
+ private function getUniqueCode($length = "") {
+ $code = md5(uniqid(rand(), true));
+ if ($length != "") { return substr($code, 0, $length); }
+ else { return $code; }
+ }
}
-?>
+? >