summaryrefslogtreecommitdiffstats
path: root/application/modules/dev/controllers/SessionController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/dev/controllers/SessionController.php')
-rw-r--r--application/modules/dev/controllers/SessionController.php184
1 files changed, 0 insertions, 184 deletions
diff --git a/application/modules/dev/controllers/SessionController.php b/application/modules/dev/controllers/SessionController.php
deleted file mode 100644
index 56a7733..0000000
--- a/application/modules/dev/controllers/SessionController.php
+++ /dev/null
@@ -1,184 +0,0 @@
-<?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 dev_SessionController extends Zend_Controller_Action {
-
- public function init() {
- /* Initialize action controller here */
- }
-
- public function indexAction() {
- $mapper = new Application_Model_SessionMapper();
- $this->view->sessions = $mapper->fetchAll();
-#print_a($_SESSION);
- }
- private function getUniqueCode($length = "") {
- $code = md5(uniqid(rand(), true));
- if ($length != "") { return substr($code, 0, $length); }
- else { return $code; }
- }
-
- public function createsessionAction() {
- $cm = new Application_Model_ClientMapper();
- $clients = $cm->fetchAll();
-
- $bm = new Application_Model_BootOsMapper();
- $bootos = $bm->fetchAll();
-
- $bi = new Application_Model_BootIsoMapper();
- $bootisos = $bi->fetchAll();
-
- $bmem = new Application_Model_BootMenuEntriesMapper();
- $bootmenuentries = $bmem->fetchAll();
-
- $mm = new Application_Model_MembershipMapper();
- $memberships = $mm->fetchAll();
-
-
- if (!isset($_POST["add"])) {
- $createsession = new dev_Form_Session(array('buttontext' => 'Create Session', 'bootmenuentries' => $bootmenuentries, 'clients' => $clients, 'bootos' => $bootos, 'bootisos' => $bootisos, 'memberships' => $memberships));
- $this->view->createsession = $createsession;
- } else {
- // TODO extend with normal function not only with post
- $createsession = new dev_Form_Session(array('buttontext' => 'Create Session', 'bootmenuentries' => $bootmenuentries, 'clients' => $clients, 'bootos' => $bootos, 'bootisos' => $bootisos), $_POST);
-#print_a($_POST);
- if ($createsession->isValid($_POST)) {
- try {
- $uniqid = $this->getUniqueCode(10);
- $sm = new Application_Model_SessionMapper();
- while(count($sm->findBy(array('alphasessionID' => $uniqid), true)) > 0) {
- $uniqid = $this->getUniqueCode(16);
- }
-
- $session = new Application_Model_Session($_POST);
- $session->setTime(strtotime($_POST['time']));
- $session->setAlphasessionID($uniqid);
-
- // UNIQUE ID IN SESSION SPEICHERN:
- $_SESSION['alphasessionID'] = $uniqid;
-
- if($session->getClientID() == '') {
- $session->setClientID(null);
- }
- if($session->getBootosID() == '') {
- $session->setBootosID(null);
- }
- if($session->getBootmenuentryID() == '') {
- $session->setBootmenuentryID(null);
- }
- if($session->getMembershipID() == '') {
- $session->setMembershipID(null);
- }
- $sessionmapper = new Application_Model_SessionMapper();
- $sessionmapper->save($session);
-
- $this->_redirect('/dev/session');
-
- } catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
- $this->view->createsession = $createsession;
- }
- }
-
- public function editsessionAction() {
- $cm = new Application_Model_ClientMapper();
- $clients = $cm->fetchAll();
-
- $bm = new Application_Model_BootOsMapper();
- $bootos = $bm->fetchAll();
-
- $bi = new Application_Model_BootIsoMapper();
- $bootisos = $bi->fetchAll();
-
- $bmem = new Application_Model_BootMenuEntriesMapper();
- $bootmenuentries = $bmem->fetchAll();
-
- $mm = new Application_Model_MembershipMapper();
- $memberships = $mm->fetchAll();
-
- if (!isset($_POST["add"])) {
- // TODO: ACL implementieren ob er editieren darf
- $sessionID = $this->_request->getParam('sessionID');
- $session = new Application_Model_Session();
- try {
-
- $sessionmapper = new Application_Model_SessionMapper();
- $sessionmapper->find($sessionID, $session);
- $session->setTime(date('d.m.Y H:i', $session->getTime()));
- $session2 = $session->toArray();
-#print_a($session2);
-
- $editsession = new dev_Form_Session(array('buttontext' => 'Edit Session', 'bootmenuentries' => $bootmenuentries, 'clients' => $clients, 'bootos' => $bootos, 'bootisos' => $bootisos, 'memberships' => $memberships));
- $editsession->populate($session2);
- $this->view->editsession = $editsession;
- } catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
-
- } else {
- try {
- $sessionID = $this->_request->getParam('sessionID');
-
- $editsession = new dev_Form_Session(array('buttontext' => 'Edit Session', 'bootmenuentries' => $bootmenuentries, 'clients' => $clients, 'bootos' => $bootos, 'bootisos' => $bootisos, 'memberships' => $memberships), $_POST);
-
- if ($editsession->isValid($_POST)) {
- $_SESSION['alphasessionID'] = $_POST['alphasessionID'];
- $session = new Application_Model_Session($_POST);
- $session->setID($this->_request->getParam('sessionID'));
- $session->setTime(strtotime($_POST['time']));
- if($session->getClientID() == '') {
- $session->setClientID(null);
- }
- if($session->getBootosID() == '') {
- $session->setBootosID(null);
- }
- if($session->getBootmenuentryID() == '') {
- $session->setBootmenuentryID(null);
- }
- if($session->getMembershipID() == '') {
- $session->setMembershipID(null);
- }
- $sessionmapper = new Application_Model_SessionMapper();
- $sessionmapper->save($session);
- echo 'valid';
- } else {
- echo 'not valid';
- }
- } catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- $this->_redirect('/dev/session');
- }
- }
-
- public function deletesessionAction() {
- $sessionID = $this->_request->getParam('sessionID');
- if(is_numeric($sessionID)) {
- $deletesession = new Application_Model_Session();
- $deletesession->setID($sessionID);
- $sessionmapper = new Application_Model_SessionMapper();
- $sessionmapper->delete($deletesession);
- }
- $this->_redirect('/dev/session');
- }
-
-
-}
-
-
-
-
-
-
-