diff options
Diffstat (limited to 'application/modules')
100 files changed, 13774 insertions, 14267 deletions
diff --git a/application/modules/dev/Bootstrap.php b/application/modules/dev/Bootstrap.php index d8dece3..4215699 100644 --- a/application/modules/dev/Bootstrap.php +++ b/application/modules/dev/Bootstrap.php @@ -1,22 +1,20 @@ -<?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 dev_Bootstrap extends Zend_Application_Module_Bootstrap -{ - function _initViewHelpers() - { - $this->bootstrap('layout'); - - $layout = $this->getResource('layout'); - $view = $layout->getView(); - $view->headLink()->appendStylesheet('/media/css/dev.css'); - } +* 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_Bootstrap extends Zend_Application_Module_Bootstrap { + function _initViewHelpers() { + $this->bootstrap('layout'); + + $layout = $this->getResource('layout'); + $view = $layout->getView(); + $view->headLink()->appendStylesheet('/media/css/dev.css'); + } } diff --git a/application/modules/dev/controllers/AuthController.php b/application/modules/dev/controllers/AuthController.php index bb59037..2e99cd7 100644 --- a/application/modules/dev/controllers/AuthController.php +++ b/application/modules/dev/controllers/AuthController.php @@ -1,247 +1,234 @@ -<?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 dev_AuthController extends Zend_Controller_Action -{ - protected $personmapper; - private $db = null; - - 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('/dev/'); - } else { - if (!isset($_POST["login"])){ - $loginForm = new dev_Form_AuthLogin(); - } else { - $loginForm = new dev_Form_AuthLogin($_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->_redirect('/dev/'); - return; - } else { - echo "Wrong Email or Password."; - } - } - } - $this->view->loginForm = $loginForm; - } - } - - public function registerAction() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - print_a('Already logged in.'); - } else { - if (!isset($_POST["register"])){ - $registerForm = new dev_Form_AuthRegister(); - } else { - $registerForm = new dev_Form_AuthRegister($_POST); - - if ($registerForm->isValid($_POST)) { - - $person = new Application_Model_Person($_POST); - $this->personmapper = new Application_Model_PersonMapper(); - - $date = new DateTime(); - $person->setRegisterdate($date->getTimestamp()); - $person->setPasswordSalt(MD5($date->getTimestamp())); - $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); - print_a($person); - try { - $this->personmapper->save($person); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - echo "Email Address already existing.."; - return; - } - echo "Successfully registered. <br/>"; - echo "Continue to Login: <a href=\""."/dev/auth/login"."\">Login</a>"; - $this->_helper->redirector('login', 'auth'); - return; - } - } - $this->view->registerForm = $registerForm; - } - } - - public function logoutAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $auth = Zend_Auth::getInstance(); - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_helper->redirector('login', 'auth'); - return; - } - - public function recoverpasswordAction() - { - if (isset($_POST["savePassword"])){ - $personID = $_POST['personID']; - $recoverPasswordForm = new dev_Form_NewPassword(array("personID" => $personID, $_POST)); - if ($recoverPasswordForm->isValid($_POST)) { - $this->personmapper = new Application_Model_PersonMapper(); - $person = $this->personmapper->find($personID); - $date = new DateTime(); - $person->setPassword($_POST['password']); - $person->setPasswordSalt(MD5($date->getTimestamp())); - $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); - try { - $this->personmapper->save($person); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - echo "Email Address already existing."; - return; - } - $this->_helper->redirector('login', 'auth'); - return; - } - } else if(isset($_GET['recoveryid'])) { - $recoveryid = $_GET['recoveryid']; - $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); - $passwordRecovery = $passwordRecoveryMapper->findBy(array("recoveryID" => $recoveryid),true); - if(count($passwordRecovery) > 0) { - $passwordRecoveryObject = new Application_Model_PasswordRecovery(); - $passwordRecoveryObject->setID($passwordRecovery[0]['personID']); - $passwordRecoveryObject->setRecoveryID($passwordRecovery[0]['recoveryID']); - $personID = $passwordRecoveryObject->getID(); - $recoverPasswordForm = new dev_Form_NewPassword(array("personID" => $personID)); - try { - $passwordRecoveryMapper->delete($passwordRecoveryObject); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - } else { - $this->_helper->redirector('login', 'auth'); - return; - } - } else { - if (!isset($_POST["recoverPassword"])){ - $recoverPasswordForm = new dev_Form_AuthRecoverPassword(); - } else { - $recoverPasswordForm = new dev_Form_AuthRecoverPassword($_POST); - if ($recoverPasswordForm->isValid($_POST)) { - $recoverPasswordForm->getView()->url(); - $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy('email', $_POST['email']); - $person = new Application_Model_Person($result[0]); - $person->setID($result[0]['personID']); - $email = $person->getEmail(); - $name = $person->getFirstname() . ' ' . $person->getName(); - $url = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->view->url(); - $recoveryid = randomString(100); - $mailbody = 'Um das Passwort zu ändern klicken Sie auf folgenden Link<br /><br /><a href="'. $url . '/auth/recoverpassword/?recoveryid='. $recoveryid . '">Passwort ändern</a>'; - $mail = new Zend_Mail(); - $mail->setBodyHtml($mailbody, 'utf8'); - $mail->getBodyHtml()->getContent(); - $mail->setFrom('admin@local', 'Admin'); - $mail->addTo($email, $name); - $mail->setSubject('Password Wiederherstellung Preboot Server'); - $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); - $passwordRecoveryObject = new Application_Model_PasswordRecovery(); - $passwordRecoveryObject->setID($person->getID()); - $passwordRecoveryObject->setRecoveryID($recoveryid); - try { - $passwordRecoveryMapper->save($passwordRecoveryObject); - $mail->send(); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('login', 'auth'); - return; - } - } - } - $this->view->recoverPasswordForm = $recoverPasswordForm; - } - - public function deleteAction() - { - if($_POST['confirmdelete']) { - $auth = Zend_Auth::getInstance(); - $result = $this->personmapper->findBy(array('email' => $auth->getIdentity()), true); - $person = $result[0]; - $personID = $person["personID"]; - if (isset($personID)){ - $this->personmapper = new Application_Model_PersonMapper(); - $person = $this->personmapper->find($personID); - try { - $this->personmapper->delete($person); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_helper->redirector('login', 'auth'); - return; - } - } else { - $deleteconfirmform = new dev_Form_ConfirmDeleteAccount(); - $this->view->deleteconfirmform = $deleteconfirmform; - } - } +* 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_AuthController extends Zend_Controller_Action { + protected $personmapper; + private $db = null; + + 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('/dev/'); + } else { + if (!isset($_POST["login"])) { + $loginForm = new dev_Form_AuthLogin(); + } else { + $loginForm = new dev_Form_AuthLogin($_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->_redirect('/dev/'); + return; + } else { + echo "Wrong Email or Password."; + } + } + } + $this->view->loginForm = $loginForm; + } + } + + public function registerAction() { + if (Zend_Auth::getInstance()->hasIdentity()) { + print_a('Already logged in.'); + } else { + if (!isset($_POST["register"])) { + $registerForm = new dev_Form_AuthRegister(); + } else { + $registerForm = new dev_Form_AuthRegister($_POST); + + if ($registerForm->isValid($_POST)) { + + $person = new Application_Model_Person($_POST); + $this->personmapper = new Application_Model_PersonMapper(); + + $date = new DateTime(); + $person->setRegisterdate($date->getTimestamp()); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + print_a($person); + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing.."; + return; + } + echo "Successfully registered. <br/>"; + echo "Continue to Login: <a href=\""."/dev/auth/login"."\">Login</a>"; + $this->_helper->redirector('login', 'auth'); + return; + } + } + $this->view->registerForm = $registerForm; + } + } + + public function logoutAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_helper->redirector('login', 'auth'); + return; + } + + public function recoverpasswordAction() { + if (isset($_POST["savePassword"])) { + $personID = $_POST['personID']; + $recoverPasswordForm = new dev_Form_NewPassword(array("personID" => $personID, $_POST)); + if ($recoverPasswordForm->isValid($_POST)) { + $this->personmapper = new Application_Model_PersonMapper(); + $person = $this->personmapper->find($personID); + $date = new DateTime(); + $person->setPassword($_POST['password']); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing."; + return; + } + $this->_helper->redirector('login', 'auth'); + return; + } + } else if(isset($_GET['recoveryid'])) { + $recoveryid = $_GET['recoveryid']; + $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); + $passwordRecovery = $passwordRecoveryMapper->findBy(array("recoveryID" => $recoveryid), true); + if(count($passwordRecovery) > 0) { + $passwordRecoveryObject = new Application_Model_PasswordRecovery(); + $passwordRecoveryObject->setID($passwordRecovery[0]['personID']); + $passwordRecoveryObject->setRecoveryID($passwordRecovery[0]['recoveryID']); + $personID = $passwordRecoveryObject->getID(); + $recoverPasswordForm = new dev_Form_NewPassword(array("personID" => $personID)); + try { + $passwordRecoveryMapper->delete($passwordRecoveryObject); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } else { + $this->_helper->redirector('login', 'auth'); + return; + } + } else { + if (!isset($_POST["recoverPassword"])) { + $recoverPasswordForm = new dev_Form_AuthRecoverPassword(); + } else { + $recoverPasswordForm = new dev_Form_AuthRecoverPassword($_POST); + if ($recoverPasswordForm->isValid($_POST)) { + $recoverPasswordForm->getView()->url(); + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy('email', $_POST['email']); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $email = $person->getEmail(); + $name = $person->getFirstname() . ' ' . $person->getName(); + $url = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->view->url(); + $recoveryid = randomString(100); + $mailbody = 'Um das Passwort zu ändern klicken Sie auf folgenden Link<br /><br /><a href="'. $url . '/auth/recoverpassword/?recoveryid='. $recoveryid . '">Passwort ändern</a>'; + $mail = new Zend_Mail(); + $mail->setBodyHtml($mailbody, 'utf8'); + $mail->getBodyHtml()->getContent(); + $mail->setFrom('admin@local', 'Admin'); + $mail->addTo($email, $name); + $mail->setSubject('Password Wiederherstellung Preboot Server'); + $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); + $passwordRecoveryObject = new Application_Model_PasswordRecovery(); + $passwordRecoveryObject->setID($person->getID()); + $passwordRecoveryObject->setRecoveryID($recoveryid); + try { + $passwordRecoveryMapper->save($passwordRecoveryObject); + $mail->send(); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('login', 'auth'); + return; + } + } + } + $this->view->recoverPasswordForm = $recoverPasswordForm; + } + + public function deleteAction() { + if($_POST['confirmdelete']) { + $auth = Zend_Auth::getInstance(); + $result = $this->personmapper->findBy(array('email' => $auth->getIdentity()), true); + $person = $result[0]; + $personID = $person["personID"]; + if (isset($personID)) { + $this->personmapper = new Application_Model_PersonMapper(); + $person = $this->personmapper->find($personID); + try { + $this->personmapper->delete($person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_helper->redirector('login', 'auth'); + return; + } + } else { + $deleteconfirmform = new dev_Form_ConfirmDeleteAccount(); + $this->view->deleteconfirmform = $deleteconfirmform; + } + } } diff --git a/application/modules/dev/controllers/BootisoController.php b/application/modules/dev/controllers/BootisoController.php index 5c250cc..d9a2b15 100644 --- a/application/modules/dev/controllers/BootisoController.php +++ b/application/modules/dev/controllers/BootisoController.php @@ -1,194 +1,185 @@ -<?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 dev_BootisoController extends Zend_Controller_Action -{ - - public function init() - { - $db = Zend_Db_Table::getDefaultAdapter(); +* 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_BootisoController extends Zend_Controller_Action { + + public function init() { + $db = Zend_Db_Table::getDefaultAdapter(); + } + + public function indexAction() { + $bootisomapper = new Application_Model_BootIsoMapper(); + $groupmapper = new Application_Model_GroupMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $personmapper = new Application_Model_PersonMapper(); + $prebootmapper = new Application_Model_PreBootMapper(); + + $this->view->bootisolist = $bootisomapper->fetchAll(); + $this->view->prebootlist = array(); + + + foreach ($this->view->bootisolist as $bootiso) { + $this->view->prebootlist[$bootiso->getID()] = $prebootmapper->find($bootiso->getPrebootID())->getTitle(); + $bootiso->setGroupID("[".$bootiso->getGroupID()."] ".$groupmapper->find($bootiso->getGroupID())->getTitle()); + $bootiso->setMembershipID("[".$bootiso->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootiso->getMembershipID())->getPersonID())->getFirstname()); } - public function indexAction() - { - $bootisomapper = new Application_Model_BootIsoMapper(); - $groupmapper = new Application_Model_GroupMapper(); - $membershipmapper = new Application_Model_MembershipMapper(); - $personmapper = new Application_Model_PersonMapper(); - $prebootmapper = new Application_Model_PreBootMapper(); - - $this->view->bootisolist = $bootisomapper->fetchAll(); - $this->view->prebootlist = array(); - - - foreach ($this->view->bootisolist as $bootiso){ - $this->view->prebootlist[$bootiso->getID()] = $prebootmapper->find($bootiso->getPrebootID())->getTitle(); - $bootiso->setGroupID("[".$bootiso->getGroupID()."] ".$groupmapper->find($bootiso->getGroupID())->getTitle()); - $bootiso->setMembershipID("[".$bootiso->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootiso->getMembershipID())->getPersonID())->getFirstname()); - } - - } - - public function downloadbootisoAction() - { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - $prebootID = $this->_request->getParam('prebootID'); - $bootisoID = $this->_request->getParam('bootisoID'); - - if(is_dir("../resources/bootmedium/$prebootID/") && is_numeric($prebootID) && is_numeric($bootisoID)){ - - chdir("../resources/bootmedium/$prebootID/"); - - header("X-Sendfile: $bootisoID".".zip"); - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="preboot.zip"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - - $handle = fopen($bootisoID.".zip", 'r'); - $chunk_size = 8192; - while ($chunk = fread($handle, $chunk_size)) { - echo $chunk; - ob_flush(); - } - - } - - - - + } + + public function downloadbootisoAction() { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + $prebootID = $this->_request->getParam('prebootID'); + $bootisoID = $this->_request->getParam('bootisoID'); + + if(is_dir("../resources/bootmedium/$prebootID/") && is_numeric($prebootID) && is_numeric($bootisoID)) { + + chdir("../resources/bootmedium/$prebootID/"); + + header("X-Sendfile: $bootisoID".".zip"); + header('Content-Type: application/x-gzip'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="preboot.zip"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + + $handle = fopen($bootisoID.".zip", 'r'); + $chunk_size = 8192; + while ($chunk = fread($handle, $chunk_size)) { + echo $chunk; + ob_flush(); + } + } - public function createbootisoAction() - { - $groupmapper = new Application_Model_GroupMapper(); - $prebootmapper = new Application_Model_PreBootMapper(); - - if (!isset($_POST["createbootiso"])){ - $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll())); - } else { - - $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()),$_POST); - - if ($createbootisoForm->isValid($_POST)) { - - $bootiso = new Application_Model_BootIso($_POST); - $bootiso->setMembershipID('1'); - $bootisomapper = new Application_Model_BootIsoMapper(); - $bootiso->setCreated(time()); - - $prebootID = $bootiso->getPrebootID(); - - try { - - $bootisoID = $bootisomapper->save($bootiso); - - copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/tmp/serial", $bootiso->getSerialnumber()); - $zip->close(); - } - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - - } - $this->_redirect('/dev/bootiso'); - } - } - - $this->view->createbootisoForm = $createbootisoForm; + + + + } + + public function createbootisoAction() { + $groupmapper = new Application_Model_GroupMapper(); + $prebootmapper = new Application_Model_PreBootMapper(); + + if (!isset($_POST["createbootiso"])) { + $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(), 'prebootlist' => $prebootmapper->fetchAll())); + } else { + + $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(), 'prebootlist' => $prebootmapper->fetchAll()), $_POST); + + if ($createbootisoForm->isValid($_POST)) { + + $bootiso = new Application_Model_BootIso($_POST); + $bootiso->setMembershipID('1'); + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso->setCreated(time()); + + $prebootID = $bootiso->getPrebootID(); + + try { + + $bootisoID = $bootisomapper->save($bootiso); + + copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res == = true) { + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/tmp/serial", $bootiso->getSerialnumber()); + $zip->close(); + } + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/dev/bootiso'); + } } - public function editbootisoAction() - { - $bootisoID = $this->_request->getParam('bootisoID'); - $groupmapper = new Application_Model_GroupMapper(); - $prebootmapper = new Application_Model_PreBootMapper(); - - - if (!isset($_POST["editbootiso"])){ - $bootisoID = $this->_request->getParam('bootisoID'); - if (!isset($bootisoID) || !is_numeric($bootisoID)){ - $this->_redirect('/dev/bootiso'); - } else { - $bootiso = new Application_Model_BootIso(); - $bootisomapper = new Application_Model_BootIsoMapper(); - $bootisomapper->find($bootisoID, $bootiso); - - $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll())); - $editbootisoForm->populate($bootiso->toArray()); - } - }else{ - $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()),$_POST); - - if ($editbootisoForm->isValid($_POST)) { - - $bootiso = new Application_Model_BootIso($_POST); - $bootiso->setMembershipID('1'); - $bootisomapper = new Application_Model_BootIsoMapper(); - $bootiso->setCreated(time()); - $bootiso->setID($bootisoID); - $prebootID = $bootiso->getPrebootID(); - - try { - - - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/serial", $bootiso->getSerialnumber()); - $zip->close(); - } - - $bootisomapper->save($bootiso); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - } - - $this->_redirect('/dev/bootiso'); - } - - } - - $this->view->editbootisoForm = $editbootisoForm; + $this->view->createbootisoForm = $createbootisoForm; + } + + public function editbootisoAction() { + $bootisoID = $this->_request->getParam('bootisoID'); + $groupmapper = new Application_Model_GroupMapper(); + $prebootmapper = new Application_Model_PreBootMapper(); + + + if (!isset($_POST["editbootiso"])) { + $bootisoID = $this->_request->getParam('bootisoID'); + if (!isset($bootisoID) || !is_numeric($bootisoID)) { + $this->_redirect('/dev/bootiso'); + } else { + $bootiso = new Application_Model_BootIso(); + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootisomapper->find($bootisoID, $bootiso); + + $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(), 'prebootlist' => $prebootmapper->fetchAll())); + $editbootisoForm->populate($bootiso->toArray()); + } + } else { + $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(), 'prebootlist' => $prebootmapper->fetchAll()), $_POST); + + if ($editbootisoForm->isValid($_POST)) { + + $bootiso = new Application_Model_BootIso($_POST); + $bootiso->setMembershipID('1'); + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso->setCreated(time()); + $bootiso->setID($bootisoID); + $prebootID = $bootiso->getPrebootID(); + + try { + + + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res == = true) { + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/serial", $bootiso->getSerialnumber()); + $zip->close(); + } + + $bootisomapper->save($bootiso); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/dev/bootiso'); + } + } - public function deletebootisoAction() - { - $bootisoID = $this->_request->getParam('bootisoID'); - if (!isset($bootisoID)){ - $this->_redirect('/dev/bootiso'); - } else { - $bootiso = new Application_Model_BootIso(); - $bootiso->setID($bootisoID); - $bootisomapper = new Application_Model_BootIsoMapper(); - $bootisomapper->delete($bootiso); - } - $this->_redirect('/dev/bootiso'); + $this->view->editbootisoForm = $editbootisoForm; + } + + public function deletebootisoAction() { + $bootisoID = $this->_request->getParam('bootisoID'); + if (!isset($bootisoID)) { + $this->_redirect('/dev/bootiso'); + } else { + $bootiso = new Application_Model_BootIso(); + $bootiso->setID($bootisoID); + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootisomapper->delete($bootiso); } + $this->_redirect('/dev/bootiso'); + } } diff --git a/application/modules/dev/controllers/BootmenuController.php b/application/modules/dev/controllers/BootmenuController.php index cada566..d05f42c 100644 --- a/application/modules/dev/controllers/BootmenuController.php +++ b/application/modules/dev/controllers/BootmenuController.php @@ -1,330 +1,313 @@ -<?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 dev_BootmenuController extends Zend_Controller_Action -{ - - public function init() - { - $db = Zend_Db_Table::getDefaultAdapter(); - } - - public function indexAction() - { - $bootmenumapper = new Application_Model_BootMenuMapper(); - $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); - $bootosmapper = new Application_Model_BootOsMapper(); - $configmapper = new Application_Model_ConfigMapper(); - $membershipmapper = new Application_Model_MembershipMapper(); - $groupmapper = new Application_Model_GroupMapper(); - $personmapper = new Application_Model_PersonMapper(); - - $this->view->bootosmapper = $bootosmapper; - $this->view->configmapper = $configmapper; - - $bootmenuID = $this->_request->getParam('bootmenuid'); - $preboot = $this->_request->getParam('preboot'); - - if($preboot=="") - { - if($bootmenuID == "") - { - $this->view->bootmenulist = $bootmenumapper->fetchAll(); - $bootmenuentries = array(); - foreach ($this->view->bootmenulist as $bootmenu){ - $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy(array('bootmenuID' => $bootmenu->getID())); - $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); - $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); - } - }else{ - $bootmenu = new Application_Model_BootMenu(); - $bootmenumapper->find($bootmenuID, $bootmenu); - - $bootmenuentries = array(); - $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); - $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); - $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); - - $this->view->bootmenulist = array($bootmenu); - - } - - $this->view->bootmenuentrylist = $bootmenuentries; - - }else{ - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - - if($bootmenuID == "") - { - $this->view->bootmenulist = $bootmenumapper->fetchAll(); - $bootmenuentries = array(); - foreach ($this->view->bootmenulist as $bootmenu){ - $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); - $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); - $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); - } - }else{ - $bootmenu = new Application_Model_BootMenu(); - $bootmenumapper->find($bootmenuID, $bootmenu); - - $cc['title'] = $bootmenu->getTitle(); - - $bootmenuentries = array(); - $bootmenuentries = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); - - foreach($bootmenuentries as $bootmenuentry){ - $ar = array(); - $ar['title'] = $bootmenuentry->getTitle(); - $ar['id'] = $bootmenuentry->getID(); - $cc['data'][] = $ar; - } - - echo json_encode($cc); - - //print_a($cc); - - } - - } +* 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_BootmenuController extends Zend_Controller_Action { + + public function init() { + $db = Zend_Db_Table::getDefaultAdapter(); + } + + public function indexAction() { + $bootmenumapper = new Application_Model_BootMenuMapper(); + $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); + $bootosmapper = new Application_Model_BootOsMapper(); + $configmapper = new Application_Model_ConfigMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $groupmapper = new Application_Model_GroupMapper(); + $personmapper = new Application_Model_PersonMapper(); + + $this->view->bootosmapper = $bootosmapper; + $this->view->configmapper = $configmapper; + + $bootmenuID = $this->_request->getParam('bootmenuid'); + $preboot = $this->_request->getParam('preboot'); + + if($preboot == "") { + if($bootmenuID == "") { + $this->view->bootmenulist = $bootmenumapper->fetchAll(); + $bootmenuentries = array(); + foreach ($this->view->bootmenulist as $bootmenu) { + $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy(array('bootmenuID' => $bootmenu->getID())); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + } + } else { + $bootmenu = new Application_Model_BootMenu(); + $bootmenumapper->find($bootmenuID, $bootmenu); + + $bootmenuentries = array(); + $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID', $bootmenuID); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + + $this->view->bootmenulist = array($bootmenu); + + } + + $this->view->bootmenuentrylist = $bootmenuentries; + + } else { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + if($bootmenuID == "") { + $this->view->bootmenulist = $bootmenumapper->fetchAll(); + $bootmenuentries = array(); + foreach ($this->view->bootmenulist as $bootmenu) { + $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID', $bootmenu->getID()); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + } + } else { + $bootmenu = new Application_Model_BootMenu(); + $bootmenumapper->find($bootmenuID, $bootmenu); + + $cc['title'] = $bootmenu->getTitle(); + + $bootmenuentries = array(); + $bootmenuentries = $bootmenuentriesmapper->findBy('bootmenuID', $bootmenuID); + + foreach($bootmenuentries as $bootmenuentry) { + $ar = array(); + $ar['title'] = $bootmenuentry->getTitle(); + $ar['id'] = $bootmenuentry->getID(); + $cc['data'][] = $ar; + } + + echo json_encode($cc); + + //print_a($cc); + + } + + } + } + + public function addbootmenuentryAction() { + $bootmenuID = $this->_request->getParam('bootmenuID'); + $bootosmapper = new Application_Model_BootOsMapper(); + $configmapper = new Application_Model_ConfigMapper(); + + if (!isset($_POST["addbootmenuentry"])) { + $addbootmenuentryForm = new dev_Form_BootmenuEntriesAdd(array('bootoslist' => $bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist' => $configmapper->fetchAll())); + $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder'))); + unset($_POST['kcl']); + unset($_POST['configID']); + $addbootmenuentryForm->populate($_POST); + } else { + + $addbootmenuentryForm = new dev_Form_BootmenuEntriesAdd(array('bootoslist' => $bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist' => $configmapper->fetchAll()), $_POST); + + if ($addbootmenuentryForm->isValid($_POST)) { + + $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentry->setBootmenuID($bootmenuID); + + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + + try { + if($bootmenuentry->getOrder() < $this->_request->getParam('maxorder')) { + $bootmenuentry->setOrder($bootmenuentry->getOrder()); + $bootmenuentrymapper->order($bootmenuentry); + } + + //print_a($bootmenuentry); + + $bootmenuentrymapper->save($bootmenuentry); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/dev/bootmenu'); + } } - public function addbootmenuentryAction() - { - $bootmenuID = $this->_request->getParam('bootmenuID'); - $bootosmapper = new Application_Model_BootOsMapper(); - $configmapper = new Application_Model_ConfigMapper(); - - if (!isset($_POST["addbootmenuentry"])){ - $addbootmenuentryForm = new dev_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll())); - $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder'))); - unset($_POST['kcl']); - unset($_POST['configID']); - $addbootmenuentryForm->populate($_POST); - } else { - - $addbootmenuentryForm = new dev_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()),$_POST); - - if ($addbootmenuentryForm->isValid($_POST)) { - - $bootmenuentry = new Application_Model_BootMenuEntries($_POST); - $bootmenuentry->setBootmenuID($bootmenuID); - - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - - try { - if($bootmenuentry->getOrder() < $this->_request->getParam('maxorder')){ - $bootmenuentry->setOrder($bootmenuentry->getOrder()); - $bootmenuentrymapper->order($bootmenuentry); - } - - //print_a($bootmenuentry); - - $bootmenuentrymapper->save($bootmenuentry); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - - } - $this->_redirect('/dev/bootmenu'); - } - } - - $this->view->addbootmenuentryForm = $addbootmenuentryForm; - + $this->view->addbootmenuentryForm = $addbootmenuentryForm; + + } + + public function createbootmenuAction() { + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["createbootmenu"])) { + $createbootmenuForm = new dev_Form_BootmenuCreate(array('grouplist' => $groupmapper->fetchAll())); + } else { + + $createbootmenuForm = new dev_Form_BootmenuCreate(array('grouplist' => $groupmapper->fetchAll()), $_POST); + + if ($createbootmenuForm->isValid($_POST)) { + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setMembershipID('1'); + $bootmenu->setCreated(time()); + $bootmenumapper = new Application_Model_BootMenuMapper(); + + try { + $bootmenumapper->save($bootmenu); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/dev/bootmenu'); + } } - public function createbootmenuAction() - { - $groupmapper = new Application_Model_GroupMapper(); - - if (!isset($_POST["createbootmenu"])){ - $createbootmenuForm = new dev_Form_BootmenuCreate(array('grouplist' => $groupmapper->fetchAll())); - } else { - - $createbootmenuForm = new dev_Form_BootmenuCreate(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($createbootmenuForm->isValid($_POST)) { - - $bootmenu = new Application_Model_BootMenu($_POST); - $bootmenu->setMembershipID('1'); - $bootmenu->setCreated(time()); - $bootmenumapper = new Application_Model_BootMenuMapper(); - - try { - $bootmenumapper->save($bootmenu); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - - } - $this->_redirect('/dev/bootmenu'); - } - } - - $this->view->createbootmenuForm = $createbootmenuForm; + $this->view->createbootmenuForm = $createbootmenuForm; + } + + public function editbootmenuAction() { + $bootmenuID = $this->_request->getParam('bootmenuID'); + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["editbootmenu"])) { + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!isset($bootmenuID) || !is_numeric($bootmenuID)) { + $this->_redirect('/bootmenu'); + } else { + $bootmenu = new Application_Model_BootMenu(); + $bootmenumapper = new Application_Model_BootMenuMapper(); + $bootmenumapper->find($bootmenuID, $bootmenu); + + $editbootmenuForm = new dev_Form_BootmenuEdit(array('grouplist' => $groupmapper->fetchAll())); + $editbootmenuForm->populate($bootmenu->toArray()); + } + } else { + $editbootmenuForm = new dev_Form_BootmenuEdit(array('grouplist' => $groupmapper->fetchAll()), $_POST); + + if ($editbootmenuForm->isValid($_POST)) { + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setMembershipID('1'); + $bootmenu->setCreated(time()); + $bootmenumapper = new Application_Model_BootMenuMapper(); + + $bootmenu->setID($bootmenuID); + + try { + + $bootmenumapper->save($bootmenu); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/dev/bootmenu'); + } + } - public function editbootmenuAction() - { - $bootmenuID = $this->_request->getParam('bootmenuID'); - $groupmapper = new Application_Model_GroupMapper(); - - if (!isset($_POST["editbootmenu"])){ - $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!isset($bootmenuID) || !is_numeric($bootmenuID)){ - $this->_redirect('/bootmenu'); - } else { - $bootmenu = new Application_Model_BootMenu(); - $bootmenumapper = new Application_Model_BootMenuMapper(); - $bootmenumapper->find($bootmenuID, $bootmenu); - - $editbootmenuForm = new dev_Form_BootmenuEdit(array('grouplist' => $groupmapper->fetchAll())); - $editbootmenuForm->populate($bootmenu->toArray()); - } - }else{ - $editbootmenuForm = new dev_Form_BootmenuEdit(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($editbootmenuForm->isValid($_POST)) { - - $bootmenu = new Application_Model_BootMenu($_POST); - $bootmenu->setMembershipID('1'); - $bootmenu->setCreated(time()); - $bootmenumapper = new Application_Model_BootMenuMapper(); - - $bootmenu->setID($bootmenuID); - - try { - - $bootmenumapper->save($bootmenu); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - } - - $this->_redirect('/dev/bootmenu'); - } - - } - - $this->view->editbootmenuForm = $editbootmenuForm; + $this->view->editbootmenuForm = $editbootmenuForm; + } + + public function editbootmenuentryAction() { + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + $bootmenuID = $this->_request->getParam('bootmenuID'); + $bootosmapper = new Application_Model_BootOsMapper(); + $configmapper = new Application_Model_ConfigMapper(); + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + + if (!isset($_POST["editbootmenuentry"])) { + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)) { + $this->_redirect('/dev/bootmenu'); + } else { + + $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); + + $editbootmenuentryForm = new dev_Form_BootmenuEntriesEdit(array('bootoslist' => $bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist' => $configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl())); + + if(!isset($_POST['configID'])) { + $editbootmenuentryForm->populate($bootmenuentry->toArray()); + } else { + unset($_POST['kcl']); + unset($_POST['configID']); + $editbootmenuentryForm->populate($_POST); + } + } + } else { + $editbootmenuentryForm = new dev_Form_BootmenuEntriesEdit(array('bootoslist' => $bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist' => $configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl()), $_POST); + + if ($editbootmenuentryForm->isValid($_POST)) { + + $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + + $bootmenuentry->setBootmenuID($bootmenuID); + $bootmenuentry->setID($bootmenuentryID); + + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + + try { + if($bootmenuentry->getOrder() < $this->_request->getParam('oldorder')) + { $bootmenuentrymapper->orderbefore($bootmenuentry, $this->_request->getParam('oldorder')); } + else + { $bootmenuentrymapper->orderafter($bootmenuentry, $this->_request->getParam('oldorder')); } + + $bootmenuentrymapper->save($bootmenuentry); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/dev/bootmenu'); + } + } - public function editbootmenuentryAction() - { - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - $bootmenuID = $this->_request->getParam('bootmenuID'); - $bootosmapper = new Application_Model_BootOsMapper(); - $configmapper = new Application_Model_ConfigMapper(); - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - - if (!isset($_POST["editbootmenuentry"])){ - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){ - $this->_redirect('/dev/bootmenu'); - } else { - - $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); - - $editbootmenuentryForm = new dev_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl())); - - if(!isset($_POST['configID'])){ - $editbootmenuentryForm->populate($bootmenuentry->toArray()); - } - else{ - unset($_POST['kcl']); - unset($_POST['configID']); - $editbootmenuentryForm->populate($_POST); - } - } - }else{ - $editbootmenuentryForm = new dev_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl()),$_POST); - - if ($editbootmenuentryForm->isValid($_POST)) { - - $bootmenuentry = new Application_Model_BootMenuEntries($_POST); - - $bootmenuentry->setBootmenuID($bootmenuID); - $bootmenuentry->setID($bootmenuentryID); - - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - - try { - if($bootmenuentry->getOrder() < $this->_request->getParam('oldorder')) - $bootmenuentrymapper->orderbefore($bootmenuentry, $this->_request->getParam('oldorder')); - else - $bootmenuentrymapper->orderafter($bootmenuentry, $this->_request->getParam('oldorder')); - - $bootmenuentrymapper->save($bootmenuentry); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - } - - $this->_redirect('/dev/bootmenu'); - } - - } - - $this->view->editbootmenuentryForm = $editbootmenuentryForm; - + $this->view->editbootmenuentryForm = $editbootmenuentryForm; + + } + + public function removebootmenuentryAction() { + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)) { + $this->_redirect('/bootmenu'); + } else { + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); + $bootmenuentrymapper->delete($bootmenuentry); + $bootmenuentrymapper->orderremove($bootmenuentry); } + $this->_redirect('/dev/bootmenu'); + } - public function removebootmenuentryAction() - { - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){ - $this->_redirect('/bootmenu'); - } else { - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); - $bootmenuentrymapper->delete($bootmenuentry); - $bootmenuentrymapper->orderremove($bootmenuentry); - } - $this->_redirect('/dev/bootmenu'); + public function deletebootmenuAction() { + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!isset($bootmenuID) || !is_numeric($bootmenuID)) { + $this->_redirect('/dev/bootmenu'); + } else { + $bootmenu = new Application_Model_BootMenu(); + $bootmenu->setID($bootmenuID); + $bootmenumapper = new Application_Model_BootMenuMapper(); + $bootmenumapper->delete($bootmenu); } + $this->_redirect('/dev/bootmenu'); + } - public function deletebootmenuAction() - { - $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!isset($bootmenuID) || !is_numeric($bootmenuID)){ - $this->_redirect('/dev/bootmenu'); - } else { - $bootmenu = new Application_Model_BootMenu(); - $bootmenu->setID($bootmenuID); - $bootmenumapper = new Application_Model_BootMenuMapper(); - $bootmenumapper->delete($bootmenu); - } - $this->_redirect('/dev/bootmenu'); + private function arrayDiff($a, $b) { + foreach($a as $k1 => $i1) { + foreach($b as $k2 => $i2) { + if($i1->getID() == $i2->getBootosID()) { + unset($a[$k1]); + } + } } + return $a; + } - private function arrayDiff($a, $b){ - foreach($a as $k1 => $i1){ - foreach($b as $k2 => $i2){ - if($i1->getID() == $i2->getBootosID()){ - unset($a[$k1]); - } - } - } - return $a; - } - } diff --git a/application/modules/dev/controllers/BootosController.php b/application/modules/dev/controllers/BootosController.php index 55537a9..dfe2765 100644 --- a/application/modules/dev/controllers/BootosController.php +++ b/application/modules/dev/controllers/BootosController.php @@ -1,218 +1,208 @@ -<?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 dev_BootosController extends Zend_Controller_Action -{ - - public function init() - { - $db = Zend_Db_Table::getDefaultAdapter(); - } +* 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_BootosController extends Zend_Controller_Action { + + public function init() { + $db = Zend_Db_Table::getDefaultAdapter(); + } + + public function indexAction() { + + $bootosmapper = new Application_Model_BootOsMapper(); + + $groupmapper = new Application_Model_GroupMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $personmapper = new Application_Model_PersonMapper(); + $configmapper = new Application_Model_ConfigMapper(); + + $this->view->bootoslist = $bootosmapper->fetchAll(); + $this->view->update = array(); - public function indexAction() - { - - $bootosmapper = new Application_Model_BootOsMapper(); - - $groupmapper = new Application_Model_GroupMapper(); - $membershipmapper = new Application_Model_MembershipMapper(); - $personmapper = new Application_Model_PersonMapper(); - $configmapper = new Application_Model_ConfigMapper(); - - $this->view->bootoslist = $bootosmapper->fetchAll(); - $this->view->update = array(); - - if(count($this->view->bootoslist)>0){ - foreach ($this->view->bootoslist as $bootos){ - $this->view->update[$bootos->getID()] = $this->checkupdateAction($bootos); - $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupmapper->find($bootos->getGroupID())->getTitle()); - $bootos->setMembershipID("[".$bootos->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootos->getMembershipID())->getPersonID())->getFirstname()); - $bootos->setConfigID("[".$bootos->getConfigID()."] ".$configmapper->find($bootos->getConfigID())->getTitle()); - - } - } - + if(count($this->view->bootoslist) > 0) { + foreach ($this->view->bootoslist as $bootos) { + $this->view->update[$bootos->getID()] = $this->checkupdateAction($bootos); + $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupmapper->find($bootos->getGroupID())->getTitle()); + $bootos->setMembershipID("[".$bootos->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootos->getMembershipID())->getPersonID())->getFirstname()); + $bootos->setConfigID("[".$bootos->getConfigID()."] ".$configmapper->find($bootos->getConfigID())->getTitle()); + + } } - public function createbootosAction() - { - $groupmapper = new Application_Model_GroupMapper(); - $configmapper = new Application_Model_ConfigMapper(); - - if (!isset($_POST["createbootos"])){ - try{ - $createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll())); - }catch(Zend_Exception $e){ - print_a($e); - } - } else { - - $createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()),$_POST); - - if ($createbootosForm->isValid($_POST)) { - - $bootos = new Application_Model_BootOs($_POST); - - $bootos->setMembershipID('1'); - if($bootos->getConfigID() == '') - $bootos->setConfigID(NULL); - $bootosmapper = new Application_Model_BootOsMapper(); - $bootos->setCreated(time()); - - try { - exec("wget --spider ".$bootos->getPath_kernel()." 2>&1 | grep 'Remote file exists.'", $exists_kernel); - exec("wget --spider ".$bootos->getPath_init()." 2>&1 | grep 'Remote file exists.'" , $exists_init); - - if(!array_pop($exists_init) || !array_pop($exists_kernel)){ - $this->view->createbootosForm = $createbootosForm; - return; - } - - $bootosID = $bootosmapper->save($bootos); - - $initpath = "../resources/bootos/".$bootosID."/initramfs/"; - $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; - - mkdir($initpath ,0777, true); - mkdir($kernelpath ,0777, true); - - exec("wget -O '".$kernelpath."kernel' ".$bootos->getPath_kernel()); - exec("wget -O '".$initpath."initramfs' ".$bootos->getPath_init()); - - - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - - } - - $this->_redirect('/dev/bootos'); - } - } - + } + + public function createbootosAction() { + $groupmapper = new Application_Model_GroupMapper(); + $configmapper = new Application_Model_ConfigMapper(); + + if (!isset($_POST["createbootos"])) { + try { + $createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() , 'configlist' => $configmapper->fetchAll())); + } catch(Zend_Exception $e) { + print_a($e); + } + } else { + + $createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() , 'configlist' => $configmapper->fetchAll()), $_POST); + + if ($createbootosForm->isValid($_POST)) { + + $bootos = new Application_Model_BootOs($_POST); + + $bootos->setMembershipID('1'); + if($bootos->getConfigID() == '') + { $bootos->setConfigID(NULL); } + $bootosmapper = new Application_Model_BootOsMapper(); + $bootos->setCreated(time()); + + try { + exec("wget --spider ".$bootos->getPath_kernel()." 2>&1 | grep 'Remote file exists.'", $exists_kernel); + exec("wget --spider ".$bootos->getPath_init()." 2>&1 | grep 'Remote file exists.'" , $exists_init); + + if(!array_pop($exists_init) || !array_pop($exists_kernel)) { $this->view->createbootosForm = $createbootosForm; + return; + } + + $bootosID = $bootosmapper->save($bootos); + + $initpath = "../resources/bootos/".$bootosID."/initramfs/"; + $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + + mkdir($initpath , 0777, true); + mkdir($kernelpath , 0777, true); + + exec("wget -O '".$kernelpath."kernel' ".$bootos->getPath_kernel()); + exec("wget -O '".$initpath."initramfs' ".$bootos->getPath_init()); + + + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + + $this->_redirect('/dev/bootos'); + } } - - public function checkupdateAction($bootos) - { - exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_kernel())."' 2>&1 | grep 'Last-Modified:'", $kerneldate); - exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_init())."' 2>&1 | grep 'Last-Modified:'", $initdate); - - $kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate)))); - $kernelname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/kernel/")); - - if($kernelname != "." && $kernelname != "..") - $kernelolddate = filemtime("../resources/bootos/".$bootos->getID()."/kernel/".$kernelname); - else - $kernelolddate = false; - - $initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate)))); - $initname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/initramfs/")); - - if($initname != "." && $initname != "..") - $initolddate = filemtime("../resources/bootos/".$bootos->getID()."/initramfs/".$initname); - else - $initolddate = false; - - //print_a($kernelname,$kerneldate,$kernelolddate,$initname,$initdate,$initolddate); - - - if($kerneldate > $kernelolddate || $initdate > $initolddate) - return true; - else - return false; - - } - - public function updatebootosAction() - { - $bootosID = $this->_request->getParam('bootosID'); - $bootosmapper = new Application_Model_BootOsMapper(); - $bootos = $bootosmapper->find($bootosID); - - $initpath = "../resources/bootos/".$bootosID."/initramfs/"; - $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; - - exec("wget -P ".$kernelpath." -N ".$bootos->getPath_kernel()); - exec("wget -P ".$initpath." -N ".$bootos->getPath_init()); - - $this->_redirect('/dev/bootos'); - } - public function editbootosAction() - { - $bootosID = $this->_request->getParam('bootosID'); - $groupmapper = new Application_Model_GroupMapper(); - $configmapper = new Application_Model_ConfigMapper(); - - if (!isset($_POST["editbootos"])){ - $bootosID = $this->_request->getParam('bootosID'); - if (!isset($bootosID) || !is_numeric($bootosID)){ - $this->_redirect('/dev/bootos'); - } else { - $bootos = new Application_Model_BootOs(); - $bootosmapper = new Application_Model_BootOsMapper(); - $bootos = $bootosmapper->find($bootosID); - - $editbootosForm = new dev_Form_BootosEdit(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll())); - $editbootosForm->populate($bootos->toArray()); - } - }else{ - $editbootosForm = new dev_Form_BootosEdit(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()),$_POST); - - if ($editbootosForm->isValid($_POST)) { - - //TODO: Check for new URL and download new files. - $bootos = new Application_Model_BootOs($_POST); - $bootos->setMembershipID('1'); - if($bootos->getConfigID() == '') - $bootos->setConfigID(NULL); - $bootosmapper = new Application_Model_BootOsMapper(); - $bootos->setCreated(time()); - $bootos->setID($bootosID); - - try { - $bootosmapper->save($bootos); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - } - - $this->_redirect('/dev/bootos'); - } - - } - - $this->view->editbootosForm = $editbootosForm; - + $this->view->createbootosForm = $createbootosForm; + } + + public function checkupdateAction($bootos) { + exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_kernel())."' 2>&1 | grep 'Last-Modified:'", $kerneldate); + exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_init())."' 2>&1 | grep 'Last-Modified:'", $initdate); + + $kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate)))); + $kernelname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/kernel/")); + + if($kernelname != "." && $kernelname != "..") + { $kernelolddate = filemtime("../resources/bootos/".$bootos->getID()."/kernel/".$kernelname); } + else + { $kernelolddate = false; } + + $initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate)))); + $initname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/initramfs/")); + + if($initname != "." && $initname != "..") + { $initolddate = filemtime("../resources/bootos/".$bootos->getID()."/initramfs/".$initname); } + else + { $initolddate = false; } + + //print_a($kernelname,$kerneldate,$kernelolddate,$initname,$initdate,$initolddate); + + + if($kerneldate > $kernelolddate || $initdate > $initolddate) + { return true; } + else + { return false; } + + } + + public function updatebootosAction() { + $bootosID = $this->_request->getParam('bootosID'); + $bootosmapper = new Application_Model_BootOsMapper(); + $bootos = $bootosmapper->find($bootosID); + + $initpath = "../resources/bootos/".$bootosID."/initramfs/"; + $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + + exec("wget -P ".$kernelpath." -N ".$bootos->getPath_kernel()); + exec("wget -P ".$initpath." -N ".$bootos->getPath_init()); + + $this->_redirect('/dev/bootos'); + } + + public function editbootosAction() { + $bootosID = $this->_request->getParam('bootosID'); + $groupmapper = new Application_Model_GroupMapper(); + $configmapper = new Application_Model_ConfigMapper(); + + if (!isset($_POST["editbootos"])) { + $bootosID = $this->_request->getParam('bootosID'); + if (!isset($bootosID) || !is_numeric($bootosID)) { + $this->_redirect('/dev/bootos'); + } else { + $bootos = new Application_Model_BootOs(); + $bootosmapper = new Application_Model_BootOsMapper(); + $bootos = $bootosmapper->find($bootosID); + + $editbootosForm = new dev_Form_BootosEdit(array('grouplist' => $groupmapper->fetchAll() , 'configlist' => $configmapper->fetchAll())); + $editbootosForm->populate($bootos->toArray()); + } + } else { + $editbootosForm = new dev_Form_BootosEdit(array('grouplist' => $groupmapper->fetchAll() , 'configlist' => $configmapper->fetchAll()), $_POST); + + if ($editbootosForm->isValid($_POST)) { + + //TODO: Check for new URL and download new files. + $bootos = new Application_Model_BootOs($_POST); + $bootos->setMembershipID('1'); + if($bootos->getConfigID() == '') + { $bootos->setConfigID(NULL); } + $bootosmapper = new Application_Model_BootOsMapper(); + $bootos->setCreated(time()); + $bootos->setID($bootosID); + + try { + $bootosmapper->save($bootos); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/dev/bootos'); + } + } - public function deletebootosAction() - { - $bootosID = $this->_request->getParam('bootosID'); - if (!isset($bootosID)){ - $this->_redirect('/dev/bootos'); - } else { - $bootos = new Application_Model_BootOs(); - $bootos->setID($bootosID); - $bootosmapper = new Application_Model_BootOsMapper(); - $bootosmapper->delete($bootos); - } - $this->_redirect('/dev/bootos'); - + $this->view->editbootosForm = $editbootosForm; + + } + + public function deletebootosAction() { + $bootosID = $this->_request->getParam('bootosID'); + if (!isset($bootosID)) { + $this->_redirect('/dev/bootos'); + } else { + $bootos = new Application_Model_BootOs(); + $bootos->setID($bootosID); + $bootosmapper = new Application_Model_BootOsMapper(); + $bootosmapper->delete($bootos); } + $this->_redirect('/dev/bootos'); + + } } diff --git a/application/modules/dev/controllers/ClientController.php b/application/modules/dev/controllers/ClientController.php index b6c202c..d70db4a 100644 --- a/application/modules/dev/controllers/ClientController.php +++ b/application/modules/dev/controllers/ClientController.php @@ -1,101 +1,93 @@ -<?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 dev_ClientController extends Zend_Controller_Action -{ - - public function init() - { - /* Initialize action controller here */ +* 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_ClientController extends Zend_Controller_Action { + + public function init() { + /* Initialize action controller here */ + } + + public function indexAction() { + $clientMapper = new Application_Model_ClientMapper(); + $this->view->clients = $clientMapper->fetchAll(); + } + + public function addclientAction() { + $mac = $this->_request->getParam('mac'); + $hh = $this->_request->getParam('hh'); + + $groupMapper = new Application_Model_GroupMapper(); + $groups = $groupMapper->fetchAll(); +#print_a($groups);die(); + + if (!isset($_POST["add"])) { + $addclient = new dev_Form_Client(array('buttontext' => 'Create Client', 'groups' => $groups)); + $this->view->addclient = $addclient; + } else { + $addfilterform = new dev_Form_Client(array('buttontext' => 'Create Client', 'groups' => $groups), $_POST); + if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $mac = ($mac != '') ? $mac : $_POST['macadress']; + $hh = ($hh != '') ? $hh : $_POST['hardwarehash']; + $client->setMacadress($mac); + $client->setHardwarehash($hh); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + print_a('inserted'); + $this->_redirect('/dev/client'); + } + $this->view->addclient = $addclient; } - - public function indexAction() - { - $clientMapper = new Application_Model_ClientMapper(); - $this->view->clients = $clientMapper->fetchAll(); - } - - public function addclientAction() - { - $mac = $this->_request->getParam('mac'); - $hh = $this->_request->getParam('hh'); - - $groupMapper = new Application_Model_GroupMapper(); - $groups = $groupMapper->fetchAll(); - #print_a($groups);die(); - - if (!isset($_POST["add"])){ - $addclient = new dev_Form_Client(array('buttontext' => 'Create Client','groups'=>$groups)); - $this->view->addclient = $addclient; - } - else{ - $addfilterform = new dev_Form_Client(array('buttontext' => 'Create Client','groups'=>$groups),$_POST); - if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $mac = ($mac!='')?$mac:$_POST['macadress']; - $hh = ($hh!='')?$hh:$_POST['hardwarehash']; - $client->setMacadress($mac); - $client->setHardwarehash($hh); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->save($client); - print_a('inserted'); - $this->_redirect('/dev/client'); - } - $this->view->addclient = $addclient; - } + } + + public function removeclientAction() { + $clientID = $this->_request->getParam('clientID'); + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($clientID)) { + $removeClient = new Application_Model_Client(); + $removeClient->setID($clientID); + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->delete($removeClient); } - - public function removeclientAction() - { - $clientID = $this->_request->getParam('clientID'); - // TODO: ACL implementieren ob er den filter löschen darf - if(is_numeric($clientID)){ - $removeClient = new Application_Model_Client(); - $removeClient->setID($clientID); - $clientMapper = new Application_Model_ClientMapper(); - $clientMapper->delete($removeClient); - } - $this->_redirect('/dev/client'); - } - - public function editclientAction() - { - $groupMapper = new Application_Model_GroupMapper(); - $groups = $groupMapper->fetchAll(); - # print_a($this);die(); - - if (!isset($_POST["add"])){ - $clientID = $this->_request->getParam('clientID'); - $data = new Application_Model_Client(); - $mapper = new Application_Model_ClientMapper(); - $mapper->find($clientID,$data); - - $editclient = new dev_Form_Client(array('buttontext' => 'Edit Client', 'groups'=>$groups)); - $editclient->populate($data->toArray()); - $this->view->editclient = $editclient; - } - else{ - $editclient = new dev_Form_Client(array('buttontext' => 'Edit Client','groups'=>$groups),$_POST); - if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $client->setID($this->_request->getParam('clientID')); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->save($client); - print_a('updated'); - $this->_redirect('/dev/client'); - } - $this->view->editclient = $editclient; - } + $this->_redirect('/dev/client'); + } + + public function editclientAction() { + $groupMapper = new Application_Model_GroupMapper(); + $groups = $groupMapper->fetchAll(); +# print_a($this);die(); + + if (!isset($_POST["add"])) { + $clientID = $this->_request->getParam('clientID'); + $data = new Application_Model_Client(); + $mapper = new Application_Model_ClientMapper(); + $mapper->find($clientID, $data); + + $editclient = new dev_Form_Client(array('buttontext' => 'Edit Client', 'groups' => $groups)); + $editclient->populate($data->toArray()); + $this->view->editclient = $editclient; + } else { + $editclient = new dev_Form_Client(array('buttontext' => 'Edit Client', 'groups' => $groups), $_POST); + if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $client->setID($this->_request->getParam('clientID')); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + print_a('updated'); + $this->_redirect('/dev/client'); + } + $this->view->editclient = $editclient; } + } } diff --git a/application/modules/dev/controllers/ConfigController.php b/application/modules/dev/controllers/ConfigController.php index d89b6e1..2b0b857 100644 --- a/application/modules/dev/controllers/ConfigController.php +++ b/application/modules/dev/controllers/ConfigController.php @@ -1,129 +1,121 @@ -<?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 dev_ConfigController extends Zend_Controller_Action -{ - - public function init() - { - $db = Zend_Db_Table::getDefaultAdapter(); - } - - public function indexAction() - { - $configmapper = new Application_Model_ConfigMapper(); - - $groupmapper = new Application_Model_GroupMapper(); - $membershipmapper = new Application_Model_MembershipMapper(); - $personmapper = new Application_Model_PersonMapper(); - - $this->view->configlist = $configmapper->fetchAll(); - - foreach ($this->view->configlist as $config){ - $config->setGroupID("[".$config->getGroupID()."] ".$groupmapper->find($config->getGroupID())->getTitle()); - $config->setMembershipID("[".$config->getMembershipID()."] ".$personmapper->find($membershipmapper->find($config->getMembershipID())->getPersonID())->getFirstname()); - } - +* 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_ConfigController extends Zend_Controller_Action { + + public function init() { + $db = Zend_Db_Table::getDefaultAdapter(); + } + + public function indexAction() { + $configmapper = new Application_Model_ConfigMapper(); + + $groupmapper = new Application_Model_GroupMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $personmapper = new Application_Model_PersonMapper(); + + $this->view->configlist = $configmapper->fetchAll(); + + foreach ($this->view->configlist as $config) { + $config->setGroupID("[".$config->getGroupID()."] ".$groupmapper->find($config->getGroupID())->getTitle()); + $config->setMembershipID("[".$config->getMembershipID()."] ".$personmapper->find($membershipmapper->find($config->getMembershipID())->getPersonID())->getFirstname()); } - public function createconfigAction() - { - $groupmapper = new Application_Model_GroupMapper(); - if (!isset($_POST["createconfig"])){ - $createconfigForm = new dev_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll())); - } else { - - $createconfigForm = new dev_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($createconfigForm->isValid($_POST)) { - - $config = new Application_Model_Config($_POST); - $config->setCreated(time()); - $config->setMembershipID('1'); - - $configmapper = new Application_Model_ConfigMapper(); - - try { - $configmapper->save($config); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - - } - $this->_redirect('/dev/config'); - } - } - - $this->view->createconfigForm = $createconfigForm; + } + + public function createconfigAction() { + $groupmapper = new Application_Model_GroupMapper(); + if (!isset($_POST["createconfig"])) { + $createconfigForm = new dev_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll())); + } else { + + $createconfigForm = new dev_Form_ConfigCreate(array('grouplist' => $groupmapper->fetchAll()), $_POST); + + if ($createconfigForm->isValid($_POST)) { + + $config = new Application_Model_Config($_POST); + $config->setCreated(time()); + $config->setMembershipID('1'); + + $configmapper = new Application_Model_ConfigMapper(); + + try { + $configmapper->save($config); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/dev/config'); + } } - public function editconfigAction() - { - $configID = $this->_request->getParam('configID'); - $groupmapper = new Application_Model_GroupMapper(); - - if (!isset($_POST["editconfig"])){ - $configID = $this->_request->getParam('configID'); - if (!isset($configID) || !is_numeric($configID)){ - $this->_redirect('/dev/config'); - } else { - $config = new Application_Model_Config(); - $configmapper = new Application_Model_ConfigMapper(); - $config = $configmapper->find($configID); - - $editconfigForm = new dev_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll())); - $editconfigForm->populate($config->toArray()); - } - }else{ - $editconfigForm = new dev_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($editconfigForm->isValid($_POST)) { - - $config = new Application_Model_Config($_POST); - $configmapper = new Application_Model_ConfigMapper(); - $config->setCreated(time()); - $config->setMembershipID('1'); - $config->setID($configID); - - try { - $configmapper->save($config); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - } - - $this->_redirect('/dev/config'); - } - - } - - $this->view->editconfigForm = $editconfigForm; + $this->view->createconfigForm = $createconfigForm; + } + + public function editconfigAction() { + $configID = $this->_request->getParam('configID'); + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["editconfig"])) { + $configID = $this->_request->getParam('configID'); + if (!isset($configID) || !is_numeric($configID)) { + $this->_redirect('/dev/config'); + } else { + $config = new Application_Model_Config(); + $configmapper = new Application_Model_ConfigMapper(); + $config = $configmapper->find($configID); + + $editconfigForm = new dev_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll())); + $editconfigForm->populate($config->toArray()); + } + } else { + $editconfigForm = new dev_Form_ConfigEdit(array('grouplist' => $groupmapper->fetchAll()), $_POST); + + if ($editconfigForm->isValid($_POST)) { + + $config = new Application_Model_Config($_POST); + $configmapper = new Application_Model_ConfigMapper(); + $config->setCreated(time()); + $config->setMembershipID('1'); + $config->setID($configID); + + try { + $configmapper->save($config); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/dev/config'); + } + } - public function deleteconfigAction() - { - $configID = $this->_request->getParam('configID'); - if (!isset($configID)){ - $this->_redirect('/dev/config'); - } else { - $config = new Application_Model_Config(); - $config->setID($configID); - $configmapper = new Application_Model_ConfigMapper(); - $configmapper->delete($config); - } - $this->_redirect('/dev/config'); + $this->view->editconfigForm = $editconfigForm; + } + + public function deleteconfigAction() { + $configID = $this->_request->getParam('configID'); + if (!isset($configID)) { + $this->_redirect('/dev/config'); + } else { + $config = new Application_Model_Config(); + $config->setID($configID); + $configmapper = new Application_Model_ConfigMapper(); + $configmapper->delete($config); } + $this->_redirect('/dev/config'); + } } diff --git a/application/modules/dev/controllers/ErrorController.php b/application/modules/dev/controllers/ErrorController.php index 6d63b1b..02f4c2f 100644 --- a/application/modules/dev/controllers/ErrorController.php +++ b/application/modules/dev/controllers/ErrorController.php @@ -1,61 +1,58 @@ -<?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 dev_ErrorController extends Zend_Controller_Action -{ - - public function errorAction() - { - $errors = $this->_getParam('error_handler'); - switch ($errors->type) { - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: - - // 404 error -- controller or action not found - $this->getResponse()->setHttpResponseCode(404); - $this->view->message = 'Page not found'; - print_a($errors); - break; - default: - // application error - $this->getResponse()->setHttpResponseCode(500); - $this->view->message = 'Application error'; - print_a($errors); - break; - } - - // Log exception, if logger available - if ($log = $this->getLog()) { - $log->crit($this->view->message, $errors->exception); - } - - // conditionally display exceptions - if ($this->getInvokeArg('displayExceptions') == true) { - $this->view->exception = $errors->exception; - } - - $this->view->request = $errors->request; +* 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_ErrorController extends Zend_Controller_Action { + + public function errorAction() { + $errors = $this->_getParam('error_handler'); + switch ($errors->type) { + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: + + // 404 error -- controller or action not found + $this->getResponse()->setHttpResponseCode(404); + $this->view->message = 'Page not found'; + print_a($errors); + break; + default: + // application error + $this->getResponse()->setHttpResponseCode(500); + $this->view->message = 'Application error'; + print_a($errors); + break; + } + + // Log exception, if logger available + if ($log = $this->getLog()) { + $log->crit($this->view->message, $errors->exception); + } + + // conditionally display exceptions + if ($this->getInvokeArg('displayExceptions') == true) { + $this->view->exception = $errors->exception; } - public function getLog() - { - $bootstrap = $this->getInvokeArg('bootstrap'); - if (!$bootstrap->hasPluginResource('Log')) { - return false; - } - $log = $bootstrap->getResource('Log'); - return $log; + $this->view->request = $errors->request; + } + + public function getLog() { + $bootstrap = $this->getInvokeArg('bootstrap'); + if (!$bootstrap->hasPluginResource('Log')) { + return false; } + $log = $bootstrap->getResource('Log'); + return $log; + } } diff --git a/application/modules/dev/controllers/FilterController.php b/application/modules/dev/controllers/FilterController.php index d68f033..b8aecfd 100644 --- a/application/modules/dev/controllers/FilterController.php +++ b/application/modules/dev/controllers/FilterController.php @@ -1,674 +1,656 @@ -<?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 dev_FilterController extends Zend_Controller_Action -{ - - private $_filtermapper = null; - - private $db = null; - - public function init() - { - try{ - $this->_filtermapper = new Application_Model_FilterMapper(); - }catch (Zend_Exception $e) { - echo "Error message 1: " . $e->getMessage() . "\n"; - } - $this->db = Zend_Db_Table::getDefaultAdapter(); +* 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_FilterController extends Zend_Controller_Action { + + private $_filtermapper = null; + + private $db = null; + + public function init() { + try { + $this->_filtermapper = new Application_Model_FilterMapper(); + } catch (Zend_Exception $e) { + echo "Error message 1: " . $e->getMessage() . "\n"; } - - public function indexAction() - { - try{ - $this->_filtermapper = new Application_Model_FilterMapper(); - $this->view->filters = $this->_filtermapper->fetchAll(); - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } - - public function addfilterAction() - { - $bmmapper = new Application_Model_BootMenuMapper(); - //TODO get bootmenu by group - $bootmenus = $bmmapper->fetchAll(); - if (!isset($_POST["add"])){ - $addfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Create Filter','bootmenus'=>$bootmenus)); - $this->view->addfilterform = $addfilterform; - }else { - $addfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Create Filter','bootmenus'=>$bootmenus),$_POST); - if ($addfilterform->isValid($_POST)) { - try{ - $newfilter = new Application_Model_Filter($_POST); - $newfilter->setCreated(time()); - - // TODO: Ändere mit ACL - $newfilter->setGroupID('1'); - $newfilter->setMembershipID('1'); - - $newfilter2 = new Application_Model_FilterMapper(); - $newfilter2->save($newfilter); - - $this->_redirect('/dev/filter'); - return; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } - $this->view->addfilterform = $addfilterform; - } + $this->db = Zend_Db_Table::getDefaultAdapter(); + } + + public function indexAction() { + try { + $this->_filtermapper = new Application_Model_FilterMapper(); + $this->view->filters = $this->_filtermapper->fetchAll(); + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + public function addfilterAction() { + $bmmapper = new Application_Model_BootMenuMapper(); + //TODO get bootmenu by group + $bootmenus = $bmmapper->fetchAll(); + if (!isset($_POST["add"])) { + $addfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Create Filter', 'bootmenus' => $bootmenus)); + $this->view->addfilterform = $addfilterform; + } else { + $addfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Create Filter', 'bootmenus' => $bootmenus), $_POST); + if ($addfilterform->isValid($_POST)) { + try { + $newfilter = new Application_Model_Filter($_POST); + $newfilter->setCreated(time()); + + // TODO: Ändere mit ACL + $newfilter->setGroupID('1'); + $newfilter->setMembershipID('1'); + + $newfilter2 = new Application_Model_FilterMapper(); + $newfilter2->save($newfilter); + + $this->_redirect('/dev/filter'); + return; + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + $this->view->addfilterform = $addfilterform; } + } + + public function removefilterAction() { + $filterID = $this->_request->getParam('filterID'); + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($filterID)) { + $deletefilter = new Application_Model_Filter(); + $deletefilter->setID($filterID); + $filtermapper = new Application_Model_FilterMapper(); + $filtermapper->delete($deletefilter); + } + $this->_redirect('/dev/filter'); + } + + public function editfilterAction() { + $bmmapper = new Application_Model_BootMenuMapper(); + //TODO get bootmenu by group + $bootmenus = $bmmapper->fetchAll(); + if (!isset($_POST["add"])) { + // TODO: ACL implementieren ob er editieren darf + $filterID = $this->_request->getParam('filterID'); + $filter = new Application_Model_Filter(); - public function removefilterAction() - { + + $filtermapper = new Application_Model_FilterMapper(); + $filtermapper->find($filterID, $filter); + $filter2 = $filter->toArray(); + + $editfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Edit Filter', 'bootmenus' => $bootmenus)); + $editfilterform->populate($filter2); + $this->view->editfilterform = $editfilterform; + + } else { + try { $filterID = $this->_request->getParam('filterID'); - // TODO: ACL implementieren ob er den filter löschen darf - if(is_numeric($filterID)){ - $deletefilter = new Application_Model_Filter(); - $deletefilter->setID($filterID); - $filtermapper = new Application_Model_FilterMapper(); - $filtermapper->delete($deletefilter); - } - $this->_redirect('/dev/filter'); - } - public function editfilterAction() - { - $bmmapper = new Application_Model_BootMenuMapper(); - //TODO get bootmenu by group - $bootmenus = $bmmapper->fetchAll(); - if (!isset($_POST["add"])){ - // TODO: ACL implementieren ob er editieren darf - $filterID = $this->_request->getParam('filterID'); - $filter = new Application_Model_Filter(); - - - $filtermapper = new Application_Model_FilterMapper(); - $filtermapper->find($filterID,$filter); - $filter2 = $filter->toArray(); - - $editfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Edit Filter','bootmenus'=>$bootmenus)); - $editfilterform->populate($filter2); - $this->view->editfilterform = $editfilterform; - - } else{ - try{ - $filterID = $this->_request->getParam('filterID'); - - $editfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Edit Filter','bootmenus'=>$bootmenus),$_POST); - //TODO: ACL integrieren - $_POST['groupID'] = 1; - $_POST['membershipID'] = 1; - $_POST['created'] = time(); - - if ($editfilterform->isValid($_POST)) { - $newfilterenty = new Application_Model_Filter($_POST); - $newfilterenty->setID($this->_request->getParam('filterID')); - $newfilter2 = new Application_Model_FilterMapper(); - $newfilter2->save($newfilterenty); - echo 'valid'; - $this->_redirect('/dev/filter'); - } - $this->view->editfilterform = $editfilterform; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } + $editfilterform = new dev_Form_FilterAdd(array('buttontext' => 'Edit Filter', 'bootmenus' => $bootmenus), $_POST); + //TODO: ACL integrieren + $_POST['groupID'] = 1; + $_POST['membershipID'] = 1; + $_POST['created'] = time(); + + if ($editfilterform->isValid($_POST)) { + $newfilterenty = new Application_Model_Filter($_POST); + $newfilterenty->setID($this->_request->getParam('filterID')); + $newfilter2 = new Application_Model_FilterMapper(); + $newfilter2->save($newfilterenty); + echo 'valid'; + $this->_redirect('/dev/filter'); + } + $this->view->editfilterform = $editfilterform; + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } } - - public function addfilterentryAction() - { - // TODO: ACL implementieren ob er editieren darf - if (!isset($_POST["add"])){ - try{ - $editfilterform = new dev_Form_FilterEntriesAdd( - array( 'buttontext' => 'Add Filterentry', - 'filterID' => $this->_request->getParam('filterID'), - 'data' => $_POST - )); - $editfilterform->populate($_POST); - $this->view->editfilterform = $editfilterform; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } else{ - $editfilterform = new dev_Form_FilterEntriesAdd(array('buttontext' => 'Add Filterentry'),$_POST); - if ($editfilterform->isValid($_POST)) { - $newfilterenty = new Application_Model_FilterEntries(); - $newfilterenty->setFilterID($_POST['filterID']); - $newfilterenty->setFiltertypeID($_POST['filtertypeID']); - - if($_POST['filtertypeID'] == 1){ - $newfilterenty->setFiltervalue($this->fillIP($_POST['filtervalue'])); - $newfilterenty->setFiltervalue2($this->fillIP($_POST['filtervalue2'])); - } - else{ - $newfilterenty->setFiltervalue($_POST['filtervalue']); - $newfilterenty->setFiltervalue2($_POST['filtervalue2']); - } - - $newfilter2 = new Application_Model_FilterEntriesMapper(); - $newfilter2->save($newfilterenty); - #print_a($newfilterenty); - $this->_redirect('/dev/filter'); - } - $this->view->editfilterform = $editfilterform; - } + } + + public function addfilterentryAction() { + // TODO: ACL implementieren ob er editieren darf + if (!isset($_POST["add"])) { + try { + $editfilterform = new dev_Form_FilterEntriesAdd( + array( 'buttontext' => 'Add Filterentry', + 'filterID' => $this->_request->getParam('filterID'), + 'data' => $_POST + )); + $editfilterform->populate($_POST); + $this->view->editfilterform = $editfilterform; + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } else { + $editfilterform = new dev_Form_FilterEntriesAdd(array('buttontext' => 'Add Filterentry'), $_POST); + if ($editfilterform->isValid($_POST)) { + $newfilterenty = new Application_Model_FilterEntries(); + $newfilterenty->setFilterID($_POST['filterID']); + $newfilterenty->setFiltertypeID($_POST['filtertypeID']); + + if($_POST['filtertypeID'] == 1) { + $newfilterenty->setFiltervalue($this->fillIP($_POST['filtervalue'])); + $newfilterenty->setFiltervalue2($this->fillIP($_POST['filtervalue2'])); + } else { + $newfilterenty->setFiltervalue($_POST['filtervalue']); + $newfilterenty->setFiltervalue2($_POST['filtervalue2']); + } + + $newfilter2 = new Application_Model_FilterEntriesMapper(); + $newfilter2->save($newfilterenty); +#print_a($newfilterenty); + $this->_redirect('/dev/filter'); + } + $this->view->editfilterform = $editfilterform; } - - public function editfilterentryAction() - { - if (!isset($_POST["add"])){ - try{ - $filterentriesID = $this->_request->getParam('filterentriesID'); - - $filterentry = new Application_Model_FilterEntries(); - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->find($filterentriesID,$filterentry); - - - - #$editfilterform->setFilterID($filterID); - if(isset($_POST['filtertypeID']) && $_POST['filtertypeID'] != $filterentry->getFiltertypeID()){ - $filterentry->setFiltertypeID($_POST['filtertypeID']) ; - } - $data = $filterentry->toArray(); - print_a($data); - $editfilterform = new dev_Form_FilterEntriesAdd( - array('buttontext' => 'Edit Filterentry', - 'data' => $data)); - - $editfilterform->populate($filterentry->toArray()); - $this->view->editfilterform = $editfilterform; - - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } else{ - try{ - $filterentriesID = $this->_request->getParam('filterentriesID'); - $editfilterform = new dev_Form_FilterEntriesAdd(array('buttontext' => 'Edit Filterentry'),$_POST); - if ($editfilterform->isValid($_POST)) { - if($_POST['filterID'] == '') - unset($_POST['filterID']); - $newfilterenty = new Application_Model_FilterEntries($_POST); - $newfilterenty->setID($filterentriesID); - if($_POST['filtertypeID'] == 1){ - $newfilterenty->setFiltervalue($this->fillIP($_POST['filtervalue'])); - $newfilterenty->setFiltervalue2($this->fillIP($_POST['filtervalue2'])); - } - else{ - $newfilterenty->setFiltervalue($_POST['filtervalue']); - $newfilterenty->setFiltervalue2($_POST['filtervalue2']); - } - $newfilter2 = new Application_Model_FilterEntriesMapper(); - $newfilter2->save($newfilterenty); - #print_a($newfilterenty); - $this->_redirect('/dev/filter'); - - } - $this->view->editfilterform = $editfilterform; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } + } + + public function editfilterentryAction() { + if (!isset($_POST["add"])) { + try { + $filterentriesID = $this->_request->getParam('filterentriesID'); + + $filterentry = new Application_Model_FilterEntries(); + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentriesmapper->find($filterentriesID, $filterentry); + + + +#$editfilterform->setFilterID($filterID); + if(isset($_POST['filtertypeID']) && $_POST['filtertypeID'] != $filterentry->getFiltertypeID()) { + $filterentry->setFiltertypeID($_POST['filtertypeID']) ; + } + $data = $filterentry->toArray(); + print_a($data); + $editfilterform = new dev_Form_FilterEntriesAdd( + array('buttontext' => 'Edit Filterentry', + 'data' => $data)); + + $editfilterform->populate($filterentry->toArray()); + $this->view->editfilterform = $editfilterform; + + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } else { + try { + $filterentriesID = $this->_request->getParam('filterentriesID'); + $editfilterform = new dev_Form_FilterEntriesAdd(array('buttontext' => 'Edit Filterentry'), $_POST); + if ($editfilterform->isValid($_POST)) { + if($_POST['filterID'] == '') + { unset($_POST['filterID']); } + $newfilterenty = new Application_Model_FilterEntries($_POST); + $newfilterenty->setID($filterentriesID); + if($_POST['filtertypeID'] == 1) { + $newfilterenty->setFiltervalue($this->fillIP($_POST['filtervalue'])); + $newfilterenty->setFiltervalue2($this->fillIP($_POST['filtervalue2'])); + } else { + $newfilterenty->setFiltervalue($_POST['filtervalue']); + $newfilterenty->setFiltervalue2($_POST['filtervalue2']); + } + $newfilter2 = new Application_Model_FilterEntriesMapper(); + $newfilter2->save($newfilterenty); +#print_a($newfilterenty); + $this->_redirect('/dev/filter'); + + } + $this->view->editfilterform = $editfilterform; + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } } - - public function removefilterentryAction() - { - try{ - $filterentriesID = $this->_request->getParam('filterentriesID'); - - // TODO: ACL implementieren ob er den filter löschen darf - if(is_numeric($filterentriesID)){ - $deletefilterentry = new Application_Model_FilterEntries(); - $deletefilterentry->setID($filterentriesID); - - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->delete($deletefilterentry); - echo "ok"; - } - $this->_redirect('/dev/filter'); - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } + } + + public function removefilterentryAction() { + try { + $filterentriesID = $this->_request->getParam('filterentriesID'); + + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($filterentriesID)) { + $deletefilterentry = new Application_Model_FilterEntries(); + $deletefilterentry->setID($filterentriesID); + + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentriesmapper->delete($deletefilterentry); + echo "ok"; + } + $this->_redirect('/dev/filter'); + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; } + } - private function fillIP($ip) - { - $ar = explode(".",$ip); - $representation = array(); - foreach($ar as $part){ - $representation[] = sprintf("%03s",$part); - } - return implode(".",$representation); + private function fillIP($ip) { + $ar = explode(".", $ip); + $representation = array(); + foreach($ar as $part) { + $representation[] = sprintf("%03s", $part); } - - private function fillMac($ip) - { - $ar = explode(":",$ip); - $representation = array(); - foreach($ar as $part){ - $representation[] = sprintf("%02s",$part); - } - return implode(":",$representation); + return implode(".", $representation); + } + + private function fillMac($ip) { + $ar = explode(":", $ip); + $representation = array(); + foreach($ar as $part) { + $representation[] = sprintf("%02s", $part); } - - public function evaluateAction() - { - $db = $this->db; - $showPartResults = false; - // For Testing Filters - - - $testFilter = (isset($_POST['submit']))?true:false; - - if($testFilter){ - $ipAdress = $_POST['ip']; - $macAdress = $_POST['mac']; - $poolID = $_POST['poolID']; - $bootisoID = $_POST['bootisoID']; - $membershipID = $_POST['membershipID']; - $groupID = $_POST['groupID']; - $time = ($_POST['time']); - $clientID = $_POST['clientID']; - $weekday = $_POST['weekday']; - $date = $_POST['date']; - print_a('Input', - array('ipAdress'=>$ipAdress, - 'macAdress'=>$macAdress, - 'poolID' => $poolID, - 'bootisoID' => $bootisoID, - 'membershipID'=>$membershipID, - 'groupID'=>$groupID, - 'time'=> $time." - ".date('d.m.Y H:i:s',$time), - 'clientID' => $clientID, - 'hardwarehash' => $hardwarehash, - 'weekday' => $weekday, - 'date' => $date)); - } - - - try{ - $mysession = '1'; - $set = array(); - - - $session = new Application_Model_Session(); - $sessionmapper = new Application_Model_SessionMapper(); - $sessionmapper->find($mysession,$session); - ######################################################### - // IP Adress - $filtertypID = 1; - // get it from session_table with session_id from the session - if(!$testFilter){ - $ipAdress = $session->getIp(); - } - $ipAdress = str_replace(".","",$this->fillIP($ipAdress)); - - $select = $db->select() - ->from(array('pbs_filterentries') - ) - ->where('filtertypeID = ?',$filtertypID) - ->where('REPLACE(filtervalue,".","") <= ?',$ipAdress) - ->where('? <= REPLACE(filtervalue2,".","")',$ipAdress); - - $stmt = $select->query(); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - - if($showPartResults) - print_a('ipAdress',$result,$set[$filtertypID]); - - ######################################################### - // Mac range - $filtertypID = 2; - // get it from session_table with session_id from the session - if(!$testFilter){ - $client = new Application_Model_Client(); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->find($session->getClientID(),$client); - $macAdress = $client->getMacadress(); - } - try{ - $macAdress = $this->fillMac($macAdress); - $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE - filtertypeID = ".$filtertypID." AND - filtervalue <= '".$macAdress."' AND - '".$macAdress."' <= filtervalue2"); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - if($showPartResults) - print_a('macAdress',$result,$set[$filtertypID]); - - ######################################################### - // PoolID - $filtertypID = 3; - // get PoolID from client_ID from session_id from the session - if(!$testFilter){ - $poolentry = new Application_Model_PoolEntries(); - $poolentrymapper = new Application_Model_PoolEntriesMapper(); - $poolentry = $poolentrymapper->findby(array('clientID' => $client->getID()),true); - $poolentry = $poolentry[0]; - - $poolID = $poolentry['poolID']; - } - - try{ - $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE - filtertypeID = ".$filtertypID." AND - filtervalue = ".$poolID." "); - $result = $stmt->fetchAll(); - if(count($result)>0){ - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('poolID',$result,$set[$filtertypID]); - ######################################################### - // ClientID - $filtertypID = 8; - // get client_ID from session_id from the session - - if(!$testFilter){ - $clientID = $session->getClientID(); - } - try{ - $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE - filtertypeID = ".$filtertypID." AND - filtervalue = ".$clientID." "); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('clientID',$result,$set[$filtertypID]); - ######################################################### - // BootIsoID - $filtertypID = 4; - // get BootIsoID from client_ID from session_id from the session - if(!$testFilter){ - $bootisoID = $session->getBootisoID(); - } - try{ - $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE - filtertypeID = ".$filtertypID." AND - filtervalue = ".$bootisoID." "); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('bootisoID',$result,$set[$filtertypID]); - ######################################################### - // MembershipID - $filtertypID = 5; - - if(!$testFilter){ - // get membership from the session - //TODO: GET MEMBERSHIP from SESSION - $membershipID = 1; - } - try{ - $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE - filtertypeID = ".$filtertypID." AND - filtervalue = ".$membershipID." "); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('membership',$result,$set[$filtertypID]); - ######################################################### - // GroupID - $filtertypID = 6; - - if(!$testFilter){ - // get membership from the session - //TODO: GET GROUP from SESSION - $groupID = 1; - } - try{ - $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE - filtertypeID = ".$filtertypID." AND - filtervalue = ".$groupID." "); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('membership',$result,$set[$filtertypID]); - ######################################################### - // Time - $filtertypID = 7; - if(!$testFilter){ - $time = time("H:i"); - } - - $nowShort = $time; - - $nowShort = str_replace(":","",$nowShort); - try{ - $select = $db->select() - ->from(array('pbs_filterentries') - ) - ->where('filtertypeID = ?',$filtertypID) - ->where('REPLACE(filtervalue,":","") <= ? AND ? <= REPLACE(filtervalue2,":","")',$nowShort); - - $stmt = $select->query(); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('time',$result,$set[$filtertypID]); - ######################################################### - // Hardwarehash - $filtertypID = 9; - if(!$testFilter){ - // get hardwarehash from session - $hardwarehash = 'aaaa'; - } - - try{ - $select = $db->select() - ->from(array('pbs_filterentries') - ) - ->where('filtertypeID = ?',$filtertypID) - ->where('`filtervalue` = ?',$hardwarehash); - $stmt = $select->query(); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('hardwarehash',$result,$set[$filtertypID]); - ######################################################### - // weekday - $filtertypID = 10; - if(!$testFilter){ - $weekday = date('N'); - } - - try{ - $select = $db->select() - ->from(array('pbs_filterentries') - ) - ->where('filtertypeID = ?',$filtertypID) - ->where('filtervalue = ? ',$weekday); - - $stmt = $select->query(); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('weekday',$result,$set[$filtertypID]); - ######################################################### - // weekday - $filtertypID = 11; - if(!$testFilter){ - $date = date('d.m.Y'); - } - - try{ - $select = $db->select() - ->from(array('pbs_filterentries') - ) - ->where('filtertypeID = ?',$filtertypID) - ->where('REPLACE(filtervalue,".","") <= ? AND ? <= REPLACE(filtervalue2,".","")',$date); - - $stmt = $select->query(); - $result = $stmt->fetchAll(); - foreach($result as $r){ - $set[$filtertypID][] = $r['filterID']; - } - } - catch(Exception $e){} - - if($showPartResults) - print_a('weekday',$result,$set[$filtertypID]); - ######################################## - // ErgebnisSet auswerten - print_a('the result sets of the filtertypes',$set); - - // Merging of the resultsets of the filter - $kk = array(); - foreach($set as $myset){ - $kk = array_merge($kk,$myset); - } - $set = $kk; - // counting how often a filter is evaluated at database - $a = array(); - foreach($set as $k=> $s){ - $a[$s] += 1; - } - print_a('Übereinstimmungen pro Filter',$a); - // Get the number of filtertypes every filter has - $stmt = $db->query('SELECT filterID, COUNT(filtertypeID) as num FROM pbs_filterentries GROUP BY filterID'); - $resultset = $stmt->fetchAll(); - foreach($resultset as $d){ - $database[$d['filterID']] = $d['num']; - } - print_a('Anzahl Filterentries in Datenbank',$database); - - // remove all filters from resultset, which to few filtertypes satisfied - $result = array(); - foreach($a as $i=>$b){ - if($a[$i] < $database[$i]){ - unset($a[$i]); - } - else{ - $result[] = $i; - } - } - - print_a('True Filters',$result); - // now selecting the filter with the highest priority - $query = 'SELECT filterID, bootmenuID, priority - FROM pbs_filter WHERE '; - foreach($result as $e){ - $queryTmp[] = "filterID = '$e'"; - } - $query .= implode(" OR ", $queryTmp); - $query .= 'ORDER BY priority DESC LIMIT 0,1'; - $bootmenuID = 'null'; - try{ - $stmt = $db->query($query); - $resultset = $stmt->fetchAll(); - $bootmenuID = $resultset[0]['bootmenuID']; - } - catch(Exception $e){ - } - if($bootmenuID != 'null'){ - $bm = new Application_Model_BootMenu(); - $bmmapper = new Application_Model_BootMenuMapper(); - $bmmapper->find($bootmenuID,$bm); - echo "<h1><a href='/bootmenu/index/bootmenuid/".$bootmenuID."'>Goto BootmenuID: ".$bootmenuID."</a></h1>"; - } - else{ - echo "<h1>No Result :-(</h1>"; - } - - }catch (Zend_Exception $e) { - echo "class: ".get_class($e)."<br>\n"; - echo "Error message 2: " . $e->getMessage() . "\n"; - } + return implode(":", $representation); + } + + public function evaluateAction() { + $db = $this->db; + $showPartResults = false; + // For Testing Filters + + + $testFilter = (isset($_POST['submit'])) ? true : false; + + if($testFilter) { + $ipAdress = $_POST['ip']; + $macAdress = $_POST['mac']; + $poolID = $_POST['poolID']; + $bootisoID = $_POST['bootisoID']; + $membershipID = $_POST['membershipID']; + $groupID = $_POST['groupID']; + $time = ($_POST['time']); + $clientID = $_POST['clientID']; + $weekday = $_POST['weekday']; + $date = $_POST['date']; + print_a('Input', + array('ipAdress' => $ipAdress, + 'macAdress' => $macAdress, + 'poolID' => $poolID, + 'bootisoID' => $bootisoID, + 'membershipID' => $membershipID, + 'groupID' => $groupID, + 'time' => $time." - ".date('d.m.Y H:i:s', $time), + 'clientID' => $clientID, + 'hardwarehash' => $hardwarehash, + 'weekday' => $weekday, + 'date' => $date)); } - public function testevaluateAction() - { - $pm = new Application_Model_PoolMapper(); - $pools = $pm->fetchAll(); - - $bim = new Application_Model_BootIsoMapper(); - $bootisos = $bim->fetchAll(); - - $mm = new Application_Model_MembershipMapper(); - $memberships = $mm->fetchAll(); - - $gm = new Application_Model_GroupMapper(); - $groups = $gm->fetchAll(); - - $cm = new Application_Model_ClientMapper(); - $clients = $cm->fetchAll(); - - $filterevaluate = new dev_Form_FilterEvaluate( - array( 'pools' => $pools, - 'bootisos' => $bootisos, - 'memberships' => $memberships, - 'groups' => $groups, - 'clients' => $clients, - - )); - $filterevaluate->populate(array( - 'ip' => '132.230.5.6', - 'mac' => '08:00:20:ae:fd:7e', - 'time'=>date('d.m.Y H:i')) - ); - $this->view->filterevaluate = $filterevaluate; + + try { + $mysession = '1'; + $set = array(); + + + $session = new Application_Model_Session(); + $sessionmapper = new Application_Model_SessionMapper(); + $sessionmapper->find($mysession, $session); +######################################################### + // IP Adress + $filtertypID = 1; + // get it from session_table with session_id from the session + if(!$testFilter) { + $ipAdress = $session->getIp(); + } + $ipAdress = str_replace(".", "", $this->fillIP($ipAdress)); + + $select = $db->select() + ->from(array('pbs_filterentries') + ) + ->where('filtertypeID = ?', $filtertypID) + ->where('REPLACE(filtervalue,".","") <= ?', $ipAdress) + ->where('? <= REPLACE(filtervalue2,".","")', $ipAdress); + + $stmt = $select->query(); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + + if($showPartResults) + { print_a('ipAdress', $result, $set[$filtertypID]); } + +######################################################### + // Mac range + $filtertypID = 2; + // get it from session_table with session_id from the session + if(!$testFilter) { + $client = new Application_Model_Client(); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->find($session->getClientID(), $client); + $macAdress = $client->getMacadress(); + } + try { + $macAdress = $this->fillMac($macAdress); + $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE + filtertypeID = ".$filtertypID." AND + filtervalue <= '".$macAdress."' AND + '".$macAdress."' <= filtervalue2"); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + if($showPartResults) + { print_a('macAdress', $result, $set[$filtertypID]); } + +######################################################### + // PoolID + $filtertypID = 3; + // get PoolID from client_ID from session_id from the session + if(!$testFilter) { + $poolentry = new Application_Model_PoolEntries(); + $poolentrymapper = new Application_Model_PoolEntriesMapper(); + $poolentry = $poolentrymapper->findby(array('clientID' => $client->getID()), true); + $poolentry = $poolentry[0]; + + $poolID = $poolentry['poolID']; + } + + try { + $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE + filtertypeID = ".$filtertypID." AND + filtervalue = ".$poolID." "); + $result = $stmt->fetchAll(); + if(count($result) > 0) { + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('poolID', $result, $set[$filtertypID]); } +######################################################### + // ClientID + $filtertypID = 8; + // get client_ID from session_id from the session + + if(!$testFilter) { + $clientID = $session->getClientID(); + } + try { + $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE + filtertypeID = ".$filtertypID." AND + filtervalue = ".$clientID." "); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('clientID', $result, $set[$filtertypID]); } +######################################################### + // BootIsoID + $filtertypID = 4; + // get BootIsoID from client_ID from session_id from the session + if(!$testFilter) { + $bootisoID = $session->getBootisoID(); + } + try { + $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE + filtertypeID = ".$filtertypID." AND + filtervalue = ".$bootisoID." "); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('bootisoID', $result, $set[$filtertypID]); } +######################################################### + // MembershipID + $filtertypID = 5; + + if(!$testFilter) { + // get membership from the session + //TODO: GET MEMBERSHIP from SESSION + $membershipID = 1; + } + try { + $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE + filtertypeID = ".$filtertypID." AND + filtervalue = ".$membershipID." "); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('membership', $result, $set[$filtertypID]); } +######################################################### + // GroupID + $filtertypID = 6; + + if(!$testFilter) { + // get membership from the session + //TODO: GET GROUP from SESSION + $groupID = 1; + } + try { + $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE + filtertypeID = ".$filtertypID." AND + filtervalue = ".$groupID." "); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('membership', $result, $set[$filtertypID]); } +######################################################### + // Time + $filtertypID = 7; + if(!$testFilter) { + $time = time("H:i"); + } + + $nowShort = $time; + + $nowShort = str_replace(":", "", $nowShort); + try { + $select = $db->select() + ->from(array('pbs_filterentries') + ) + ->where('filtertypeID = ?', $filtertypID) + ->where('REPLACE(filtervalue,":","") <= ? AND ? <= REPLACE(filtervalue2,":","")', $nowShort); + + $stmt = $select->query(); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('time', $result, $set[$filtertypID]); } +######################################################### + // Hardwarehash + $filtertypID = 9; + if(!$testFilter) { + // get hardwarehash from session + $hardwarehash = 'aaaa'; + } + + try { + $select = $db->select() + ->from(array('pbs_filterentries') + ) + ->where('filtertypeID = ?', $filtertypID) + ->where('`filtervalue` = ?', $hardwarehash); + $stmt = $select->query(); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('hardwarehash', $result, $set[$filtertypID]); } +######################################################### + // weekday + $filtertypID = 10; + if(!$testFilter) { + $weekday = date('N'); + } + + try { + $select = $db->select() + ->from(array('pbs_filterentries') + ) + ->where('filtertypeID = ?', $filtertypID) + ->where('filtervalue = ? ', $weekday); + + $stmt = $select->query(); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('weekday', $result, $set[$filtertypID]); } +######################################################### + // weekday + $filtertypID = 11; + if(!$testFilter) { + $date = date('d.m.Y'); + } + + try { + $select = $db->select() + ->from(array('pbs_filterentries') + ) + ->where('filtertypeID = ?', $filtertypID) + ->where('REPLACE(filtervalue,".","") <= ? AND ? <= REPLACE(filtervalue2,".","")', $date); + + $stmt = $select->query(); + $result = $stmt->fetchAll(); + foreach($result as $r) { + $set[$filtertypID][] = $r['filterID']; + } + } catch(Exception $e) { + } + + if($showPartResults) + { print_a('weekday', $result, $set[$filtertypID]); } +######################################## + // ErgebnisSet auswerten + print_a('the result sets of the filtertypes', $set); + + // Merging of the resultsets of the filter + $kk = array(); + foreach($set as $myset) { + $kk = array_merge($kk, $myset); + } + $set = $kk; + // counting how often a filter is evaluated at database + $a = array(); + foreach($set as $k => $s) { + $a[$s] += 1; + } + print_a('Übereinstimmungen pro Filter', $a); + // Get the number of filtertypes every filter has + $stmt = $db->query('SELECT filterID, COUNT(filtertypeID) as num FROM pbs_filterentries GROUP BY filterID'); + $resultset = $stmt->fetchAll(); + foreach($resultset as $d) { + $database[$d['filterID']] = $d['num']; + } + print_a('Anzahl Filterentries in Datenbank', $database); + + // remove all filters from resultset, which to few filtertypes satisfied + $result = array(); + foreach($a as $i => $b) { + if($a[$i] < $database[$i]) { + unset($a[$i]); + } else { + $result[] = $i; + } + } + + print_a('True Filters', $result); + // now selecting the filter with the highest priority + $query = 'SELECT filterID, bootmenuID, priority + FROM pbs_filter WHERE '; + foreach($result as $e) { + $queryTmp[] = "filterID = '$e'"; + } + $query . = implode(" OR ", $queryTmp); + $query . = 'ORDER BY priority DESC LIMIT 0,1'; + $bootmenuID = 'null'; + try { + $stmt = $db->query($query); + $resultset = $stmt->fetchAll(); + $bootmenuID = $resultset[0]['bootmenuID']; + } catch(Exception $e) { + } + if($bootmenuID != 'null') { + $bm = new Application_Model_BootMenu(); + $bmmapper = new Application_Model_BootMenuMapper(); + $bmmapper->find($bootmenuID, $bm); + echo "<h1><a href='/bootmenu/index/bootmenuid/".$bootmenuID."'>Goto BootmenuID: ".$bootmenuID."</a></h1>"; + } else { + echo "<h1>No Result :-(</h1>"; + } + + } catch (Zend_Exception $e) { + echo "class: ".get_class($e)."<br>\n"; + echo "Error message 2: " . $e->getMessage() . "\n"; } + } + + public function testevaluateAction() { + $pm = new Application_Model_PoolMapper(); + $pools = $pm->fetchAll(); + + $bim = new Application_Model_BootIsoMapper(); + $bootisos = $bim->fetchAll(); + + $mm = new Application_Model_MembershipMapper(); + $memberships = $mm->fetchAll(); + + $gm = new Application_Model_GroupMapper(); + $groups = $gm->fetchAll(); + + $cm = new Application_Model_ClientMapper(); + $clients = $cm->fetchAll(); + + $filterevaluate = new dev_Form_FilterEvaluate( + array( 'pools' => $pools, + 'bootisos' => $bootisos, + 'memberships' => $memberships, + 'groups' => $groups, + 'clients' => $clients, + + )); + $filterevaluate->populate(array( + 'ip' => '132.230.5.6', + 'mac' => '08:00:20:ae:fd:7e', + 'time' => date('d.m.Y H:i')) + ); + $this->view->filterevaluate = $filterevaluate; + } } diff --git a/application/modules/dev/controllers/GroupController.php b/application/modules/dev/controllers/GroupController.php index 4188a1d..08bbe45 100644 --- a/application/modules/dev/controllers/GroupController.php +++ b/application/modules/dev/controllers/GroupController.php @@ -1,258 +1,240 @@ -<?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 dev_GroupController extends Zend_Controller_Action -{ - protected $groupMapper; - protected $groupGroupsMapper; - protected $membershipMapper; - protected $groupRequestMapper; - protected $personmapper; - protected $rolemapper; - protected $groupList; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->groupMapper = new Application_Model_GroupMapper(); - $this->groupGroupsMapper = new Application_Model_GroupGroupsMapper(); - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); - $this->personmapper = new Application_Model_PersonMapper(); - $this->rolemapper = new Application_Model_RoleMapper(); - $this->groupList = $this->groupMapper->fetchAll(); - } else { - $this->_helper->redirector('login', 'auth'); - return; - } - } - - public function indexAction() - { - $this->view->groupList = $this->groupList; - } - - public function addAction() - { - if (!isset($_POST["add"])){ - $addForm = new dev_Form_GroupAdd(array('grouplist' => $this->groupList)); - } else { - $addForm = new dev_Form_GroupAdd(array('grouplist' => $this->groupList),$_POST); - - if ($addForm->isValid($_POST)) { - $group = new Application_Model_Group($_POST); - try { - $this->groupMapper->save($group); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - if($_POST['superordinatedGroupID'] != -1) { - $lastID = $this->groupMapper->getDbTable()->getDefaultAdapter()->lastInsertId(); - $groupgroups = new Application_Model_GroupGroups(); - $groupgroups->setParentID($_POST['superordinatedGroupID']); - $groupgroups->setGroupID($lastID); - try { - $this->groupGroupsMapper->save($groupgroups); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - - } - $this->_helper->redirector('', 'group'); - return; - } - } - - $this->view->addForm = $addForm; - } - - public function editAction() - { - $groupID = $this->_request->getParam('groupID'); - if(!isset($groupID)) { - $addForm = new dev_Form_GroupAdd(array('grouplist' => $this->groupList)); - $this->view->addForm = $addForm; - return; - } - if (!isset($_POST["save"])){ - $group = $this->groupMapper->find($groupID); - $_POST['title'] = $group->getTitle(); - $_POST['description'] = $group->getDescription(); - $editForm = new dev_Form_GroupEdit(); - } else { - $editForm = new dev_Form_GroupEdit($_POST); - if ($editForm->isValid($_POST)) { - $group = new Application_Model_Group($_POST); - $group->setID($this->_request->getParam('groupID')); - try { - $this->groupMapper->save($group); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'group'); - return; - } - } - - $this->view->editForm = $editForm; - - } - - public function showAction() - { - $groupID = $this->_request->getParam('groupID'); - if($groupID) { - $groupRequests = $this->groupRequestMapper->findBy(array('groupID' => $groupID),true); - if(isset($groupRequests)) { - foreach($groupRequests as $groupRequest) { - $person = $this->personmapper->find($groupRequest['personID']); - $groupRequestList[] = array( - 'grouprequestID' => $groupRequest['grouprequestID'], - 'person' => $person - ); - } - if(is_array($groupRequestList)) { - $this->view->groupRequestList = $groupRequestList; - } - $this->view->roleList = $this->rolemapper->findBy('groupID', $groupID); - } - $members = $this->membershipMapper->findBy('groupID', $groupID); - if(isset($members)) { - foreach($members as $member) { - $person = $this->personmapper->find($member['personID']); - $membersList[] = array( - 'membershipID' => $member['membershipID'], - 'person' => $person - ); - } - if(is_array($membersList)) { - $this->view->membersList = $membersList; - } - } - $groupgroups = $this->groupGroupsMapper->findBy('groupID', $groupID); - if(is_object($groupgroups)) { - $parentGroup = $this->groupMapper->find($groupgroups->getParentID()); - $this->view->$parentGroup = $parentGroup; - } - $group = $this->groupMapper->find($groupID); - $this->view->group = $group; - $this->view->groupID = $groupID; - } - } - - public function linkAction() - { - if (!isset($_POST["link"])){ - $linkForm = new dev_Form_GroupLink(array('grouplist' => $this->groupList)); - } else { - $linkForm = new dev_Form_GroupLink(array('grouplist' => $this->groupList),$_POST); - - if ($linkForm->isValid($_POST)) { - $groupgroups = new Application_Model_GroupGroups(); - $groupgroups->setParentID($_POST['superordinatedGroupID']); - $groupgroups->setGroupID($_POST['groupID']); - try { - $this->groupGroupsMapper->save($groupgroups); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'group'); - return; - } - } - - $this->view->linkForm = $linkForm; - } - - public function deleteAction() - { - $this->_helper->viewRenderer->setNoRender(); - $groupID = $this->_request->getParam('groupID'); - if (isset($groupID)){ - $group = $this->groupMapper->find($groupID); - try { - $this->groupMapper->delete($group); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'group'); - return; - } - } - - public function grantpersonAction() - { - $this->_helper->viewRenderer->setNoRender(); - if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) { - $groupRequest = $this->groupRequestMapper->find($_POST['grouprequestID']); - try { - $this->groupRequestMapper->delete($groupRequest); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $membership = new Application_Model_Membership(); - $membership->setGroupID($groupRequest->getGroupID()); - $membership->setPersonID($groupRequest->getPersonID()); - $membership->setRoleID($_POST['roleID']); - try { - $this->membershipMapper->save($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/dev/group/show/groupID/" . $groupRequest->getGroupID()); - } - } - - public function revokepersonAction() - { - $this->_helper->viewRenderer->setNoRender(); - $membershipID = $this->_request->getParam('membershipID'); - if(isset($membershipID)) { - $membership = $this->membershipMapper->find($membershipID); - if(isset($membership)) { - try { - $this->membershipMapper->delete($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/dev/group/edit/groupID/" . $membership->getGroupID()); - } - - } - } +* 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_GroupController extends Zend_Controller_Action { + protected $groupMapper; + protected $groupGroupsMapper; + protected $membershipMapper; + protected $groupRequestMapper; + protected $personmapper; + protected $rolemapper; + protected $groupList; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->groupMapper = new Application_Model_GroupMapper(); + $this->groupGroupsMapper = new Application_Model_GroupGroupsMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); + $this->personmapper = new Application_Model_PersonMapper(); + $this->rolemapper = new Application_Model_RoleMapper(); + $this->groupList = $this->groupMapper->fetchAll(); + } else { + $this->_helper->redirector('login', 'auth'); + return; + } + } + + public function indexAction() { + $this->view->groupList = $this->groupList; + } + + public function addAction() { + if (!isset($_POST["add"])) { + $addForm = new dev_Form_GroupAdd(array('grouplist' => $this->groupList)); + } else { + $addForm = new dev_Form_GroupAdd(array('grouplist' => $this->groupList), $_POST); + + if ($addForm->isValid($_POST)) { + $group = new Application_Model_Group($_POST); + try { + $this->groupMapper->save($group); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + if($_POST['superordinatedGroupID'] != -1) { + $lastID = $this->groupMapper->getDbTable()->getDefaultAdapter()->lastInsertId(); + $groupgroups = new Application_Model_GroupGroups(); + $groupgroups->setParentID($_POST['superordinatedGroupID']); + $groupgroups->setGroupID($lastID); + try { + $this->groupGroupsMapper->save($groupgroups); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + + } + $this->_helper->redirector('', 'group'); + return; + } + } + + $this->view->addForm = $addForm; + } + + public function editAction() { + $groupID = $this->_request->getParam('groupID'); + if(!isset($groupID)) { + $addForm = new dev_Form_GroupAdd(array('grouplist' => $this->groupList)); + $this->view->addForm = $addForm; + return; + } + if (!isset($_POST["save"])) { + $group = $this->groupMapper->find($groupID); + $_POST['title'] = $group->getTitle(); + $_POST['description'] = $group->getDescription(); + $editForm = new dev_Form_GroupEdit(); + } else { + $editForm = new dev_Form_GroupEdit($_POST); + if ($editForm->isValid($_POST)) { + $group = new Application_Model_Group($_POST); + $group->setID($this->_request->getParam('groupID')); + try { + $this->groupMapper->save($group); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'group'); + return; + } + } + + $this->view->editForm = $editForm; + + } + + public function showAction() { + $groupID = $this->_request->getParam('groupID'); + if($groupID) { + $groupRequests = $this->groupRequestMapper->findBy(array('groupID' => $groupID), true); + if(isset($groupRequests)) { + foreach($groupRequests as $groupRequest) { + $person = $this->personmapper->find($groupRequest['personID']); + $groupRequestList[] = array( + 'grouprequestID' => $groupRequest['grouprequestID'], + 'person' => $person + ); + } + if(is_array($groupRequestList)) { + $this->view->groupRequestList = $groupRequestList; + } + $this->view->roleList = $this->rolemapper->findBy('groupID', $groupID); + } + $members = $this->membershipMapper->findBy('groupID', $groupID); + if(isset($members)) { + foreach($members as $member) { + $person = $this->personmapper->find($member['personID']); + $membersList[] = array( + 'membershipID' => $member['membershipID'], + 'person' => $person + ); + } + if(is_array($membersList)) { + $this->view->membersList = $membersList; + } + } + $groupgroups = $this->groupGroupsMapper->findBy('groupID', $groupID); + if(is_object($groupgroups)) { + $parentGroup = $this->groupMapper->find($groupgroups->getParentID()); + $this->view->$parentGroup = $parentGroup; + } + $group = $this->groupMapper->find($groupID); + $this->view->group = $group; + $this->view->groupID = $groupID; + } + } + + public function linkAction() { + if (!isset($_POST["link"])) { + $linkForm = new dev_Form_GroupLink(array('grouplist' => $this->groupList)); + } else { + $linkForm = new dev_Form_GroupLink(array('grouplist' => $this->groupList), $_POST); + + if ($linkForm->isValid($_POST)) { + $groupgroups = new Application_Model_GroupGroups(); + $groupgroups->setParentID($_POST['superordinatedGroupID']); + $groupgroups->setGroupID($_POST['groupID']); + try { + $this->groupGroupsMapper->save($groupgroups); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'group'); + return; + } + } + + $this->view->linkForm = $linkForm; + } + + public function deleteAction() { + $this->_helper->viewRenderer->setNoRender(); + $groupID = $this->_request->getParam('groupID'); + if (isset($groupID)) { + $group = $this->groupMapper->find($groupID); + try { + $this->groupMapper->delete($group); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'group'); + return; + } + } + + public function grantpersonAction() { + $this->_helper->viewRenderer->setNoRender(); + if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) { + $groupRequest = $this->groupRequestMapper->find($_POST['grouprequestID']); + try { + $this->groupRequestMapper->delete($groupRequest); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $membership = new Application_Model_Membership(); + $membership->setGroupID($groupRequest->getGroupID()); + $membership->setPersonID($groupRequest->getPersonID()); + $membership->setRoleID($_POST['roleID']); + try { + $this->membershipMapper->save($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/dev/group/show/groupID/" . $groupRequest->getGroupID()); + } + } + + public function revokepersonAction() { + $this->_helper->viewRenderer->setNoRender(); + $membershipID = $this->_request->getParam('membershipID'); + if(isset($membershipID)) { + $membership = $this->membershipMapper->find($membershipID); + if(isset($membership)) { + try { + $this->membershipMapper->delete($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/dev/group/edit/groupID/" . $membership->getGroupID()); + } + + } + } } diff --git a/application/modules/dev/controllers/IndexController.php b/application/modules/dev/controllers/IndexController.php index 2b8873d..cbf4e77 100644 --- a/application/modules/dev/controllers/IndexController.php +++ b/application/modules/dev/controllers/IndexController.php @@ -1,28 +1,25 @@ -<?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 dev_IndexController extends Zend_Controller_Action -{ - - public function init() - { - /* Initialize action controller here */ - } - - public function indexAction() - { - // action body - - } +* 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_IndexController extends Zend_Controller_Action { + + public function init() { + /* Initialize action controller here */ + } + + public function indexAction() { + // action body + + } } diff --git a/application/modules/dev/controllers/PersonController.php b/application/modules/dev/controllers/PersonController.php index 25c415a..3119ab9 100644 --- a/application/modules/dev/controllers/PersonController.php +++ b/application/modules/dev/controllers/PersonController.php @@ -1,176 +1,167 @@ -<?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 dev_PersonController extends Zend_Controller_Action -{ - protected $person; - protected $personmapper; - protected $membershipMapper; - protected $memberships; - protected $groupMapper; - protected $groups; - protected $groupRequestMapper; - - 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->groupMapper = new Application_Model_GroupMapper(); - $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->memberships = $this->membershipMapper->findBy("personID",$this->person->getID()); - if(isset($this->memberships)) { - foreach($this->memberships as $membership) { - $group = $this->groupMapper->find($membership['groupID']); - $this->groups[] = array ( - 'groupID' => $group->getID(), - 'title' => $group->getTitle(), - 'description' => $group->getDescription(), - 'membershipID' => $membership['membershipID'] - ); - } - } - } else { - $this->_helper->redirector('login', 'auth'); - return; - } - } - - public function indexAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $this->_helper->redirector('show', 'person'); - return; - } - - public function showAction() - { - $this->view->person = $this->person; - $this->view->groups = $this->groups; - } - - public function editAction() - { - $this->view->person = $this->person; - if (!isset($_POST["save"])){ - $editForm = new dev_Form_PersonEdit(); - } else { - $editForm = new dev_Form_PersonEdit($_POST); - if ($editForm->isValid($_POST)) { - if(isset($_POST['newpassword'])) { - $date = new DateTime(); - $this->person->setPassword($_POST['newpassword']); - $this->person->setPasswordSalt(MD5($date->getTimestamp())); - $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); - } - $this->person->setOptions($_POST); - try { - $this->personmapper->save($this->person); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - echo "Email Address already existing."; - return; - } - $this->_helper->redirector('show', 'person'); - return; - } - } - $this->view->editForm = $editForm; - } - - public function requestAction() - { - $this->view->person = $this->person; - $allgroups = $this->groupMapper->fetchAll(); - $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()),true); - $count = 0; - foreach($allgroups as $group) { - foreach($groupRequests as $groupRequest) { - if($groupRequest['groupID'] == $group->getID()) { - $groupsFound[$count] = true; - } else { - $groupsFound[$count] = false; - } - } - foreach($this->memberships as $membership) { - if($membership['groupID'] == $group->getID()) { - $groupsFound[$count] = true; - } else { - if($groupsFound[$count] != true) { - $groupsFound[$count] = false; - } - } - } - $count++; - } - if(count($groupsFound) > 0) { - foreach($groupsFound as $k => $v) { - if($v == true) { - unset($allgroups[$k]); - } - } - } - if (!isset($_POST["request"])){ - if(count($allgroups) <= 0) { - echo "No Groups to choose."; - } - $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups)); - } else { - $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups), $_POST); - if ($requestForm->isValid($_POST)) { - $groupRequestMapper = new Application_Model_GroupRequestMapper(); - $groupRequest = new Application_Model_GroupRequest(); - $groupRequest->setGroupID($_POST['groupID']); - $date = new DateTime(); - $groupRequest->setTime($date->getTimestamp()); - $groupRequest->setPersonID($this->person->getID()); - try { - $groupRequestMapper->save($groupRequest); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('show', 'person'); - return; - } - } - $this->view->requestForm = $requestForm; - } - - public function leaveAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $this->view->person = $this->person; - $membershipID = $this->_request->getParam('membershipID'); - if(isset($membershipID)) { - $membership = $this->membershipMapper->find($membershipID); - try { - $this->membershipMapper->delete($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('show', 'person'); - 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 dev_PersonController extends Zend_Controller_Action { + protected $person; + protected $personmapper; + protected $membershipMapper; + protected $memberships; + protected $groupMapper; + protected $groups; + protected $groupRequestMapper; + + 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->groupMapper = new Application_Model_GroupMapper(); + $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->memberships = $this->membershipMapper->findBy("personID", $this->person->getID()); + if(isset($this->memberships)) { + foreach($this->memberships as $membership) { + $group = $this->groupMapper->find($membership['groupID']); + $this->groups[] = array ( + 'groupID' => $group->getID(), + 'title' => $group->getTitle(), + 'description' => $group->getDescription(), + 'membershipID' => $membership['membershipID'] + ); + } + } + } else { + $this->_helper->redirector('login', 'auth'); + return; + } + } + + public function indexAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $this->_helper->redirector('show', 'person'); + return; + } + + public function showAction() { + $this->view->person = $this->person; + $this->view->groups = $this->groups; + } + + public function editAction() { + $this->view->person = $this->person; + if (!isset($_POST["save"])) { + $editForm = new dev_Form_PersonEdit(); + } else { + $editForm = new dev_Form_PersonEdit($_POST); + if ($editForm->isValid($_POST)) { + if(isset($_POST['newpassword'])) { + $date = new DateTime(); + $this->person->setPassword($_POST['newpassword']); + $this->person->setPasswordSalt(MD5($date->getTimestamp())); + $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); + } + $this->person->setOptions($_POST); + try { + $this->personmapper->save($this->person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing."; + return; + } + $this->_helper->redirector('show', 'person'); + return; + } + } + $this->view->editForm = $editForm; + } + + public function requestAction() { + $this->view->person = $this->person; + $allgroups = $this->groupMapper->fetchAll(); + $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()), true); + $count = 0; + foreach($allgroups as $group) { + foreach($groupRequests as $groupRequest) { + if($groupRequest['groupID'] == $group->getID()) { + $groupsFound[$count] = true; + } else { + $groupsFound[$count] = false; + } + } + foreach($this->memberships as $membership) { + if($membership['groupID'] == $group->getID()) { + $groupsFound[$count] = true; + } else { + if($groupsFound[$count] != true) { + $groupsFound[$count] = false; + } + } + } + $count++; + } + if(count($groupsFound) > 0) { + foreach($groupsFound as $k => $v) { + if($v == true) { + unset($allgroups[$k]); + } + } + } + if (!isset($_POST["request"])) { + if(count($allgroups) <= 0) { + echo "No Groups to choose."; + } + $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups)); + } else { + $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups), $_POST); + if ($requestForm->isValid($_POST)) { + $groupRequestMapper = new Application_Model_GroupRequestMapper(); + $groupRequest = new Application_Model_GroupRequest(); + $groupRequest->setGroupID($_POST['groupID']); + $date = new DateTime(); + $groupRequest->setTime($date->getTimestamp()); + $groupRequest->setPersonID($this->person->getID()); + try { + $groupRequestMapper->save($groupRequest); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('show', 'person'); + return; + } + } + $this->view->requestForm = $requestForm; + } + + public function leaveAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $this->view->person = $this->person; + $membershipID = $this->_request->getParam('membershipID'); + if(isset($membershipID)) { + $membership = $this->membershipMapper->find($membershipID); + try { + $this->membershipMapper->delete($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('show', 'person'); + return; + } + } } diff --git a/application/modules/dev/controllers/PoolController.php b/application/modules/dev/controllers/PoolController.php index 6f80468..6e31161 100644 --- a/application/modules/dev/controllers/PoolController.php +++ b/application/modules/dev/controllers/PoolController.php @@ -1,175 +1,167 @@ -<?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 dev_PoolController extends Zend_Controller_Action -{ - - public function init() - { - /* Initialize action controller here */ +* 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_PoolController extends Zend_Controller_Action { + + public function init() { + /* Initialize action controller here */ + } + + public function indexAction() { + $poolMapper = new Application_Model_PoolMapper(); + $this->view->pools = $poolMapper->fetchAll(); + + $clientmapper = new Application_Model_ClientMapper(); + $clients = $clientmapper->fetchAll(); + foreach($clients as $c) { +#$client = new Application_Model_Client($c); + $clientsArray[] = $c->toArray(); } - - public function indexAction() - { - $poolMapper = new Application_Model_PoolMapper(); - $this->view->pools = $poolMapper->fetchAll(); - - $clientmapper = new Application_Model_ClientMapper(); - $clients = $clientmapper->fetchAll(); - foreach($clients as $c){ - #$client = new Application_Model_Client($c); - $clientsArray[] = $c->toArray(); - } - $assignedclientmapper = new Application_Model_PoolEntriesMapper(); - $assignedclients = $assignedclientmapper->fetchAll(); - foreach($assignedclients as $c){ - $assignedclientsArray[] = $c->toArray(); - } - $freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray); - - $this->view->freeclients = $freeclients; - + $assignedclientmapper = new Application_Model_PoolEntriesMapper(); + $assignedclients = $assignedclientmapper->fetchAll(); + foreach($assignedclients as $c) { + $assignedclientsArray[] = $c->toArray(); } - - public function createpoolAction() - { - if (!isset($_POST["add"])){ - $addfilterform = new dev_Form_Pool(array('buttontext' => 'Create Pool')); - $this->view->addpool = $addfilterform; - }else { - $addpoolform = new dev_Form_Pool(array('buttontext' => 'Create Pool'),$_POST); - if ($addpoolform->isValid($_POST)) { - try{ - $pool = new Application_Model_Pool($_POST); - $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->save($pool); - $this->_redirect('/dev/pool'); - return; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } - $this->view->addpool = $addfilterform; - } + $freeclients = $this->arrayDiff($clientsArray, $assignedclientsArray); + + $this->view->freeclients = $freeclients; + + } + + public function createpoolAction() { + if (!isset($_POST["add"])) { + $addfilterform = new dev_Form_Pool(array('buttontext' => 'Create Pool')); + $this->view->addpool = $addfilterform; + } else { + $addpoolform = new dev_Form_Pool(array('buttontext' => 'Create Pool'), $_POST); + if ($addpoolform->isValid($_POST)) { + try { + $pool = new Application_Model_Pool($_POST); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->save($pool); + $this->_redirect('/dev/pool'); + return; + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + $this->view->addpool = $addfilterform; } - - public function deletepoolAction() - { - $poolID = $this->_request->getParam('poolID'); - // TODO: ACL implementieren ob er den pool löschen darf - if(is_numeric($poolID)){ - $deletepool = new Application_Model_Pool(); - $deletepool->setID($poolID); - $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->delete($deletepool); - } - $this->_redirect('/dev/pool'); + } + + public function deletepoolAction() { + $poolID = $this->_request->getParam('poolID'); + // TODO: ACL implementieren ob er den pool löschen darf + if(is_numeric($poolID)) { + $deletepool = new Application_Model_Pool(); + $deletepool->setID($poolID); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->delete($deletepool); } - - public function editpoolAction() - { - if (!isset($_POST["add"])){ - $poolID = $this->_request->getParam('poolID'); - - $pool = new Application_Model_Pool(); - $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->find($poolID,$pool); - $poolArray = $pool->toArray(); - - $editpool = new dev_Form_Pool(array('buttontext' => 'Edit Pool')); - $editpool->populate($poolArray); - $this->view->editpoolform = $editpool; - - }else { - $editpoolform = new dev_Form_Pool(array('buttontext' => 'Edit Pool'),$_POST); - if ($editpoolform->isValid($_POST)) { - try{ - $pool = new Application_Model_Pool($_POST); - $pool->setID($this->_request->getParam('poolID')); - $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->save($pool); - $this->_redirect('/dev/pool'); - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } - $this->view->editpoolform = $editpoolform; - } + $this->_redirect('/dev/pool'); + } + + public function editpoolAction() { + if (!isset($_POST["add"])) { + $poolID = $this->_request->getParam('poolID'); + + $pool = new Application_Model_Pool(); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->find($poolID, $pool); + $poolArray = $pool->toArray(); + + $editpool = new dev_Form_Pool(array('buttontext' => 'Edit Pool')); + $editpool->populate($poolArray); + $this->view->editpoolform = $editpool; + + } else { + $editpoolform = new dev_Form_Pool(array('buttontext' => 'Edit Pool'), $_POST); + if ($editpoolform->isValid($_POST)) { + try { + $pool = new Application_Model_Pool($_POST); + $pool->setID($this->_request->getParam('poolID')); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->save($pool); + $this->_redirect('/dev/pool'); + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + $this->view->editpoolform = $editpoolform; } + } + + public function linkclientAction() { + $clientID = $this->_request->getParam('clientID'); + $poolID = $this->_request->getParam('poolID'); + if(!isset($_POST['clientID']) && ($clientID == '')) { + $clientmapper = new Application_Model_ClientMapper(); + $clients = $clientmapper->fetchAll(); + foreach($clients as $c) { + $clientsArray[] = $c->toArray(); + } + $assignedclientmapper = new Application_Model_PoolEntriesMapper(); + $assignedclients = $assignedclientmapper->fetchAll(); + foreach($assignedclients as $c) { + $assignedclientsArray[] = $c->toArray(); + } + $freeclients = $this->arrayDiff($clientsArray, $assignedclientsArray); + + $poolclient = new dev_Form_PoolClient(array('buttontext' => 'Link Client', 'clients' => $freeclients)); + $this->view->poolclient = $poolclient; + } else { + $poolclient = new dev_Form_PoolClient(array('buttontext' => 'Link Client'), $_POST); + try { + $pool = new Application_Model_PoolEntries($_POST); + $pool->setPoolID($this->_request->getParam('poolID')); + if($pool->getClientID() == '') { + $pool->setClientID($this->_request->getParam('clientID')); + } + $poolmapper = new Application_Model_PoolEntriesMapper(); + $poolmapper->save($pool); + $this->_redirect('/dev/pool'); + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + $this->view->poolclient = $poolclient; - public function linkclientAction() - { - $clientID = $this->_request->getParam('clientID'); - $poolID = $this->_request->getParam('poolID'); - if(!isset($_POST['clientID']) && ($clientID == '')){ - $clientmapper = new Application_Model_ClientMapper(); - $clients = $clientmapper->fetchAll(); - foreach($clients as $c){ - $clientsArray[] = $c->toArray(); - } - $assignedclientmapper = new Application_Model_PoolEntriesMapper(); - $assignedclients = $assignedclientmapper->fetchAll(); - foreach($assignedclients as $c){ - $assignedclientsArray[] = $c->toArray(); - } - $freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray); - - $poolclient = new dev_Form_PoolClient(array('buttontext' => 'Link Client','clients'=> $freeclients)); - $this->view->poolclient = $poolclient; - }else { - $poolclient = new dev_Form_PoolClient(array('buttontext' => 'Link Client'),$_POST); - try{ - $pool = new Application_Model_PoolEntries($_POST); - $pool->setPoolID($this->_request->getParam('poolID')); - if($pool->getClientID() == ''){ - $pool->setClientID($this->_request->getParam('clientID')); - } - $poolmapper = new Application_Model_PoolEntriesMapper(); - $poolmapper->save($pool); - $this->_redirect('/dev/pool'); - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - $this->view->poolclient = $poolclient; - - } } - private function arrayDiff($a, $b){ - foreach($a as $k1 => $i1){ - foreach($b as $k2 => $i2){ - if($i1['clientID'] == $i2['clientID']){ - unset($a[$k1]); - } - } - } - return $a; - } - - - public function unlinkclientAction() - { - $poolentriesID = $this->_request->getParam('poolentriesID'); - - // TODO: ACL implementieren ob er den filter löschen darf - if(is_numeric($poolentriesID)){ - $deletepoolentries = new Application_Model_PoolEntries(); - $deletepoolentries->setID($poolentriesID); - - $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper(); - $deletepoolentriesmapper->delete($deletepoolentries); - echo "ok"; - } - $this->_redirect('/dev/pool'); + } + private function arrayDiff($a, $b) { + foreach($a as $k1 => $i1) { + foreach($b as $k2 => $i2) { + if($i1['clientID'] == $i2['clientID']) { + unset($a[$k1]); + } + } + } + return $a; + } + + + public function unlinkclientAction() { + $poolentriesID = $this->_request->getParam('poolentriesID'); + + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($poolentriesID)) { + $deletepoolentries = new Application_Model_PoolEntries(); + $deletepoolentries->setID($poolentriesID); + + $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper(); + $deletepoolentriesmapper->delete($deletepoolentries); + echo "ok"; } + $this->_redirect('/dev/pool'); + } } diff --git a/application/modules/dev/controllers/PrebootController.php b/application/modules/dev/controllers/PrebootController.php index c3933c6..4936d2c 100644 --- a/application/modules/dev/controllers/PrebootController.php +++ b/application/modules/dev/controllers/PrebootController.php @@ -1,206 +1,195 @@ -<?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 dev_PrebootController extends Zend_Controller_Action -{ - - public function init() - { - $db = Zend_Db_Table::getDefaultAdapter(); - } +* 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_PrebootController extends Zend_Controller_Action { + + public function init() { + $db = Zend_Db_Table::getDefaultAdapter(); + } - public function indexAction() - { - $prebootmapper = new Application_Model_PreBootMapper(); - $groupmapper = new Application_Model_GroupMapper(); - $membershipmapper = new Application_Model_MembershipMapper(); - $personmapper = new Application_Model_PersonMapper(); - - $this->view->prebootlist = $prebootmapper->fetchAll(); - $this->view->update = array(); - - foreach ($this->view->prebootlist as $preboot){ - $this->view->update[$preboot->getID()] = $this->checkupdateAction($preboot); - $preboot->setGroupID("[".$preboot->getGroupID()."] ".$groupmapper->find($preboot->getGroupID())->getTitle()); - $preboot->setMembershipID("[".$preboot->getMembershipID()."] ".$personmapper->find($membershipmapper->find($preboot->getMembershipID())->getPersonID())->getFirstname()); - } + public function indexAction() { + $prebootmapper = new Application_Model_PreBootMapper(); + $groupmapper = new Application_Model_GroupMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $personmapper = new Application_Model_PersonMapper(); + + $this->view->prebootlist = $prebootmapper->fetchAll(); + $this->view->update = array(); + + foreach ($this->view->prebootlist as $preboot) { + $this->view->update[$preboot->getID()] = $this->checkupdateAction($preboot); + $preboot->setGroupID("[".$preboot->getGroupID()."] ".$groupmapper->find($preboot->getGroupID())->getTitle()); + $preboot->setMembershipID("[".$preboot->getMembershipID()."] ".$personmapper->find($membershipmapper->find($preboot->getMembershipID())->getPersonID())->getFirstname()); } - - public function createprebootAction() - { - $groupmapper = new Application_Model_GroupMapper(); - - if (!isset($_POST["createpreboot"])){ - $createprebootForm = new dev_Form_PrebootCreate(array('grouplist' => $groupmapper->fetchAll())); - } else { - - $createprebootForm = new dev_Form_PrebootCreate(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($createprebootForm->isValid($_POST)) { - - $preboot = new Application_Model_PreBoot($_POST); - $preboot->setMembershipID('1'); - $prebootmapper = new Application_Model_PreBootMapper(); - - try { - - exec("wget --spider ".$preboot->getPath_preboot()." 2>&1 | grep 'Remote file exists.'", $exists_preboot); - - if(!array_pop($exists_preboot)){ - $this->view->createprebootForm = $createprebootForm; - return; - } - - $prebootID = $prebootmapper->save($preboot); - - $path_preboot = "../resources/bootmedium/$prebootID/"; - mkdir($path_preboot ,0777, true); - - exec("wget -O '".$path_preboot."preboot.zip' ".$preboot->getPath_preboot()); - - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - - } - $this->_redirect('/dev/preboot'); - } - } - + } + + public function createprebootAction() { + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["createpreboot"])) { + $createprebootForm = new dev_Form_PrebootCreate(array('grouplist' => $groupmapper->fetchAll())); + } else { + + $createprebootForm = new dev_Form_PrebootCreate(array('grouplist' => $groupmapper->fetchAll()), $_POST); + + if ($createprebootForm->isValid($_POST)) { + + $preboot = new Application_Model_PreBoot($_POST); + $preboot->setMembershipID('1'); + $prebootmapper = new Application_Model_PreBootMapper(); + + try { + + exec("wget --spider ".$preboot->getPath_preboot()." 2>&1 | grep 'Remote file exists.'", $exists_preboot); + + if(!array_pop($exists_preboot)) { $this->view->createprebootForm = $createprebootForm; + return; + } + + $prebootID = $prebootmapper->save($preboot); + + $path_preboot = "../resources/bootmedium/$prebootID/"; + mkdir($path_preboot , 0777, true); + + exec("wget -O '".$path_preboot."preboot.zip' ".$preboot->getPath_preboot()); + + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/dev/preboot'); + } } - - public function checkupdateAction($preboot) - { - $prebootID = $preboot->getID(); - exec("wget --server-response --spider ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'Last-Modified:'", $prebootdate); - - //print_a($prebootdate); - - $prebootdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($prebootdate)))); - - if(is_file("../resources/bootmedium/$prebootID/preboot.zip")) - $prebootolddate = filemtime("../resources/bootmedium/".$prebootID."/preboot.zip"); - else - $prebootolddate = false; - - //print_a($prebootname,$prebootdate,$prebootolddate); - - - if($prebootdate > $prebootolddate) - return true; - else - return false; - - } - - public function updateprebootAction() - { - - $prebootID = $this->_request->getParam('prebootID'); - - $prebootmapper = new Application_Model_PreBootMapper(); - $preboot = new Application_Model_PreBoot(); - $prebootmapper->find($prebootID,$preboot); - - $path_preboot = "../resources/bootmedium/$prebootID/"; - - exec("wget -O '".$path_preboot."preboot.zip' ".$preboot->getPath_preboot()); - - $filelist = array(); - $filelist = scandir($path_preboot); - - $bootisoMapper = new Application_Model_BootIsoMapper(); - - foreach($filelist as $file){ - if($file == "." || $file == ".." || $file == "preboot.zip"){ - //do nothing - } - else{ - $bootisoID = str_replace('.zip', '', $file); - $serialnumber = $bootisoMapper->find($bootisoID)->getSerialnumber(); - - copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); - $zip->close(); - } - } - } - - $this->_redirect('/dev/preboot'); + + $this->view->createprebootForm = $createprebootForm; + } + + public function checkupdateAction($preboot) { + $prebootID = $preboot->getID(); + exec("wget --server-response --spider ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'Last-Modified:'", $prebootdate); + + //print_a($prebootdate); + + $prebootdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($prebootdate)))); + + if(is_file("../resources/bootmedium/$prebootID/preboot.zip")) + { $prebootolddate = filemtime("../resources/bootmedium/".$prebootID."/preboot.zip"); } + else + { $prebootolddate = false; } + + //print_a($prebootname,$prebootdate,$prebootolddate); + + + if($prebootdate > $prebootolddate) + { return true; } + else + { return false; } + + } + + public function updateprebootAction() { + + $prebootID = $this->_request->getParam('prebootID'); + + $prebootmapper = new Application_Model_PreBootMapper(); + $preboot = new Application_Model_PreBoot(); + $prebootmapper->find($prebootID, $preboot); + + $path_preboot = "../resources/bootmedium/$prebootID/"; + + exec("wget -O '".$path_preboot."preboot.zip' ".$preboot->getPath_preboot()); + + $filelist = array(); + $filelist = scandir($path_preboot); + + $bootisoMapper = new Application_Model_BootIsoMapper(); + + foreach($filelist as $file) { + if($file == "." || $file == ".." || $file == "preboot.zip") { + //do nothing + } else { + $bootisoID = str_replace('.zip', '', $file); + $serialnumber = $bootisoMapper->find($bootisoID)->getSerialnumber(); + + copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res == = true) { + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); + $zip->close(); + } + } } - public function editprebootAction() - { - $prebootID = $this->_request->getParam('prebootID'); - $groupmapper = new Application_Model_GroupMapper(); - - if (!isset($_POST["editpreboot"])){ - $prebootID = $this->_request->getParam('prebootID'); - if (!isset($prebootID) || !is_numeric($prebootID)){ - $this->_redirect('/dev/preboot'); - } else { - $preboot = new Application_Model_PreBoot(); - $prebootmapper = new Application_Model_PreBootMapper(); - $prebootmapper->find($prebootID, $preboot); - - $editprebootForm = new dev_Form_PrebootEdit(array('grouplist' => $groupmapper->fetchAll())); - $editprebootForm->populate($preboot->toArray()); - } - }else{ - $editprebootForm = new dev_Form_PrebootEdit(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($editprebootForm->isValid($_POST)) { - - $preboot = new Application_Model_PreBoot($_POST); - $preboot->setMembershipID('1'); - $prebootmapper = new Application_Model_PreBootMapper(); - $preboot->setID($prebootID); - - try { - $prebootmapper->save($preboot); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - } - - $this->_redirect('/dev/preboot'); - } - - } - - $this->view->editprebootForm = $editprebootForm; + $this->_redirect('/dev/preboot'); + } + + public function editprebootAction() { + $prebootID = $this->_request->getParam('prebootID'); + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["editpreboot"])) { + $prebootID = $this->_request->getParam('prebootID'); + if (!isset($prebootID) || !is_numeric($prebootID)) { + $this->_redirect('/dev/preboot'); + } else { + $preboot = new Application_Model_PreBoot(); + $prebootmapper = new Application_Model_PreBootMapper(); + $prebootmapper->find($prebootID, $preboot); + + $editprebootForm = new dev_Form_PrebootEdit(array('grouplist' => $groupmapper->fetchAll())); + $editprebootForm->populate($preboot->toArray()); + } + } else { + $editprebootForm = new dev_Form_PrebootEdit(array('grouplist' => $groupmapper->fetchAll()), $_POST); + + if ($editprebootForm->isValid($_POST)) { + + $preboot = new Application_Model_PreBoot($_POST); + $preboot->setMembershipID('1'); + $prebootmapper = new Application_Model_PreBootMapper(); + $preboot->setID($prebootID); + + try { + $prebootmapper->save($preboot); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/dev/preboot'); + } + } - public function deleteprebootAction() - { - $prebootID = $this->_request->getParam('prebootID'); - if (!isset($prebootID)){ - $this->_redirect('/dev/preboot'); - } else { - $preboot = new Application_Model_PreBoot(); - $preboot->setID($prebootID); - $prebootmapper = new Application_Model_PreBootMapper(); - $prebootmapper->delete($preboot); - } - $this->_redirect('/dev/preboot'); + $this->view->editprebootForm = $editprebootForm; + } + + public function deleteprebootAction() { + $prebootID = $this->_request->getParam('prebootID'); + if (!isset($prebootID)) { + $this->_redirect('/dev/preboot'); + } else { + $preboot = new Application_Model_PreBoot(); + $preboot->setID($prebootID); + $prebootmapper = new Application_Model_PreBootMapper(); + $prebootmapper->delete($preboot); } + $this->_redirect('/dev/preboot'); + } } diff --git a/application/modules/dev/controllers/ResourceController.php b/application/modules/dev/controllers/ResourceController.php index 6889f9b..0c5fa85 100644 --- a/application/modules/dev/controllers/ResourceController.php +++ b/application/modules/dev/controllers/ResourceController.php @@ -1,172 +1,163 @@ -<?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 dev_ResourceController extends Zend_Controller_Action -{ - - private $thisSession; - - public function init() - { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - - $alphasessionID = $this->_request->getParam('alpha'); - $session = new Application_Model_Session(); - $sm = new Application_Model_SessionMapper(); - $result = $sm->findBy(array('alphasessionID' => $alphasessionID), true); - # print_a($result); - $this->thisSession = $session->setOptions($result[0]); - $this->thisSession->setID($result[0]['sessionID']); - } - - public function indexAction() - { - - - } - - public function getinitramfsAction() - { - - $bootosID = $this->thisSession->getBootosID(); - - if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){ - - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="initramfs"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - // create file. - chdir("../resources/bootos/$bootosID/initramfs/"); - $initname = array_pop(scandir("./")); - - passthru( "cat ".$initname); - } - } - - public function getconfigAction() - { - $bootmenuentryID = $this->thisSession->getBootmenuentryID(); - - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bmm = new Application_Model_BootMenuEntriesMapper(); - $bmm->find($bootmenuentryID,$bootmenuentry); - # print_a($bootmenuentry); - - $configID = $bootmenuentry->getConfigID(); - - if(is_dir("../resources/config/$configID/config/") && is_numeric($configID)){ - - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="config.tgz"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - // create the gzipped tarfile. - chdir("../resources/config/$configID/config/"); - passthru( "tar cz ./"); - } - } - - public function getkernelAction() - { - $bootosID = $this->thisSession->getBootosID(); - - if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){ - - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="kernel"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - // create the gzipped tarfile. - chdir("../resources/bootos/$bootosID/kernel/"); - $kernelname = array_pop(scandir("./")); - - passthru( "cat ". $kernelname); - } - } - - public function getkclAction() - { - $bmeID = $this->thisSession->getBootmenuentryID(); - - if(is_numeric($bmeID)){ - - $bmemapper = new Application_Model_BootMenuEntriesMapper(); - $bme = new Application_Model_BootMenuEntries(); - $bmemapper->find($bmeID,$bme); - - header('Content-Type: text/html'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - if($bme->getKcl() != null) - $result = $bme->getKcl() . " " . $bme->getKclappend(); - else - $result = $bme->getKclappend(); - - echo $result; - - - } - - } - - public function getbootmenuentryAction() - { - // obsolete function (now only for debugging) - // after selecting the BootOS it will be saved in session - // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction - // can be called with session-identifier - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - $bootosID = $this->_request->getParam('bootosID'); - - $this->thisSession->setBootosID($bootosID)->setBootmenuentryID($bootmenuentryID); - $sessionMapper = new Application_Model_SessionMapper(); - $sessionMapper->save($this->thisSession); - - if($this->thisSession->getBootmenuentryID() != null){ - header('Content-Type: application/json'); - $return_val = - array( - 'info' => 'This function is for debugging purpose only', - 'kernel' => $this->generateURL('getkernel', 'alpha', $_SESSION['alphasessionID'], "kernel"), - 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $_SESSION['alphasessionID'], "initramfs"), - 'kcl' => $this->generateURL('getkcl', 'alpha', $_SESSION['alphasessionID'], "kcl.txt"), - 'config' => $_SESSION['alphasessionID'] - ); - echo json_encode($return_val); - } - else{ - echo json_encode( - array( 'info' => 'This function is for debugging purpose only', - 'error'=> 'your session is out of date') - ); - } - } - - private function generateURL($action, $varname, $varvalue, $filename){ - $path = '/dev/resource/'. $action .'/' . $varname .'/' . $varvalue .'/file/' . $filename ; - $path = "http://" . $_SERVER['SERVER_NAME'] . $path; - return $path; - } +* 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_ResourceController extends Zend_Controller_Action { + + private $thisSession; + + public function init() { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $alphasessionID = $this->_request->getParam('alpha'); + $session = new Application_Model_Session(); + $sm = new Application_Model_SessionMapper(); + $result = $sm->findBy(array('alphasessionID' => $alphasessionID), true); +# print_a($result); + $this->thisSession = $session->setOptions($result[0]); + $this->thisSession->setID($result[0]['sessionID']); + } + + public function indexAction() { + + + } + + public function getinitramfsAction() { + + $bootosID = $this->thisSession->getBootosID(); + + if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)) { + + header('Content-Type: application/x-gzip'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="initramfs"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + // create file. + chdir("../resources/bootos/$bootosID/initramfs/"); + $initname = array_pop(scandir("./")); + + passthru( "cat ".$initname); + } + } + + public function getconfigAction() { + $bootmenuentryID = $this->thisSession->getBootmenuentryID(); + + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bmm = new Application_Model_BootMenuEntriesMapper(); + $bmm->find($bootmenuentryID, $bootmenuentry); +# print_a($bootmenuentry); + + $configID = $bootmenuentry->getConfigID(); + + if(is_dir("../resources/config/$configID/config/") && is_numeric($configID)) { + + header('Content-Type: application/x-gzip'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="config.tgz"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + // create the gzipped tarfile. + chdir("../resources/config/$configID/config/"); + passthru( "tar cz ./"); + } + } + + public function getkernelAction() { + $bootosID = $this->thisSession->getBootosID(); + + if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)) { + + header('Content-Type: application/x-gzip'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="kernel"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + // create the gzipped tarfile. + chdir("../resources/bootos/$bootosID/kernel/"); + $kernelname = array_pop(scandir("./")); + + passthru( "cat ". $kernelname); + } + } + + public function getkclAction() { + $bmeID = $this->thisSession->getBootmenuentryID(); + + if(is_numeric($bmeID)) { + + $bmemapper = new Application_Model_BootMenuEntriesMapper(); + $bme = new Application_Model_BootMenuEntries(); + $bmemapper->find($bmeID, $bme); + + header('Content-Type: text/html'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + if($bme->getKcl() != null) + { $result = $bme->getKcl() . " " . $bme->getKclappend(); } + else + { $result = $bme->getKclappend(); } + + echo $result; + + + } + + } + + public function getbootmenuentryAction() { + // obsolete function (now only for debugging) + // after selecting the BootOS it will be saved in session + // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction + // can be called with session-identifier + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + $bootosID = $this->_request->getParam('bootosID'); + + $this->thisSession->setBootosID($bootosID)->setBootmenuentryID($bootmenuentryID); + $sessionMapper = new Application_Model_SessionMapper(); + $sessionMapper->save($this->thisSession); + + if($this->thisSession->getBootmenuentryID() != null) { + header('Content-Type: application/json'); + $return_val = + array( + 'info' => 'This function is for debugging purpose only', + 'kernel' => $this->generateURL('getkernel', 'alpha', $_SESSION['alphasessionID'], "kernel"), + 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $_SESSION['alphasessionID'], "initramfs"), + 'kcl' => $this->generateURL('getkcl', 'alpha', $_SESSION['alphasessionID'], "kcl.txt"), + 'config' => $_SESSION['alphasessionID'] + ); + echo json_encode($return_val); + } else { + echo json_encode( + array( 'info' => 'This function is for debugging purpose only', + 'error' => 'your session is out of date') + ); + } + } + + private function generateURL($action, $varname, $varvalue, $filename) { + $path = '/dev/resource/'. $action .'/' . $varname .'/' . $varvalue .'/file/' . $filename ; + $path = "http://" . $_SERVER['SERVER_NAME'] . $path; + return $path; + } } diff --git a/application/modules/dev/controllers/RoleController.php b/application/modules/dev/controllers/RoleController.php index ab5870b..468e2ae 100644 --- a/application/modules/dev/controllers/RoleController.php +++ b/application/modules/dev/controllers/RoleController.php @@ -1,279 +1,263 @@ -<?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 dev_RoleController extends Zend_Controller_Action -{ - protected $roleMapper; - protected $rightMapper; - protected $rightRolesMapper; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->roleMapper = new Application_Model_RoleMapper(); - $this->rightMapper = new Application_Model_RightMapper(); - $this->rightRolesMapper = new Application_Model_RightRolesMapper(); - } else { - $this->_helper->redirector('login', 'auth'); - } - } - - public function indexAction() - { - $roleNamespace = Zend_Session::namespaceGet('role'); - if(isset($roleNamespace['groupID'])) { - $roleList = $this->roleMapper->findBy(array('groupID' => $roleNamespace['groupID']),true); - $this->view->groupID = $roleNamespace['groupID']; - $this->view->roleList = $roleList; - } else { - $this->_helper->redirector('groupselect', 'role'); - return; - } - } - - public function addAction() - { - $roleNamespace = Zend_Session::namespaceGet('role'); - if(isset($roleNamespace['groupID'])) { - if (!isset($_POST["add"])){ - $addForm = new dev_Form_RoleAdd(array('rightlist' => $rightList)); - } else { - $addForm = new dev_Form_RoleAdd(array('rightlist' => $rightList),$_POST); - if ($addForm->isValid($_POST)) { - - $_POST['groupID'] = $roleNamespace['groupID']; - $role = new Application_Model_Role($_POST); - try { - $this->roleMapper->save($role); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'role'); - return; - } - } - - $this->view->addForm = $addForm; - } else { - $this->_helper->redirector('groupselect', 'role'); - return; - } - } - - public function editAction() - { - $roleID = $this->_request->getParam('roleID'); - if(!isset($roleID)) { - $addForm = new dev_Form_RoleAdd(); - $this->view->addForm = $addForm; - return; - } - if (!isset($_POST["save"])){ - $role = $this->roleMapper->find($roleID); - $_POST['title'] = $role->getTitle(); - $_POST['description'] = $role->getDescription(); - $_POST['groupID'] = $role->getGroupID(); - $_POST['inheritance'] = $role->getInheritance(); - $editForm = new dev_Form_RoleEdit(); - } else { - $editForm = new dev_Form_RoleEdit($_POST); - if ($editForm->isValid($_POST)) { - $role = new Application_Model_Role($_POST); - $role->setID($this->_request->getParam('roleID')); - try { - $this->roleMapper->save($role); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'role'); - return; - } - } - $this->view->editForm = $editForm; - } - - public function showAction() - { - $roleID = $this->_request->getParam('roleID'); - if($roleID) { - $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID),true); - if(count($rightroles) > 0) { - foreach($rightroles as $rightrole) { - $right = $this->rightMapper->find($rightrole['rightID']); - $rightsList[] = $right; - } - if(is_array($rightsList)) { - $this->view->rightsList = $rightsList; - } - } - $this->view->role = $this->roleMapper->find($roleID); - $this->view->roleID = $roleID; - } else { - $this->_helper->redirector('', 'role'); - return; - } - } - - public function deleteAction() - { - $this->_helper->viewRenderer->setNoRender(); - $roleID = $this->_request->getParam('roleID'); - if (isset($roleID)){ - $role = $this->roleMapper->find($roleID); - try { - $this->roleMapper->delete($role); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'role'); - return; - } else { - $this->_helper->redirector('', 'role'); - return; - } - } - - public function linkrightAction() - { - $roleID = $this->_request->getParam('roleID'); - if(isset($roleID)) { - $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID),true); - $rights = $this->rightMapper->fetchAll(); - if(count($rightroles) > 0) { - if(count($rights) > 0) { - foreach($rights as $right) { - foreach($rightroles as $rightrole) { - if($right->getID() == $rightrole['rightID']) { - $found = true; - break; - } - } - if(!$found) { - $rightlist[] = $right; - } - $found = false; - } - } - } else { - $rightlist = $rights; - } - if(count($rightlist) > 0) { - if (!isset($_POST["link"])){ - $linkForm = new dev_Form_LinkRight(array('rightlist' => $rightlist, 'roleID' => $roleID)); - } else { - $linkForm = new dev_Form_LinkRight(array('rightlist' => $rightlist),$_POST); - if ($linkForm->isValid($_POST)) { - $rightroles = new Application_Model_RightRoles(); - $rightroles->setRightID($_POST['rightID']); - $rightroles->setRoleID($roleID); - try { - $this->rightRolesMapper->save($rightroles); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect('/dev/role/show/roleID/' . $roleID); - return; - } - } - $this->view->linkForm = $linkForm; - } else { - $this->_redirect('/dev/role/show/roleID/' . $roleID); - return; - } - } else { - $this->_helper->redirector('', 'role'); - return; - } - } - - public function unlinkrightAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $rightRolesID = $this->_request->getParam('rightrolesID'); - if(isset($rightRolesID)) { - $rightRolesID = explode('-',$rightRolesID); - $roleID = $rightRolesID[0]; - $rightID = $rightRolesID[1]; - if (isset($roleID) && isset($rightID)){ - $rightroles = new Application_Model_RightRoles(); - $rightroles->setRoleID($roleID); - $rightroles->setRightID($rightID); - try { - $this->rightRolesMapper->delete($rightroles); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect('/dev/role/show/roleID/' . $roleID); - return; - } - } else { - $this->_helper->redirector('', 'role'); - return; - } - } - - public function groupselectAction() - { - $roleNamespace = Zend_Session::namespaceGet('role'); - if(isset($roleNamespace['groupID'])) { - $this->_helper->redirector('', 'role'); - } else { - if(isset($_POST['selectgroup'])) { - $roleSession = new Zend_Session_Namespace('role'); - $roleSession->groupID = $_POST['groupID']; - $this->_helper->redirector('', 'role'); - return; - } else { - $personMapper = new Application_Model_PersonMapper(); - $result = $personMapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $person = new Application_Model_Person($result[0]); - $person->setID($result[0]['personID']); - $membershipMapper = new Application_Model_MembershipMapper(); - $memberships = $membershipMapper->findBy(array("personID" => $person->getID(), true)); - $groupMapper = new Application_Model_GroupMapper(); - if(isset($memberships)) { - foreach($memberships as $membership) { - $group = $groupMapper->find($membership['groupID']); - $groupList[] = $group; - } - } - $groupSelectForm = new dev_Form_GroupSelect(array('grouplist' => $groupList)); - $this->view->groupSelectForm = $groupSelectForm; - } - } - } - - public function changegroupAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - Zend_Session::namespaceUnset('role'); - $this->_helper->redirector('groupselect', 'role'); - 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 dev_RoleController extends Zend_Controller_Action { + protected $roleMapper; + protected $rightMapper; + protected $rightRolesMapper; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->roleMapper = new Application_Model_RoleMapper(); + $this->rightMapper = new Application_Model_RightMapper(); + $this->rightRolesMapper = new Application_Model_RightRolesMapper(); + } else { + $this->_helper->redirector('login', 'auth'); + } + } + + public function indexAction() { + $roleNamespace = Zend_Session::namespaceGet('role'); + if(isset($roleNamespace['groupID'])) { + $roleList = $this->roleMapper->findBy(array('groupID' => $roleNamespace['groupID']), true); + $this->view->groupID = $roleNamespace['groupID']; + $this->view->roleList = $roleList; + } else { + $this->_helper->redirector('groupselect', 'role'); + return; + } + } + + public function addAction() { + $roleNamespace = Zend_Session::namespaceGet('role'); + if(isset($roleNamespace['groupID'])) { + if (!isset($_POST["add"])) { + $addForm = new dev_Form_RoleAdd(array('rightlist' => $rightList)); + } else { + $addForm = new dev_Form_RoleAdd(array('rightlist' => $rightList), $_POST); + if ($addForm->isValid($_POST)) { + + $_POST['groupID'] = $roleNamespace['groupID']; + $role = new Application_Model_Role($_POST); + try { + $this->roleMapper->save($role); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'role'); + return; + } + } + + $this->view->addForm = $addForm; + } else { + $this->_helper->redirector('groupselect', 'role'); + return; + } + } + + public function editAction() { + $roleID = $this->_request->getParam('roleID'); + if(!isset($roleID)) { + $addForm = new dev_Form_RoleAdd(); + $this->view->addForm = $addForm; + return; + } + if (!isset($_POST["save"])) { + $role = $this->roleMapper->find($roleID); + $_POST['title'] = $role->getTitle(); + $_POST['description'] = $role->getDescription(); + $_POST['groupID'] = $role->getGroupID(); + $_POST['inheritance'] = $role->getInheritance(); + $editForm = new dev_Form_RoleEdit(); + } else { + $editForm = new dev_Form_RoleEdit($_POST); + if ($editForm->isValid($_POST)) { + $role = new Application_Model_Role($_POST); + $role->setID($this->_request->getParam('roleID')); + try { + $this->roleMapper->save($role); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'role'); + return; + } + } + $this->view->editForm = $editForm; + } + + public function showAction() { + $roleID = $this->_request->getParam('roleID'); + if($roleID) { + $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID), true); + if(count($rightroles) > 0) { + foreach($rightroles as $rightrole) { + $right = $this->rightMapper->find($rightrole['rightID']); + $rightsList[] = $right; + } + if(is_array($rightsList)) { + $this->view->rightsList = $rightsList; + } + } + $this->view->role = $this->roleMapper->find($roleID); + $this->view->roleID = $roleID; + } else { + $this->_helper->redirector('', 'role'); + return; + } + } + + public function deleteAction() { + $this->_helper->viewRenderer->setNoRender(); + $roleID = $this->_request->getParam('roleID'); + if (isset($roleID)) { + $role = $this->roleMapper->find($roleID); + try { + $this->roleMapper->delete($role); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'role'); + return; + } else { + $this->_helper->redirector('', 'role'); + return; + } + } + + public function linkrightAction() { + $roleID = $this->_request->getParam('roleID'); + if(isset($roleID)) { + $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID), true); + $rights = $this->rightMapper->fetchAll(); + if(count($rightroles) > 0) { + if(count($rights) > 0) { + foreach($rights as $right) { + foreach($rightroles as $rightrole) { + if($right->getID() == $rightrole['rightID']) { + $found = true; + break; + } + } + if(!$found) { + $rightlist[] = $right; + } + $found = false; + } + } + } else { + $rightlist = $rights; + } + if(count($rightlist) > 0) { + if (!isset($_POST["link"])) { + $linkForm = new dev_Form_LinkRight(array('rightlist' => $rightlist, 'roleID' => $roleID)); + } else { + $linkForm = new dev_Form_LinkRight(array('rightlist' => $rightlist), $_POST); + if ($linkForm->isValid($_POST)) { + $rightroles = new Application_Model_RightRoles(); + $rightroles->setRightID($_POST['rightID']); + $rightroles->setRoleID($roleID); + try { + $this->rightRolesMapper->save($rightroles); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect('/dev/role/show/roleID/' . $roleID); + return; + } + } + $this->view->linkForm = $linkForm; + } else { + $this->_redirect('/dev/role/show/roleID/' . $roleID); + return; + } + } else { + $this->_helper->redirector('', 'role'); + return; + } + } + + public function unlinkrightAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $rightRolesID = $this->_request->getParam('rightrolesID'); + if(isset($rightRolesID)) { + $rightRolesID = explode('-', $rightRolesID); + $roleID = $rightRolesID[0]; + $rightID = $rightRolesID[1]; + if (isset($roleID) && isset($rightID)) { + $rightroles = new Application_Model_RightRoles(); + $rightroles->setRoleID($roleID); + $rightroles->setRightID($rightID); + try { + $this->rightRolesMapper->delete($rightroles); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect('/dev/role/show/roleID/' . $roleID); + return; + } + } else { + $this->_helper->redirector('', 'role'); + return; + } + } + + public function groupselectAction() { + $roleNamespace = Zend_Session::namespaceGet('role'); + if(isset($roleNamespace['groupID'])) { + $this->_helper->redirector('', 'role'); + } else { + if(isset($_POST['selectgroup'])) { + $roleSession = new Zend_Session_Namespace('role'); + $roleSession->groupID = $_POST['groupID']; + $this->_helper->redirector('', 'role'); + return; + } else { + $personMapper = new Application_Model_PersonMapper(); + $result = $personMapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()), true); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $membershipMapper = new Application_Model_MembershipMapper(); + $memberships = $membershipMapper->findBy(array("personID" => $person->getID(), true)); + $groupMapper = new Application_Model_GroupMapper(); + if(isset($memberships)) { + foreach($memberships as $membership) { + $group = $groupMapper->find($membership['groupID']); + $groupList[] = $group; + } + } + $groupSelectForm = new dev_Form_GroupSelect(array('grouplist' => $groupList)); + $this->view->groupSelectForm = $groupSelectForm; + } + } + } + + public function changegroupAction() { + $this->_helper-> viewRenderer-> setNoRender(); + Zend_Session::namespaceUnset('role'); + $this->_helper->redirector('groupselect', 'role'); + return; + } } diff --git a/application/modules/dev/controllers/SessionController.php b/application/modules/dev/controllers/SessionController.php index 11da1be..58b4316 100644 --- a/application/modules/dev/controllers/SessionController.php +++ b/application/modules/dev/controllers/SessionController.php @@ -1,186 +1,177 @@ -<?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 dev_SessionController extends Zend_Controller_Action -{ - - public function init() - { - /* Initialize action controller here */ +* 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 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 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'); + } + + 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'); + } } diff --git a/application/modules/dev/forms/AuthDelete.php b/application/modules/dev/forms/AuthDelete.php index c8f4a8f..fd0707c 100644 --- a/application/modules/dev/forms/AuthDelete.php +++ b/application/modules/dev/forms/AuthDelete.php @@ -1,37 +1,35 @@ -<?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 dev_Form_AuthDelete extends Zend_Form -{ +class dev_Form_AuthDelete extends Zend_Form { - public function init() - { - $this->setName("Delete"); - $this->setMethod('post'); + public function init() { + $this->setName("Delete"); + $this->setMethod('post'); - $this->addElement('text', 'ID', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'ID:', - )); - $this->addElement('submit', 'delete', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Delete', - )); - } + $this->addElement('text', 'ID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'ID:', + )); + $this->addElement('submit', 'delete', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Delete', + )); + } } diff --git a/application/modules/dev/forms/AuthLogin.php b/application/modules/dev/forms/AuthLogin.php index 2192c35..193b2ff 100644 --- a/application/modules/dev/forms/AuthLogin.php +++ b/application/modules/dev/forms/AuthLogin.php @@ -1,47 +1,45 @@ -<?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 dev_Form_AuthLogin 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, - 'label' => 'E-Mail:', - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Password:', - )); - - $this->addElement('submit', 'login', array( - 'required' => false, - '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 dev_Form_AuthLogin 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, + 'label' => 'E-Mail:', + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'login', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Login', + )); + } } diff --git a/application/modules/dev/forms/AuthRecoverPassword.php b/application/modules/dev/forms/AuthRecoverPassword.php index 2502b7a..31d2c00 100644 --- a/application/modules/dev/forms/AuthRecoverPassword.php +++ b/application/modules/dev/forms/AuthRecoverPassword.php @@ -1,37 +1,35 @@ -<?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 dev_Form_AuthRecoverPassword extends Zend_Form -{ +class dev_Form_AuthRecoverPassword extends Zend_Form { - public function init() - { - $this->setName("RecoverPassword"); - $this->setMethod('post'); + public function init() { + $this->setName("RecoverPassword"); + $this->setMethod('post'); - $this->addElement('text', 'email', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 30)), - ), - 'required' => true, - 'label' => 'Email:', - )); - $this->addElement('submit', 'recoverPassword', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Recover', - )); - } + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 30)), + ), + 'required' => true, + 'label' => 'Email:', + )); + $this->addElement('submit', 'recoverPassword', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Recover', + )); + } } diff --git a/application/modules/dev/forms/AuthRegister.php b/application/modules/dev/forms/AuthRegister.php index 823bd31..0f1ee4a 100644 --- a/application/modules/dev/forms/AuthRegister.php +++ b/application/modules/dev/forms/AuthRegister.php @@ -1,115 +1,113 @@ -<?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 dev_Form_AuthRegister extends Zend_Form -{ - - public function init() - { - $this->setName("Register"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - - $this->addElement('text', 'name', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Name:', - )); - - $this->addElement('text', 'firstname', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Firstname:', - )); - - $this->addElement('text', 'street', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Street:', - )); - - $this->addElement('text', 'housenumber', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Housenumber:', - )); - - $this->addElement('text', 'city', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'City:', - )); - - $this->addElement('text', 'postalcode', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Postalcode:', - )); - - $this->addElement('text', 'email', array( - 'filters' => array('StringTrim', 'StringToLower'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Email:', - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Password:', - )); - - $this->addElement('submit', 'register', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Register', - )); - - - } - - +* 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_Form_AuthRegister extends Zend_Form { + + public function init() { + $this->setName("Register"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + + $this->addElement('text', 'name', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Name:', + )); + + $this->addElement('text', 'firstname', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Firstname:', + )); + + $this->addElement('text', 'street', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Street:', + )); + + $this->addElement('text', 'housenumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Housenumber:', + )); + + $this->addElement('text', 'city', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'City:', + )); + + $this->addElement('text', 'postalcode', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Postalcode:', + )); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Email:', + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'register', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Register', + )); + + + } + + } diff --git a/application/modules/dev/forms/BootisoCreate.php b/application/modules/dev/forms/BootisoCreate.php index edb1053..eed1e87 100644 --- a/application/modules/dev/forms/BootisoCreate.php +++ b/application/modules/dev/forms/BootisoCreate.php @@ -1,119 +1,117 @@ -<?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 dev_Form_BootisoCreate extends Zend_Form -{ - - private $grouplist; - private $prebootlist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - public function setPrebootlist($prebootlist){ - $this->prebootlist = $prebootlist; - +* 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_Form_BootisoCreate extends Zend_Form { + + private $grouplist; + private $prebootlist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + public function setPrebootlist($prebootlist) { + $this->prebootlist = $prebootlist; + + } + + + public function init() { + $this->setName("BootIsoCreate"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } - - - public function init() - { - $this->setName("BootIsoCreate"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $prebootfield = $this->createElement('select','prebootID'); - $prebootfield ->setLabel('Preboot:'); - - if(count($this->prebootlist)>0){ - foreach($this->prebootlist as $preboot => $p){ - $prebootfield->addMultiOption($p->getID(), $p->getTitle()); - } - } - $prebootfield->setRegisterInArrayValidator(false); - $this->addElement($prebootfield); - - $serial = time(); - for($i=2; $i<14; $i+=3) - $serial = substr($serial,0,$i) .'-'. substr($serial,$i,strlen($serial)); - - $this->addElement('text', 'serialnumber', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Serialnumber:', - 'value' => $serial - )); - - - - - $date = new DateTime(); - $date->add(new DateInterval('P1Y')); - $this->addElement('text', 'expires', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Expires:', - 'value' => $date->format('Y-m-d'), - )); - - $this->addElement('text', 'public', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Public-Level:', - 'value' => '0' - )); - - $this->addElement('submit', 'createbootiso', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Create BootISO', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/dev/bootiso"' - )); + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $prebootfield = $this->createElement('select', 'prebootID'); + $prebootfield ->setLabel('Preboot:'); + if(count($this->prebootlist) > 0) { + foreach($this->prebootlist as $preboot => $p) { + $prebootfield->addMultiOption($p->getID(), $p->getTitle()); + } } + $prebootfield->setRegisterInArrayValidator(false); + $this->addElement($prebootfield); + + $serial = time(); + for($i = 2; $i < 14; $i += 3) + { $serial = substr($serial, 0, $i) .'-'. substr($serial, $i, strlen($serial)); } + + $this->addElement('text', 'serialnumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Serialnumber:', + 'value' => $serial + )); + + + + + $date = new DateTime(); + $date->add(new DateInterval('P1Y')); + $this->addElement('text', 'expires', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Expires:', + 'value' => $date->format('Y-m-d'), + )); + + $this->addElement('text', 'public', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Public-Level:', + 'value' => '0' + )); + + $this->addElement('submit', 'createbootiso', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Create BootISO', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/bootiso"' + )); + + } + - } diff --git a/application/modules/dev/forms/BootisoEdit.php b/application/modules/dev/forms/BootisoEdit.php index f1ad6a7..2478036 100644 --- a/application/modules/dev/forms/BootisoEdit.php +++ b/application/modules/dev/forms/BootisoEdit.php @@ -1,111 +1,109 @@ -<?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 dev_Form_BootisoEdit extends Zend_Form -{ - - - private $grouplist; - private $prebootlist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - public function setPrebootlist($prebootlist){ - $this->prebootlist = $prebootlist; - +* 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_Form_BootisoEdit extends Zend_Form { + + + private $grouplist; + private $prebootlist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + public function setPrebootlist($prebootlist) { + $this->prebootlist = $prebootlist; + + } + + + public function init() { + $this->setName("BootIsoCreate"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } - - - public function init() - { - $this->setName("BootIsoCreate"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $prebootfield = $this->createElement('select','prebootID'); - $prebootfield ->setLabel('Preboot:'); - - if(count($this->prebootlist)>0){ - foreach($this->prebootlist as $preboot => $p){ - $prebootfield->addMultiOption($p->getID(), $p->getTitle()); - } - } - $prebootfield->setRegisterInArrayValidator(false); - $this->addElement($prebootfield); - - $this->addElement('text', 'serialnumber', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Serialnumber:', - )); - - $date = new DateTime(); - $date->add(new DateInterval('P1Y')); - $this->addElement('text', 'expires', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Expires:', - 'value' => $date->format('Y-m-d'), - )); - - $this->addElement('text', 'public', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Public-Level:', - 'value' => '0' - )); - - - $this->addElement('submit', 'editbootiso', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Edit BootISO', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/dev/bootiso"' - )); + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $prebootfield = $this->createElement('select', 'prebootID'); + $prebootfield ->setLabel('Preboot:'); + if(count($this->prebootlist) > 0) { + foreach($this->prebootlist as $preboot => $p) { + $prebootfield->addMultiOption($p->getID(), $p->getTitle()); + } } + $prebootfield->setRegisterInArrayValidator(false); + $this->addElement($prebootfield); + + $this->addElement('text', 'serialnumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Serialnumber:', + )); + + $date = new DateTime(); + $date->add(new DateInterval('P1Y')); + $this->addElement('text', 'expires', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Expires:', + 'value' => $date->format('Y-m-d'), + )); + + $this->addElement('text', 'public', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Public-Level:', + 'value' => '0' + )); + + + $this->addElement('submit', 'editbootiso', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit BootISO', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/bootiso"' + )); + + } } diff --git a/application/modules/dev/forms/BootmenuCreate.php b/application/modules/dev/forms/BootmenuCreate.php index f94f3c5..5d4ff28 100644 --- a/application/modules/dev/forms/BootmenuCreate.php +++ b/application/modules/dev/forms/BootmenuCreate.php @@ -1,60 +1,58 @@ -<?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 dev_Form_BootmenuCreate extends Zend_Form -{ - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function init() - { - $this->setName("BootMenuCreate"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('submit', 'createbootmenu', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Create Bootmenu', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/bootmenu"' - )); +* 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_Form_BootmenuCreate extends Zend_Form { + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function init() { + $this->setName("BootMenuCreate"); + $this->setMethod('post'); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('submit', 'createbootmenu', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Create Bootmenu', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootmenu"' + )); + + } } diff --git a/application/modules/dev/forms/BootmenuEdit.php b/application/modules/dev/forms/BootmenuEdit.php index f20cd08..d8d80d7 100644 --- a/application/modules/dev/forms/BootmenuEdit.php +++ b/application/modules/dev/forms/BootmenuEdit.php @@ -1,61 +1,59 @@ -<?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 dev_Form_BootmenuEdit extends Zend_Form -{ - - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function init() - { - $this->setName("BootMenuEdit"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('submit', 'editbootmenu', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Edit BootMenu', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/bootmenu"' - )); +* 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_Form_BootmenuEdit extends Zend_Form { + + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function init() { + $this->setName("BootMenuEdit"); + $this->setMethod('post'); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('submit', 'editbootmenu', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit BootMenu', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootmenu"' + )); + + } } diff --git a/application/modules/dev/forms/BootmenuEntriesAdd.php b/application/modules/dev/forms/BootmenuEntriesAdd.php index 9b17c3a..0d33916 100644 --- a/application/modules/dev/forms/BootmenuEntriesAdd.php +++ b/application/modules/dev/forms/BootmenuEntriesAdd.php @@ -1,147 +1,145 @@ -<?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 dev_Form_BootmenuEntriesAdd extends Zend_Form -{ - private $bootoslist; - private $configlist; - private $maxorder; - - public function setBootoslist($bootoslist){ - $this->bootoslist = $bootoslist; +* 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_Form_BootmenuEntriesAdd extends Zend_Form { + private $bootoslist; + private $configlist; + private $maxorder; + + public function setBootoslist($bootoslist) { + $this->bootoslist = $bootoslist; + } + + public function setMaxorder($maxorder) { + $this->maxorder = $maxorder; + + } + + public function setConfiglist($configlist) { + $this->configlist = $configlist; + + } + + + public function init() { + + if(!isset($_POST['bootosID'])) { + $firstbootos = array_slice($this->bootoslist, 0, 1); + $_POST['bootosID'] = $firstbootos[0]->getID(); + $_POST['kclactive'] = true; } - - public function setMaxorder($maxorder){ - $this->maxorder = $maxorder; - + + $this->setName("BootMenuEntryAdd"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $bootosfield = $this->createElement('select', 'bootosID'); + $bootosfield ->setLabel('BootOs:'); + $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); + + if(count($this->bootoslist) > 0) { + foreach($this->bootoslist as $bootos => $b) { + $bootosfield->addMultiOption($b->getID(), $b->getTitle()); + } + } + $bootosfield->setRegisterInArrayValidator(false); + + $this->addElement($bootosfield); + + $kclactive = $this->createElement('checkbox', 'kclactive'); + $kclactive->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); + $kclactive->setLabel('Use default KCL:'); + $kclactive->setValue(true); + $this->addElement($kclactive); + + + if($_POST['kclactive']) { + $this->addElement('textarea', 'kcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'cols' => 50, + 'rows' => 5, + 'label' => 'KCL:', + 'readOnly' => true, + 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl() + + )); } - - public function setConfiglist($configlist){ - $this->configlist = $configlist; - + + if($_POST['kclactive']) + { $kcllength = 175 - strlen($this->bootoslist[$_POST['bootosID']]->getDefaultkcl()); } + else + { $kcllength = 175; } + + $this->addElement('textarea', 'kclappend', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, $kcllength)), + ), + 'required' => false, + 'cols' => 50, + 'rows' => 5, + 'label' => 'KCL-Append:', + 'description' => 'Chars left: ' . $kcllength + )); + + $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID(); + $configfield = $this->createElement('select', 'configID'); + $configfield->setLabel('Config:'); + $configfield->addMultiOption($defaultconfigid, 'default'); + + if(count($this->configlist) > 0) { + foreach($this->configlist as $config => $c) { + if($c->getID() != $defaultconfigid) + { $configfield->addMultiOption($c->getID(), $c->getTitle()); } + } } - - - public function init() - { - - if(!isset($_POST['bootosID'])){ - $firstbootos = array_slice($this->bootoslist,0,1); - $_POST['bootosID'] = $firstbootos[0]->getID(); - $_POST['kclactive'] = true; - } - - $this->setName("BootMenuEntryAdd"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $bootosfield = $this->createElement('select','bootosID'); - $bootosfield ->setLabel('BootOs:'); - $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); - - if(count($this->bootoslist)>0){ - foreach($this->bootoslist as $bootos => $b){ - $bootosfield->addMultiOption($b->getID(), $b->getTitle()); - } - } - $bootosfield->setRegisterInArrayValidator(false); - - $this->addElement($bootosfield); - - $kclactive = $this->createElement('checkbox','kclactive'); - $kclactive->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); - $kclactive->setLabel('Use default KCL:'); - $kclactive->setValue(true); - $this->addElement($kclactive); - - - if($_POST['kclactive']){ - $this->addElement('textarea', 'kcl', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'cols' => 50, - 'rows' => 5, - 'label' => 'KCL:', - 'readOnly' => true, - 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl() - - )); - } - - if($_POST['kclactive']) - $kcllength = 175 - strlen($this->bootoslist[$_POST['bootosID']]->getDefaultkcl()); - else - $kcllength = 175; - - $this->addElement('textarea', 'kclappend', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, $kcllength)), - ), - 'required' => false, - 'cols' => 50, - 'rows' => 5, - 'label' => 'KCL-Append:', - 'description' => 'Chars left: ' . $kcllength - )); - - $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID(); - $configfield = $this->createElement('select','configID'); - $configfield->setLabel('Config:'); - $configfield->addMultiOption($defaultconfigid, 'default'); - - if(count($this->configlist)>0){ - foreach($this->configlist as $config => $c){ - if($c->getID() != $defaultconfigid) - $configfield->addMultiOption($c->getID(), $c->getTitle()); - } - } - - $configfield->setRegisterInArrayValidator(false); - $this->addElement($configfield); - - $orderfield = $this->createElement('select','order'); - $orderfield ->setLabel('Position:'); - - for ($i = 0; $i <= $this->maxorder; $i++) { - $orderfield->addMultiOption($i, $i+1); - } - $orderfield->setRegisterInArrayValidator(false); - $this->addElement($orderfield); - - $this->addElement('submit', 'addbootmenuentry', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add Bootmenuentry', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/dev/bootmenu"' - )); + $configfield->setRegisterInArrayValidator(false); + $this->addElement($configfield); + + $orderfield = $this->createElement('select', 'order'); + $orderfield ->setLabel('Position:'); + + for ($i = 0; $i <= $this->maxorder; $i++) { + $orderfield->addMultiOption($i, $i + 1); } - - + $orderfield->setRegisterInArrayValidator(false); + $this->addElement($orderfield); + + $this->addElement('submit', 'addbootmenuentry', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add Bootmenuentry', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/bootmenu"' + )); + + } + + } diff --git a/application/modules/dev/forms/BootmenuEntriesEdit.php b/application/modules/dev/forms/BootmenuEntriesEdit.php index 87fcb9e..096d0f4 100644 --- a/application/modules/dev/forms/BootmenuEntriesEdit.php +++ b/application/modules/dev/forms/BootmenuEntriesEdit.php @@ -1,150 +1,148 @@ -<?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 dev_Form_BootmenuEntriesEdit extends Zend_Form -{ - - private $bootoslist; - private $configlist; - private $maxorder; - private $kcl; - - public function setBootoslist($bootoslist){ - $this->bootoslist = $bootoslist; +* 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_Form_BootmenuEntriesEdit extends Zend_Form { + + private $bootoslist; + private $configlist; + private $maxorder; + private $kcl; + + public function setBootoslist($bootoslist) { + $this->bootoslist = $bootoslist; + } + + public function setMaxorder($maxorder) { + $this->maxorder = $maxorder; + } + + public function setConfiglist($configlist) { + $this->configlist = $configlist; + } + public function setKcl($kcl) { + $this->kcl = $kcl; + } + + + public function init() { + + if(!isset($_POST['bootosID'])) { + $firstbootos = array_slice($this->bootoslist, 0, 1); + $_POST['bootosID'] = $firstbootos[0]->getID(); + if(isset($this->kcl)) + { $_POST['kclactive'] = true; } + else + { $_POST['kclactive'] = false; } } - - public function setMaxorder($maxorder){ - $this->maxorder = $maxorder; + + $this->setName("BootMenuEntryAdd"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $bootosfield = $this->createElement('select', 'bootosID'); + $bootosfield->setLabel('BootOs:'); + $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); + + + if(count($this->bootoslist) > 0) { + foreach($this->bootoslist as $bootos => $b) { + $bootosfield->addMultiOption($b->getID(), $b->getTitle()); + } } - - public function setConfiglist($configlist){ - $this->configlist = $configlist; + $bootosfield->setRegisterInArrayValidator(false); + $this->addElement($bootosfield); + + $kclactive = $this->createElement('checkbox', 'kclactive'); + $kclactive->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); + $kclactive->setLabel('Use default KCL:'); + $kclactive->setValue($_POST['kclactive']); + $this->addElement($kclactive); + + if($_POST['kclactive']) { + $this->addElement('textarea', 'kcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'cols' => 50, + 'rows' => 5, + 'label' => 'KCL:', + 'readOnly' => true, + 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl() + )); } - public function setKcl($kcl){ - $this->kcl = $kcl; + + if($_POST['kclactive']) + { $kcllength = 175 - strlen($this->bootoslist[$_POST['bootosID']]->getDefaultkcl()); } + else + { $kcllength = 175; } + + $this->addElement('textarea', 'kclappend', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, $kcllength)), + ), + 'required' => false, + 'cols' => 50, + 'rows' => 5, + 'label' => 'KCL-Append:', + 'description' => 'Chars left: ' . $kcllength + + )); + + $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID(); + $configfield = $this->createElement('select', 'configID'); + $configfield->setLabel('Config:'); + $configfield->addMultiOption($defaultconfigid, 'default'); + + if(count($this->configlist) > 0) { + foreach($this->configlist as $config => $c) { + if($c->getID() != $defaultconfigid) + { $configfield->addMultiOption($c->getID(), $c->getTitle()); } + } } - - - public function init() - { - - if(!isset($_POST['bootosID'])){ - $firstbootos = array_slice($this->bootoslist,0,1); - $_POST['bootosID'] = $firstbootos[0]->getID(); - if(isset($this->kcl)) - $_POST['kclactive'] = true; - else - $_POST['kclactive'] = false; - } - - $this->setName("BootMenuEntryAdd"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $bootosfield = $this->createElement('select','bootosID'); - $bootosfield->setLabel('BootOs:'); - $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); - - - if(count($this->bootoslist)>0){ - foreach($this->bootoslist as $bootos => $b){ - $bootosfield->addMultiOption($b->getID(), $b->getTitle()); - } - } - $bootosfield->setRegisterInArrayValidator(false); - $this->addElement($bootosfield); - - $kclactive = $this->createElement('checkbox','kclactive'); - $kclactive->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); - $kclactive->setLabel('Use default KCL:'); - $kclactive->setValue($_POST['kclactive']); - $this->addElement($kclactive); - - if($_POST['kclactive']){ - $this->addElement('textarea', 'kcl', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'cols' => 50, - 'rows' => 5, - 'label' => 'KCL:', - 'readOnly' => true, - 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl() - )); - } - - if($_POST['kclactive']) - $kcllength = 175 - strlen($this->bootoslist[$_POST['bootosID']]->getDefaultkcl()); - else - $kcllength = 175; - - $this->addElement('textarea', 'kclappend', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, $kcllength)), - ), - 'required' => false, - 'cols' => 50, - 'rows' => 5, - 'label' => 'KCL-Append:', - 'description' => 'Chars left: ' . $kcllength - - )); - - $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID(); - $configfield = $this->createElement('select','configID'); - $configfield->setLabel('Config:'); - $configfield->addMultiOption($defaultconfigid, 'default'); - - if(count($this->configlist)>0){ - foreach($this->configlist as $config => $c){ - if($c->getID() != $defaultconfigid) - $configfield->addMultiOption($c->getID(), $c->getTitle()); - } - } - $configfield->setRegisterInArrayValidator(false); - $this->addElement($configfield); - - $orderfield = $this->createElement('select','order'); - $orderfield ->setLabel('Position:'); - - for ($i = 0; $i < $this->maxorder; $i++) { - $orderfield->addMultiOption($i, $i+1); - } - $orderfield->setRegisterInArrayValidator(false); - $this->addElement($orderfield); - - $this->addElement('submit', 'editbootmenuentry', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Edit Bootmenuentry', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/dev/bootmenu"' - )); + $configfield->setRegisterInArrayValidator(false); + $this->addElement($configfield); + + $orderfield = $this->createElement('select', 'order'); + $orderfield ->setLabel('Position:'); + for ($i = 0; $i < $this->maxorder; $i++) { + $orderfield->addMultiOption($i, $i + 1); } - + $orderfield->setRegisterInArrayValidator(false); + $this->addElement($orderfield); + + $this->addElement('submit', 'editbootmenuentry', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit Bootmenuentry', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/bootmenu"' + )); + + } + } diff --git a/application/modules/dev/forms/BootosCreate.php b/application/modules/dev/forms/BootosCreate.php index b13e9e6..78ad28d 100644 --- a/application/modules/dev/forms/BootosCreate.php +++ b/application/modules/dev/forms/BootosCreate.php @@ -1,144 +1,142 @@ -<?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 dev_Form_BootosCreate extends Zend_Form -{ - - private $grouplist; - private $configlist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function setConfiglist($configlist){ - $this->configlist = $configlist; - +* 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_Form_BootosCreate extends Zend_Form { + + private $grouplist; + private $configlist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function setConfiglist($configlist) { + $this->configlist = $configlist; + + } + + public function init() { + $this->setName("BootOsCreate"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + + $configfield = $this->createElement('select', 'configID'); + $configfield ->setLabel('Config:'); + + if(count($this->configlist) > 0) { + foreach($this->configlist as $config => $c) { + $configfield->addMultiOption($c->getID(), $c->getTitle()); + } } - - public function init() - { - $this->setName("BootOsCreate"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - - $configfield = $this->createElement('select','configID'); - $configfield ->setLabel('Config:'); - - if(count($this->configlist)>0){ - foreach($this->configlist as $config => $c){ - $configfield->addMultiOption($c->getID(), $c->getTitle()); - } - } - $configfield->setRegisterInArrayValidator(false); - $this->addElement($configfield); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('text', 'path_init', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 250)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Init-Path:', - )); - - $this->addElement('text', 'path_kernel', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 250)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Kernel-Path:', - )); - - $this->addElement('textarea', 'defaultkcl', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 175)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Default-KCL:', - )); - - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Description:', - )); - - $date = new DateTime(); - $date->add(new DateInterval('P1Y')); - $this->addElement('text', 'expires', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Expires:', - 'value' => $date->format('Y-m-d'), - )); - - - $this->addElement('text', 'public', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Public-Level:', - 'value' => '0', - )); - - $this->addElement('submit', 'createbootos', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Create BootOS', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/bootos"' - )); + $configfield->setRegisterInArrayValidator(false); + $this->addElement($configfield); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('text', 'path_init', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 250)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Init-Path:', + )); + + $this->addElement('text', 'path_kernel', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 250)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Kernel-Path:', + )); + + $this->addElement('textarea', 'defaultkcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 175)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Default-KCL:', + )); + + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Description:', + )); + + $date = new DateTime(); + $date->add(new DateInterval('P1Y')); + $this->addElement('text', 'expires', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Expires:', + 'value' => $date->format('Y-m-d'), + )); + + + $this->addElement('text', 'public', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Public-Level:', + 'value' => '0', + )); + + $this->addElement('submit', 'createbootos', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Create BootOS', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootos"' + )); + + } } diff --git a/application/modules/dev/forms/BootosEdit.php b/application/modules/dev/forms/BootosEdit.php index c7224f7..5f10051 100644 --- a/application/modules/dev/forms/BootosEdit.php +++ b/application/modules/dev/forms/BootosEdit.php @@ -1,152 +1,150 @@ -<?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 dev_Form_BootosEdit extends Zend_Form -{ - - private $grouplist; - private $configlist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function setConfiglist($configlist){ - $this->configlist = $configlist; - +* 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_Form_BootosEdit extends Zend_Form { + + private $grouplist; + private $configlist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function setConfiglist($configlist) { + $this->configlist = $configlist; + + } + + public function init() { + $this->setName("BootOsEdit"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $configfield = $this->createElement('select', 'configID'); + $configfield ->setLabel('Config:'); + + if(count($this->configlist) > 0) { + foreach($this->configlist as $config => $c) { + $configfield->addMultiOption($c->getID(), $c->getTitle()); + } } - - public function init() - { - $this->setName("BootOsEdit"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $configfield = $this->createElement('select','configID'); - $configfield ->setLabel('Config:'); - - if(count($this->configlist)>0){ - foreach($this->configlist as $config => $c){ - $configfield->addMultiOption($c->getID(), $c->getTitle()); - } - } - $configfield->setRegisterInArrayValidator(false); - $this->addElement($configfield); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('text', 'path_init', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Init-Path:', - )); - - $this->addElement('text', 'path_kernel', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Kernel-Path:', - )); - - $this->addElement('textarea', 'defaultkcl', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 175)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Default-KCL:', - )); - - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Description:', - )); - - $date = new DateTime(); - $date->add(new DateInterval('P1Y')); - $this->addElement('text', 'expires', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Expires:', - 'value' => $date->format('Y-m-d'), - )); - - - $this->addElement('text', 'public', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Public-Level:', - 'value' => '0', - )); - - $this->addElement('submit', 'editbootos', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Edit BootOS', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/bootos"' - )); + $configfield->setRegisterInArrayValidator(false); + $this->addElement($configfield); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('text', 'path_init', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Init-Path:', + )); + + $this->addElement('text', 'path_kernel', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Kernel-Path:', + )); + + $this->addElement('textarea', 'defaultkcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 175)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Default-KCL:', + )); + + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Description:', + )); + + $date = new DateTime(); + $date->add(new DateInterval('P1Y')); + $this->addElement('text', 'expires', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Expires:', + 'value' => $date->format('Y-m-d'), + )); + + + $this->addElement('text', 'public', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Public-Level:', + 'value' => '0', + )); + + $this->addElement('submit', 'editbootos', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit BootOS', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootos"' + )); + + } } diff --git a/application/modules/dev/forms/Client.php b/application/modules/dev/forms/Client.php index 6bf16dd..bc94154 100644 --- a/application/modules/dev/forms/Client.php +++ b/application/modules/dev/forms/Client.php @@ -1,68 +1,66 @@ -<?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 dev_Form_Client extends Zend_Form -{ +class dev_Form_Client extends Zend_Form { - public function init() - { - $this->setName("pool"); - $this->setMethod('post'); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - foreach($this->groups as $c){ - $groupfield->addMultiOption($c->getID(),$c->getTitle()); - } - $this->addElement($groupfield); - - - $this->addElement('text', 'macadress', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'MacAdress:', - )); - $this->addElement('text', 'hardwarehash', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Hardwarehash:', - )); + public function init() { + $this->setName("pool"); + $this->setMethod('post'); - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/dev/client"' - )); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + foreach($this->groups as $c) { + $groupfield->addMultiOption($c->getID(), $c->getTitle()); } - private $buttontext = 'Save'; - private $groups; - function setButtontext($v){ - $this->buttontext = $v; - } - public function setGroups($groups){ - $this->groups = $groups; - return $this; - } + $this->addElement($groupfield); + + + $this->addElement('text', 'macadress', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'MacAdress:', + )); + $this->addElement('text', 'hardwarehash', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Hardwarehash:', + )); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/client"' + )); + } + private $buttontext = 'Save'; + private $groups; + function setButtontext($v) { + $this->buttontext = $v; + } + public function setGroups($groups) { + $this->groups = $groups; + return $this; + } } diff --git a/application/modules/dev/forms/ConfigCreate.php b/application/modules/dev/forms/ConfigCreate.php index 8e05937..8ebc560 100644 --- a/application/modules/dev/forms/ConfigCreate.php +++ b/application/modules/dev/forms/ConfigCreate.php @@ -1,73 +1,71 @@ -<?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 dev_Form_ConfigCreate extends Zend_Form -{ +class dev_Form_ConfigCreate extends Zend_Form { - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function init() - { - $this->setName("ConfigCreate"); - $this->setMethod('post'); + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function init() { + $this->setName("ConfigCreate"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('textarea', 'shellscript', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'rows' => 10, - 'cols' => 70, - 'label' => 'Shellscript:', - )); - - $this->addElement('submit', 'createconfig', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Create Config', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/config"' - )); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('textarea', 'shellscript', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'rows' => 10, + 'cols' => 70, + 'label' => 'Shellscript:', + )); + + $this->addElement('submit', 'createconfig', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Create Config', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/config"' + )); + + } + } diff --git a/application/modules/dev/forms/ConfigEdit.php b/application/modules/dev/forms/ConfigEdit.php index b6d3ae7..809929c 100644 --- a/application/modules/dev/forms/ConfigEdit.php +++ b/application/modules/dev/forms/ConfigEdit.php @@ -1,72 +1,70 @@ -<?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 dev_Form_ConfigEdit extends Zend_Form -{ - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } +class dev_Form_ConfigEdit extends Zend_Form { + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } - public function init() - { - $this->setName("ConfigEdit"); - $this->setMethod('post'); + public function init() { + $this->setName("ConfigEdit"); + $this->setMethod('post'); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('textarea', 'shellscript', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'rows' => 10, - 'cols' => 70, - 'label' => 'Shellscript:', - )); - - $this->addElement('submit', 'editconfig', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Edit Config', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/config"' - )); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('textarea', 'shellscript', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'rows' => 10, + 'cols' => 70, + 'label' => 'Shellscript:', + )); + + $this->addElement('submit', 'editconfig', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit Config', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/config"' + )); + + } + } diff --git a/application/modules/dev/forms/ConfirmDeleteAccount.php b/application/modules/dev/forms/ConfirmDeleteAccount.php index 567fec0..a27e02a 100644 --- a/application/modules/dev/forms/ConfirmDeleteAccount.php +++ b/application/modules/dev/forms/ConfirmDeleteAccount.php @@ -1,35 +1,33 @@ -<?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 dev_Form_ConfirmDeleteAccount extends Zend_Form -{ +class dev_Form_ConfirmDeleteAccount extends Zend_Form { - public function init() - { - $this->setName("ConfirmDeleteAccount"); - $this->setMethod('post'); - - $this->addElement('submit', 'confirmdelete', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Confirm', - )); + public function init() { + $this->setName("ConfirmDeleteAccount"); + $this->setMethod('post'); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + $this->addElement('submit', 'confirmdelete', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Confirm', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/FilterAdd.php b/application/modules/dev/forms/FilterAdd.php index 67acd6f..3b3b905 100644 --- a/application/modules/dev/forms/FilterAdd.php +++ b/application/modules/dev/forms/FilterAdd.php @@ -1,75 +1,73 @@ -<?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 dev_Form_FilterAdd extends Zend_Form -{ - private $bootmenus; +class dev_Form_FilterAdd extends Zend_Form { + private $bootmenus; - public function init() - { - $this->setName("Add Filter"); - $this->setMethod('post'); + public function init() { + $this->setName("Add Filter"); + $this->setMethod('post'); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'required' => false, - 'label' => 'Description:', - )); - - $bootmenufield = $this->createElement('select','bootmenuID'); - $bootmenufield ->setLabel('Bootmenu:'); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'required' => false, + 'label' => 'Description:', + )); - if(count($this->bootmenus)>0){ - foreach($this->bootmenus as $id => $g){ - $bootmenufield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $bootmenufield->setRegisterInArrayValidator(false); - $this->addElement($bootmenufield); + $bootmenufield = $this->createElement('select', 'bootmenuID'); + $bootmenufield ->setLabel('Bootmenu:'); - $this->addElement('text', 'priority', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Priority:', - )); - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/filter"' - )); + if(count($this->bootmenus) > 0) { + foreach($this->bootmenus as $id => $g) { + $bootmenufield->addMultiOption($g->getID(), $g->getTitle()); + } } - function setBootmenus($val){ - $this->bootmenus = $val; - return; - } - private $buttontext = 'Save'; - function setButtontext($v){ - $this->buttontext = $v; - } + $bootmenufield->setRegisterInArrayValidator(false); + $this->addElement($bootmenufield); + + $this->addElement('text', 'priority', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Priority:', + )); + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/filter"' + )); + } + function setBootmenus($val) { + $this->bootmenus = $val; + return; + } + private $buttontext = 'Save'; + function setButtontext($v) { + $this->buttontext = $v; + } } diff --git a/application/modules/dev/forms/FilterEntriesAdd.php b/application/modules/dev/forms/FilterEntriesAdd.php index d196cc9..dd15a22 100644 --- a/application/modules/dev/forms/FilterEntriesAdd.php +++ b/application/modules/dev/forms/FilterEntriesAdd.php @@ -1,155 +1,153 @@ -<?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 dev_Form_FilterEntriesAdd extends Zend_Form -{ - private $filterID = 0; +class dev_Form_FilterEntriesAdd extends Zend_Form { + private $filterID = 0; - public function init() - { - $this->setName("Add Filterentry"); - $this->setMethod('post'); - $this->setAttrib('id','filterentryform'); - #print_a($this->data); + public function init() { + $this->setName("Add Filterentry"); + $this->setMethod('post'); + $this->setAttrib('id', 'filterentryform'); +#print_a($this->data); - try{ - $filtertypemapper = new Application_Model_FilterTypeMapper(); - $filtertype = $filtertypemapper->fetchAll(); - - $filtertypes = $this->createElement('select','filtertypeID'); - $filtertypes ->setLabel('Type:'); - $filtertypes ->setAttrib('id','filtertype'); - $filtertypes->addMultiOption('',''); - foreach($filtertype as $f){ - $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename()); - } - $filterentry = $filtertypes->getMultiOption($this->data['filtertypeID']); - $filterentryID = $this->data['filtertypeID']; - }catch (Zend_Exception $e) { - echo "Error message 1: " . $e->getMessage() . "\n"; - } - switch($filterentryID){ - default: - $desc = "Select the filtertype"; - $label1 = 'Value 1:'; - $label2 = 'Value 2:'; - break; - case "1": - $desc = "You can set one IP or an IP-Range"; - $label1 = 'Start:'; - $label2 = 'End:'; - break; - case "2": - $desc = "You can set one Mac-Adress or an Mac-Range"; - $label1 = 'Start:'; - $label2 = 'End:'; - break; - case "3": - $desc = "Select your Pool"; - $label1 = 'PoolID:'; - break; - case "4": - $desc = "Select your BootIso"; - $label1 = 'BootIsoID:'; - break; - case "5": - $desc = "Select a Membership"; - $label1 = 'Membership:'; - break; - case "6": - $desc = "Select a Group"; - $label1 = 'Group:'; - break; - case "7": - $desc = "Specify a time-range"; - $label1 = 'Start:'; - $label2 = 'End:'; - break; - case "8": - $desc = "Select a Client"; - $label1 = 'Client:'; - break; - case "9": - $desc = "Define a Hardwarehash"; - $label1 = 'Hardwarehash:'; - break; - case "10": - $desc = "Specify the Weekday (Monday:1, Tuesday:2 ... Sunday:7) or a range"; - $label1 = 'Start Day:'; - $label2 = 'End Day:'; - break; - case "11": - $desc = "Specify the date or a day range of the filter"; - $label1 = 'Start Date:'; - $label2 = 'End Date:'; - break; - } - $filtertypes->setDescription($desc); - $this->addElement($filtertypes); - - $this->addElement('text', 'filtervalue', array( - 'label' => $label1, - 'id' => 'val1' - )); - - if(!in_array($filterentryID,array(3,4,5,6,8,9))){ - $this->addElement('text', 'filtervalue2', array( - 'label' => $label2, - 'id' => 'val2' - )); - } + try { + $filtertypemapper = new Application_Model_FilterTypeMapper(); + $filtertype = $filtertypemapper->fetchAll(); - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/filter"' - )); - - $this->addElement('hidden', 'filterID', array( - 'value' => $this->filterID - )); - - + $filtertypes = $this->createElement('select', 'filtertypeID'); + $filtertypes ->setLabel('Type:'); + $filtertypes ->setAttrib('id', 'filtertype'); + $filtertypes->addMultiOption('', ''); + foreach($filtertype as $f) { + $filtertypes->addMultiOption($f->getID(), $f->getFiltertypename()); + } + $filterentry = $filtertypes->getMultiOption($this->data['filtertypeID']); + $filterentryID = $this->data['filtertypeID']; + } catch (Zend_Exception $e) { + echo "Error message 1: " . $e->getMessage() . "\n"; } + switch($filterentryID) { + default: + $desc = "Select the filtertype"; + $label1 = 'Value 1:'; + $label2 = 'Value 2:'; + break; + case "1": + $desc = "You can set one IP or an IP-Range"; + $label1 = 'Start:'; + $label2 = 'End:'; + break; + case "2": + $desc = "You can set one Mac-Adress or an Mac-Range"; + $label1 = 'Start:'; + $label2 = 'End:'; + break; + case "3": + $desc = "Select your Pool"; + $label1 = 'PoolID:'; + break; + case "4": + $desc = "Select your BootIso"; + $label1 = 'BootIsoID:'; + break; + case "5": + $desc = "Select a Membership"; + $label1 = 'Membership:'; + break; + case "6": + $desc = "Select a Group"; + $label1 = 'Group:'; + break; + case "7": + $desc = "Specify a time-range"; + $label1 = 'Start:'; + $label2 = 'End:'; + break; + case "8": + $desc = "Select a Client"; + $label1 = 'Client:'; + break; + case "9": + $desc = "Define a Hardwarehash"; + $label1 = 'Hardwarehash:'; + break; + case "10": + $desc = "Specify the Weekday (Monday:1, Tuesday:2 ... Sunday:7) or a range"; + $label1 = 'Start Day:'; + $label2 = 'End Day:'; + break; + case "11": + $desc = "Specify the date or a day range of the filter"; + $label1 = 'Start Date:'; + $label2 = 'End Date:'; + break; + } + $filtertypes->setDescription($desc); + $this->addElement($filtertypes); + + $this->addElement('text', 'filtervalue', array( + 'label' => $label1, + 'id' => 'val1' + )); + + if(!in_array($filterentryID, array(3, 4, 5, 6, 8, 9))) { + $this->addElement('text', 'filtervalue2', array( + 'label' => $label2, + 'id' => 'val2' + )); + } + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/filter"' + )); + + $this->addElement('hidden', 'filterID', array( + 'value' => $this->filterID + )); + + + } - private $buttontext = 'Save'; - function setButtontext($v){ - $this->buttontext = $v; - } - private $data ; - function setData($v){ - $this->data = $v; - } - function setFilterID($v){ - $this->filterID = $v; - } + private $buttontext = 'Save'; + function setButtontext($v) { + $this->buttontext = $v; + } + private $data ; + function setData($v) { + $this->data = $v; + } + function setFilterID($v) { + $this->filterID = $v; + } } -?> -<script type="text/javascript"> - $('#filtertype').change(function(){ - //alert($("#filtertype option:selected").val()); - $('#filterentryform').submit(); - }); - $('#val1').focusout(function(){ - if($("#filtertype option:selected").val() == 1 && $('#val2').val() == ""){ - $('#val2').val($('#val1').val()); - } - if($("#filtertype option:selected").val() == 2 && $('#val2').val() == ""){ - $('#val2').val($('#val1').val()); - } - }); -</script> +? > +< script type = "text/javascript" > +$('#filtertype').change(function() { + //alert($("#filtertype option:selected").val()); + $('#filterentryform').submit(); +}); +$('#val1').focusout(function() { + if($("#filtertype option:selected").val() == 1 && $('#val2').val() == "") { + $('#val2').val($('#val1').val()); + } + if($("#filtertype option:selected").val() == 2 && $('#val2').val() == "") { + $('#val2').val($('#val1').val()); + } +}); +< / script > diff --git a/application/modules/dev/forms/FilterEvaluate.php b/application/modules/dev/forms/FilterEvaluate.php index 4cd67d0..b5f6fb1 100644 --- a/application/modules/dev/forms/FilterEvaluate.php +++ b/application/modules/dev/forms/FilterEvaluate.php @@ -1,140 +1,138 @@ -<?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 dev_Form_FilterEvaluate extends Zend_Form -{ - private $pools; - private $bootisos; - private $memberships; - private $groups; - private $clients; +class dev_Form_FilterEvaluate extends Zend_Form { + private $pools; + private $bootisos; + private $memberships; + private $groups; + private $clients; - public function init() - { - $this->setName("Test Filter"); - $this->setMethod('post'); - $this->setAction('/dev/filter/evaluate'); + public function init() { + $this->setName("Test Filter"); + $this->setMethod('post'); + $this->setAction('/dev/filter/evaluate'); - $this->addElement('text', 'ip', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'IP:', - )); - ###################################### - $this->addElement('text', 'mac', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Mac:', - )); - ###################################### - $poolfield = $this->createElement('select','poolID'); - $poolfield ->setLabel('Pool:'); - $poolfield->addMultiOption('',''); - if(count($this->pools)>0){ - foreach($this->pools as $id => $g){ - $poolfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $poolfield->setRegisterInArrayValidator(false); - $this->addElement($poolfield); - ###################################### - $bootisofield = $this->createElement('select','bootisoID'); - $bootisofield ->setLabel('BootIso:'); - $bootisofield->addMultiOption('',''); - if(count($this->bootisos)>0){ - foreach($this->bootisos as $id => $g){ - $bootisofield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $bootisofield->setRegisterInArrayValidator(false); - $this->addElement($bootisofield); - ###################################### - $membershipfield = $this->createElement('select','membershipID'); - $membershipfield ->setLabel('Membership:'); - $membershipfield->addMultiOption('',''); - if(count($this->memberships)>0){ - foreach($this->memberships as $id => $g){ - $membershipfield->addMultiOption($g->getID(), $g->getPersonID()); - } - } - $membershipfield->setRegisterInArrayValidator(false); - $this->addElement($membershipfield); - ###################################### - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - $groupfield->addMultiOption('',''); - if(count($this->groups)>0){ - foreach($this->groups as $id => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - ###################################### - $this->addElement('text', 'time', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Time:', - )); - ###################################### - $clientfield = $this->createElement('select','clientID'); - $clientfield ->setLabel('Client:'); - $clientfield->addMultiOption('',''); - if(count($this->clients)>0){ - foreach($this->clients as $id => $g){ - $clientfield->addMultiOption($g->getID(), $g->getID() . " - " . $g->getMacadress()); - } - } - $clientfield->setRegisterInArrayValidator(false); - $this->addElement($clientfield); - ###################################### - $this->addElement('text', 'hardwarehash', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Hardwarehash:', - )); - - $this->addElement('submit', 'submit', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Get It On!', - )); + $this->addElement('text', 'ip', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'IP:', + )); +###################################### + $this->addElement('text', 'mac', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Mac:', + )); +###################################### + $poolfield = $this->createElement('select', 'poolID'); + $poolfield ->setLabel('Pool:'); + $poolfield->addMultiOption('', ''); + if(count($this->pools) > 0) { + foreach($this->pools as $id => $g) { + $poolfield->addMultiOption($g->getID(), $g->getTitle()); + } } - function setPools($v){ - $this->pools = $v; - } - function setBootisos($v){ - $this->bootisos = $v; - } - function setMemberships($v){ - $this->memberships = $v; - } - function setGroups($v){ - $this->groups = $v; - } - function setClients($v){ - $this->clients = $v; - } + $poolfield->setRegisterInArrayValidator(false); + $this->addElement($poolfield); +###################################### + $bootisofield = $this->createElement('select', 'bootisoID'); + $bootisofield ->setLabel('BootIso:'); + $bootisofield->addMultiOption('', ''); + if(count($this->bootisos) > 0) { + foreach($this->bootisos as $id => $g) { + $bootisofield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $bootisofield->setRegisterInArrayValidator(false); + $this->addElement($bootisofield); +###################################### + $membershipfield = $this->createElement('select', 'membershipID'); + $membershipfield ->setLabel('Membership:'); + $membershipfield->addMultiOption('', ''); + if(count($this->memberships) > 0) { + foreach($this->memberships as $id => $g) { + $membershipfield->addMultiOption($g->getID(), $g->getPersonID()); + } + } + $membershipfield->setRegisterInArrayValidator(false); + $this->addElement($membershipfield); +###################################### + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + $groupfield->addMultiOption('', ''); + if(count($this->groups) > 0) { + foreach($this->groups as $id => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); +###################################### + $this->addElement('text', 'time', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Time:', + )); +###################################### + $clientfield = $this->createElement('select', 'clientID'); + $clientfield ->setLabel('Client:'); + $clientfield->addMultiOption('', ''); + if(count($this->clients) > 0) { + foreach($this->clients as $id => $g) { + $clientfield->addMultiOption($g->getID(), $g->getID() . " - " . $g->getMacadress()); + } + } + $clientfield->setRegisterInArrayValidator(false); + $this->addElement($clientfield); +###################################### + $this->addElement('text', 'hardwarehash', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Hardwarehash:', + )); + + $this->addElement('submit', 'submit', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Get It On!', + )); + } + function setPools($v) { + $this->pools = $v; + } + function setBootisos($v) { + $this->bootisos = $v; + } + function setMemberships($v) { + $this->memberships = $v; + } + function setGroups($v) { + $this->groups = $v; + } + function setClients($v) { + $this->clients = $v; + } } diff --git a/application/modules/dev/forms/GroupAdd.php b/application/modules/dev/forms/GroupAdd.php index 89595e6..b0df640 100644 --- a/application/modules/dev/forms/GroupAdd.php +++ b/application/modules/dev/forms/GroupAdd.php @@ -1,74 +1,72 @@ -<?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 dev_Form_GroupAdd extends Zend_Form -{ - private $grouplist; +class dev_Form_GroupAdd extends Zend_Form { + private $grouplist; - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + } - public function init() - { - $this->setName("GroupAdd"); - $this->setMethod('post'); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); + public function init() { + $this->setName("GroupAdd"); + $this->setMethod('post'); - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - )); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); - $groupfield = $this->createElement('select','superordinatedGroupID'); - $groupfield ->setLabel('superordinated Group:'); + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + )); - $groupfield->addMultiOption('-1', '---- none ----'); + $groupfield = $this->createElement('select', 'superordinatedGroupID'); + $groupfield ->setLabel('superordinated Group:'); - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); + $groupfield->addMultiOption('-1', '---- none ----'); - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add', - )); + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/GroupEdit.php b/application/modules/dev/forms/GroupEdit.php index a3828f5..a90c7d2 100644 --- a/application/modules/dev/forms/GroupEdit.php +++ b/application/modules/dev/forms/GroupEdit.php @@ -1,57 +1,55 @@ -<?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 dev_Form_GroupEdit extends Zend_Form -{ - - - public function init() - { - $this->setName("GroupEdit"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - 'value' => $_POST['title'], - )); - - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - 'value' => $_POST['description'], - )); - - $this->addElement('submit', 'save', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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_Form_GroupEdit extends Zend_Form { + + + public function init() { + $this->setName("GroupEdit"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + 'value' => $_POST['title'], + )); + + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + 'value' => $_POST['description'], + )); + + $this->addElement('submit', 'save', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/GroupLink.php b/application/modules/dev/forms/GroupLink.php index cd77565..4857655 100644 --- a/application/modules/dev/forms/GroupLink.php +++ b/application/modules/dev/forms/GroupLink.php @@ -1,64 +1,62 @@ -<?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 dev_Form_GroupLink extends Zend_Form -{ - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function init() - { - $this->setName("GroupLink"); - $this->setMethod('post'); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $groupfield1 = $this->createElement('select','superordinatedGroupID'); - $groupfield1 ->setLabel('superordinated Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield1->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield1->setRegisterInArrayValidator(false); - $this->addElement($groupfield1); - - $this->addElement('submit', 'link', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Link', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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_Form_GroupLink extends Zend_Form { + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function init() { + $this->setName("GroupLink"); + $this->setMethod('post'); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $groupfield1 = $this->createElement('select', 'superordinatedGroupID'); + $groupfield1 ->setLabel('superordinated Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield1->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield1->setRegisterInArrayValidator(false); + $this->addElement($groupfield1); + + $this->addElement('submit', 'link', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Link', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/GroupRequest.php b/application/modules/dev/forms/GroupRequest.php index 691c24b..8a1acbf 100644 --- a/application/modules/dev/forms/GroupRequest.php +++ b/application/modules/dev/forms/GroupRequest.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 dev_Form_GroupRequest extends Zend_Form -{ - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function getGrouplist(){ - return $this->grouplist; - } - - public function init() - { - $this->setName("GroupRequest"); - $this->setMethod('post'); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('submit', 'request', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Request', - )); - - } +* 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_Form_GroupRequest extends Zend_Form { + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function getGrouplist() { + return $this->grouplist; + } + + public function init() { + $this->setName("GroupRequest"); + $this->setMethod('post'); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('submit', 'request', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Request', + )); + + } } diff --git a/application/modules/dev/forms/GroupSelect.php b/application/modules/dev/forms/GroupSelect.php index cd5dfc6..0080044 100644 --- a/application/modules/dev/forms/GroupSelect.php +++ b/application/modules/dev/forms/GroupSelect.php @@ -1,51 +1,49 @@ -<?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 dev_Form_GroupSelect extends Zend_Form -{ - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function getGrouplist(){ - return $this->grouplist; - } - - public function init() - { - $this->setName("GroupSelect"); - $this->setMethod('post'); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('submit', 'selectgroup', array( - 'required' => false, - '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 dev_Form_GroupSelect extends Zend_Form { + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function getGrouplist() { + return $this->grouplist; + } + + public function init() { + $this->setName("GroupSelect"); + $this->setMethod('post'); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('submit', 'selectgroup', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Select', + )); + } } diff --git a/application/modules/dev/forms/LinkRight.php b/application/modules/dev/forms/LinkRight.php index 38a14f9..5894905 100644 --- a/application/modules/dev/forms/LinkRight.php +++ b/application/modules/dev/forms/LinkRight.php @@ -1,57 +1,55 @@ -<?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 dev_Form_LinkRight extends Zend_Form -{ - private $rightlist; - private $roleID; - - public function setRightlist($rightlist){ - $this->rightlist = $rightlist; - } - - public function setRoleID($roleID){ - $this->roleID = $roleID; - } - - public function init() - { - $this->setName("LinkRight"); - $this->setMethod('post'); - - $rightfield = $this->createElement('select','rightID'); - $rightfield ->setLabel('Right:'); - - if(count($this->rightlist)>0){ - foreach($this->rightlist as $right => $r){ - $rightfield->addMultiOption($r->getID(), $r->getTitle()); - } - } - $rightfield->setRegisterInArrayValidator(false); - $this->addElement($rightfield); - - $this->addElement('submit', 'link', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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_Form_LinkRight extends Zend_Form { + private $rightlist; + private $roleID; + + public function setRightlist($rightlist) { + $this->rightlist = $rightlist; + } + + public function setRoleID($roleID) { + $this->roleID = $roleID; + } + + public function init() { + $this->setName("LinkRight"); + $this->setMethod('post'); + + $rightfield = $this->createElement('select', 'rightID'); + $rightfield ->setLabel('Right:'); + + if(count($this->rightlist) > 0) { + foreach($this->rightlist as $right => $r) { + $rightfield->addMultiOption($r->getID(), $r->getTitle()); + } + } + $rightfield->setRegisterInArrayValidator(false); + $this->addElement($rightfield); + + $this->addElement('submit', 'link', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/NewPassword.php b/application/modules/dev/forms/NewPassword.php index 4a7f1cf..ca2be56 100644 --- a/application/modules/dev/forms/NewPassword.php +++ b/application/modules/dev/forms/NewPassword.php @@ -1,47 +1,45 @@ -<?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 dev_Form_NewPassword extends Zend_Form -{ - private $personID; - - public function setPersonID($personID){ - $this->personID = $personID; - } - - public function init() - { - $this->setName("NewPassword"); - $this->setMethod('post'); - - $this->addElement('hidden', 'personID', array( - 'value' => $this->personID - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Password:', - )); - - $this->addElement('submit', 'savePassword', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); - } +* 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_Form_NewPassword extends Zend_Form { + private $personID; + + public function setPersonID($personID) { + $this->personID = $personID; + } + + public function init() { + $this->setName("NewPassword"); + $this->setMethod('post'); + + $this->addElement('hidden', 'personID', array( + 'value' => $this->personID + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'savePassword', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + } }
\ No newline at end of file diff --git a/application/modules/dev/forms/PersonEdit.php b/application/modules/dev/forms/PersonEdit.php index 67f317c..b49ce7b 100644 --- a/application/modules/dev/forms/PersonEdit.php +++ b/application/modules/dev/forms/PersonEdit.php @@ -1,126 +1,124 @@ -<?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 dev_Form_PersonEdit extends Zend_Form -{ - - public function init() - { - $this->setName("PersonEdit"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - 'value' => $this->getView()->person->getTitle(), - )); - - - $this->addElement('text', 'name', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Name:', - 'value' => $this->getView()->person->getName(), - )); - - $this->addElement('text', 'firstname', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Firstname:', - 'value' => $this->getView()->person->getFirstname(), - )); - - $this->addElement('text', 'street', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Street:', - 'value' => $this->getView()->person->getStreet(), - )); - - $this->addElement('text', 'housenumber', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Housenumber:', - 'value' => $this->getView()->person->getHousenumber(), - )); - - $this->addElement('text', 'city', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'City:', - 'value' => $this->getView()->person->getCity(), - )); - - $this->addElement('text', 'postalcode', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Postalcode:', - 'value' => $this->getView()->person->getPostalcode(), - )); - - $this->addElement('text', 'email', array( - 'filters' => array('StringTrim', 'StringToLower'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Email:', - 'value' => $this->getView()->person->getEmail(), - )); - - $this->addElement('password', 'newpassword', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Neues Password:', - )); - - $this->addElement('submit', 'save', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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_Form_PersonEdit extends Zend_Form { + + public function init() { + $this->setName("PersonEdit"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + 'value' => $this->getView()->person->getTitle(), + )); + + + $this->addElement('text', 'name', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Name:', + 'value' => $this->getView()->person->getName(), + )); + + $this->addElement('text', 'firstname', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Firstname:', + 'value' => $this->getView()->person->getFirstname(), + )); + + $this->addElement('text', 'street', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Street:', + 'value' => $this->getView()->person->getStreet(), + )); + + $this->addElement('text', 'housenumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Housenumber:', + 'value' => $this->getView()->person->getHousenumber(), + )); + + $this->addElement('text', 'city', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'City:', + 'value' => $this->getView()->person->getCity(), + )); + + $this->addElement('text', 'postalcode', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Postalcode:', + 'value' => $this->getView()->person->getPostalcode(), + )); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Email:', + 'value' => $this->getView()->person->getEmail(), + )); + + $this->addElement('password', 'newpassword', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Neues Password:', + )); + + $this->addElement('submit', 'save', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/Pool.php b/application/modules/dev/forms/Pool.php index 7fff200..dc2efb2 100644 --- a/application/modules/dev/forms/Pool.php +++ b/application/modules/dev/forms/Pool.php @@ -1,61 +1,59 @@ -<?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 dev_Form_Pool extends Zend_Form -{ - - public function init() - { - $this->setName("pool"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'required' => false, - 'label' => 'Description:', - )); - // TODO: Add target of Filter - - $this->addElement('text', 'location', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Location:', - )); - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/pool"' - )); - } - private $buttontext = 'Save'; - function setButtontext($v){ - $this->buttontext = $v; - } +* 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_Form_Pool extends Zend_Form { + + public function init() { + $this->setName("pool"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'required' => false, + 'label' => 'Description:', + )); + // TODO: Add target of Filter + + $this->addElement('text', 'location', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Location:', + )); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/pool"' + )); + } + private $buttontext = 'Save'; + function setButtontext($v) { + $this->buttontext = $v; + } } diff --git a/application/modules/dev/forms/PoolClient.php b/application/modules/dev/forms/PoolClient.php index 434343a..a9dc880 100644 --- a/application/modules/dev/forms/PoolClient.php +++ b/application/modules/dev/forms/PoolClient.php @@ -1,42 +1,40 @@ -<?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 dev_Form_PoolClient extends Zend_Form -{ - private $clients; +class dev_Form_PoolClient extends Zend_Form { + private $clients; - public function init() - { - $this->setName("addClientToPool"); - $this->setMethod('post'); - - $clientfield = $this->createElement('select','clientID'); - $clientfield ->setLabel('Client:'); - print_a($this->clients); - foreach($this->clients as $c){ - $clientfield->addMultiOption($c['clientID'],$c['macadress']." - ".$c['hardwarehash']); - } - $this->addElement($clientfield); - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); + public function init() { + $this->setName("addClientToPool"); + $this->setMethod('post'); + + $clientfield = $this->createElement('select', 'clientID'); + $clientfield ->setLabel('Client:'); + print_a($this->clients); + foreach($this->clients as $c) { + $clientfield->addMultiOption($c['clientID'], $c['macadress']." - ".$c['hardwarehash']); } - public function setClients($clients){ - $this->clients = $clients; - return $this; - } - + $this->addElement($clientfield); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + } + public function setClients($clients) { + $this->clients = $clients; + return $this; + } + } diff --git a/application/modules/dev/forms/PrebootCreate.php b/application/modules/dev/forms/PrebootCreate.php index 2979606..5365640 100644 --- a/application/modules/dev/forms/PrebootCreate.php +++ b/application/modules/dev/forms/PrebootCreate.php @@ -1,72 +1,70 @@ -<?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 dev_Form_PrebootCreate extends Zend_Form -{ +class dev_Form_PrebootCreate extends Zend_Form { - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function init() - { - $this->setName("PreBootCreate"); - $this->setMethod('post'); + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function init() { + $this->setName("PreBootCreate"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('text', 'path_preboot', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 240)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Path to Preboot:', - )); - - $this->addElement('submit', 'createpreboot', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Create Preboot', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/dev/preboot"' - )); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('text', 'path_preboot', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 240)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Path to Preboot:', + )); + + $this->addElement('submit', 'createpreboot', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Create Preboot', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/preboot"' + )); + + } + - } diff --git a/application/modules/dev/forms/PrebootEdit.php b/application/modules/dev/forms/PrebootEdit.php index 6e8268b..a691bff 100644 --- a/application/modules/dev/forms/PrebootEdit.php +++ b/application/modules/dev/forms/PrebootEdit.php @@ -1,69 +1,67 @@ -<?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 dev_Form_PrebootEdit extends Zend_Form -{ - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function init() - { - $this->setName("PreBootEdit"); - $this->setMethod('post'); +class dev_Form_PrebootEdit extends Zend_Form { + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function init() { + $this->setName("PreBootEdit"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('text', 'path_preboot', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 240)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Path to Preboot:', - )); - - $this->addElement('submit', 'editpreboot', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Edit Preboot', - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/dev/preboot"' - )); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('text', 'path_preboot', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 240)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Path to Preboot:', + )); + + $this->addElement('submit', 'editpreboot', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit Preboot', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/preboot"' + )); + + } } diff --git a/application/modules/dev/forms/RoleAdd.php b/application/modules/dev/forms/RoleAdd.php index a9ada27..46cf025 100644 --- a/application/modules/dev/forms/RoleAdd.php +++ b/application/modules/dev/forms/RoleAdd.php @@ -1,63 +1,61 @@ -<?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 dev_Form_RoleAdd extends Zend_Form -{ - private $rightlist; - - public function setRightlist($rightlist){ - $this->rightlist = $rightlist; - } - - public function init() - { - $this->setName("RoleAdd"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - )); - - $this->addElement('checkbox', 'inheritance', array( - 'label' => 'Inheritance:', - )); - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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_Form_RoleAdd extends Zend_Form { + private $rightlist; + + public function setRightlist($rightlist) { + $this->rightlist = $rightlist; + } + + public function init() { + $this->setName("RoleAdd"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + )); + + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/RoleEdit.php b/application/modules/dev/forms/RoleEdit.php index 8ae4733..a36795e 100644 --- a/application/modules/dev/forms/RoleEdit.php +++ b/application/modules/dev/forms/RoleEdit.php @@ -1,71 +1,69 @@ -<?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 dev_Form_RoleEdit extends Zend_Form -{ +class dev_Form_RoleEdit extends Zend_Form { - public function init() - { - $this->setName("RoleEdit"); - $this->setMethod('post'); + public function init() { + $this->setName("RoleEdit"); + $this->setMethod('post'); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - 'value' => $_POST['title'], - )); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + 'value' => $_POST['title'], + )); - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - 'value' => $_POST['description'], - )); + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + 'value' => $_POST['description'], + )); - if($_POST['inheritance'] == 1) { - $this->addElement('checkbox', 'inheritance', array( - 'label' => 'Inheritance:', - 'checked' => 'checked', - )); - } else { - $this->addElement('checkbox', 'inheritance', array( - 'label' => 'Inheritance:', - )); - } + if($_POST['inheritance'] == 1) { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + 'checked' => 'checked', + )); + } else { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + } - $this->addElement('hidden', 'groupID', array( - 'value' => $_POST['groupID'], - )); + $this->addElement('hidden', 'groupID', array( + 'value' => $_POST['groupID'], + )); - $this->addElement('submit', 'save', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); + $this->addElement('submit', 'save', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/dev/forms/Session.php b/application/modules/dev/forms/Session.php index c543188..14004ef 100644 --- a/application/modules/dev/forms/Session.php +++ b/application/modules/dev/forms/Session.php @@ -1,149 +1,147 @@ -<?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 dev_Form_Session extends Zend_Form -{ - - private $clients; - private $bootos; - private $bootisos; - private $bootmenuentries; - private $memberships; - - public function init() - { - $this->setName("session"); - $this->setMethod('post'); - - $this->addElement('text', 'alphasessionID', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 16)), - ), - 'required' => false, - 'label' => 'alphasessionID:', - )); - - $clientfield = $this->createElement('select','clientID'); - $clientfield ->setLabel('Client:'); - $clientfield->addMultiOption('',''); - if(count($this->clients)>0){ - foreach($this->clients as $id => $g){ - $clientfield->addMultiOption($g->getID(), $g->getMacadress()); - } - } - $clientfield->setRegisterInArrayValidator(false); - $this->addElement($clientfield); - - - $bootmenuentrieyfield = $this->createElement('select','bootmenuentryID'); - $bootmenuentrieyfield->setLabel('BootmenuentryID:'); - $bootmenuentrieyfield->addMultiOption('',''); - if(count($this->bootmenuentries)>0){ - foreach($this->bootmenuentries as $id => $g){ - $bootmenuentrieyfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $bootmenuentrieyfield->setRegisterInArrayValidator(false); - $this->addElement($bootmenuentrieyfield); - - - $bootosfield = $this->createElement('select','bootosID'); - $bootosfield ->setLabel('BootOs:'); - $bootosfield->addMultiOption('',''); - if(count($this->bootos)>0){ - foreach($this->bootos as $id => $g){ - $bootosfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $bootosfield->setRegisterInArrayValidator(false); - $this->addElement($bootosfield); - - $bootisofield = $this->createElement('select','bootisoID'); - $bootisofield ->setLabel('BootIso:'); - if(count($this->bootisos)>0){ - foreach($this->bootisos as $id => $g){ - $bootisofield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $bootisofield->setRegisterInArrayValidator(false); - $this->addElement($bootisofield); - - $membershipfield = $this->createElement('select','membershipID'); - $membershipfield ->setLabel('Membership:'); - $membershipfield ->addMultiOption('',''); - if(count($this->memberships)>0){ - foreach($this->memberships as $id => $g){ - $membershipfield->addMultiOption($g->getID(), $g->getPersonID()); - } - } - $membershipfield->setRegisterInArrayValidator(false); - $this->addElement($membershipfield); - -$this->addElement('text', 'time', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'time:', - )); -$this->addElement('text', 'ip', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'ip:', - )); -$this->addElement('text', 'ip6', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'ip6:', - )); - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/session"' - )); +* 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_Form_Session extends Zend_Form { + + private $clients; + private $bootos; + private $bootisos; + private $bootmenuentries; + private $memberships; + + public function init() { + $this->setName("session"); + $this->setMethod('post'); + + $this->addElement('text', 'alphasessionID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 16)), + ), + 'required' => false, + 'label' => 'alphasessionID:', + )); + + $clientfield = $this->createElement('select', 'clientID'); + $clientfield ->setLabel('Client:'); + $clientfield->addMultiOption('', ''); + if(count($this->clients) > 0) { + foreach($this->clients as $id => $g) { + $clientfield->addMultiOption($g->getID(), $g->getMacadress()); + } } - function setClients($v){ - $this->clients = $v; - } - function setBootos($v){ - $this->bootos = $v; - } - function setBootisos($v){ - $this->bootisos = $v; - } - function setBootmenuentries($v){ - $this->bootmenuentries = $v; - } - function setMemberships($v){ - $this->memberships = $v; - } - private $buttontext = 'Save'; - function setButtontext($v){ - $this->buttontext = $v; - } - + $clientfield->setRegisterInArrayValidator(false); + $this->addElement($clientfield); + + + $bootmenuentrieyfield = $this->createElement('select', 'bootmenuentryID'); + $bootmenuentrieyfield->setLabel('BootmenuentryID:'); + $bootmenuentrieyfield->addMultiOption('', ''); + if(count($this->bootmenuentries) > 0) { + foreach($this->bootmenuentries as $id => $g) { + $bootmenuentrieyfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $bootmenuentrieyfield->setRegisterInArrayValidator(false); + $this->addElement($bootmenuentrieyfield); + + + $bootosfield = $this->createElement('select', 'bootosID'); + $bootosfield ->setLabel('BootOs:'); + $bootosfield->addMultiOption('', ''); + if(count($this->bootos) > 0) { + foreach($this->bootos as $id => $g) { + $bootosfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $bootosfield->setRegisterInArrayValidator(false); + $this->addElement($bootosfield); + + $bootisofield = $this->createElement('select', 'bootisoID'); + $bootisofield ->setLabel('BootIso:'); + if(count($this->bootisos) > 0) { + foreach($this->bootisos as $id => $g) { + $bootisofield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $bootisofield->setRegisterInArrayValidator(false); + $this->addElement($bootisofield); + + $membershipfield = $this->createElement('select', 'membershipID'); + $membershipfield ->setLabel('Membership:'); + $membershipfield ->addMultiOption('', ''); + if(count($this->memberships) > 0) { + foreach($this->memberships as $id => $g) { + $membershipfield->addMultiOption($g->getID(), $g->getPersonID()); + } + } + $membershipfield->setRegisterInArrayValidator(false); + $this->addElement($membershipfield); + + $this->addElement('text', 'time', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'time:', + )); + $this->addElement('text', 'ip', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'ip:', + )); + $this->addElement('text', 'ip6', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'ip6:', + )); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/session"' + )); + } + function setClients($v) { + $this->clients = $v; + } + function setBootos($v) { + $this->bootos = $v; + } + function setBootisos($v) { + $this->bootisos = $v; + } + function setBootmenuentries($v) { + $this->bootmenuentries = $v; + } + function setMemberships($v) { + $this->memberships = $v; + } + private $buttontext = 'Save'; + function setButtontext($v) { + $this->buttontext = $v; + } + } 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', + )); + } } diff --git a/application/modules/ipxe/controllers/AuthController.php b/application/modules/ipxe/controllers/AuthController.php index e6f1336..b59c146 100644 --- a/application/modules/ipxe/controllers/AuthController.php +++ b/application/modules/ipxe/controllers/AuthController.php @@ -1,218 +1,213 @@ -<?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 Ipxe_AuthController extends Zend_Controller_Action -{ - protected $session; - protected $sessionMapper; - protected $error; - - public function init() - { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - $this->db = Zend_Db_Table::getDefaultAdapter(); - - $this->session = new Application_Model_Session(); - $this->sessionMapper = new Application_Model_SessionMapper(); - - $alphaID = $this->_request->getParam('alpha'); - - if(isset($alphaID)){ - $alphasessionID = $alphaID; - $result = $this->sessionMapper->findBy(array('alphasessionID' => $alphasessionID),true); - if(isset($result)){ - $this->session = $this->session->setOptions($result[0]); - $this->session->setID($result[0]['sessionID']); - }else{ - $this->error = "session"; - } - } - } - - public function serialAction() - { - $serialnumber = $this->_request->getParam('serialnumber'); - $mac = $this->_request->getParam('mac'); - - if(isset($serialnumber)){ - // Create a session - $n = new Pbs_Session(); - - $bootisomapper = new Application_Model_BootIsoMapper(); - $bootiso = new Application_Model_BootIso(); - - $results = $bootisomapper->findBy(array('serialnumber' => $serialnumber),true); - - if(isset($results)){ - $bootiso->setOptions($results[0]); - $bootiso->setID($results[0]['bootisoID']); - $groupID = $bootiso->getGroupID(); - - $client = new Application_Model_Client(); - $client->setGroupID($groupID); - $client->setMacadress($mac); - $client->setCreated(time()); - $client = $n->createClient($client); - $clientID = $client->getID(); - - $this->session->setBootisoID($bootiso->getID()); - $this->session->setClientID($clientID); - $this->session->setTime(time()); - $this->session->setIp($_SERVER['REMOTE_ADDR']); - $this->session = $n->createSession($this->session); - }else{ - $this->error = "serial"; - } - } - else{ - $this->error = "serial"; - } - - header('Content-Type: text/plain'); - - $result = "#!ipxe\n"; - if(isset($this->session)){ - $result .= "set filename http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$this->session->getAlphasessionID()."/error/".$this->error."\n"; - $result .= ":start\n"; - $result .= "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 \${filename}\n"; - $result .= "goto start\n"; - }else{ - $result .= "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/serialnumber/$serialnumber/mac/$mac/error/$this->error\n"; - } - header("Content-Length: ".(strlen($result))); - echo $result; - - } - - public function loginAction() - { - $alpha = $this->_request->getParam('alpha'); - $login = $this->_request->getParam('login'); - - if (isset($login)){ - header('Content-Type: text/plain'); - $result = "#!ipxe\n"; - $result .= "clear username\n"; - $result .= "clear password\n"; - $result .= "login\n"; - $result .= "isset \${username} || set username null\n"; - $result .= "chain http://\${username:uristring}:\${password:uristring}@".$_SERVER['HTTP_HOST']."/ipxe/auth/login/alpha/".$alpha."\n"; - header("Content-Length: ".(strlen($result))); - echo $result; - exit; - } - - if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])){ - header('WWW-Authenticate: Basic realm=""'); - header('HTTP/1.0 401 Unauthorized'); - $result = "#!ipxe\n"; - $result .= "set filename http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$this->session->getAlphasessionID()."/error/login\n"; - header("Content-Length: ".(strlen($result))); - echo $result; - exit; - } - - $email = $_SERVER['PHP_AUTH_USER']; - $password = $_SERVER['PHP_AUTH_PW']; - - $auth = Zend_Auth::getInstance(); - $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); - $adapter->setIdentity($email); - $adapter->setCredential($password); - - $result = $auth->authenticate($adapter); - - if (isset($this->session)){ - if ($result->isValid()) { - - $personmapper = new Application_Model_PersonMapper(); - $result = $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()); - $personmapper->save($person); - - $this->session->setPersonID($person->getID()); - $this->sessionMapper->save($this->session); - - } else { - $this->error = "login"; - } - }else{ - $this->error = "session"; - } - - - header('Content-Type: text/plain'); - $result = "#!ipxe\n"; - $result .= "set filename http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$this->session->getAlphasessionID()."/error/".$this->error."\n"; - header("Content-Length: ".(strlen($result))); - echo $result; - exit; - - - - } - - public function logoutAction(){ - - $alpha = $this->_request->getParam('alpha'); - - if (isset($this->session)){ - $this->session->setPersonID(null); - $this->session->setMembershipID(null); - $this->sessionMapper->save($this->session); - }else{ - $this->error = "session"; - } - - $this->_redirect('/ipxe/resource/getvesamenuconfig/alpha/'.$alpha.'/error/'.$this->error); - - } - - public function switchgroupAction(){ - - $alpha = $this->_request->getParam('alpha'); - - if (isset($this->session)){ - $this->session->setMembershipID(null); - $this->sessionMapper->save($this->session); - }else{ - $this->error = "session"; - } - - $this->_redirect('/ipxe/resource/getvesamenuconfig/alpha/'.$alpha.'/error/'.$this->error); - } - - public function setgroupAction(){ - - $alpha = $this->_request->getParam('alpha'); - $membershipID = $this->_request->getParam('membershipid'); - - //TODO test if member of group - if (isset($this->session)){ - $this->session->setMembershipID($membershipID); - $this->sessionMapper->save($this->session); - }else{ - $this->error = "session"; - } - - $this->_redirect('/ipxe/resource/getvesamenuconfig/alpha/'.$alpha.'/error/'.$this->error); - } - - - - - +* 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 Ipxe_AuthController extends Zend_Controller_Action { + protected $session; + protected $sessionMapper; + protected $error; + + public function init() { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $this->db = Zend_Db_Table::getDefaultAdapter(); + + $this->session = new Application_Model_Session(); + $this->sessionMapper = new Application_Model_SessionMapper(); + + $alphaID = $this->_request->getParam('alpha'); + + if(isset($alphaID)) { + $alphasessionID = $alphaID; + $result = $this->sessionMapper->findBy(array('alphasessionID' => $alphasessionID), true); + if(isset($result)) { + $this->session = $this->session->setOptions($result[0]); + $this->session->setID($result[0]['sessionID']); + } else { + $this->error = "session"; + } + } + } + + public function serialAction() { + $serialnumber = $this->_request->getParam('serialnumber'); + $mac = $this->_request->getParam('mac'); + + if(isset($serialnumber)) { + // Create a session + $n = new Pbs_Session(); + + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso = new Application_Model_BootIso(); + + $results = $bootisomapper->findBy(array('serialnumber' => $serialnumber), true); + + if(isset($results)) { + $bootiso->setOptions($results[0]); + $bootiso->setID($results[0]['bootisoID']); + $groupID = $bootiso->getGroupID(); + + $client = new Application_Model_Client(); + $client->setGroupID($groupID); + $client->setMacadress($mac); + $client->setCreated(time()); + $client = $n->createClient($client); + $clientID = $client->getID(); + + $this->session->setBootisoID($bootiso->getID()); + $this->session->setClientID($clientID); + $this->session->setTime(time()); + $this->session->setIp($_SERVER['REMOTE_ADDR']); + $this->session = $n->createSession($this->session); + } else { + $this->error = "serial"; + } + } else { + $this->error = "serial"; + } + + header('Content-Type: text/plain'); + + $result = "#!ipxe\n"; + if(isset($this->session)) { + $result . = "set filename http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$this->session->getAlphasessionID()."/error/".$this->error."\n"; + $result . = ":start\n"; + $result . = "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 \${filename}\n"; + $result . = "goto start\n"; + } else { + $result . = "chain http://".$_SERVER['HTTP_HOST']."/ipxe/vesamenu.c32 http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/serialnumber/$serialnumber/mac/$mac/error/$this->error\n"; + } + header("Content-Length: ".(strlen($result))); + echo $result; + + } + + public function loginAction() { + $alpha = $this->_request->getParam('alpha'); + $login = $this->_request->getParam('login'); + + if (isset($login)) { + header('Content-Type: text/plain'); + $result = "#!ipxe\n"; + $result . = "clear username\n"; + $result . = "clear password\n"; + $result . = "login\n"; + $result . = "isset \${username} || set username null\n"; + $result . = "chain http://\${username:uristring}:\${password:uristring}@".$_SERVER['HTTP_HOST']."/ipxe/auth/login/alpha/".$alpha."\n"; + header("Content-Length: ".(strlen($result))); + echo $result; + exit; + } + + if(!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { + header('WWW-Authenticate: Basic realm=""'); + header('HTTP/1.0 401 Unauthorized'); + $result = "#!ipxe\n"; + $result . = "set filename http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$this->session->getAlphasessionID()."/error/login\n"; + header("Content-Length: ".(strlen($result))); + echo $result; + exit; + } + + $email = $_SERVER['PHP_AUTH_USER']; + $password = $_SERVER['PHP_AUTH_PW']; + + $auth = Zend_Auth::getInstance(); + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); + $adapter->setIdentity($email); + $adapter->setCredential($password); + + $result = $auth->authenticate($adapter); + + if (isset($this->session)) { + if ($result->isValid()) { + + $personmapper = new Application_Model_PersonMapper(); + $result = $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()); + $personmapper->save($person); + + $this->session->setPersonID($person->getID()); + $this->sessionMapper->save($this->session); + + } else { + $this->error = "login"; + } + } else { + $this->error = "session"; + } + + + header('Content-Type: text/plain'); + $result = "#!ipxe\n"; + $result . = "set filename http://".$_SERVER['HTTP_HOST']."/ipxe/resource/getvesamenuconfig/alpha/".$this->session->getAlphasessionID()."/error/".$this->error."\n"; + header("Content-Length: ".(strlen($result))); + echo $result; + exit; + + + + } + + public function logoutAction() { + + $alpha = $this->_request->getParam('alpha'); + + if (isset($this->session)) { + $this->session->setPersonID(null); + $this->session->setMembershipID(null); + $this->sessionMapper->save($this->session); + } else { + $this->error = "session"; + } + + $this->_redirect('/ipxe/resource/getvesamenuconfig/alpha/'.$alpha.'/error/'.$this->error); + + } + + public function switchgroupAction() { + + $alpha = $this->_request->getParam('alpha'); + + if (isset($this->session)) { + $this->session->setMembershipID(null); + $this->sessionMapper->save($this->session); + } else { + $this->error = "session"; + } + + $this->_redirect('/ipxe/resource/getvesamenuconfig/alpha/'.$alpha.'/error/'.$this->error); + } + + public function setgroupAction() { + + $alpha = $this->_request->getParam('alpha'); + $membershipID = $this->_request->getParam('membershipid'); + + //TODO test if member of group + if (isset($this->session)) { + $this->session->setMembershipID($membershipID); + $this->sessionMapper->save($this->session); + } else { + $this->error = "session"; + } + + $this->_redirect('/ipxe/resource/getvesamenuconfig/alpha/'.$alpha.'/error/'.$this->error); + } + + + + + } diff --git a/application/modules/ipxe/controllers/ResourceController.php b/application/modules/ipxe/controllers/ResourceController.php index 0f5988a..c33ed45 100644 --- a/application/modules/ipxe/controllers/ResourceController.php +++ b/application/modules/ipxe/controllers/ResourceController.php @@ -1,199 +1,196 @@ -<?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 Ipxe_ResourceController extends Zend_Controller_Action -{ - - private $session; - - public function init() - { - - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - - $this->session = new Application_Model_Session(); - $sessionMapper = new Application_Model_SessionMapper(); - - //TODO Error Messages if something failed - $alphaID = $this->_request->getParam('alpha'); - - if(isset($alphaID)){ - $alphasessionID = $alphaID; - $result = $sessionMapper->findBy(array('alphasessionID' => $alphasessionID),true); - # print_a($result); - $this->session = $this->session->setOptions($result[0]); - $this->session->setID($result[0]['sessionID']); - } - - $bootmenuntryID = $this->_request->getParam('bme'); - - if(isset($bootmenuntryID) && isset($this->session)){ - //TODO check if allowed - $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentriesMapper->find($bootmenuntryID,$bootmenuentry); - - $this->session->setBootmenuentryID($bootmenuntryID); - $this->session->setBootosID($bootmenuentry->getBootosID()); - $sessionMapper->save($this->session); - } - } - - public function getvesamenuconfigAction(){ - - header('Content-Type: text/html'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="vesamenu.conf"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - $vesamenuView = new Zend_View(); - $vesamenuView->addScriptPath(APPLICATION_PATH.'/modules/ipxe/views/scripts/resource/'); - - $vesamenuView->host = $_SERVER['HTTP_HOST']; - $vesamenuView->error = $this->_request->getParam('error'); - - if (isset($this->session)){ - $vesamenuView->alphaID = $this->session->getAlphasessionID(); - - if ($this->session->getPersonID() != null){ - $personMapper = new Application_Model_PersonMapper(); - $person = $personMapper->find($this->session->getPersonID()); - $vesamenuView->name = $person->getName(); - $vesamenuView->firstname = $person->getFirstname(); - $vesamenuView->loggedin = true; - }else{ - $vesamenuView->loggedin = false; - } - - if($this->session->getMembershipID() != null){ - $groupMapper = new Application_Model_GroupMapper(); - $membershipMapper = new Application_Model_MembershipMapper(); - $membership = $membershipMapper->find($this->session->getMembershipID()); - $vesamenuView->group = $groupMapper->find($membership->getGroupID())->getTitle(); - $_SESSION['userIDs']['membershipID'] = $this->session->getMembershipID(); - $_SESSION['userIDs']['groupID'] = $membership->getGroupID(); - } - - if ($this->session->getPersonID() != null && $this->session->getMembershipID() == null ){ - $groupMapper = new Application_Model_GroupMapper(); - $roleMapper = new Application_Model_RoleMapper(); - $membershipMapper = new Application_Model_MembershipMapper(); - $memberships = $membershipMapper->findBy(array('personID' => $this->session->getPersonID()),true); - - if(isset($memberships)) { - foreach($memberships as $membership) { - $group = $groupMapper->find($membership['groupID']); - $role = $roleMapper->find($membership['roleID']); - $membershipList[] = array( - 'membershipID' => $membership['membershipID'], - 'group' => $group->getTitle(), - 'role' => $role->getTitle() - ); - } - $vesamenuView->memberships = $membershipList; - }else{ - $vesamenuView->memberships = null; - } - - $vesamenuView->action = "selectmembership"; - - } - - // Request Bootmenu - $_SESSION['alphasessionID'] = $this->session->getAlphasessionID(); - $pbsFilter = new Pbs_Filter(); - $bootmenuID = $pbsFilter->evaluate(); - - if($bootmenuID != null){ - $bootmenuMapper = new Application_Model_BootMenuMapper(); - $bm = $bootmenuMapper->find($bootmenuID); - $vesamenuView->title = $bm->getTitle(); - $vesamenuView->startcounter = $bm->getStartcounter(); - - $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); - $vesamenuView->bmelist = $res; - }else{ - $vesamenuView->bmelist = null; - } - }else{ - $vesamenuView->serialnumber = $this->_request->getParam('serialnumber'); - $vesamenuView->mac = $this->_request->getParam('mac'); - if($vesamenuView->error == "serial"){ - $vesamenuView->error = "serial"; - }else{ - $vesamenuView->error = "session"; - } - } - - $vesamenu = $vesamenuView->render('getvesamenu.phtml'); - - header("Content-Length: ".(strlen($vesamenu))); - - echo $vesamenu; - } - - public function getkernelAction(){ - - //TODO session & bme error - $bootosID = $this->session->getBootosID(); - - if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){ - - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="kernel"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - // create the gzipped tarfile. - chdir("../resources/bootos/$bootosID/kernel/"); - $kernelname = array_pop(scandir("./")); - - header("Content-Length: ".filesize(getcwd()."/".$kernelname)); - - passthru( "cat ". $kernelname); - }else{ - header('HTTP/1.0 404 Not Found'); - } - } - - public function getinitramfsAction() - { - - $bootosID = $this->session->getBootosID(); - - if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){ - - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="initramfs"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - // create file. - chdir("../resources/bootos/$bootosID/initramfs/"); - $initname = array_pop(scandir("./")); - - header("Content-Length: ".filesize(getcwd()."/".$initname)); - - passthru( "cat ".$initname); - }else{ - header('HTTP/1.0 404 Not Found'); - } - } - +* 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 Ipxe_ResourceController extends Zend_Controller_Action { + + private $session; + + public function init() { + + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $this->session = new Application_Model_Session(); + $sessionMapper = new Application_Model_SessionMapper(); + + //TODO Error Messages if something failed + $alphaID = $this->_request->getParam('alpha'); + + if(isset($alphaID)) { + $alphasessionID = $alphaID; + $result = $sessionMapper->findBy(array('alphasessionID' => $alphasessionID), true); +# print_a($result); + $this->session = $this->session->setOptions($result[0]); + $this->session->setID($result[0]['sessionID']); + } + + $bootmenuntryID = $this->_request->getParam('bme'); + + if(isset($bootmenuntryID) && isset($this->session)) { + //TODO check if allowed + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentriesMapper->find($bootmenuntryID, $bootmenuentry); + + $this->session->setBootmenuentryID($bootmenuntryID); + $this->session->setBootosID($bootmenuentry->getBootosID()); + $sessionMapper->save($this->session); + } + } + + public function getvesamenuconfigAction() { + + header('Content-Type: text/html'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="vesamenu.conf"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + $vesamenuView = new Zend_View(); + $vesamenuView->addScriptPath(APPLICATION_PATH.'/modules/ipxe/views/scripts/resource/'); + + $vesamenuView->host = $_SERVER['HTTP_HOST']; + $vesamenuView->error = $this->_request->getParam('error'); + + if (isset($this->session)) { + $vesamenuView->alphaID = $this->session->getAlphasessionID(); + + if ($this->session->getPersonID() != null) { + $personMapper = new Application_Model_PersonMapper(); + $person = $personMapper->find($this->session->getPersonID()); + $vesamenuView->name = $person->getName(); + $vesamenuView->firstname = $person->getFirstname(); + $vesamenuView->loggedin = true; + } else { + $vesamenuView->loggedin = false; + } + + if($this->session->getMembershipID() != null) { + $groupMapper = new Application_Model_GroupMapper(); + $membershipMapper = new Application_Model_MembershipMapper(); + $membership = $membershipMapper->find($this->session->getMembershipID()); + $vesamenuView->group = $groupMapper->find($membership->getGroupID())->getTitle(); + $_SESSION['userIDs']['membershipID'] = $this->session->getMembershipID(); + $_SESSION['userIDs']['groupID'] = $membership->getGroupID(); + } + + if ($this->session->getPersonID() != null && $this->session->getMembershipID() == null ) { + $groupMapper = new Application_Model_GroupMapper(); + $roleMapper = new Application_Model_RoleMapper(); + $membershipMapper = new Application_Model_MembershipMapper(); + $memberships = $membershipMapper->findBy(array('personID' => $this->session->getPersonID()), true); + + if(isset($memberships)) { + foreach($memberships as $membership) { + $group = $groupMapper->find($membership['groupID']); + $role = $roleMapper->find($membership['roleID']); + $membershipList[] = array( + 'membershipID' => $membership['membershipID'], + 'group' => $group->getTitle(), + 'role' => $role->getTitle() + ); + } + $vesamenuView->memberships = $membershipList; + } else { + $vesamenuView->memberships = null; + } + + $vesamenuView->action = "selectmembership"; + + } + + // Request Bootmenu + $_SESSION['alphasessionID'] = $this->session->getAlphasessionID(); + $pbsFilter = new Pbs_Filter(); + $bootmenuID = $pbsFilter->evaluate(); + + if($bootmenuID != null) { + $bootmenuMapper = new Application_Model_BootMenuMapper(); + $bm = $bootmenuMapper->find($bootmenuID); + $vesamenuView->title = $bm->getTitle(); + $vesamenuView->startcounter = $bm->getStartcounter(); + + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID), false); + $vesamenuView->bmelist = $res; + } else { + $vesamenuView->bmelist = null; + } + } else { + $vesamenuView->serialnumber = $this->_request->getParam('serialnumber'); + $vesamenuView->mac = $this->_request->getParam('mac'); + if($vesamenuView->error == "serial") { + $vesamenuView->error = "serial"; + } else { + $vesamenuView->error = "session"; + } + } + + $vesamenu = $vesamenuView->render('getvesamenu.phtml'); + + header("Content-Length: ".(strlen($vesamenu))); + + echo $vesamenu; + } + + public function getkernelAction() { + + //TODO session & bme error + $bootosID = $this->session->getBootosID(); + + if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)) { + + header('Content-Type: application/x-gzip'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="kernel"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + // create the gzipped tarfile. + chdir("../resources/bootos/$bootosID/kernel/"); + $kernelname = array_pop(scandir("./")); + + header("Content-Length: ".filesize(getcwd()."/".$kernelname)); + + passthru( "cat ". $kernelname); + } else { + header('HTTP/1.0 404 Not Found'); + } + } + + public function getinitramfsAction() { + + $bootosID = $this->session->getBootosID(); + + if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)) { + + header('Content-Type: application/x-gzip'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="initramfs"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + // create file. + chdir("../resources/bootos/$bootosID/initramfs/"); + $initname = array_pop(scandir("./")); + + header("Content-Length: ".filesize(getcwd()."/".$initname)); + + passthru( "cat ".$initname); + } else { + header('HTTP/1.0 404 Not Found'); + } + } + } diff --git a/application/modules/user/Bootstrap.php b/application/modules/user/Bootstrap.php index 2537ee0..a80ceac 100644 --- a/application/modules/user/Bootstrap.php +++ b/application/modules/user/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 user_Bootstrap extends Zend_Application_Module_Bootstrap -{ - function _initViewHelpers() - { - $this->bootstrap('layout'); - - $layout = $this->getResource('layout'); - $view = $layout->getView(); - $view->headLink()->appendStylesheet('/media/css/user.css'); - } +class user_Bootstrap extends Zend_Application_Module_Bootstrap { + function _initViewHelpers() { + $this->bootstrap('layout'); + + $layout = $this->getResource('layout'); + $view = $layout->getView(); + $view->headLink()->appendStylesheet('/media/css/user.css'); + } } diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php index cc3fec4..ec5bb2b 100644 --- a/application/modules/user/controllers/AuthController.php +++ b/application/modules/user/controllers/AuthController.php @@ -1,261 +1,248 @@ -<?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 User_AuthController extends Zend_Controller_Action -{ - protected $personmapper = null; - private $db = null; +class User_AuthController extends Zend_Controller_Action { + protected $personmapper = null; + private $db = null; - public function init() - { - $this->db = Zend_Db_Table::getDefaultAdapter(); - $this->personmapper = new Application_Model_PersonMapper(); - } + 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 indexAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $this->_helper->redirector('login', 'auth'); + } - public function loginAction() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->_redirect('/user/'); - } else { - if (!isset($_POST["login"])){ - $loginForm = new user_Form_Login(); - } else { - $loginForm = new user_Form_Login($_POST); + public function loginAction() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->_redirect('/user/'); + } else { + if (!isset($_POST["login"])) { + $loginForm = new user_Form_Login(); + } else { + $loginForm = new user_Form_Login($_POST); - if ($loginForm->isValid($_POST)) { + if ($loginForm->isValid($_POST)) { - $auth = Zend_Auth::getInstance(); + $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')); + $adapter = new Zend_Auth_Adapter_DbTable( $this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); - $result = $auth->authenticate($adapter); + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); - 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]); - print_a('case1',$person); - $person->setID($result[0]['personID']); - $date = new DateTime(); - $person->setLogindate($date->getTimestamp()); - if($person->getSuspend()) { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Your Account is suspended', 'error'); - } else { - $this->personmapper->save($person); - $this->_helper->redirector('selectmembership', 'person'); - return; - } - } else { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Wrong Email or Password', 'error'); - } - } - } - $this->view->loginForm = $loginForm; - } - } + $result = $auth->authenticate($adapter); - public function logoutAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - $auth = Zend_Auth::getInstance(); - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_helper->redirector('login', 'auth'); - return; - } + 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]); + print_a('case1', $person); + $person->setID($result[0]['personID']); + $date = new DateTime(); + $person->setLogindate($date->getTimestamp()); + if($person->getSuspend()) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Your Account is suspended', 'error'); + } else { + $this->personmapper->save($person); + $this->_helper->redirector('selectmembership', 'person'); + return; + } + } else { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Wrong Email or Password', 'error'); + } + } + } + $this->view->loginForm = $loginForm; + } + } - public function registerAction() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Already logged in.', 'error'); - } else { - if (!isset($_POST["register"])){ - $registerForm = new user_Form_Register(); - } else { - foreach($_POST as $k => $v) { - if($v != '') { - $data[$k] = $v; - } - } - $registerForm = new user_Form_Register($data); - if ($registerForm->isValid($_POST)) { - $person = new Application_Model_Person($_POST); - $this->personmapper = new Application_Model_PersonMapper(); - $date = new DateTime(); - $person->setSuspend(0) - ->setRegisterdate($date->getTimestamp()) - ->setPasswordSalt(MD5($date->getTimestamp())) - ->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$')) - ->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); - try { - $this->personmapper->save($person); - }catch(Zend_Exception $e) - { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); - $this->view->registerForm = $registerForm; - return; - } - $this->_helper->redirector('login', 'auth'); - return; - } - } - $this->view->registerForm = $registerForm; - } - } + public function logoutAction() { + $this->_helper-> viewRenderer-> setNoRender(); + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_helper->redirector('login', 'auth'); + return; + } - public function deleteAction() - { - if($this->_request->getParam('personID')) { - if(!Pbs_Acl::checkRight('peoa')) { - $this->_redirect('/user'); - } - $personID = $this->_request->getParam('personID'); - } else { - if(!Pbs_Acl::checkRight('pdo')) { - $this->_redirect('/user'); - } - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - $personID = $userIDsNamespace['personID']; - } - if($_POST['confirmdelete']) { - if (isset($personID)){ - $this->personmapper = new Application_Model_PersonMapper(); - $person = $this->personmapper->find($personID); - print_r($person); - try { - $this->personmapper->delete($person); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - if($this->_request->getParam('personID')) { - $this->_helper->redirector('', 'person'); - } else { - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_helper->redirector('login', 'auth'); - } - return; - } - } else { - $deleteconfirmform = new user_Form_ConfirmDeleteAccount(); - $this->view->deleteconfirmform = $deleteconfirmform; - } - } + public function registerAction() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Already logged in.', 'error'); + } else { + if (!isset($_POST["register"])) { + $registerForm = new user_Form_Register(); + } else { + foreach($_POST as $k => $v) { + if($v != '') { + $data[$k] = $v; + } + } + $registerForm = new user_Form_Register($data); + if ($registerForm->isValid($_POST)) { + $person = new Application_Model_Person($_POST); + $this->personmapper = new Application_Model_PersonMapper(); + $date = new DateTime(); + $person->setSuspend(0) + ->setRegisterdate($date->getTimestamp()) + ->setPasswordSalt(MD5($date->getTimestamp())) + ->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$')) + ->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); + $this->view->registerForm = $registerForm; + return; + } + $this->_helper->redirector('login', 'auth'); + return; + } + } + $this->view->registerForm = $registerForm; + } + } - public function recoverpasswordAction() - { - if (isset($_POST["savePassword"])){ - $personID = $_POST['personID']; - $recoverPasswordForm = new user_Form_NewPassword(array("personID" => $personID, $_POST)); - if ($recoverPasswordForm->isValid($_POST)) { - $this->personmapper = new Application_Model_PersonMapper(); - $person = $this->personmapper->find($personID); - $date = new DateTime(); - $person->setPassword($_POST['password']) - ->setPasswordSalt(MD5($date->getTimestamp())) - ->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$')) - ->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); - try { - $this->personmapper->save($person); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - echo "Email Address already existing."; - return; - } - $this->_helper->redirector('login', 'auth'); - return; - } - } else if(isset($_GET['recoveryid'])) { - $recoveryid = $_GET['recoveryid']; - $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); - $passwordRecovery = $passwordRecoveryMapper->findBy(array("recoveryID" => $recoveryid),true); - if(count($passwordRecovery) > 0) { - $passwordRecoveryObject = new Application_Model_PasswordRecovery(); - $passwordRecoveryObject->setID($passwordRecovery[0]['personID']); - $passwordRecoveryObject->setRecoveryID($passwordRecovery[0]['recoveryID']); - $personID = $passwordRecoveryObject->getID(); - $recoverPasswordForm = new user_Form_NewPassword(array("personID" => $personID)); - try { - $passwordRecoveryMapper->delete($passwordRecoveryObject); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - } else { - $this->_helper->redirector('login', 'auth'); - return; - } - } else { - if (!isset($_POST["recoverPassword"])){ - $recoverPasswordForm = new user_Form_RecoverPassword(); - } else { - $recoverPasswordForm = new user_Form_RecoverPassword($_POST); - if ($recoverPasswordForm->isValid($_POST)) { - $recoverPasswordForm->getView()->url(); - $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy(array('email' => $_POST['email']),true); - $person = new Application_Model_Person($result[0]); - $person->setID($result[0]['personID']); - $email = $person->getEmail(); - $name = $person->getFirstname() . ' ' . $person->getName(); - $url = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->view->url(); - $recoveryid = randomString(100); - $mailbody = 'Um das Passwort zu ändern klicken Sie auf folgenden Link<br /><br /><a href="'. $url . '/auth/recoverpassword/?recoveryid='. $recoveryid . '">Passwort ändern</a>'; - $mail = new Zend_Mail(); - $mail->setBodyHtml($mailbody, 'utf8') - ->getBodyHtml()->getContent() - ->setFrom('admin@local', 'Admin') - ->addTo($email, $name) - ->setSubject('Password Wiederherstellung Preboot Server'); - $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); - $passwordRecoveryObject = new Application_Model_PasswordRecovery(); - $passwordRecoveryObject->setID($person->getID()) - ->setRecoveryID($recoveryid); - try { - $passwordRecoveryMapper->save($passwordRecoveryObject); - $mail->send(); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('login', 'auth'); - return; - } - } - } - $this->view->recoverPasswordForm = $recoverPasswordForm; - } + public function deleteAction() { + if($this->_request->getParam('personID')) { + if(!Pbs_Acl::checkRight('peoa')) { + $this->_redirect('/user'); + } + $personID = $this->_request->getParam('personID'); + } else { + if(!Pbs_Acl::checkRight('pdo')) { + $this->_redirect('/user'); + } + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $personID = $userIDsNamespace['personID']; + } + if($_POST['confirmdelete']) { + if (isset($personID)) { + $this->personmapper = new Application_Model_PersonMapper(); + $person = $this->personmapper->find($personID); + print_r($person); + try { + $this->personmapper->delete($person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + if($this->_request->getParam('personID')) { + $this->_helper->redirector('', 'person'); + } else { + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_helper->redirector('login', 'auth'); + } + return; + } + } else { + $deleteconfirmform = new user_Form_ConfirmDeleteAccount(); + $this->view->deleteconfirmform = $deleteconfirmform; + } + } + + public function recoverpasswordAction() { + if (isset($_POST["savePassword"])) { + $personID = $_POST['personID']; + $recoverPasswordForm = new user_Form_NewPassword(array("personID" => $personID, $_POST)); + if ($recoverPasswordForm->isValid($_POST)) { + $this->personmapper = new Application_Model_PersonMapper(); + $person = $this->personmapper->find($personID); + $date = new DateTime(); + $person->setPassword($_POST['password']) + ->setPasswordSalt(MD5($date->getTimestamp())) + ->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$')) + ->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing."; + return; + } + $this->_helper->redirector('login', 'auth'); + return; + } + } else if(isset($_GET['recoveryid'])) { + $recoveryid = $_GET['recoveryid']; + $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); + $passwordRecovery = $passwordRecoveryMapper->findBy(array("recoveryID" => $recoveryid), true); + if(count($passwordRecovery) > 0) { + $passwordRecoveryObject = new Application_Model_PasswordRecovery(); + $passwordRecoveryObject->setID($passwordRecovery[0]['personID']); + $passwordRecoveryObject->setRecoveryID($passwordRecovery[0]['recoveryID']); + $personID = $passwordRecoveryObject->getID(); + $recoverPasswordForm = new user_Form_NewPassword(array("personID" => $personID)); + try { + $passwordRecoveryMapper->delete($passwordRecoveryObject); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } else { + $this->_helper->redirector('login', 'auth'); + return; + } + } else { + if (!isset($_POST["recoverPassword"])) { + $recoverPasswordForm = new user_Form_RecoverPassword(); + } else { + $recoverPasswordForm = new user_Form_RecoverPassword($_POST); + if ($recoverPasswordForm->isValid($_POST)) { + $recoverPasswordForm->getView()->url(); + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => $_POST['email']), true); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $email = $person->getEmail(); + $name = $person->getFirstname() . ' ' . $person->getName(); + $url = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->view->url(); + $recoveryid = randomString(100); + $mailbody = 'Um das Passwort zu ändern klicken Sie auf folgenden Link<br /><br /><a href="'. $url . '/auth/recoverpassword/?recoveryid='. $recoveryid . '">Passwort ändern</a>'; + $mail = new Zend_Mail(); + $mail->setBodyHtml($mailbody, 'utf8') + ->getBodyHtml()->getContent() + ->setFrom('admin@local', 'Admin') + ->addTo($email, $name) + ->setSubject('Password Wiederherstellung Preboot Server'); + $passwordRecoveryMapper = new Application_Model_PasswordRecoveryMapper(); + $passwordRecoveryObject = new Application_Model_PasswordRecovery(); + $passwordRecoveryObject->setID($person->getID()) + ->setRecoveryID($recoveryid); + try { + $passwordRecoveryMapper->save($passwordRecoveryObject); + $mail->send(); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('login', 'auth'); + return; + } + } + } + $this->view->recoverPasswordForm = $recoverPasswordForm; + } } diff --git a/application/modules/user/controllers/BootisoController.php b/application/modules/user/controllers/BootisoController.php index f1cf37a..a5619f4 100644 --- a/application/modules/user/controllers/BootisoController.php +++ b/application/modules/user/controllers/BootisoController.php @@ -1,339 +1,330 @@ -<?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 user_BootisoController extends Zend_Controller_Action -{ - - protected $bootisoMapper; - protected $membershipMapper; - protected $membership; - protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $this->_redirect('/user/index'); - } - - $this->bootisoMapper = new Application_Model_BootIsoMapper(); - - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->db = Zend_Db_Table::getDefaultAdapter(); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('downloadresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('download',$result); - } - - - $groupMapper = new Application_Model_GroupMapper(); - - $groupID = $this->membership->getGroupID(); - - //ACL Darf er BootISOMenu sehen? - if(!Pbs_Acl::checkRight('bai') && !Pbs_Acl::checkRight('bui')) - $this->_redirect('/user/index'); - - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - - $parents = array(); - $this->view->bootisolist = array(); - $parents = $groupgroupsMapper->getParentGroups($groupID); - - foreach($parents as $k => $parent){ - foreach($parent as $p){ - $bootiso = $this->bootisoMapper->findBy(array("groupID" => $p)); - foreach ($bootiso as $b) - if($b->getPublic() - $k >= 0 ) - $this->view->bootisolist[] = $b; - elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('bc')) - $this->view->bootisolist[] = $b; - } - } - - $this->view->bootisolist = array_reverse($this->view->bootisolist); - - $prebootMapper = new Application_Model_PreBootMapper(); - $this->view->prebootlist = array(); - - foreach ($this->view->bootisolist as $bootiso){ - $bootiso->setPrebootID("[".$bootiso->getPrebootID()."] ".$prebootMapper->find($bootiso->getPrebootID())->getTitle()); - $bootiso->setGroupID("[".$bootiso->getGroupID()."] ".$groupMapper->find($bootiso->getGroupID())->getTitle()); - $bootiso->setCreated(date(Zend_Registry::get('dateformat'),$bootiso->getCreated())); - if($bootiso->getExpires() == ""){ - $bootiso->setExpires(0); - } - $bootiso->setExpires(date(Zend_Registry::get('dateformat'),$bootiso->getExpires())); - } - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('bootiso'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->bootisolist = $mySearch->search($this->view->bootisolist); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->view->bootisolist); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/bootiso/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $this->view->bootisolist = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - } - - public function searchAction(){ - $this->_redirect('/user/bootiso/index/search/'.($_GET['search'])); - } - - public function downloadbootisoAction() - { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - //ACL Darf er BootISOs downloaden? - if(!Pbs_Acl::checkRight('bdld')) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/forbidden'); - - $bootisoID = $this->_request->getParam('bootisoID'); - - if(!is_numeric($bootisoID)) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/forbidden'); - - $bootiso = $this->bootisoMapper->find($bootisoID); - $prebootID = $bootiso->getPrebootID(); - - if(!is_dir("../resources/bootmedium/$prebootID/")) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/404'); - - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/preboot.zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/tmp/serial", $bootiso->getSerialnumber()); - $zip->close(); - } - - chdir("../resources/bootmedium/$prebootID/"); - - header("X-Sendfile: preboot.zip"); - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="preboot.zip"'); - header('Pragma: no-cache'); - header('Expires: 0'); - - $handle = fopen("preboot.zip", 'r'); - $chunk_size = 8192; - while ($chunk = fread($handle, $chunk_size)) { - echo $chunk; - ob_flush(); - } - - } - - public function createbootisoAction() - { - //ACL Darf er BootISOs erstellen? - if(!Pbs_Acl::checkRight('bc')) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/addresult/forbidden'); - - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - $groupID = $this->membership->getGroupID(); - - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); - - $prebootMapper = new Application_Model_PreBootMapper(); - $prebootlist = $prebootMapper->findBy(array("groupID" => $groupID)); - if (!isset($_POST["createbootiso"])){ - $bootisoForm = new user_Form_Bootiso(array( - 'action' => 'createbootiso', - 'prebootlist' => $prebootlist, - 'groupdepth' => $childgroups, - 'page'=>$this->page)); - } else { - - $bootisoForm = new user_Form_Bootiso(array( - 'action' => 'createbootiso', - 'prebootlist' => $prebootlist, - 'groupdepth' => $childgroups, - 'page'=>$this->page),$_POST); - - if ($bootisoForm->isValid($_POST)) { - - $bootiso = new Application_Model_BootIso($_POST); - - $bootiso->setGroupID($this->membership->getGroupID()); - $bootiso->setCreated(time()); - - try { - $bootisoID = $this->bootisoMapper->save($bootiso); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/addresult/error'); - //TODO Delete File & delete bootiso from DB - - } - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/addresult/ok'); - } - } - - $this->view->bootisoForm = $bootisoForm; - } - - public function editbootisoAction() - { - //ACL Darf er BootISOs editieren? - if(!Pbs_Acl::checkRight('be') && !Pbs_Acl::checkRight('bem')) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); - - $bootisoID = $this->_request->getParam('bootisoID'); - if (!is_numeric($bootisoID)) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); - - $groupID = $this->membership->getGroupID(); - - $prebootMapper = new Application_Model_PreBootMapper(); - $prebootlist = $prebootMapper->findBy(array("groupID" => $groupID)); - - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); - - $bootiso = new Application_Model_BootIso(); - $this->bootisoMapper->find($bootisoID, $bootiso); - - if($this->membership->getGroupID() != $bootiso->getGroupID()) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); - - if (!isset($_POST["editbootiso"])){ - - $bootisoForm = new user_Form_Bootiso(array( - 'action' => 'editbootiso', - 'prebootlist' => $prebootlist, - 'groupdepth' => $childgroups, - 'page' => $this->page)); - $bootisoForm->populate($bootiso->toArray()); - - }else{ - $bootisoForm = new user_Form_Bootiso(array( - 'action' => 'editbootiso', - 'prebootlist' => $prebootlist, - 'groupdepth' => $childgroups, - 'page' => $this->page),$_POST); - - if ($bootisoForm->isValid($_POST)) { - - $bootisoold = $bootiso; - - $bootiso = new Application_Model_BootIso($_POST); - $bootiso->setGroupID($this->membership->getGroupID()); - $bootiso->setCreated(time()); - $bootiso->setID($bootisoID); - $prebootID = $bootiso->getPrebootID(); - - if( $bootiso->getPrebootID() != $bootisoold->getPrebootID() || - $bootiso->getExpires() != $bootisoold->getExpires() || - $bootiso->getPublic() != $bootisoold->getPublic() || - $bootiso->getSerialnumber() != $bootisoold->getSerialnumber()){ - //ACL Is he allowed to edit other than Metadata? - if(!Pbs_Acl::checkRight('be')) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); - } - - try { - - $this->bootisoMapper->save($bootiso); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/error'); - //TODO Redo Serial in Files... - } - - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/ok'); - } - - } - - $this->view->bootisoForm = $bootisoForm; - } - - public function deletebootisoAction() - { - //ACL Darf er BootISOs löschen? - if(!Pbs_Acl::checkRight('bd')) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/forbidden'); - - try{ - - $bootisoID = $this->_request->getParam('bootisoID'); - if (!is_numeric($bootisoID)) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/forbidden'); - - $bootiso = new Application_Model_BootIso(); - $this->bootisoMapper->find($bootisoID,$bootiso); - - if($this->membership->getGroupID() != $bootiso->getGroupID()) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/forbidden'); - - $this->bootisoMapper->delete($bootiso); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/ok'); - } +* 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 user_BootisoController extends Zend_Controller_Action { + + protected $bootisoMapper; + protected $membershipMapper; + protected $membership; + protected $page; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $this->_redirect('/user/index'); + } + + $this->bootisoMapper = new Application_Model_BootIsoMapper(); + + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + + $this->db = Zend_Db_Table::getDefaultAdapter(); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + $result = $this->_request->getParam('downloadresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('download', $result); + } + + + $groupMapper = new Application_Model_GroupMapper(); + + $groupID = $this->membership->getGroupID(); + + //ACL Darf er BootISOMenu sehen? + if(!Pbs_Acl::checkRight('bai') && !Pbs_Acl::checkRight('bui')) + { $this->_redirect('/user/index'); } + + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + + $parents = array(); + $this->view->bootisolist = array(); + $parents = $groupgroupsMapper->getParentGroups($groupID); + + foreach($parents as $k => $parent) { + foreach($parent as $p) { + $bootiso = $this->bootisoMapper->findBy(array("groupID" => $p)); + foreach ($bootiso as $b) + if($b->getPublic() - $k >= 0 ) + { $this->view->bootisolist[] = $b; } + elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('bc')) + $this->view->bootisolist[] = $b; + } + } + + $this->view->bootisolist = array_reverse($this->view->bootisolist); + + $prebootMapper = new Application_Model_PreBootMapper(); + $this->view->prebootlist = array(); + + foreach ($this->view->bootisolist as $bootiso) { + $bootiso->setPrebootID("[".$bootiso->getPrebootID()."] ".$prebootMapper->find($bootiso->getPrebootID())->getTitle()); + $bootiso->setGroupID("[".$bootiso->getGroupID()."] ".$groupMapper->find($bootiso->getGroupID())->getTitle()); + $bootiso->setCreated(date(Zend_Registry::get('dateformat'), $bootiso->getCreated())); + if($bootiso->getExpires() == "") { + $bootiso->setExpires(0); + } + $bootiso->setExpires(date(Zend_Registry::get('dateformat'), $bootiso->getExpires())); + } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('bootiso'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $this->view->bootisolist = $mySearch->search($this->view->bootisolist); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->view->bootisolist); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/bootiso/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $this->view->bootisolist = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + } + + public function searchAction() { + $this->_redirect('/user/bootiso/index/search/'.($_GET['search'])); + } + + public function downloadbootisoAction() { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + //ACL Darf er BootISOs downloaden? + if(!Pbs_Acl::checkRight('bdld')) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/forbidden'); } + + $bootisoID = $this->_request->getParam('bootisoID'); + + if(!is_numeric($bootisoID)) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/forbidden'); } + + $bootiso = $this->bootisoMapper->find($bootisoID); + $prebootID = $bootiso->getPrebootID(); + + if(!is_dir("../resources/bootmedium/$prebootID/")) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/404'); } + + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/preboot.zip"); + if($res == = true) { + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/tmp/serial", $bootiso->getSerialnumber()); + $zip->close(); + } + + chdir("../resources/bootmedium/$prebootID/"); + + header("X-Sendfile: preboot.zip"); + header('Content-Type: application/x-gzip'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="preboot.zip"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + $handle = fopen("preboot.zip", 'r'); + $chunk_size = 8192; + while ($chunk = fread($handle, $chunk_size)) { + echo $chunk; + ob_flush(); + } + + } + + public function createbootisoAction() { + //ACL Darf er BootISOs erstellen? + if(!Pbs_Acl::checkRight('bc')) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/addresult/forbidden'); } + + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + $groupID = $this->membership->getGroupID(); + + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); + + $prebootMapper = new Application_Model_PreBootMapper(); + $prebootlist = $prebootMapper->findBy(array("groupID" => $groupID)); + if (!isset($_POST["createbootiso"])) { + $bootisoForm = new user_Form_Bootiso(array( + 'action' => 'createbootiso', + 'prebootlist' => $prebootlist, + 'groupdepth' => $childgroups, + 'page' => $this->page)); + } else { + + $bootisoForm = new user_Form_Bootiso(array( + 'action' => 'createbootiso', + 'prebootlist' => $prebootlist, + 'groupdepth' => $childgroups, + 'page' => $this->page), $_POST); + + if ($bootisoForm->isValid($_POST)) { + + $bootiso = new Application_Model_BootIso($_POST); + + $bootiso->setGroupID($this->membership->getGroupID()); + $bootiso->setCreated(time()); + + try { + $bootisoID = $this->bootisoMapper->save($bootiso); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/addresult/error'); + //TODO Delete File & delete bootiso from DB + + } + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->bootisoForm = $bootisoForm; + } + + public function editbootisoAction() { + //ACL Darf er BootISOs editieren? + if(!Pbs_Acl::checkRight('be') && !Pbs_Acl::checkRight('bem')) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); } + + $bootisoID = $this->_request->getParam('bootisoID'); + if (!is_numeric($bootisoID)) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); } + + $groupID = $this->membership->getGroupID(); + + $prebootMapper = new Application_Model_PreBootMapper(); + $prebootlist = $prebootMapper->findBy(array("groupID" => $groupID)); + + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); + + $bootiso = new Application_Model_BootIso(); + $this->bootisoMapper->find($bootisoID, $bootiso); + + if($this->membership->getGroupID() != $bootiso->getGroupID()) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); } + + if (!isset($_POST["editbootiso"])) { + + $bootisoForm = new user_Form_Bootiso(array( + 'action' => 'editbootiso', + 'prebootlist' => $prebootlist, + 'groupdepth' => $childgroups, + 'page' => $this->page)); + $bootisoForm->populate($bootiso->toArray()); + + } else { + $bootisoForm = new user_Form_Bootiso(array( + 'action' => 'editbootiso', + 'prebootlist' => $prebootlist, + 'groupdepth' => $childgroups, + 'page' => $this->page), $_POST); + + if ($bootisoForm->isValid($_POST)) { + + $bootisoold = $bootiso; + + $bootiso = new Application_Model_BootIso($_POST); + $bootiso->setGroupID($this->membership->getGroupID()); + $bootiso->setCreated(time()); + $bootiso->setID($bootisoID); + $prebootID = $bootiso->getPrebootID(); + + if( $bootiso->getPrebootID() != $bootisoold->getPrebootID() || + $bootiso->getExpires() != $bootisoold->getExpires() || + $bootiso->getPublic() != $bootisoold->getPublic() || + $bootiso->getSerialnumber() != $bootisoold->getSerialnumber()) { + //ACL Is he allowed to edit other than Metadata? + if(!Pbs_Acl::checkRight('be')) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/forbidden'); } + } + + try { + + $this->bootisoMapper->save($bootiso); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/error'); + //TODO Redo Serial in Files... + } + + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/modifyresult/ok'); + } + + } + + $this->view->bootisoForm = $bootisoForm; + } + + public function deletebootisoAction() { + //ACL Darf er BootISOs löschen? + if(!Pbs_Acl::checkRight('bd')) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/forbidden'); } + + try { + + $bootisoID = $this->_request->getParam('bootisoID'); + if (!is_numeric($bootisoID)) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/forbidden'); } + + $bootiso = new Application_Model_BootIso(); + $this->bootisoMapper->find($bootisoID, $bootiso); + + if($this->membership->getGroupID() != $bootiso->getGroupID()) + { $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/forbidden'); } + + $this->bootisoMapper->delete($bootiso); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/error'); + } + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/ok'); + } } diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php index 3d6fbf1..33201ec 100644 --- a/application/modules/user/controllers/BootmenuController.php +++ b/application/modules/user/controllers/BootmenuController.php @@ -1,601 +1,587 @@ -<?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 user_BootmenuController extends Zend_Controller_Action -{ - - protected $bootmenuMapper; - protected $bootmenuentryMapper; - protected $membershipMapper; - protected $membership; - protected $page; - protected $type; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $this->_redirect('/user/index'); - } - - $this->bootmenuMapper = new Application_Model_BootMenuMapper(); - $this->bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper(); - - - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->db = Zend_Db_Table::getDefaultAdapter(); - - $this->type = $this->_request->getParam('type'); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('json'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('json',$result); - } - - - //ACL Darf er Bootmenus sehen? - if(!Pbs_Acl::checkRight('booai') && !Pbs_Acl::checkRight('booui')) - $this->_redirect('/user/index'); - - $this->bootMenumapper = new Application_Model_BootMenuMapper(); - $this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $bootosMapper = new Application_Model_BootOsMapper(); - $configMapper = new Application_Model_ConfigMapper(); - - $bootmenuentries = array(); - if($this->type =='group' && Pbs_Acl::checkRight('booai')){ - $this->view->type = 'group'; - $bootmenu = $this->bootmenuMapper->findBy(array('groupID' => $this->membership->getGroupID())); - foreach ($bootmenu as $bm){ - $bm->setCreated(date(Zend_Registry::get('dateformat'),$bm->getCreated())); - $bootmenuID = $bm->getID(); - $bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID)); - foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry){ - $kcl = $bootosMapper->find($bootmenuentry->getBootosID())->getDefaultkcl(); - if($bootmenuentry->getKcl() && $kcl != null) - $bootmenuentry->setKcl($kcl); - else - $bootmenuentry->setKcl("deactivated (edit Bootmenuentry to activate)"); - if($bootmenuentry->getKclappend() == null) - $bootmenuentry->setKclappend("none (edit Bootmenuentry to set KCL-Append)"); - $bootmenuentry->setBootosID("[".$bootmenuentry->getBootosID()."] ".$bootosMapper->find($bootmenuentry->getBootosID())->getTitle()); - if($bootmenuentry->getConfigID() != null) - $bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->getTitle()); - } - } - }else{ - $this->view->type = 'own'; - $bootmenu = $this->bootmenuMapper->findBy(array('membershipID' => $this->membership->getID())); - if($bootmenu != null){ - $bootmenu[0]->setCreated(date(Zend_Registry::get('dateformat'),$bootmenu[0]->getCreated())); - $bootmenuID = $bootmenu[0]->getID(); - $bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID)); - foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry){ - $kcl = $bootosMapper->find($bootmenuentry->getBootosID())->getDefaultkcl(); - if($bootmenuentry->getKcl() && $kcl != null) - $bootmenuentry->setKcl($kcl); - else - $bootmenuentry->setKcl("deactivated (edit Bootmenuentry to activate)"); - if($bootmenuentry->getKclappend() == null) - $bootmenuentry->setKclappend("none"); - $bootmenuentry->setBootosID("[".$bootmenuentry->getBootosID()."] ".$bootosMapper->find($bootmenuentry->getBootosID())->getTitle()); - if($bootmenuentry->getConfigID() != null) - $bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->gettitle()); - } - } - } - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setType($this->type); - $mySearch->setModule('bootmenu'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $bootmenu = $mySearch->search($bootmenu); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($bootmenu); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/bootmenu/index/type/'.$this->type.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $bootmenu = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - - $this->view->bootmenulist = $bootmenu; - $this->view->bootmenuentrylist = $bootmenuentries; - - } - - public function searchAction(){ - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/search/'.($_GET['search'])); - } - - - public function createbootmenuAction() - { - //ACL Darf er BootMenus erstellen? - if(!Pbs_Acl::checkRight('booc')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); - - if (!isset($_POST["createbootmenu"])){ - $bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu','page' => $this->page, 'type'=>$this->type)); - } else { - - $bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu','page' => $this->page, 'type'=>$this->type),$_POST); - - if ($bootmenuForm->isValid($_POST)) { - - $bootmenu = new Application_Model_BootMenu($_POST); - $bootmenu->setCreated(time()); - $bootmenu->setGroupID($this->membership->getGroupID()); - $bootmenu->setDefaultbootmenu('0'); - - try{ - $this->bootmenuMapper->save($bootmenu); - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); - } - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); - } - } - - $this->view->bootmenuForm = $bootmenuForm; - } - - public function editbootmenuAction() - { - - //ACL Is he allowed to edit BootMenus? - if(!Pbs_Acl::checkRight('booe')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - - $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!is_numeric($bootmenuID)) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - - $bootmenu = new Application_Model_BootMenu(); - $this->bootmenuMapper->find($bootmenuID, $bootmenu); - - if($this->membership->getGroupID() != $bootmenu->getGroupID()) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - - if (!isset($_POST["editbootmenu"])){ - - $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu','page' => $this->page, 'type'=>$this->type)); - $bootmenuForm->populate($bootmenu->toArray()); - - }else{ - $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu','page' => $this->page, 'type'=>$this->type),$_POST); - - if ($bootmenuForm->isValid($_POST)) { - - $bootmenuold = $bootmenu; - - $bootmenu = new Application_Model_BootMenu($_POST); - $bootmenu->setGroupID($this->membership->getGroupID()); - $bootmenu->setCreated(time()); - $bootmenu->setID($bootmenuID); - $bootmenu->setDefaultbootmenu($bootmenuold->getDefaultbootmenu()); - print_a($bootmenu); - try { - $this->bootmenuMapper->save($bootmenu); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - } - - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); - } - - } - - $this->view->bootmenuForm = $bootmenuForm; - } - - public function deletebootmenuAction() - { - - //ACL Is he allowed to delete Bootmenu? - if(!Pbs_Acl::checkRight('bood')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - - try{ - $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!is_numeric($bootmenuID)) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - - $bootmenu = new Application_Model_BootMenu(); - $this->bootmenuMapper->find($bootmenuID, $bootmenu); - - if($this->membership->getGroupID() != $bootmenu->getGroupID()) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - - $this->bootmenuMapper->delete($bootmenu); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); - } - - public function defaultbootmenuAction() - { - - //ACL Is he allowed to set Bootmenu as Default? - if(!Pbs_Acl::checkRight('boodbm')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - - try{ - $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!is_numeric($bootmenuID)) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $bootmenu = new Application_Model_BootMenu(); - - $this->bootmenuMapper->find($bootmenuID, $bootmenu); - - if($bootmenu->getDefaultbootmenu() == false){ - - list($defaultbootmenu) = $this->bootmenuMapper->findBy(array('defaultbootmenu' => '1')); - if($defaultbootmenu != null){ - $defaultbootmenu->setDefaultbootmenu(false); - $this->bootmenuMapper->save($defaultbootmenu); - } - $bootmenu->setDefaultbootmenu(true); - $this->bootmenuMapper->save($bootmenu); - } - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - } - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); - - } - - public function addbootmenuentryAction() - { - - //ACL Darf er BootMenuEntries erstellen? - if(!Pbs_Acl::checkRight('booae') && !Pbs_Acl::checkRight('booaeo')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); - - $bootmenuID = $this->_request->getParam('bootmenuID'); - $maxorder = $this->_request->getParam('maxorder'); - - if (!is_numeric($bootmenuID) || !is_numeric($maxorder)) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $bootosMapper = new Application_Model_BootOsMapper(); - $configMapper = new Application_Model_ConfigMapper(); - $groupMapper = new Application_Model_GroupMapper(); - - $groupID = $this->membership->getGroupID(); - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - - $parents = array(); - $bootoslist = array(); - $parents = $groupgroupsMapper->getParentGroups($groupID); - - $configlist = array('Preset' => array(), 'Custom' => Array()); - - foreach($parents as $k => $parent){ - foreach($parent as $p){ - $bootos = $bootosMapper->findBy(array("groupID" => $p)); - foreach ($bootos as $b) - if($b->getPublic() - $k >= 0 ){ - $grouptitle = $groupMapper->find($p)->getTitle(); - $bootoslist[$b->getID()] = $b; - $bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle(); - $configlist['Preset'][$b->getID()] = $configMapper->findBy(array('bootosID' => $b->getID(), 'visible' => '1')); - $configlist['Custom'][$b->getID()] = $configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $b->getID(), 'visible' => '1')); - } - } - } - - - - - $bootmenu = new Application_Model_BootMenu(); - $this->bootmenuMapper->find($bootmenuID, $bootmenu); - - if($bootmenu->getMembershipID() != null){ - if($this->membership->getID() != $bootmenu->getMembershipID() || !Pbs_Acl::checkRight('booaeo')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $bootmenu->getGroupID() || !Pbs_Acl::checkRight('booae')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); - } - - if (!isset($_POST["addbootmenuentry"])){ - - if(!isset($_POST['kcl'])) - $_POST['kcl'] = true; - - $bootmenuentryForm = new user_Form_BootmenuEntries(array( - 'bootoslist'=> $bootoslist, - 'bootosanzeige' => $bootosanzeige, - 'maxorder'=> $maxorder, - 'configlist'=> $configlist, - 'page' => $this->page, - 'type' => $this->type, - 'action' => 'addbootmenuentry', - )); - - $bootmenuentryForm->populate(array('order' => $maxorder)); - unset($_POST['defaultkcl']); - unset($_POST['configID']); - $bootmenuentryForm->populate($_POST); - - } else { - - $bootmenuentryForm = new user_Form_BootmenuEntries(array( - 'bootoslist'=>$bootoslist, - 'bootosanzeige' => $bootosanzeige, - 'maxorder'=> $maxorder, - 'configlist'=>$configlist, - 'page' => $this->page, - 'type' => $this->type, - 'action' => 'addbootmenuentry', - ),$_POST); - - if ($bootmenuentryForm->isValid($_POST)) { - - $bootmenuentry = new Application_Model_BootMenuEntries($_POST); - $bootmenuentry->setBootmenuID($bootmenuID); - - try { - if($bootmenuentry->getOrder() < $maxorder){ - $bootmenuentry->setOrder($bootmenuentry->getOrder()); - $this->bootmenuentryMapper->order($bootmenuentry); - } - - //print_a($bootmenuentry); - - $this->bootmenuentryMapper->save($bootmenuentry); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); - - } - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); - } - } - - $this->view->bootmenuentryForm = $bootmenuentryForm; - - } - - public function editbootmenuentryAction() - { - //ACL Is he allowed to edit BootMenus? - if(!Pbs_Acl::checkRight('booee') && !Pbs_Acl::checkRight('booeem') && !Pbs_Acl::checkRight('booeeo')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - $maxorder = $this->_request->getParam('maxorder'); - $oldorder = $this->_request->getParam('oldorder'); - if (!is_numeric($bootmenuentryID) || !is_numeric($maxorder) || !is_numeric($oldorder)) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $bootosMapper = new Application_Model_BootOsMapper(); - $configMapper = new Application_Model_ConfigMapper(); - - $groupID = $this->membership->getGroupID(); - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - $groupMapper = new Application_Model_GroupMapper(); - - $parents = array(); - $bootoslist = array(); - $parents = $groupgroupsMapper->getParentGroups($groupID); - - foreach($parents as $k => $parent){ - foreach($parent as $p){ - $bootos = $bootosMapper->findBy(array("groupID" => $p)); - foreach ($bootos as $b) - if($b->getPublic() - $k >= 0 ){ - $grouptitle = $groupMapper->find($p)->getTitle(); - $bootoslist[$b->getID()] = $b; - $bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle(); - $configlist['Preset'][$b->getID()] = $configMapper->findBy(array('bootosID' => $b->getID(), 'visible' => '1')); - $configlist['Custom'][$b->getID()] = $configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $b->getID(), 'visible' => '1')); - - } - } - } - - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenu = new Application_Model_BootMenu(); - $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); - $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu); - - if($bootmenu->getMembershipID() != null){ - if($this->membership->getID() != $bootmenu->getMembershipID() || !Pbs_Acl::checkRight('booeeo')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $bootmenu->getGroupID() || (!Pbs_Acl::checkRight('booee') && !Pbs_Acl::checkRight('booeem'))) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - } - - $neworder = $this->_request->getParam('neworder'); - if($neworder != ''){ - if($neworder == 'undefined') - $neworder = $maxorder-1; - - $_POST = array( - 'title' => $bootmenuentry->getTitle(), - 'bootosID' => $bootmenuentry->getBootosID(), - 'kcl' => $bootmenuentry->getKcl(), - 'kclappend' => $bootmenuentry->getKclappend(), - 'configID' => $bootmenuentry->getConfigID(), - 'order' => $neworder, - 'editbootmenuentry' => 'Edit Bootmenuentry', - ); - } - - if (!isset($_POST["editbootmenuentry"])){ - if(!isset($_POST['bootosID'])) - $_POST['bootosID'] = $bootmenuentry->getBootosID(); - if(!isset($_POST['kcl'])) - $_POST['kcl'] = $bootmenuentry->getKcl(); - - $bootmenuentryForm = new user_Form_BootmenuEntries(array( - 'bootoslist'=> $bootoslist, - 'bootosanzeige' => $bootosanzeige, - 'maxorder'=> $maxorder-1, - 'configlist'=> $configlist, - 'page' => $this->page, - 'type' => $this->type, - 'action' => 'editbootmenuentry', - )); - - if(!isset($_POST['configID'])){ - $bootmenuentryForm->populate($bootmenuentry->toArray()); - } - else{ - unset($_POST['defaultkcl']); - unset($_POST['configID']); - $bootmenuentryForm->populate($_POST); - } - - }else{ - $bootmenuentryForm = new user_Form_BootmenuEntries(array( - 'bootoslist'=> $bootoslist, - 'bootosanzeige' => $bootosanzeige, - 'maxorder'=> $maxorder-1, - 'configlist'=> $configlist, - 'page' => $this->page, - 'type' => $this->type, - 'action' => 'editbootmenuentry'),$_POST); - - if ($bootmenuentryForm->isValid($_POST)) { - - $bootmenuentryold= $bootmenuentry; - - $bootmenuentry = new Application_Model_BootMenuEntries($_POST); - $bootmenuentry->setBootmenuID($bootmenu->getID()); - $bootmenuentry->setID($bootmenuentryID); - - if( $bootmenuentryold->getBootosID() != $bootmenuentry->getBootosID() || - $bootmenuentryold->getConfigID() != $bootmenuentry->getConfigID() || - $bootmenuentryold->getKcl() != $bootmenuentry->getKcl() || - $bootmenuentryold->getKclappend() != $bootmenuentry->getKclappend()){ - //ACL Is he allowed to edit this? - if(!Pbs_Acl::checkRight('booee') && !Pbs_Acl::checkRight('booeeo')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - } - - try { - if($bootmenuentry->getOrder() < $oldorder) - $this->bootmenuentryMapper->orderbefore($bootmenuentry, $oldorder); - else - $this->bootmenuentryMapper->orderafter($bootmenuentry, $oldorder); - - $this->bootmenuentryMapper->save($bootmenuentry); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - } - - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); - } - - } - - $this->view->bootmenuentryForm = $bootmenuentryForm; - - } - - public function removebootmenuentryAction() - { - //ACL Is he allowed to delete Bootos? - if(!Pbs_Acl::checkRight('boode') && !Pbs_Acl::checkRight('boodeo')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - - try{ - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - if (!is_numeric($bootmenuentryID)) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenu = new Application_Model_BootMenu(); - $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); - $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu); - - if($bootmenu->getMembershipID() != null){ - if($this->membership->getID() != $bootmenu->getMembershipID() || !Pbs_Acl::checkRight('boodeo')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $bootmenu->getGroupID() || !Pbs_Acl::checkRight('boode')) - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - } - - $this->bootmenuentryMapper->delete($bootmenuentry); - $this->bootmenuentryMapper->orderremove($bootmenuentry); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); - } +* 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 user_BootmenuController extends Zend_Controller_Action { + + protected $bootmenuMapper; + protected $bootmenuentryMapper; + protected $membershipMapper; + protected $membership; + protected $page; + protected $type; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $this->_redirect('/user/index'); + } + + $this->bootmenuMapper = new Application_Model_BootMenuMapper(); + $this->bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper(); + + + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + + $this->db = Zend_Db_Table::getDefaultAdapter(); + + $this->type = $this->_request->getParam('type'); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + $result = $this->_request->getParam('json'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('json', $result); + } + + + //ACL Darf er Bootmenus sehen? + if(!Pbs_Acl::checkRight('booai') && !Pbs_Acl::checkRight('booui')) + { $this->_redirect('/user/index'); } + + $this->bootMenumapper = new Application_Model_BootMenuMapper(); + $this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $bootosMapper = new Application_Model_BootOsMapper(); + $configMapper = new Application_Model_ConfigMapper(); + + $bootmenuentries = array(); + if($this->type == 'group' && Pbs_Acl::checkRight('booai')) { + $this->view->type = 'group'; + $bootmenu = $this->bootmenuMapper->findBy(array('groupID' => $this->membership->getGroupID())); + foreach ($bootmenu as $bm) { + $bm->setCreated(date(Zend_Registry::get('dateformat'), $bm->getCreated())); + $bootmenuID = $bm->getID(); + $bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID)); + foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry) { + $kcl = $bootosMapper->find($bootmenuentry->getBootosID())->getDefaultkcl(); + if($bootmenuentry->getKcl() && $kcl != null) + { $bootmenuentry->setKcl($kcl); } + else + { $bootmenuentry->setKcl("deactivated (edit Bootmenuentry to activate)"); } + if($bootmenuentry->getKclappend() == null) + { $bootmenuentry->setKclappend("none (edit Bootmenuentry to set KCL-Append)"); } + $bootmenuentry->setBootosID("[".$bootmenuentry->getBootosID()."] ".$bootosMapper->find($bootmenuentry->getBootosID())->getTitle()); + if($bootmenuentry->getConfigID() != null) + { $bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->getTitle()); } + } + } + } else { + $this->view->type = 'own'; + $bootmenu = $this->bootmenuMapper->findBy(array('membershipID' => $this->membership->getID())); + if($bootmenu != null) { + $bootmenu[0]->setCreated(date(Zend_Registry::get('dateformat'), $bootmenu[0]->getCreated())); + $bootmenuID = $bootmenu[0]->getID(); + $bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID)); + foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry) { + $kcl = $bootosMapper->find($bootmenuentry->getBootosID())->getDefaultkcl(); + if($bootmenuentry->getKcl() && $kcl != null) + { $bootmenuentry->setKcl($kcl); } + else + { $bootmenuentry->setKcl("deactivated (edit Bootmenuentry to activate)"); } + if($bootmenuentry->getKclappend() == null) + { $bootmenuentry->setKclappend("none"); } + $bootmenuentry->setBootosID("[".$bootmenuentry->getBootosID()."] ".$bootosMapper->find($bootmenuentry->getBootosID())->getTitle()); + if($bootmenuentry->getConfigID() != null) + { $bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->gettitle()); } + } + } + } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setType($this->type); + $mySearch->setModule('bootmenu'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $bootmenu = $mySearch->search($bootmenu); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($bootmenu); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/bootmenu/index/type/'.$this->type.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $bootmenu = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + + $this->view->bootmenulist = $bootmenu; + $this->view->bootmenuentrylist = $bootmenuentries; + + } + + public function searchAction() { + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/search/'.($_GET['search'])); + } + + + public function createbootmenuAction() { + //ACL Darf er BootMenus erstellen? + if(!Pbs_Acl::checkRight('booc')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); } + + if (!isset($_POST["createbootmenu"])) { + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu', 'page' => $this->page, 'type' => $this->type)); + } else { + + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu', 'page' => $this->page, 'type' => $this->type), $_POST); + + if ($bootmenuForm->isValid($_POST)) { + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setCreated(time()); + $bootmenu->setGroupID($this->membership->getGroupID()); + $bootmenu->setDefaultbootmenu('0'); + + try { + $this->bootmenuMapper->save($bootmenu); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); + } + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->bootmenuForm = $bootmenuForm; + } + + public function editbootmenuAction() { + + //ACL Is he allowed to edit BootMenus? + if(!Pbs_Acl::checkRight('booe')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!is_numeric($bootmenuID)) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuMapper->find($bootmenuID, $bootmenu); + + if($this->membership->getGroupID() != $bootmenu->getGroupID()) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + + if (!isset($_POST["editbootmenu"])) { + + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'page' => $this->page, 'type' => $this->type)); + $bootmenuForm->populate($bootmenu->toArray()); + + } else { + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'page' => $this->page, 'type' => $this->type), $_POST); + + if ($bootmenuForm->isValid($_POST)) { + + $bootmenuold = $bootmenu; + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setGroupID($this->membership->getGroupID()); + $bootmenu->setCreated(time()); + $bootmenu->setID($bootmenuID); + $bootmenu->setDefaultbootmenu($bootmenuold->getDefaultbootmenu()); + print_a($bootmenu); + try { + $this->bootmenuMapper->save($bootmenu); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + } + + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); + } + + } + + $this->view->bootmenuForm = $bootmenuForm; + } + + public function deletebootmenuAction() { + + //ACL Is he allowed to delete Bootmenu? + if(!Pbs_Acl::checkRight('bood')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + + try { + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!is_numeric($bootmenuID)) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuMapper->find($bootmenuID, $bootmenu); + + if($this->membership->getGroupID() != $bootmenu->getGroupID()) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + + $this->bootmenuMapper->delete($bootmenu); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); + } + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); + } + + public function defaultbootmenuAction() { + + //ACL Is he allowed to set Bootmenu as Default? + if(!Pbs_Acl::checkRight('boodbm')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + + try { + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!is_numeric($bootmenuID)) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); } + + $bootmenu = new Application_Model_BootMenu(); + + $this->bootmenuMapper->find($bootmenuID, $bootmenu); + + if($bootmenu->getDefaultbootmenu() == false) { + + list($defaultbootmenu) = $this->bootmenuMapper->findBy(array('defaultbootmenu' => '1')); + if($defaultbootmenu != null) { + $defaultbootmenu->setDefaultbootmenu(false); + $this->bootmenuMapper->save($defaultbootmenu); + } + $bootmenu->setDefaultbootmenu(true); + $this->bootmenuMapper->save($bootmenu); + } + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + } + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); + + } + + public function addbootmenuentryAction() { + + //ACL Darf er BootMenuEntries erstellen? + if(!Pbs_Acl::checkRight('booae') && !Pbs_Acl::checkRight('booaeo')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); } + + $bootmenuID = $this->_request->getParam('bootmenuID'); + $maxorder = $this->_request->getParam('maxorder'); + + if (!is_numeric($bootmenuID) || !is_numeric($maxorder)) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); } + + $bootosMapper = new Application_Model_BootOsMapper(); + $configMapper = new Application_Model_ConfigMapper(); + $groupMapper = new Application_Model_GroupMapper(); + + $groupID = $this->membership->getGroupID(); + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + + $parents = array(); + $bootoslist = array(); + $parents = $groupgroupsMapper->getParentGroups($groupID); + + $configlist = array('Preset' => array(), 'Custom' => Array()); + + foreach($parents as $k => $parent) { + foreach($parent as $p) { + $bootos = $bootosMapper->findBy(array("groupID" => $p)); + foreach ($bootos as $b) + if($b->getPublic() - $k >= 0 ) { + $grouptitle = $groupMapper->find($p)->getTitle(); + $bootoslist[$b->getID()] = $b; + $bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle(); + $configlist['Preset'][$b->getID()] = $configMapper->findBy(array('bootosID' => $b->getID(), 'visible' => '1')); + $configlist['Custom'][$b->getID()] = $configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $b->getID(), 'visible' => '1')); + } + } + } + + + + + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuMapper->find($bootmenuID, $bootmenu); + + if($bootmenu->getMembershipID() != null) { + if($this->membership->getID() != $bootmenu->getMembershipID() || !Pbs_Acl::checkRight('booaeo')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); } + } else { + if($this->membership->getGroupID() != $bootmenu->getGroupID() || !Pbs_Acl::checkRight('booae')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); } + } + + if (!isset($_POST["addbootmenuentry"])) { + + if(!isset($_POST['kcl'])) + { $_POST['kcl'] = true; } + + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist' => $bootoslist, + 'bootosanzeige' => $bootosanzeige, + 'maxorder' => $maxorder, + 'configlist' => $configlist, + 'page' => $this->page, + 'type' => $this->type, + 'action' => 'addbootmenuentry', + )); + + $bootmenuentryForm->populate(array('order' => $maxorder)); + unset($_POST['defaultkcl']); + unset($_POST['configID']); + $bootmenuentryForm->populate($_POST); + + } else { + + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist' => $bootoslist, + 'bootosanzeige' => $bootosanzeige, + 'maxorder' => $maxorder, + 'configlist' => $configlist, + 'page' => $this->page, + 'type' => $this->type, + 'action' => 'addbootmenuentry', + ), $_POST); + + if ($bootmenuentryForm->isValid($_POST)) { + + $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentry->setBootmenuID($bootmenuID); + + try { + if($bootmenuentry->getOrder() < $maxorder) { + $bootmenuentry->setOrder($bootmenuentry->getOrder()); + $this->bootmenuentryMapper->order($bootmenuentry); + } + + //print_a($bootmenuentry); + + $this->bootmenuentryMapper->save($bootmenuentry); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); + + } + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->bootmenuentryForm = $bootmenuentryForm; + + } + + public function editbootmenuentryAction() { + //ACL Is he allowed to edit BootMenus? + if(!Pbs_Acl::checkRight('booee') && !Pbs_Acl::checkRight('booeem') && !Pbs_Acl::checkRight('booeeo')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + $maxorder = $this->_request->getParam('maxorder'); + $oldorder = $this->_request->getParam('oldorder'); + if (!is_numeric($bootmenuentryID) || !is_numeric($maxorder) || !is_numeric($oldorder)) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); } + + $bootosMapper = new Application_Model_BootOsMapper(); + $configMapper = new Application_Model_ConfigMapper(); + + $groupID = $this->membership->getGroupID(); + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + $groupMapper = new Application_Model_GroupMapper(); + + $parents = array(); + $bootoslist = array(); + $parents = $groupgroupsMapper->getParentGroups($groupID); + + foreach($parents as $k => $parent) { + foreach($parent as $p) { + $bootos = $bootosMapper->findBy(array("groupID" => $p)); + foreach ($bootos as $b) + if($b->getPublic() - $k >= 0 ) { + $grouptitle = $groupMapper->find($p)->getTitle(); + $bootoslist[$b->getID()] = $b; + $bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle(); + $configlist['Preset'][$b->getID()] = $configMapper->findBy(array('bootosID' => $b->getID(), 'visible' => '1')); + $configlist['Custom'][$b->getID()] = $configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $b->getID(), 'visible' => '1')); + + } + } + } + + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); + $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu); + + if($bootmenu->getMembershipID() != null) { + if($this->membership->getID() != $bootmenu->getMembershipID() || !Pbs_Acl::checkRight('booeeo')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + } else { + if($this->membership->getGroupID() != $bootmenu->getGroupID() || (!Pbs_Acl::checkRight('booee') && !Pbs_Acl::checkRight('booeem'))) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + } + + $neworder = $this->_request->getParam('neworder'); + if($neworder != '') { + if($neworder == 'undefined') + { $neworder = $maxorder - 1; } + + $_POST = array( + 'title' => $bootmenuentry->getTitle(), + 'bootosID' => $bootmenuentry->getBootosID(), + 'kcl' => $bootmenuentry->getKcl(), + 'kclappend' => $bootmenuentry->getKclappend(), + 'configID' => $bootmenuentry->getConfigID(), + 'order' => $neworder, + 'editbootmenuentry' => 'Edit Bootmenuentry', + ); + } + + if (!isset($_POST["editbootmenuentry"])) { + if(!isset($_POST['bootosID'])) + { $_POST['bootosID'] = $bootmenuentry->getBootosID(); } + if(!isset($_POST['kcl'])) + { $_POST['kcl'] = $bootmenuentry->getKcl(); } + + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist' => $bootoslist, + 'bootosanzeige' => $bootosanzeige, + 'maxorder' => $maxorder - 1, + 'configlist' => $configlist, + 'page' => $this->page, + 'type' => $this->type, + 'action' => 'editbootmenuentry', + )); + + if(!isset($_POST['configID'])) { + $bootmenuentryForm->populate($bootmenuentry->toArray()); + } else { + unset($_POST['defaultkcl']); + unset($_POST['configID']); + $bootmenuentryForm->populate($_POST); + } + + } else { + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist' => $bootoslist, + 'bootosanzeige' => $bootosanzeige, + 'maxorder' => $maxorder - 1, + 'configlist' => $configlist, + 'page' => $this->page, + 'type' => $this->type, + 'action' => 'editbootmenuentry'), $_POST); + + if ($bootmenuentryForm->isValid($_POST)) { + + $bootmenuentryold = $bootmenuentry; + + $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentry->setBootmenuID($bootmenu->getID()); + $bootmenuentry->setID($bootmenuentryID); + + if( $bootmenuentryold->getBootosID() != $bootmenuentry->getBootosID() || + $bootmenuentryold->getConfigID() != $bootmenuentry->getConfigID() || + $bootmenuentryold->getKcl() != $bootmenuentry->getKcl() || + $bootmenuentryold->getKclappend() != $bootmenuentry->getKclappend()) { + //ACL Is he allowed to edit this? + if(!Pbs_Acl::checkRight('booee') && !Pbs_Acl::checkRight('booeeo')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + } + + try { + if($bootmenuentry->getOrder() < $oldorder) + { $this->bootmenuentryMapper->orderbefore($bootmenuentry, $oldorder); } + else + { $this->bootmenuentryMapper->orderafter($bootmenuentry, $oldorder); } + + $this->bootmenuentryMapper->save($bootmenuentry); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + + } + + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); + } + + } + + $this->view->bootmenuentryForm = $bootmenuentryForm; + + } + + public function removebootmenuentryAction() { + //ACL Is he allowed to delete Bootos? + if(!Pbs_Acl::checkRight('boode') && !Pbs_Acl::checkRight('boodeo')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + + try { + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + if (!is_numeric($bootmenuentryID)) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); + $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu); + + if($bootmenu->getMembershipID() != null) { + if($this->membership->getID() != $bootmenu->getMembershipID() || !Pbs_Acl::checkRight('boodeo')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + } else { + if($this->membership->getGroupID() != $bootmenu->getGroupID() || !Pbs_Acl::checkRight('boode')) + { $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + } + + $this->bootmenuentryMapper->delete($bootmenuentry); + $this->bootmenuentryMapper->orderremove($bootmenuentry); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); + } + $this->_redirect('/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); + } } diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index f7fad49..c428937 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -1,354 +1,346 @@ -<?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 user_BootosController extends Zend_Controller_Action -{ - - protected $bootosMapper; - protected $membershipMapper; - protected $membership; - protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $this->_redirect('/user/index'); - } - - $this->bootosMapper = new Application_Model_BootOsMapper(); - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->db = Zend_Db_Table::getDefaultAdapter(); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('updateresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('update',$result); - } - - $groupID = $this->membership->getGroupID(); - - //ACL Darf er BootOs sehen? - if(!Pbs_Acl::checkRight('boai') && !Pbs_Acl::checkRight('boui')) - $this->_redirect('/user/index'); - - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - - $parents = array(); - $this->view->bootoslist = array(); - $parents = $groupgroupsMapper->getParentGroups($groupID); - - foreach($parents as $k => $parent){ - foreach($parent as $p){ - $bootos = $this->bootosMapper->findBy(array("groupID" => $p)); - foreach ($bootos as $b) - if($b->getPublic() - $k >= 0 ) - $this->view->bootoslist[] = $b; - elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('boc')) - $this->view->bootoslist[] = $b; - } - } - - $this->view->bootoslist = array_reverse($this->view->bootoslist); - $this->view->resources = array(); - - $groupMapper = new Application_Model_GroupMapper(); - - if(count($this->view->bootoslist)>0){ - foreach ($this->view->bootoslist as $bootos){ - if($bootos->getDefaultkcl() == null) - $bootos->setDefaultkcl("none (edit Bootos to set KCL)"); - $this->view->resources[$bootos->getID()]['kernel'] = is_file("../resources/bootos/".$bootos->getID()."/kernel/kernel"); - $this->view->resources[$bootos->getID()]['initramfs'] = is_file("../resources/bootos/".$bootos->getID()."/initramfs/initramfs"); - $this->view->resources[$bootos->getID()]['config'] = is_file("../resources/bootos/".$bootos->getID()."/config/default.tgz"); - $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); - $bootos->setCreated(date(Zend_Registry::get('dateformat'),$bootos->getCreated())); - $bootos->setExpires(date(Zend_Registry::get('dateformat'),$bootos->getExpires())); - } - } - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('bootos'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->bootoslist = $mySearch->search($this->view->bootoslist); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->view->bootoslist); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/bootos/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $this->view->bootoslist = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - - } - public function searchAction(){ - $this->_redirect('/user/bootos/index/search/'.($_GET['search'])); - } - - public function createbootosAction() - { - - //ACL Darf er BootISOs erstellen? - if(!Pbs_Acl::checkRight('boc')) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/forbidden'); - - $groupID = $this->membership->getGroupID(); - - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); - - if (!isset($_POST["createbootos"])){ - $bootosForm = new user_Form_Bootos(array( - 'action' => 'createbootos', - 'groupdepth' => $childgroups, - 'page' => $this->page)); - } else { - - $bootosForm = new user_Form_Bootos(array( - 'action' => 'createbootos', - 'groupdepth' => $childgroups, - 'page' => $this->page),$_POST); - - if ($bootosForm->isValid($_POST)) { - - $bootos = new Application_Model_BootOs($_POST); - - $bootos->setGroupID($this->membership->getGroupID()); - $bootos->setCreated(time()); - $bootos->setSource($_SERVER['REMOTE_ADDR']); - - try { - - $bootosID = $this->bootosMapper->save($bootos); - $bootos->setID($bootosID); - - if( $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != '' || - $_FILES['init']['size'] == 0 && $_FILES['init']['name'] != '' || - $_FILES['config']['size'] == 0 && $_FILES['config']['name'] != '' ){ - $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/file'); - } - - $initpath = "../resources/bootos/".$bootosID."/initramfs/"; - $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; - $configpath = "../resources/bootos/".$bootosID."/config/"; - - mkdir($initpath ,0777, true); - mkdir($kernelpath ,0777, true); - mkdir($configpath ,0777, true); - - if($_FILES['kernel']['name'] != ''){ - move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel"); - } - if($_FILES['init']['name'] != ''){ - move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs"); - } - if($_FILES['config']['name'] != ''){ - move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz"); - $newconfig = new Pbs_NewConfig(); - $newconfig->createDefaultConfig($bootos); - } - - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/error'); - //TODO Delete File & delete bootiso from DB - - } - - $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/ok'); - } - } - - $this->view->bootosForm = $bootosForm; - } - - public function editbootosAction() - { - - //ACL Is he allowed to edit Bootos? - if(!Pbs_Acl::checkRight('boe') && !Pbs_Acl::checkRight('boem')) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); - - $bootosID = $this->_request->getParam('bootosID'); - if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); - - $groupID = $this->membership->getGroupID(); - - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); - $bootos = new Application_Model_BootOs(); - $bootos = $this->bootosMapper->find($bootosID); - - if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); - - if (!isset($_POST["editbootos"])){ - - $bootosForm = new user_Form_Bootos(array( - 'action' => 'editbootos', - 'groupdepth' => $childgroups, - 'page' => $this->page)); - - $bootosForm->populate($bootos->toArray()); - - }else{ - $bootosForm = new user_Form_Bootos(array( - 'action' => 'editbootos', - 'groupdepth' => $childgroups, - 'page' => $this->page),$_POST); - - if ($bootosForm->isValid($_POST)) { - - $bootosold = $bootos; - - $bootos = new Application_Model_BootOs($_POST); - $bootos->setGroupID($this->membership->getGroupID()); - $bootos->setSource($bootosold->getSource()); - $bootos->setCreated(time()); - $bootos->setID($bootosID); - - try { - - if( $bootos->getDistro() != $bootosold->getDistro() || - $bootos->getDistroversion() != $bootosold->getDistroversion() || - $bootos->getShare() != $bootosold->getShare() || - $bootos->getShortname() != $bootosold->getShortname() || - $bootos->getDefaultkcl() != $bootosold->getDefaultkcl() || - $bootos->getExpires() != $bootosold->getExpires() || - $bootos->getPublic() != $bootosold->getPublic() ){ - //ACL Is he allowed to edit this? - if(!Pbs_Acl::checkRight('boe')) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); - } - - if($_FILES['kernel']['name'] != '' || $_FILES['init']['name'] != '' || $_FILES['config']['name'] != ''){ - //ACL Is he allowed to edit the Kernel/Init Path? - if(!Pbs_Acl::checkRight('boe')) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); - } - - if( $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != '' || - $_FILES['init']['size'] == 0 && $_FILES['init']['name'] != '' || - $_FILES['config']['size'] == 0 && $_FILES['config']['name'] != '' ){ - $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/file'); - } - - $initpath = "../resources/bootos/".$bootosID."/initramfs/"; - $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; - $configpath = "../resources/bootos/".$bootosID."/config/"; - - mkdir($initpath ,0777, true); - mkdir($kernelpath ,0777, true); - mkdir($configpath ,0777, true); - - - if($_FILES['kernel']['name'] != ''){ - $bootos->setSource($_SERVER['REMOTE_ADDR']); - move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel"); - } - if($_FILES['init']['name'] != ''){ - $bootos->setSource($_SERVER['REMOTE_ADDR']); - move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs"); - } - if($_FILES['config']['name'] != ''){ - $bootos->setSource($_SERVER['REMOTE_ADDR']); - move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz"); - } - - $this->bootosMapper->save($bootos); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/error'); - //TODO Delete Folder + Preboot - } - - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/ok'); - } - - } - - $this->view->bootosForm = $bootosForm; - - } - - public function deletebootosAction() - { - //ACL Is he allowed to delete Bootos? - if(!Pbs_Acl::checkRight('bod')) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden'); - - try{ - $bootosID = $this->_request->getParam('bootosID'); - if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden'); - - $bootos = new Application_Model_BootOs(); - $this->bootosMapper->find($bootosID, $bootos); - - if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden'); - - $this->bootosMapper->delete($bootos); - exec("rm -r ../resources/bootos/".$bootosID); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/ok'); - } +* 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 user_BootosController extends Zend_Controller_Action { + + protected $bootosMapper; + protected $membershipMapper; + protected $membership; + protected $page; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $this->_redirect('/user/index'); + } + + $this->bootosMapper = new Application_Model_BootOsMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + + $this->db = Zend_Db_Table::getDefaultAdapter(); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + $result = $this->_request->getParam('updateresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('update', $result); + } + + $groupID = $this->membership->getGroupID(); + + //ACL Darf er BootOs sehen? + if(!Pbs_Acl::checkRight('boai') && !Pbs_Acl::checkRight('boui')) + { $this->_redirect('/user/index'); } + + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + + $parents = array(); + $this->view->bootoslist = array(); + $parents = $groupgroupsMapper->getParentGroups($groupID); + + foreach($parents as $k => $parent) { + foreach($parent as $p) { + $bootos = $this->bootosMapper->findBy(array("groupID" => $p)); + foreach ($bootos as $b) + if($b->getPublic() - $k >= 0 ) + { $this->view->bootoslist[] = $b; } + elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('boc')) + $this->view->bootoslist[] = $b; + } + } + + $this->view->bootoslist = array_reverse($this->view->bootoslist); + $this->view->resources = array(); + + $groupMapper = new Application_Model_GroupMapper(); + + if(count($this->view->bootoslist) > 0) { + foreach ($this->view->bootoslist as $bootos) { + if($bootos->getDefaultkcl() == null) + { $bootos->setDefaultkcl("none (edit Bootos to set KCL)"); } + $this->view->resources[$bootos->getID()]['kernel'] = is_file("../resources/bootos/".$bootos->getID()."/kernel/kernel"); + $this->view->resources[$bootos->getID()]['initramfs'] = is_file("../resources/bootos/".$bootos->getID()."/initramfs/initramfs"); + $this->view->resources[$bootos->getID()]['config'] = is_file("../resources/bootos/".$bootos->getID()."/config/default.tgz"); + $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); + $bootos->setCreated(date(Zend_Registry::get('dateformat'), $bootos->getCreated())); + $bootos->setExpires(date(Zend_Registry::get('dateformat'), $bootos->getExpires())); + } + } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('bootos'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $this->view->bootoslist = $mySearch->search($this->view->bootoslist); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->view->bootoslist); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/bootos/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $this->view->bootoslist = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + + } + public function searchAction() { + $this->_redirect('/user/bootos/index/search/'.($_GET['search'])); + } + + public function createbootosAction() { + + //ACL Darf er BootISOs erstellen? + if(!Pbs_Acl::checkRight('boc')) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/forbidden'); } + + $groupID = $this->membership->getGroupID(); + + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); + + if (!isset($_POST["createbootos"])) { + $bootosForm = new user_Form_Bootos(array( + 'action' => 'createbootos', + 'groupdepth' => $childgroups, + 'page' => $this->page)); + } else { + + $bootosForm = new user_Form_Bootos(array( + 'action' => 'createbootos', + 'groupdepth' => $childgroups, + 'page' => $this->page), $_POST); + + if ($bootosForm->isValid($_POST)) { + + $bootos = new Application_Model_BootOs($_POST); + + $bootos->setGroupID($this->membership->getGroupID()); + $bootos->setCreated(time()); + $bootos->setSource($_SERVER['REMOTE_ADDR']); + + try { + + $bootosID = $this->bootosMapper->save($bootos); + $bootos->setID($bootosID); + + if( $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != '' || + $_FILES['init']['size'] == 0 && $_FILES['init']['name'] != '' || + $_FILES['config']['size'] == 0 && $_FILES['config']['name'] != '' ) { + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/file'); + } + + $initpath = "../resources/bootos/".$bootosID."/initramfs/"; + $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + $configpath = "../resources/bootos/".$bootosID."/config/"; + + mkdir($initpath , 0777, true); + mkdir($kernelpath , 0777, true); + mkdir($configpath , 0777, true); + + if($_FILES['kernel']['name'] != '') { + move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel"); + } + if($_FILES['init']['name'] != '') { + move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs"); + } + if($_FILES['config']['name'] != '') { + move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz"); + $newconfig = new Pbs_NewConfig(); + $newconfig->createDefaultConfig($bootos); + } + + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/error'); + //TODO Delete File & delete bootiso from DB + + } + + $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->bootosForm = $bootosForm; + } + + public function editbootosAction() { + + //ACL Is he allowed to edit Bootos? + if(!Pbs_Acl::checkRight('boe') && !Pbs_Acl::checkRight('boem')) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); } + + $bootosID = $this->_request->getParam('bootosID'); + if (!is_numeric($bootosID)) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); } + + $groupID = $this->membership->getGroupID(); + + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + $childgroups = count($groupgroupsMapper->getChildGroups($groupID)); + $bootos = new Application_Model_BootOs(); + $bootos = $this->bootosMapper->find($bootosID); + + if($this->membership->getGroupID() != $bootos->getGroupID()) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); } + + if (!isset($_POST["editbootos"])) { + + $bootosForm = new user_Form_Bootos(array( + 'action' => 'editbootos', + 'groupdepth' => $childgroups, + 'page' => $this->page)); + + $bootosForm->populate($bootos->toArray()); + + } else { + $bootosForm = new user_Form_Bootos(array( + 'action' => 'editbootos', + 'groupdepth' => $childgroups, + 'page' => $this->page), $_POST); + + if ($bootosForm->isValid($_POST)) { + + $bootosold = $bootos; + + $bootos = new Application_Model_BootOs($_POST); + $bootos->setGroupID($this->membership->getGroupID()); + $bootos->setSource($bootosold->getSource()); + $bootos->setCreated(time()); + $bootos->setID($bootosID); + + try { + + if( $bootos->getDistro() != $bootosold->getDistro() || + $bootos->getDistroversion() != $bootosold->getDistroversion() || + $bootos->getShare() != $bootosold->getShare() || + $bootos->getShortname() != $bootosold->getShortname() || + $bootos->getDefaultkcl() != $bootosold->getDefaultkcl() || + $bootos->getExpires() != $bootosold->getExpires() || + $bootos->getPublic() != $bootosold->getPublic() ) { + //ACL Is he allowed to edit this? + if(!Pbs_Acl::checkRight('boe')) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); } + } + + if($_FILES['kernel']['name'] != '' || $_FILES['init']['name'] != '' || $_FILES['config']['name'] != '') { + //ACL Is he allowed to edit the Kernel/Init Path? + if(!Pbs_Acl::checkRight('boe')) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/forbidden'); } + } + + if( $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != '' || + $_FILES['init']['size'] == 0 && $_FILES['init']['name'] != '' || + $_FILES['config']['size'] == 0 && $_FILES['config']['name'] != '' ) { + $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/file'); + } + + $initpath = "../resources/bootos/".$bootosID."/initramfs/"; + $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + $configpath = "../resources/bootos/".$bootosID."/config/"; + + mkdir($initpath , 0777, true); + mkdir($kernelpath , 0777, true); + mkdir($configpath , 0777, true); + + + if($_FILES['kernel']['name'] != '') { + $bootos->setSource($_SERVER['REMOTE_ADDR']); + move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel"); + } + if($_FILES['init']['name'] != '') { + $bootos->setSource($_SERVER['REMOTE_ADDR']); + move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs"); + } + if($_FILES['config']['name'] != '') { + $bootos->setSource($_SERVER['REMOTE_ADDR']); + move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz"); + } + + $this->bootosMapper->save($bootos); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/error'); + //TODO Delete Folder + Preboot + } + + $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/ok'); + } + + } + + $this->view->bootosForm = $bootosForm; + + } + + public function deletebootosAction() { + //ACL Is he allowed to delete Bootos? + if(!Pbs_Acl::checkRight('bod')) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden'); } + + try { + $bootosID = $this->_request->getParam('bootosID'); + if (!is_numeric($bootosID)) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden'); } + + $bootos = new Application_Model_BootOs(); + $this->bootosMapper->find($bootosID, $bootos); + + if($this->membership->getGroupID() != $bootos->getGroupID()) + { $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden'); } + + $this->bootosMapper->delete($bootos); + exec("rm -r ../resources/bootos/".$bootosID); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/error'); + } + $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/ok'); + } } diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index 76419a8..40c8c73 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -1,203 +1,193 @@ -<?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 User_ClientController extends Zend_Controller_Action -{ - private $membership; - protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('No membershipID set','forbidden'); - } - /* Initialize action controller here */ - $membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - // ACL: is he authorized to see this ? - if(!Pbs_Acl::checkRight('clo')) - $this->_redirect('/user'); - - // Get the Clients which booted with a bootiso of this group - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - - $clientMapper = new Application_Model_ClientMapper(); - $clientsInGroup = $clientMapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('client'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $clientsInGroup = $mySearch->search($clientsInGroup); - } - $this->view->searchform = $mySearch->searchForm(); - - // Format Time-String - foreach($clientsInGroup as $k=>$cig){ - $clientsInGroup[$k]['created'] = date(Zend_Registry::get('dateformat'),$cig['created']); - } - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10) - ->setElement($clientsInGroup) - ->setRequestPage($this->_request->getParam('page')) - ->setPageUrl('/user/client/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $clientsInGroup = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->clients = $clientsInGroup; - - } - public function searchAction(){ - $this->_redirect('/user/client/index/search/'.($_GET['search'])); - } - - public function addclientAction() - { - $mac = $this->_request->getParam('mac'); - $hh = $this->_request->getParam('hh'); - - // ACL: is he authorized to create new clients? - if(!Pbs_Acl::checkRight('cla')) - $this->_redirect('/user'); - - if (!isset($_POST["add"])){ - $addclient = new user_Form_Client(array( - 'buttontext' => 'Create Client', - 'page' => $this->page)); - $this->view->addclient = $addclient; - } - else{ - $addclient = new user_Form_Client(array( - 'buttontext' => 'Create Client', - 'page' => $this->page),$_POST); - if ($addclient->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $mac = ($mac!='')?$mac:$_POST['macadress']; - $hh = ($hh!='')?$hh:$_POST['hardwarehash']; - $client->setMacadress($mac) - ->setHardwarehash($hh) - ->setCreated(time()) - ->setGroupID($this->membership->getGroupID()); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->save($client); - $this->_redirect('/user/client/index/addresult/ok'); - } - $this->view->addclient = $addclient; - } - } - - public function removeclientAction() - { - $clientID = $this->_request->getParam('clientID'); - - // ACL: is he authorized to delete clients? - if(!Pbs_Acl::checkRight('cld')) - $this->_redirect('/user'); - - $clientMapper = new Application_Model_ClientMapper(); - if(is_numeric($clientID)){ - $client = new Application_Model_Client(); - $clientMapper->find($clientID,$client); - if($client->getGroupID() == $this->membership->getGroupID()){ - $clientMapper = new Application_Model_ClientMapper(); - $clientMapper->delete($client); - $this->_redirect('/user/client/index/page/'.$this->page.'/deleteresult/ok'); - } - else{ - $this->_redirect('/user/client/index/page/'.$this->page.'/deleteresult/forbidden'); - } - } - $this->_redirect('/user/client/index/page/'.$this->page.'/deleteresult/error'); - } - - public function editclientAction(){ - // ACL: Is he authorized to edit clients ? - if(!Pbs_Acl::checkRight('cle')) - $this->_redirect('/user'); - - if (!isset($_POST["add"])){ - $clientID = $this->_request->getParam('clientID'); - $client = new Application_Model_Client(); - $mapper = new Application_Model_ClientMapper(); - $mapper->find($clientID,$client); - - if($client->getGroupID() == $this->membership->getGroupID()){ - $editclient = new user_Form_Client(array( - 'buttontext' => 'Edit Client', - 'page' => $this->page)); - $editclient->populate($client->toArray()); - $this->view->editclient = $editclient; - } - else{ - $this->_redirect('/user/client/index/page/'.$this->page.'/modifyresult/error'); - } - } - else{ - $editclient = new user_Form_Client(array( - 'buttontext' => 'Edit Client', - 'page' => $this->page),$_POST); - if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $client->setID($this->_request->getParam('clientID')); - - $dbclient = new Application_Model_Client(); - $clientMapper = new Application_Model_ClientMapper(); - $clientMapper->find($this->_request->getParam('clientID'),$dbclient); - - $client->setCreated($dbclient->getCreated()); - - if($dbclient->getGroupID() == $this->membership->getGroupID()){ - $client->setGroupID($this->membership->getGroupID()); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->save($client); - $this->_redirect('/user/client/index/page/'.$this->page.'/modifyresult/ok'); - } - else{ - $this->_redirect('/user/client/index/page/'.$this->page.'/modifyresult/error'); - } - } - $this->view->editclient = $editclient; - } - } +* 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 User_ClientController extends Zend_Controller_Action { + private $membership; + protected $page; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set', 'forbidden'); + } + /* Initialize action controller here */ + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + // ACL: is he authorized to see this ? + if(!Pbs_Acl::checkRight('clo')) + { $this->_redirect('/user'); } + + // Get the Clients which booted with a bootiso of this group + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + + $clientMapper = new Application_Model_ClientMapper(); + $clientsInGroup = $clientMapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('client'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $clientsInGroup = $mySearch->search($clientsInGroup); + } + $this->view->searchform = $mySearch->searchForm(); + + // Format Time-String + foreach($clientsInGroup as $k => $cig) { + $clientsInGroup[$k]['created'] = date(Zend_Registry::get('dateformat'), $cig['created']); + } + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10) + ->setElement($clientsInGroup) + ->setRequestPage($this->_request->getParam('page')) + ->setPageUrl('/user/client/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $clientsInGroup = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + $this->view->clients = $clientsInGroup; + + } + public function searchAction() { + $this->_redirect('/user/client/index/search/'.($_GET['search'])); + } + + public function addclientAction() { + $mac = $this->_request->getParam('mac'); + $hh = $this->_request->getParam('hh'); + + // ACL: is he authorized to create new clients? + if(!Pbs_Acl::checkRight('cla')) + { $this->_redirect('/user'); } + + if (!isset($_POST["add"])) { + $addclient = new user_Form_Client(array( + 'buttontext' => 'Create Client', + 'page' => $this->page)); + $this->view->addclient = $addclient; + } else { + $addclient = new user_Form_Client(array( + 'buttontext' => 'Create Client', + 'page' => $this->page), $_POST); + if ($addclient->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $mac = ($mac != '') ? $mac : $_POST['macadress']; + $hh = ($hh != '') ? $hh : $_POST['hardwarehash']; + $client->setMacadress($mac) + ->setHardwarehash($hh) + ->setCreated(time()) + ->setGroupID($this->membership->getGroupID()); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + $this->_redirect('/user/client/index/addresult/ok'); + } + $this->view->addclient = $addclient; + } + } + + public function removeclientAction() { + $clientID = $this->_request->getParam('clientID'); + + // ACL: is he authorized to delete clients? + if(!Pbs_Acl::checkRight('cld')) + { $this->_redirect('/user'); } + + $clientMapper = new Application_Model_ClientMapper(); + if(is_numeric($clientID)) { + $client = new Application_Model_Client(); + $clientMapper->find($clientID, $client); + if($client->getGroupID() == $this->membership->getGroupID()) { + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->delete($client); + $this->_redirect('/user/client/index/page/'.$this->page.'/deleteresult/ok'); + } else { + $this->_redirect('/user/client/index/page/'.$this->page.'/deleteresult/forbidden'); + } + } + $this->_redirect('/user/client/index/page/'.$this->page.'/deleteresult/error'); + } + + public function editclientAction() { + // ACL: Is he authorized to edit clients ? + if(!Pbs_Acl::checkRight('cle')) + { $this->_redirect('/user'); } + + if (!isset($_POST["add"])) { + $clientID = $this->_request->getParam('clientID'); + $client = new Application_Model_Client(); + $mapper = new Application_Model_ClientMapper(); + $mapper->find($clientID, $client); + + if($client->getGroupID() == $this->membership->getGroupID()) { + $editclient = new user_Form_Client(array( + 'buttontext' => 'Edit Client', + 'page' => $this->page)); + $editclient->populate($client->toArray()); + $this->view->editclient = $editclient; + } else { + $this->_redirect('/user/client/index/page/'.$this->page.'/modifyresult/error'); + } + } else { + $editclient = new user_Form_Client(array( + 'buttontext' => 'Edit Client', + 'page' => $this->page), $_POST); + if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $client->setID($this->_request->getParam('clientID')); + + $dbclient = new Application_Model_Client(); + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->find($this->_request->getParam('clientID'), $dbclient); + + $client->setCreated($dbclient->getCreated()); + + if($dbclient->getGroupID() == $this->membership->getGroupID()) { + $client->setGroupID($this->membership->getGroupID()); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + $this->_redirect('/user/client/index/page/'.$this->page.'/modifyresult/ok'); + } else { + $this->_redirect('/user/client/index/page/'.$this->page.'/modifyresult/error'); + } + } + $this->view->editclient = $editclient; + } + } } diff --git a/application/modules/user/controllers/ConfigController.php b/application/modules/user/controllers/ConfigController.php index b271974..d38c981 100644 --- a/application/modules/user/controllers/ConfigController.php +++ b/application/modules/user/controllers/ConfigController.php @@ -1,542 +1,532 @@ -<?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 user_ConfigController extends Zend_Controller_Action -{ - - protected $configMapper; - protected $bootosMapper; - protected $bootosuserMapper; - protected $bootmenuMapper; - protected $bootmenuentriesMapper; - protected $membershipMapper; - protected $membership; - protected $page; - protected $config; - protected $type; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $this->_redirect('/user/index'); - } - - $this->configMapper = new Application_Model_ConfigMapper(); - $this->bootosuserMapper = new Application_Model_BootOsUserMapper(); - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->db = Zend_Db_Table::getDefaultAdapter(); - - $this->type = $this->_request->getParam('type'); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - - $groupID = $this->membership->getGroupID(); - - //ACL Darf er Configs sehen? - if(!Pbs_Acl::checkRight('csai') && !Pbs_Acl::checkRight('csui')) - $this->_redirect('/user/index'); - - $this->configMapper = new Application_Model_ConfigMapper(); - $this->bootosMapper = new Application_Model_BootOsMapper(); - $this->bootmenuMapper = new Application_Model_BootMenuMapper(); - $this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $groupMapper = new Application_Model_GroupMapper(); - $this->view->bootoslist = array(); - $this->view->configlist = array(); - - if($this->type =='own' && Pbs_Acl::checkRight('csui')){ - $this->view->type = 'own'; - $bootmenu = $this->bootmenuMapper->findBy(array('membershipID' => $this->membership->getID())); - if($bootmenu != null){ - $bootmenuID = $bootmenu[0]->getID(); - $bootmenuentries = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID)); - foreach ($bootmenuentries as $bootmenuentry){ - $bootos = $this->bootosMapper->find($bootmenuentry->getBootosID()); - $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); - $this->view->bootoslist[$bootos->getID()] = $bootos; - $this->view->configlist[$bootos->getID()] = $this->configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $bootos->getID())); - foreach ($this->view->configlist[$bootos->getID()] as $config){ - $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated())); - } - } - } - }else{ - $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); - - $parents = array(); - $groupconfs = array(); - $ownerconfs = array(); - $parents = $groupgroupsMapper->getParentGroups($groupID); - - foreach($parents as $k => $parent){ - foreach($parent as $p){ - $bootos = $this->bootosMapper->findBy(array("groupID" => $p)); - foreach ($bootos as $b) - if($b->getPublic() - $k >= 0 ){ - $this->view->bootoslist[] = $b; - if(Pbs_Acl::checkRight('cc')){ - $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID())); - if($groupID != $b->getGroupID()) - $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID())); - $this->view->configlist[$b->getID()] = array_merge($ownerconfs,$groupconfs); - }else{ - $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); - if($groupID != $b->getGroupID()) - $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); - $this->view->configlist[$b->getID()] = array_merge($ownerconfs,$groupconfs); - - } - foreach ($this->view->configlist[$b->getID()] as $config){ - $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated())); - } - } - elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('boc')){ - $this->view->bootoslist[] = $b; - if(Pbs_Acl::checkRight('cc')){ - $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID())); - if($groupID != $b->getGroupID()) - $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID())); - $this->view->configlist[$b->getID()] = array_merge($ownerconfs,$groupconfs); - }else{ - $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); - if($groupID != $b->getGroupID()) - $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); - $this->view->configlist[$b->getID()] = array_merge($ownerconfs,$groupconfs); - } - foreach ($this->view->configlist[$b->getID()] as $config){ - $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated())); - } - } - } - } - - $this->view->bootoslist = array_reverse($this->view->bootoslist); - - if(count($this->view->bootoslist)>0){ - foreach ($this->view->bootoslist as $bootos){ - $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); - } - } - $this->view->type = 'group'; - //$this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID())); - } - - //print_a($this->view->configlist); - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setType($this->type); - $mySearch->setModule('config'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->configlist = $mySearch->search($this->view->configlist - ); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->view->bootoslist); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/config/index/type/'.$this->type.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $this->view->bootoslist = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - - } - - public function searchAction(){ - $this->_redirect('/user/config/index/type/'.$this->type.'/search/'.($_GET['search'])); - } - - public function createconfigAction() - { - //ACL Darf er Configs erstellen? - if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); - - $bootosID = $this->_request->getParam('bootosID'); - - if (!is_numeric($bootosID)) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); - - if (!isset($_POST["createconfig"])){ - $configForm = new user_Form_Config(array('action' => 'createconfig','page'=>$this->page, 'type'=>$this->type)); - } else { - $configForm = new user_Form_Config(array('action' => 'createconfig','page'=>$this->page, 'type'=>$this->type),$_POST); - - if ($configForm->isValid($_POST)) { - - $config = new Application_Model_Config($_POST); - $config->setCreated(time()); - $config->setBootosID($bootosID); - - if(Pbs_Acl::checkRight('cc') && $this->_request->getParam('type') == 'group'){ - $config->setGroupID($this->membership->getGroupID()); - } - elseif(Pbs_Acl::checkRight('cco') && $this->_request->getParam('type') == 'own'){ - $config->setVisible('1'); - $config->setMembershipID($this->membership->getID()); - } - else - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); - - try { - $this->configMapper->save($config); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); - } - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); - } - } - - $this->view->configForm = $configForm; - } - - public function showconfigAction(){ - - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - - $configID = $this->_request->getParam('configID'); - if (!is_numeric($configID)) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $groupID = $this->membership->getGroupID(); - - $config = new Application_Model_Config(); - $this->configMapper->find($configID, $config); - - $hometypeMapper = new Application_Model_HomeTypeMapper(); - - $this->view->configID = $configID; - $this->view->type = $this->_request->getParam('type'); - $this->view->config = $this->configMapper->find($configID)->getTitle(); - $this->view->userlist = $this->bootosuserMapper->findBy(array('configID' => $configID)); - foreach($this->view->userlist as $user){ - $user->setHometypeID("[".$user->getHometypeID()."] ".$hometypeMapper->find($user->getHometypeID())->getName()); - } - - } - - public function adduserAction(){ - $configID = $this->_request->getParam('configID'); - if (!is_numeric($configID)) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error'); - //ACL Darf er User adden? - if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco')) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/forbidden'); - - $hometypeMapper = new Application_Model_HomeTypeMapper(); - $hometype = $hometypeMapper->fetchAll(); - - if (!isset($_POST["addbootosuser"])){ - $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST); - } else { - $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST); - - if ($bootosuserForm->isValid($_POST)) { - - $bootosuser = new Application_Model_BootOsUser($_POST); - $bootosuser->setConfigID($configID); - $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath())); - if($bootosuser->getPassword() != '%password%') - $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$')); - - try { - $this->bootosuserMapper->save($bootosuser); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error'); - } - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/ok'); - } - } - - $this->view->bootosuserForm = $bootosuserForm; - } - - - public function edituserAction(){ - //ACL Darf er Configs editieren? - if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo')) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); - - $configID = $this->_request->getParam('configID'); - $bootosuserID = $this->_request->getParam('bootosuserID'); - - if (!is_numeric($configID) || !is_numeric($bootosuserID)) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error'); - - $groupID = $this->membership->getGroupID(); - - $bootosuser = new Application_Model_BootOsUser(); - $this->bootosuserMapper->find($bootosuserID,$bootosuser); - - $config = new Application_Model_Config(); - $this->configMapper->find($configID, $config); - - $hometypeMapper = new Application_Model_HomeTypeMapper(); - $hometype = $hometypeMapper->fetchAll(); - - if($config->getMembershipID() != null){ - if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo')) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem'))) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); - } - - if (!isset($_POST["editbootosuser"])){ - if(!isset($_POST['homepath'])){ - $_POST['login'] = $bootosuser->getLogin(); - $_POST['hometypeID'] = $bootosuser->getHometypeID(); - - } - - $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST); - - if(!isset($_POST['homepath']) && $bootosuser->getHometypeID() == '2') - $bootosuserForm->populate(array('homepath' => $bootosuser->getHomepath())); - }else{ - $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST); - - if ($bootosuserForm->isValid($_POST)) { - - $bootosuserold = $bootosuser; - - $bootosuser = new Application_Model_BootOsUser($_POST); - - if($bootosuserold->getHometypeID() != $bootosuser->getHometypeID() || - $bootosuserold->getHomepath() != $bootosuser->getHomepath()){ - //ACL Is he allowed to edit other than Metadata? - if(!Pbs_Acl::checkRight('ce')) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); - } - - $bootosuser->setID($bootosuserID); - $bootosuser->setConfigID($configID); - $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath())); - if($bootosuser->getPassword() != '%password%') - $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$')); - - try { - $this->bootosuserMapper->save($bootosuser); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error'); - } - - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/ok'); - } - - } - - $this->view->bootosuserForm = $bootosuserForm; - } - - public function deleteuserAction(){ - - $configID = $this->_request->getParam('configID'); - $bootosuserID = $this->_request->getParam('bootosuserID'); - if (!is_numeric($configID) || !is_numeric($bootosuserID)) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error'); - //ACL Darf er User löschen? - if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo')) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); - - try{ - $bootosuser = new Application_Model_BootOsUser(); - $this->bootosuserMapper->find($bootosuserID,$bootosuser); - - $config = new Application_Model_Config(); - $this->configMapper->find($configID,$config); - - if($config->getMembershipID() != null){ - if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo')) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd')) - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); - } - - $this->bootosuserMapper->delete($bootosuser); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error'); - } - $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/ok'); - } - - - - public function editconfigAction() - { - //ACL Darf er Configs editieren? - if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - - $configID = $this->_request->getParam('configID'); - if (!is_numeric($configID)) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $groupID = $this->membership->getGroupID(); - - $config = new Application_Model_Config(); - $this->configMapper->find($configID, $config); - - if($config->getMembershipID() != null){ - if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem'))) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - } - - if (!isset($_POST["editconfig"])){ - - $configForm = new user_Form_Config(array('action' => 'editconfig','page'=>$this->page, 'type'=>$this->type)); - $configForm->populate($config->toArray()); - - }else{ - $configForm = new user_Form_Config(array('action' => 'editconfig','page'=>$this->page, 'type'=>$this->type),$_POST); - - if ($configForm->isValid($_POST)) { - - $configold = $config; - - $config = new Application_Model_Config($_POST); - $config->setCreated(time()); - $config->setBootosID($configold->getBootosID()); - - if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null){ - $config->setGroupID($this->membership->getGroupID()); - } - elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null){ - $config->setVisible($configold->getVisible()); - $config->setMembershipID($this->membership->getID()); - } - else - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $config->setID($configID); - - if($configold->getVisible() != $config->getVisible()){ - //ACL Is he allowed to edit other than Metadata? - if(!Pbs_Acl::checkRight('ce')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); - } - - - try { - $this->configMapper->save($config); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - } - - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); - } - - } - - $this->view->configForm = $configForm; - } - - public function deleteconfigAction() - { - //ACL Darf er Configs löschen? - if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - - try{ - $configID = $this->_request->getParam('configID'); - if (!is_numeric($configID)) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); - - $config = new Application_Model_Config(); - $this->configMapper->find($configID,$config); - - if($config->getMembershipID() != null){ - if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - }else{ - if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd')) - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); - } - - $this->configMapper->delete($config); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); - } +* 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 user_ConfigController extends Zend_Controller_Action { + + protected $configMapper; + protected $bootosMapper; + protected $bootosuserMapper; + protected $bootmenuMapper; + protected $bootmenuentriesMapper; + protected $membershipMapper; + protected $membership; + protected $page; + protected $config; + protected $type; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $this->_redirect('/user/index'); + } + + $this->configMapper = new Application_Model_ConfigMapper(); + $this->bootosuserMapper = new Application_Model_BootOsUserMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + + $this->db = Zend_Db_Table::getDefaultAdapter(); + + $this->type = $this->_request->getParam('type'); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + + $groupID = $this->membership->getGroupID(); + + //ACL Darf er Configs sehen? + if(!Pbs_Acl::checkRight('csai') && !Pbs_Acl::checkRight('csui')) + { $this->_redirect('/user/index'); } + + $this->configMapper = new Application_Model_ConfigMapper(); + $this->bootosMapper = new Application_Model_BootOsMapper(); + $this->bootmenuMapper = new Application_Model_BootMenuMapper(); + $this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $groupMapper = new Application_Model_GroupMapper(); + $this->view->bootoslist = array(); + $this->view->configlist = array(); + + if($this->type == 'own' && Pbs_Acl::checkRight('csui')) { + $this->view->type = 'own'; + $bootmenu = $this->bootmenuMapper->findBy(array('membershipID' => $this->membership->getID())); + if($bootmenu != null) { + $bootmenuID = $bootmenu[0]->getID(); + $bootmenuentries = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID)); + foreach ($bootmenuentries as $bootmenuentry) { + $bootos = $this->bootosMapper->find($bootmenuentry->getBootosID()); + $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); + $this->view->bootoslist[$bootos->getID()] = $bootos; + $this->view->configlist[$bootos->getID()] = $this->configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $bootos->getID())); + foreach ($this->view->configlist[$bootos->getID()] as $config) { + $config->setCreated(date(Zend_Registry::get('dateformat'), $config->getCreated())); + } + } + } + } else { + $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); + + $parents = array(); + $groupconfs = array(); + $ownerconfs = array(); + $parents = $groupgroupsMapper->getParentGroups($groupID); + + foreach($parents as $k => $parent) { + foreach($parent as $p) { + $bootos = $this->bootosMapper->findBy(array("groupID" => $p)); + foreach ($bootos as $b) + if($b->getPublic() - $k >= 0 ) { + $this->view->bootoslist[] = $b; + if(Pbs_Acl::checkRight('cc')) { + $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID())); + if($groupID != $b->getGroupID()) + { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID())); } + $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs); + } else { + $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); + if($groupID != $b->getGroupID()) + { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); } + $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs); + + } + foreach ($this->view->configlist[$b->getID()] as $config) { + $config->setCreated(date(Zend_Registry::get('dateformat'), $config->getCreated())); + } + } + elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('boc')) { + $this->view->bootoslist[] = $b; + if(Pbs_Acl::checkRight('cc')) { + $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID())); + if($groupID != $b->getGroupID()) + { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID())); } + $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs); + } else { + $ownerconfs = $this->configMapper->findBy(array('groupID' => $b->getGroupID(), 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); + if($groupID != $b->getGroupID()) + { $groupconfs = $this->configMapper->findBy(array('groupID' => $groupID, 'membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1')); } + $this->view->configlist[$b->getID()] = array_merge($ownerconfs, $groupconfs); + } + foreach ($this->view->configlist[$b->getID()] as $config) { + $config->setCreated(date(Zend_Registry::get('dateformat'), $config->getCreated())); + } + } + } + } + + $this->view->bootoslist = array_reverse($this->view->bootoslist); + + if(count($this->view->bootoslist) > 0) { + foreach ($this->view->bootoslist as $bootos) { + $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); + } + } + $this->view->type = 'group'; + //$this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID())); + } + + //print_a($this->view->configlist); + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setType($this->type); + $mySearch->setModule('config'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $this->view->configlist = $mySearch->search($this->view->configlist + ); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->view->bootoslist); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/config/index/type/'.$this->type.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $this->view->bootoslist = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + + } + + public function searchAction() { + $this->_redirect('/user/config/index/type/'.$this->type.'/search/'.($_GET['search'])); + } + + public function createconfigAction() { + //ACL Darf er Configs erstellen? + if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco')) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden'); } + + $bootosID = $this->_request->getParam('bootosID'); + + if (!is_numeric($bootosID)) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); } + + if (!isset($_POST["createconfig"])) { + $configForm = new user_Form_Config(array('action' => 'createconfig', 'page' => $this->page, 'type' => $this->type)); + } else { + $configForm = new user_Form_Config(array('action' => 'createconfig', 'page' => $this->page, 'type' => $this->type), $_POST); + + if ($configForm->isValid($_POST)) { + + $config = new Application_Model_Config($_POST); + $config->setCreated(time()); + $config->setBootosID($bootosID); + + if(Pbs_Acl::checkRight('cc') && $this->_request->getParam('type') == 'group') { + $config->setGroupID($this->membership->getGroupID()); + } + elseif(Pbs_Acl::checkRight('cco') && $this->_request->getParam('type') == 'own') { + $config->setVisible('1'); + $config->setMembershipID($this->membership->getID()); + } + else + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); } + + try { + $this->configMapper->save($config); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error'); + } + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->configForm = $configForm; + } + + public function showconfigAction() { + + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + + $configID = $this->_request->getParam('configID'); + if (!is_numeric($configID)) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); } + + $groupID = $this->membership->getGroupID(); + + $config = new Application_Model_Config(); + $this->configMapper->find($configID, $config); + + $hometypeMapper = new Application_Model_HomeTypeMapper(); + + $this->view->configID = $configID; + $this->view->type = $this->_request->getParam('type'); + $this->view->config = $this->configMapper->find($configID)->getTitle(); + $this->view->userlist = $this->bootosuserMapper->findBy(array('configID' => $configID)); + foreach($this->view->userlist as $user) { + $user->setHometypeID("[".$user->getHometypeID()."] ".$hometypeMapper->find($user->getHometypeID())->getName()); + } + + } + + public function adduserAction() { + $configID = $this->_request->getParam('configID'); + if (!is_numeric($configID)) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error'); } + //ACL Darf er User adden? + if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco')) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/forbidden'); } + + $hometypeMapper = new Application_Model_HomeTypeMapper(); + $hometype = $hometypeMapper->fetchAll(); + + if (!isset($_POST["addbootosuser"])) { + $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST); + } else { + $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST); + + if ($bootosuserForm->isValid($_POST)) { + + $bootosuser = new Application_Model_BootOsUser($_POST); + $bootosuser->setConfigID($configID); + $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath())); + if($bootosuser->getPassword() != '%password%') + { $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$')); } + + try { + $this->bootosuserMapper->save($bootosuser); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error'); + } + $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/ok'); + } + } + + $this->view->bootosuserForm = $bootosuserForm; + } + + + public function edituserAction() { + //ACL Darf er Configs editieren? + if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo')) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); } + + $configID = $this->_request->getParam('configID'); + $bootosuserID = $this->_request->getParam('bootosuserID'); + + if (!is_numeric($configID) || !is_numeric($bootosuserID)) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error'); } + + $groupID = $this->membership->getGroupID(); + + $bootosuser = new Application_Model_BootOsUser(); + $this->bootosuserMapper->find($bootosuserID, $bootosuser); + + $config = new Application_Model_Config(); + $this->configMapper->find($configID, $config); + + $hometypeMapper = new Application_Model_HomeTypeMapper(); + $hometype = $hometypeMapper->fetchAll(); + + if($config->getMembershipID() != null) { + if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo')) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); } + } else { + if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem'))) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); } + } + + if (!isset($_POST["editbootosuser"])) { + if(!isset($_POST['homepath'])) { + $_POST['login'] = $bootosuser->getLogin(); + $_POST['hometypeID'] = $bootosuser->getHometypeID(); + + } + + $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST); + + if(!isset($_POST['homepath']) && $bootosuser->getHometypeID() == '2') + { $bootosuserForm->populate(array('homepath' => $bootosuser->getHomepath())); } + } else { + $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type' => $this->type, 'configID' => $configID, 'hometype' => $hometype), $_POST); + + if ($bootosuserForm->isValid($_POST)) { + + $bootosuserold = $bootosuser; + + $bootosuser = new Application_Model_BootOsUser($_POST); + + if($bootosuserold->getHometypeID() != $bootosuser->getHometypeID() || + $bootosuserold->getHomepath() != $bootosuser->getHomepath()) { + //ACL Is he allowed to edit other than Metadata? + if(!Pbs_Acl::checkRight('ce')) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden'); } + } + + $bootosuser->setID($bootosuserID); + $bootosuser->setConfigID($configID); + $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath())); + if($bootosuser->getPassword() != '%password%') + { $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$')); } + + try { + $this->bootosuserMapper->save($bootosuser); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error'); + } + + $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/ok'); + } + + } + + $this->view->bootosuserForm = $bootosuserForm; + } + + public function deleteuserAction() { + + $configID = $this->_request->getParam('configID'); + $bootosuserID = $this->_request->getParam('bootosuserID'); + if (!is_numeric($configID) || !is_numeric($bootosuserID)) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error'); } + //ACL Darf er User löschen? + if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo')) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); } + + try { + $bootosuser = new Application_Model_BootOsUser(); + $this->bootosuserMapper->find($bootosuserID, $bootosuser); + + $config = new Application_Model_Config(); + $this->configMapper->find($configID, $config); + + if($config->getMembershipID() != null) { + if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo')) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); } + } else { + if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd')) + { $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden'); } + } + + $this->bootosuserMapper->delete($bootosuser); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error'); + } + $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/ok'); + } + + + + public function editconfigAction() { + //ACL Darf er Configs editieren? + if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo')) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + + $configID = $this->_request->getParam('configID'); + if (!is_numeric($configID)) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); } + + $groupID = $this->membership->getGroupID(); + + $config = new Application_Model_Config(); + $this->configMapper->find($configID, $config); + + if($config->getMembershipID() != null) { + if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo')) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + } else { + if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem'))) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + } + + if (!isset($_POST["editconfig"])) { + + $configForm = new user_Form_Config(array('action' => 'editconfig', 'page' => $this->page, 'type' => $this->type)); + $configForm->populate($config->toArray()); + + } else { + $configForm = new user_Form_Config(array('action' => 'editconfig', 'page' => $this->page, 'type' => $this->type), $_POST); + + if ($configForm->isValid($_POST)) { + + $configold = $config; + + $config = new Application_Model_Config($_POST); + $config->setCreated(time()); + $config->setBootosID($configold->getBootosID()); + + if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null) { + $config->setGroupID($this->membership->getGroupID()); + } + elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null) { + $config->setVisible($configold->getVisible()); + $config->setMembershipID($this->membership->getID()); + } + else + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); } + + $config->setID($configID); + + if($configold->getVisible() != $config->getVisible()) { + //ACL Is he allowed to edit other than Metadata? + if(!Pbs_Acl::checkRight('ce')) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden'); } + } + + + try { + $this->configMapper->save($config); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + } + + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/ok'); + } + + } + + $this->view->configForm = $configForm; + } + + public function deleteconfigAction() { + //ACL Darf er Configs löschen? + if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo')) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + + try { + $configID = $this->_request->getParam('configID'); + if (!is_numeric($configID)) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); } + + $config = new Application_Model_Config(); + $this->configMapper->find($configID, $config); + + if($config->getMembershipID() != null) { + if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo')) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + } else { + if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd')) + { $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/forbidden'); } + } + + $this->configMapper->delete($config); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/error'); + } + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/deleteresult/ok'); + } } diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php index 11f5445..13e63eb 100644 --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -1,512 +1,493 @@ -<?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 User_FilterController extends Zend_Controller_Action -{ - protected $filterMapper; - protected $membershipMapper; - protected $page; - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('No membershipID set','forbidden'); - } - $this->filterMapper = new Application_Model_FilterMapper(); - - $membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->db = Zend_Db_Table::getDefaultAdapter(); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - // ACL: Is he allowed to see the overview - if(!Pbs_Acl::checkRight('fo')) - $this->_redirect('/user'); - - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - - $filters = $this->filterMapper->findBy(array('groupID' => $this->membership->getGroupID(),'membershipID'=>null),true,array('priority'=>'DESC')); - $bootmenuMapper = new Application_Model_BootMenuMapper(); - foreach($filters as $filter){ - $ff = new Application_Model_Filter(); - $ff->setOptions($filter); - $ff->setID($filter['filterID']); - $ff->setBootmenuID("[".$ff->getBootmenuID()."] ".$bootmenuMapper->find($ff->getBootmenuID())->getTitle()); - $ff->setCreated(date(Zend_Registry::get('dateformat'),$ff->getCreated())); - $allFilter[] = $ff; - } - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search)->setModule('filter'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $allFilter = $mySearch->search($allFilter); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10) - ->setElement($allFilter) - ->setRequestPage($this->_request->getParam('page')) - ->setPageUrl('/user/filter/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $allFilter = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->filters = $allFilter; - - } - - public function searchAction(){ - $this->_redirect('/user/filter/index/search/'.($_GET['search'])); - } - - public function addfilterAction() - { - // ACL: Is he allowed to add a Filter - if(!Pbs_Acl::checkRight('fa')) - $this->_redirect('/user'); - - $bmmapper = new Application_Model_BootMenuMapper(); - - $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - - foreach($result as $rr){ - $bm = new Application_Model_BootMenu(); - $bm->setOptions($rr); - $bm->setID($rr['bootmenuID']); - $bootmenus[] = $bm; - } - - $this->view->bootmenus = $bootmenus; - - if (!isset($_POST["add"])){ - $addfilterform = new user_Form_Filter(array( - 'buttontext' => 'Create Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page)); - $this->view->addfilterform = $addfilterform; - }else { - $addfilterform = new user_Form_Filter(array( - 'buttontext' => 'Create Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page),$_POST); - if ($addfilterform->isValid($_POST)) { - try{ - $newfilter = new Application_Model_Filter($_POST); - $newfilter->setCreated(time()) - ->setGroupID($this->membership->getGroupID()) - ->setMembershipID(null); - $newfilter2 = new Application_Model_FilterMapper(); - $id = $newfilter2->save($newfilter); - - $filterentriesMapper = new Application_Model_FilterEntriesMapper(); - $filterentry = new Application_Model_FilterEntries(); - $filterentry->setFilterID($id) - ->setFiltertypeID(6) - ->setFiltervalue($this->membership->getGroupID()); - $filterentriesMapper->save($filterentry); - - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok'); - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error'); - } - } - $this->view->addfilterform = $addfilterform; - } - } - - public function removefilterAction() - { - $filterID = $this->_request->getParam('filterID'); - $filtermapper = new Application_Model_FilterMapper(); - - // ACL: Is he allowed to remove the filter - if(!Pbs_Acl::checkRight('fd')) - $this->_redirect('/user'); - - if(is_numeric($filterID)){ - $filter = new Application_Model_Filter(); - $filtermapper->find($filterID,$filter); - if($filter->getGroupID() == $this->membership->getGroupID()){ - $deletefilter = new Application_Model_Filter(); - $deletefilter->setID($filterID); - $filtermapper->delete($deletefilter); - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok'); - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden'); - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); - } - } - - public function editfilterAction() - { - $bmmapper = new Application_Model_BootMenuMapper(); - $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - foreach($result as $rr){ - $bm = new Application_Model_BootMenu(); - $bm->setOptions($rr); - $bm->setID($rr['bootmenuID']); - $bootmenus[] = $bm; - } - - // ACL: Is he allowed to edit the filter or the filterpriority? - if(!Pbs_Acl::checkRight('fe') && !Pbs_Acl::checkRight('fefp')) - $this->_redirect('/user'); - - if (!isset($_POST["add"])){ - $filterID = $this->_request->getParam('filterID'); - $filter = new Application_Model_Filter(); - - $filtermapper = new Application_Model_FilterMapper(); - $filtermapper->find($filterID,$filter); - if($filter->getGroupID() == $this->membership->getGroupID()){ - $filter2 = $filter->toArray(); - $editfilterform = new user_Form_Filter(array( - 'buttontext' => 'Edit Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page)); - $editfilterform->populate($filter2); - $this->view->editfilterform = $editfilterform; - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - } else{ - try{ - $filterID = $this->_request->getParam('filterID'); - $filter = new Application_Model_Filter(); - $filtermapper = new Application_Model_FilterMapper(); - $filtermapper->find($filterID,$filter); - if($filter->getGroupID() == $this->membership->getGroupID()){ - $editfilterform = new user_Form_Filter(array( - 'buttontext' => 'Edit Filter', - 'bootmenus'=>$bootmenus, - 'page' => $this->page),$_POST); - if ($editfilterform->isValid($_POST)) { - $filtermapper = new Application_Model_FilterMapper(); - - $newfilterentry = new Application_Model_Filter($_POST); - $newfilterentry->setID($this->_request->getParam('filterID')) - ->setGroupID($this->membership->getGroupID()) - ->setMembershipID(null); - - // ACL: if he is only allowed to edit filterpriority - if(Pbs_Acl::checkRight('fefp') && !Pbs_Acl::checkRight('fe')){ - $DBfilterentry = new Application_Model_Filter(); - $filtermapper->find($this->_request->getParam('filterID'),$DBfilterentry); - - $compareresult = $filtermapper->compare($newfilterentry,$DBfilterentry); - if(isset($compareresult['priority']) && count($compareresult) == 1){ - $filtermapper->save($newfilterentry); - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - } - // ACL: he is allowed to edit the filter - elseif(Pbs_Acl::checkRight('fe')){ - $filtermapper->save($newfilterentry); - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); - } - } - $this->view->editfilterform = $editfilterform; - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); - } - } - } - - private function prepareFormData(){ - $poolMapper = new Application_Model_PoolMapper(); - $pools = $poolMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - $bootisoMapper = new Application_Model_BootIsoMapper(); - $bootisos = $bootisoMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - $membershipMapper = new Application_Model_MembershipMapper(); - $memberships = $membershipMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - $grouppMapper = new Application_Model_GroupMapper(); - $group = new Application_Model_Group(); - $grouppMapper->find($this->membership->getGroupID(),$group); - $groups[] = $group->toArray(); - - $clientMapper = new Application_Model_ClientMapper(); - $clients = $clientMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - - return array ( 'clients' => $clients, - 'memberships' => $memberships, - 'groups' => $groups, - 'bootisos' => $bootisos, - 'pools' => $pools); - - } - - public function addfilterentryAction() - { - // ACL: is he allowed to create a new filterentry? - if(!Pbs_Acl::checkRight('ffa')) - $this->_redirect('/user'); - - $filterID = $this->_request->getParam('filterID'); - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterID,$filter); - - $selectData = $this->prepareFormData(); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - if (!isset($_POST["add"])){ - try{ - $addform = new user_Form_FilterEntry(array( - 'buttontext' => 'Add Filterentry', - 'filterID' => $filterID, - 'selectData' => $selectData, - 'data' => $_POST, - 'page' => $this->page)); - $addform->populate($_POST); - $this->view->addform = $addform; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error'); - } - } else{ - $addform = new user_Form_FilterEntry(array( - 'buttontext' => 'Add Filterentry', - 'selectData' => $selectData, - 'data' => $_POST, - 'page' => $this->page)); - if ($addform->isValid($_POST)) { - # print_a('valid'); - $newfilterenty = new Application_Model_FilterEntries(); - $newfilterenty->setFilterID($filterID) - ->setFiltertypeID($_POST['filtertypeID']); - - if($_POST['filtertypeID'] == 1){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.')); - } - elseif($_POST['filtertypeID'] == 2){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,':')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':')); - } - elseif($_POST['filtertypeID'] == 11){ - $newfilterenty->setFiltervalue(strtotime($_POST['filtervalue'])); - $newfilterenty->setFiltervalue2(strtotime($_POST['filtervalue2'])); - } - else{ - $newfilterenty->setFiltervalue($_POST['filtervalue']); - if(isset($_POST['filtervalue2'])){ - $newfilterenty->setFiltervalue2($_POST['filtervalue2']); - } - } - - $newfilter2 = new Application_Model_FilterEntriesMapper(); - $newfilter2->save($newfilterenty); - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok'); - } - $this->view->addform = $addform; - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/forbidden'); - } - } - - public function editfilterentryAction() - { - //ACL: is he allowed to edit filterentrys ? - if(!Pbs_Acl::checkRight('ffe')) - $this->_redirect('/user'); - $selectData = $this->prepareFormData(); - if (!isset($_POST["add"])){ - try{ - $filterentriesID = $this->_request->getParam('filterentriesID'); - $filterentry = new Application_Model_FilterEntries(); - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->find($filterentriesID,$filterentry); - - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterentry->getFilterID(),$filter); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - if(isset($_POST['filtertypeID']) && $_POST['filtertypeID'] != $filterentry->getFiltertypeID()){ - $filterentry->setFiltertypeID($_POST['filtertypeID']) ; - } - if($filterentry->getFiltertypeID() == 11){ - $filterentry->setFiltervalue(date('d.m.Y',$filterentry->getFiltervalue())); - $filterentry->setFiltervalue2(date('d.m.Y',$filterentry->getFiltervalue2())); - } - $data = $filterentry->toArray(); - $editfilterform = new user_Form_FilterEntry(array( - 'buttontext' => 'Edit Filterentry', - 'selectData' => $selectData, - 'data' => $data, - 'page' => $this->page)); - - $editfilterform->populate($filterentry->toArray()); - $this->view->editfilterform = $editfilterform; - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); - } - } else{ - try{ - $filterentriesID = $this->_request->getParam('filterentriesID'); - $editfilterform = new user_Form_FilterEntry(array( - 'buttontext' => 'Edit Filterentry', - 'selectData' => $selectData, - 'data' => $_POST, - 'page' => $this->page)); - if ($editfilterform->isValid($_POST)) { - $filterentry = new Application_Model_FilterEntries(); - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->find($filterentriesID,$filterentry); - - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterentry->getFilterID(),$filter); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - if($_POST['filterID'] == '') - unset($_POST['filterID']); - - $newfilterenty = new Application_Model_FilterEntries($_POST); - $newfilterenty->setID($filterentriesID); - if($_POST['filtertypeID'] == 1){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],3,'.')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],3,'.')); - } - elseif($_POST['filtertypeID'] == 2){ - $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'],2,';')); - $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'],2,':')); - } - elseif($_POST['filtertypeID'] == 11){ - $newfilterenty->setFiltervalue(strtotime($_POST['filtervalue'])); - $newfilterenty->setFiltervalue2(strtotime($_POST['filtervalue2'])); - } - else{ - $newfilterenty->setFiltervalue($_POST['filtervalue']); - $newfilterenty->setFiltervalue2($_POST['filtervalue2']); - } - - $newfilter2 = new Application_Model_FilterEntriesMapper(); - $newfilter2->save($newfilterenty); - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); - - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); - } - } - $this->view->editfilterform = $editfilterform; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); - } - } - } - - public function removefilterentryAction() - { - //ACL: is he autohorized to delete a filterentry? - if(!Pbs_Acl::checkRight('ffd')) - $this->_redirect('/user'); - - $filterentriesID = $this->_request->getParam('filterentriesID'); - if(is_numeric($filterentriesID)){ - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentry = new Application_Model_FilterEntries(); - $filterentriesmapper->find($filterentriesID, $filterentry); - $filterID = $filterentry->getFilterID(); - - $filterMapper = new Application_Model_FilterMapper(); - $filter = new Application_Model_Filter(); - $filterMapper->find($filterID,$filter); - - if($filter->getGroupID() == $this->membership->getGroupID()){ - try{ - $deletefilterentry = new Application_Model_FilterEntries(); - $deletefilterentry->setID($filterentriesID); - - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->delete($deletefilterentry); - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok'); - - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden'); - } - } - else{ - $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); - } - } - private function fillup($string, $length, $seperator=':',$sign='0'){ - $ar = explode($seperator,$string); - $representation = array(); - foreach($ar as $part){ - $representation[] = sprintf("%".$sign.$length."s",$part); - } - return implode($seperator,$representation); - } +* 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 User_FilterController extends Zend_Controller_Action { + protected $filterMapper; + protected $membershipMapper; + protected $page; + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set', 'forbidden'); + } + $this->filterMapper = new Application_Model_FilterMapper(); + + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + + $this->db = Zend_Db_Table::getDefaultAdapter(); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + // ACL: Is he allowed to see the overview + if(!Pbs_Acl::checkRight('fo')) + { $this->_redirect('/user'); } + + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + + $filters = $this->filterMapper->findBy(array('groupID' => $this->membership->getGroupID(), 'membershipID' => null), true, array('priority' => 'DESC')); + $bootmenuMapper = new Application_Model_BootMenuMapper(); + foreach($filters as $filter) { + $ff = new Application_Model_Filter(); + $ff->setOptions($filter); + $ff->setID($filter['filterID']); + $ff->setBootmenuID("[".$ff->getBootmenuID()."] ".$bootmenuMapper->find($ff->getBootmenuID())->getTitle()); + $ff->setCreated(date(Zend_Registry::get('dateformat'), $ff->getCreated())); + $allFilter[] = $ff; + } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search)->setModule('filter'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $allFilter = $mySearch->search($allFilter); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10) + ->setElement($allFilter) + ->setRequestPage($this->_request->getParam('page')) + ->setPageUrl('/user/filter/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $allFilter = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + $this->view->filters = $allFilter; + + } + + public function searchAction() { + $this->_redirect('/user/filter/index/search/'.($_GET['search'])); + } + + public function addfilterAction() { + // ACL: Is he allowed to add a Filter + if(!Pbs_Acl::checkRight('fa')) + { $this->_redirect('/user'); } + + $bmmapper = new Application_Model_BootMenuMapper(); + + $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + + foreach($result as $rr) { + $bm = new Application_Model_BootMenu(); + $bm->setOptions($rr); + $bm->setID($rr['bootmenuID']); + $bootmenus[] = $bm; + } + + $this->view->bootmenus = $bootmenus; + + if (!isset($_POST["add"])) { + $addfilterform = new user_Form_Filter(array( + 'buttontext' => 'Create Filter', + 'bootmenus' => $bootmenus, + 'page' => $this->page)); + $this->view->addfilterform = $addfilterform; + } else { + $addfilterform = new user_Form_Filter(array( + 'buttontext' => 'Create Filter', + 'bootmenus' => $bootmenus, + 'page' => $this->page), $_POST); + if ($addfilterform->isValid($_POST)) { + try { + $newfilter = new Application_Model_Filter($_POST); + $newfilter->setCreated(time()) + ->setGroupID($this->membership->getGroupID()) + ->setMembershipID(null); + $newfilter2 = new Application_Model_FilterMapper(); + $id = $newfilter2->save($newfilter); + + $filterentriesMapper = new Application_Model_FilterEntriesMapper(); + $filterentry = new Application_Model_FilterEntries(); + $filterentry->setFilterID($id) + ->setFiltertypeID(6) + ->setFiltervalue($this->membership->getGroupID()); + $filterentriesMapper->save($filterentry); + + $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok'); + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error'); + } + } + $this->view->addfilterform = $addfilterform; + } + } + + public function removefilterAction() { + $filterID = $this->_request->getParam('filterID'); + $filtermapper = new Application_Model_FilterMapper(); + + // ACL: Is he allowed to remove the filter + if(!Pbs_Acl::checkRight('fd')) + { $this->_redirect('/user'); } + + if(is_numeric($filterID)) { + $filter = new Application_Model_Filter(); + $filtermapper->find($filterID, $filter); + if($filter->getGroupID() == $this->membership->getGroupID()) { + $deletefilter = new Application_Model_Filter(); + $deletefilter->setID($filterID); + $filtermapper->delete($deletefilter); + $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok'); + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden'); + } + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); + } + } + + public function editfilterAction() { + $bmmapper = new Application_Model_BootMenuMapper(); + $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + foreach($result as $rr) { + $bm = new Application_Model_BootMenu(); + $bm->setOptions($rr); + $bm->setID($rr['bootmenuID']); + $bootmenus[] = $bm; + } + + // ACL: Is he allowed to edit the filter or the filterpriority? + if(!Pbs_Acl::checkRight('fe') && !Pbs_Acl::checkRight('fefp')) + { $this->_redirect('/user'); } + + if (!isset($_POST["add"])) { + $filterID = $this->_request->getParam('filterID'); + $filter = new Application_Model_Filter(); + + $filtermapper = new Application_Model_FilterMapper(); + $filtermapper->find($filterID, $filter); + if($filter->getGroupID() == $this->membership->getGroupID()) { + $filter2 = $filter->toArray(); + $editfilterform = new user_Form_Filter(array( + 'buttontext' => 'Edit Filter', + 'bootmenus' => $bootmenus, + 'page' => $this->page)); + $editfilterform->populate($filter2); + $this->view->editfilterform = $editfilterform; + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); + } + } else { + try { + $filterID = $this->_request->getParam('filterID'); + $filter = new Application_Model_Filter(); + $filtermapper = new Application_Model_FilterMapper(); + $filtermapper->find($filterID, $filter); + if($filter->getGroupID() == $this->membership->getGroupID()) { + $editfilterform = new user_Form_Filter(array( + 'buttontext' => 'Edit Filter', + 'bootmenus' => $bootmenus, + 'page' => $this->page), $_POST); + if ($editfilterform->isValid($_POST)) { + $filtermapper = new Application_Model_FilterMapper(); + + $newfilterentry = new Application_Model_Filter($_POST); + $newfilterentry->setID($this->_request->getParam('filterID')) + ->setGroupID($this->membership->getGroupID()) + ->setMembershipID(null); + + // ACL: if he is only allowed to edit filterpriority + if(Pbs_Acl::checkRight('fefp') && !Pbs_Acl::checkRight('fe')) { + $DBfilterentry = new Application_Model_Filter(); + $filtermapper->find($this->_request->getParam('filterID'), $DBfilterentry); + + $compareresult = $filtermapper->compare($newfilterentry, $DBfilterentry); + if(isset($compareresult['priority']) && count($compareresult) == 1) { + $filtermapper->save($newfilterentry); + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); + } + } + // ACL: he is allowed to edit the filter + elseif(Pbs_Acl::checkRight('fe')) { + $filtermapper->save($newfilterentry); + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); + } + } + $this->view->editfilterform = $editfilterform; + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); + } + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); + } + } + } + + private function prepareFormData() { + $poolMapper = new Application_Model_PoolMapper(); + $pools = $poolMapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + + $bootisoMapper = new Application_Model_BootIsoMapper(); + $bootisos = $bootisoMapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + + $membershipMapper = new Application_Model_MembershipMapper(); + $memberships = $membershipMapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + + $grouppMapper = new Application_Model_GroupMapper(); + $group = new Application_Model_Group(); + $grouppMapper->find($this->membership->getGroupID(), $group); + $groups[] = $group->toArray(); + + $clientMapper = new Application_Model_ClientMapper(); + $clients = $clientMapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + + return array ( 'clients' => $clients, + 'memberships' => $memberships, + 'groups' => $groups, + 'bootisos' => $bootisos, + 'pools' => $pools); + + } + + public function addfilterentryAction() { + // ACL: is he allowed to create a new filterentry? + if(!Pbs_Acl::checkRight('ffa')) + { $this->_redirect('/user'); } + + $filterID = $this->_request->getParam('filterID'); + $filterMapper = new Application_Model_FilterMapper(); + $filter = new Application_Model_Filter(); + $filterMapper->find($filterID, $filter); + + $selectData = $this->prepareFormData(); + + if($filter->getGroupID() == $this->membership->getGroupID()) { + if (!isset($_POST["add"])) { + try { + $addform = new user_Form_FilterEntry(array( + 'buttontext' => 'Add Filterentry', + 'filterID' => $filterID, + 'selectData' => $selectData, + 'data' => $_POST, + 'page' => $this->page)); + $addform->populate($_POST); + $this->view->addform = $addform; + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/error'); + } + } else { + $addform = new user_Form_FilterEntry(array( + 'buttontext' => 'Add Filterentry', + 'selectData' => $selectData, + 'data' => $_POST, + 'page' => $this->page)); + if ($addform->isValid($_POST)) { +# print_a('valid'); + $newfilterenty = new Application_Model_FilterEntries(); + $newfilterenty->setFilterID($filterID) + ->setFiltertypeID($_POST['filtertypeID']); + + if($_POST['filtertypeID'] == 1) { + $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'], 3, '.')); + $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'], 3, '.')); + } + elseif($_POST['filtertypeID'] == 2) { + $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'], 2, ':')); + $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'], 2, ':')); + } + elseif($_POST['filtertypeID'] == 11) { + $newfilterenty->setFiltervalue(strtotime($_POST['filtervalue'])); + $newfilterenty->setFiltervalue2(strtotime($_POST['filtervalue2'])); + } + else { + $newfilterenty->setFiltervalue($_POST['filtervalue']); + if(isset($_POST['filtervalue2'])) { + $newfilterenty->setFiltervalue2($_POST['filtervalue2']); + } + } + + $newfilter2 = new Application_Model_FilterEntriesMapper(); + $newfilter2->save($newfilterenty); + $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/ok'); + } + $this->view->addform = $addform; + } + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/addresult/forbidden'); + } + } + + public function editfilterentryAction() { + //ACL: is he allowed to edit filterentrys ? + if(!Pbs_Acl::checkRight('ffe')) + { $this->_redirect('/user'); } + $selectData = $this->prepareFormData(); + if (!isset($_POST["add"])) { + try { + $filterentriesID = $this->_request->getParam('filterentriesID'); + $filterentry = new Application_Model_FilterEntries(); + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentriesmapper->find($filterentriesID, $filterentry); + + $filterMapper = new Application_Model_FilterMapper(); + $filter = new Application_Model_Filter(); + $filterMapper->find($filterentry->getFilterID(), $filter); + + if($filter->getGroupID() == $this->membership->getGroupID()) { + if(isset($_POST['filtertypeID']) && $_POST['filtertypeID'] != $filterentry->getFiltertypeID()) { + $filterentry->setFiltertypeID($_POST['filtertypeID']) ; + } + if($filterentry->getFiltertypeID() == 11) { + $filterentry->setFiltervalue(date('d.m.Y', $filterentry->getFiltervalue())); + $filterentry->setFiltervalue2(date('d.m.Y', $filterentry->getFiltervalue2())); + } + $data = $filterentry->toArray(); + $editfilterform = new user_Form_FilterEntry(array( + 'buttontext' => 'Edit Filterentry', + 'selectData' => $selectData, + 'data' => $data, + 'page' => $this->page)); + + $editfilterform->populate($filterentry->toArray()); + $this->view->editfilterform = $editfilterform; + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); + } + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); + } + } else { + try { + $filterentriesID = $this->_request->getParam('filterentriesID'); + $editfilterform = new user_Form_FilterEntry(array( + 'buttontext' => 'Edit Filterentry', + 'selectData' => $selectData, + 'data' => $_POST, + 'page' => $this->page)); + if ($editfilterform->isValid($_POST)) { + $filterentry = new Application_Model_FilterEntries(); + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentriesmapper->find($filterentriesID, $filterentry); + + $filterMapper = new Application_Model_FilterMapper(); + $filter = new Application_Model_Filter(); + $filterMapper->find($filterentry->getFilterID(), $filter); + + if($filter->getGroupID() == $this->membership->getGroupID()) { + if($_POST['filterID'] == '') + { unset($_POST['filterID']); } + + $newfilterenty = new Application_Model_FilterEntries($_POST); + $newfilterenty->setID($filterentriesID); + if($_POST['filtertypeID'] == 1) { + $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'], 3, '.')); + $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'], 3, '.')); + } + elseif($_POST['filtertypeID'] == 2) { + $newfilterenty->setFiltervalue($this->fillup($_POST['filtervalue'], 2, ';')); + $newfilterenty->setFiltervalue2($this->fillup($_POST['filtervalue2'], 2, ':')); + } + elseif($_POST['filtertypeID'] == 11) { + $newfilterenty->setFiltervalue(strtotime($_POST['filtervalue'])); + $newfilterenty->setFiltervalue2(strtotime($_POST['filtervalue2'])); + } + else { + $newfilterenty->setFiltervalue($_POST['filtervalue']); + $newfilterenty->setFiltervalue2($_POST['filtervalue2']); + } + + $newfilter2 = new Application_Model_FilterEntriesMapper(); + $newfilter2->save($newfilterenty); + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); + + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); + } + } + $this->view->editfilterform = $editfilterform; + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/error'); + } + } + } + + public function removefilterentryAction() { + //ACL: is he autohorized to delete a filterentry? + if(!Pbs_Acl::checkRight('ffd')) + { $this->_redirect('/user'); } + + $filterentriesID = $this->_request->getParam('filterentriesID'); + if(is_numeric($filterentriesID)) { + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentry = new Application_Model_FilterEntries(); + $filterentriesmapper->find($filterentriesID, $filterentry); + $filterID = $filterentry->getFilterID(); + + $filterMapper = new Application_Model_FilterMapper(); + $filter = new Application_Model_Filter(); + $filterMapper->find($filterID, $filter); + + if($filter->getGroupID() == $this->membership->getGroupID()) { + try { + $deletefilterentry = new Application_Model_FilterEntries(); + $deletefilterentry->setID($filterentriesID); + + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentriesmapper->delete($deletefilterentry); + $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/ok'); + + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); + } + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/forbidden'); + } + } else { + $this->_redirect('/user/filter/index/page/'.$this->page.'/deleteresult/error'); + } + } + private function fillup($string, $length, $seperator = ':', $sign = '0') { + $ar = explode($seperator, $string); + $representation = array(); + foreach($ar as $part) { + $representation[] = sprintf("%".$sign.$length."s", $part); + } + return implode($seperator, $representation); + } } diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php index 66fe02b..60b4c4d 100644 --- a/application/modules/user/controllers/GroupController.php +++ b/application/modules/user/controllers/GroupController.php @@ -1,559 +1,533 @@ -<?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 User_GroupController extends Zend_Controller_Action -{ - protected $groupMapper = null; - protected $groupGroupsMapper = null; - protected $membershipMapper = null; - protected $groupRequestMapper = null; - protected $personmapper = null; - protected $rolemapper = null; - protected $groupList = null; - protected $userIDsNamespace = null; - protected $membership; - protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - $this->groupMapper = new Application_Model_GroupMapper(); - $this->groupGroupsMapper = new Application_Model_GroupGroupsMapper(); - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); - $this->personmapper = new Application_Model_PersonMapper(); - $this->rolemapper = new Application_Model_RoleMapper(); - $this->groupList = $this->groupMapper->fetchAll(); - - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - $this->membership = new Application_Model_Membership(); - $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->page = $this->_request->getParam('page'); - } else { - $this->_helper->redirector('login', 'auth'); - return; - } - } - - public function indexAction() - { - // ACL show overview - if(!Pbs_Acl::checkRight('gso')) - $this->_redirect('/user'); - - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - - $this->view->groupList = $this->groupList; - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('group'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->groupList = $mySearch->search($this->view->groupList); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->view->groupList); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/group/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - - $this->view->groupList = $pagination->getElements(); - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->userIDsNamespace = $this->userIDsNamespace; - } - - public function searchAction(){ - $this->_redirect('/user/group/index/search/'.($_GET['search'])); - } - - public function addAction() - { - // ACL create new group - if(!Pbs_Acl::checkRight('gc')) - $this->_redirect('/user'); - - if (!isset($_POST["add"])){ - $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList)); - } else { - $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList),$_POST); - - if ($addForm->isValid($_POST)) { - $group = new Application_Model_Group($_POST); - - $db = $this->groupMapper->findBy(array('title'=>$group->getTitle())); - if(count($db)>=1){ - $this->_redirect('/user/group/index/page/'.$this->page.'/addresult/error'); - } - - try { - $this->groupMapper->save($group); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $groupID = $this->groupMapper->getDbTable()->getDefaultAdapter()->lastInsertId(); - $membership = $this->membershipMapper->find($this->userIDsNamespace['membershipID']); - // setting the actually used role in the new group - $roleID = $this->membership->getRoleID(); - $membership->setID(); - $membership->setGroupID($groupID); - $membership->setRoleID($roleID); - - try { - $this->membershipMapper->save($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - foreach($rightroleslist as $rightroles) { - $rightroles->setRoleID($roleID); - try { - $rightrolesMapper->save($rightroles); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - } - if($_POST['superordinatedGroupID'] != -1) { - $groupgroups = new Application_Model_GroupGroups(); - #print_a($this->membership->getGroupID(),$this->membership); - $groupgroups->setParentID($this->membership->getGroupID()); - $groupgroups->setGroupID($groupID); - try { - $this->groupGroupsMapper->save($groupgroups); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - - } - $this->_redirect('/user/group/index/page/'.$this->page.'/addresult/ok'); - return; - } - } - - $this->view->addForm = $addForm; - } - - public function editAction() - { - // ACL edit a group - if(!Pbs_Acl::checkRight('geo') && !Pbs_Acl::checkRight('ge')) - $this->_redirect('/user'); - - $groupID = $this->_request->getParam('groupID'); - if(!isset($groupID)) { - if(count($this->userIDsNamespace) > 0) { - $groupID = $this->userIDsNamespace['groupID']; - } - } - if(!isset($groupID)) { - $this->_helper->redirector('add', 'group'); - return; - } - if((!Pbs_Acl::checkRight('geo') && $groupID == $this->membership->getGroupID()) || ( !Pbs_Acl::checkRight('ge') && $groupID != $this->membership->getGroupID() )) - $this->_redirect('/user/group/index/page/'.$this->page.'/modifyresult/forbidden'); - if (!isset($_POST["save"])){ - $group = $this->groupMapper->find($groupID); - $_POST['title'] = $group->getTitle(); - $_POST['description'] = $group->getDescription(); - $editForm = new user_Form_GroupEdit(array('groupID' => $groupID)); - } else { - $editForm = new user_Form_GroupEdit(array('groupID' => $groupID), $_POST); - if ($editForm->isValid($_POST)) { - $group = new Application_Model_Group($_POST); - $group->setID($groupID); - try { - $this->groupMapper->save($group); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect('/user/group/index/page/'.$this->page.'/modifyresult/ok'); - return; - } - } - $this->view->editForm = $editForm; - } - - public function showAction() - { - // ACL create new group - if(!Pbs_Acl::checkRight('gsdo') && !Pbs_Acl::checkRight('gsdog')) - $this->_redirect('/user'); - - $groupID = $this->_request->getParam('groupID'); - if($groupID == '' || !Pbs_Acl::checkRight('gsdog')) { - if(count($this->userIDsNamespace) > 0) { - $groupID = $this->userIDsNamespace['groupID']; - } - } - if($groupID == $this->membership->getGroupID() && !Pbs_Acl::checkRight('gsdo')) - $this->_redirect('/user'); - - $this->view->usergroup = $this->membership->getGroupID(); - $this->view->requestgroup = $groupID; - $groupRequests = $this->groupRequestMapper->findBy(array('groupID' => $groupID),true); - if(isset($groupRequests)) { - $groupRequestList = array(); - foreach($groupRequests as $groupRequest) { - $person = $this->personmapper->find($groupRequest['personID']); - $groupRequestList[] = array( - 'grouprequestID' => $groupRequest['grouprequestID'], - 'person' => $person - ); - } - if(count($groupRequestList) > 0) { - $this->view->groupRequestList = $groupRequestList; - } - // Search all inherit Roles - $roles = array(); - $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); - $parents = $groupGroupsMapper->getParentGroups($groupID); - $groupMapper = new Application_Model_GroupMapper(); - $crawled = array(); - foreach($parents as $p){ - foreach($p as $a){ - if(!in_array($a,$crawled)){ - $crawled[] = $a; - $group = $groupMapper->find($a); - if($groupID != $a) - $r = $this->rolemapper->findBy(array('groupID' => $a,'inheritance'=>"1")); - else - $r = $this->rolemapper->findBy(array('groupID' => $a)); - foreach($r as $d){ - $roles[$group->getTitle()][] = $d; - } - } - } - } - $this->view->roleList = $roles; - } - - if(Pbs_Acl::checkRight('gsmg') || Pbs_Acl::checkRight('gsmgo')){ - $members = $this->membershipMapper->findBy(array('groupID' => $groupID),true); - if(isset($members)) { - foreach($members as $member) { - $person = $this->personmapper->find($member['personID']); - $membership_tmp = $this->membershipMapper->find($member['membershipID']); - $role = $this->rolemapper->find($membership_tmp->getRoleID()); - $membersList[] = array( - 'membershipID' => $member['membershipID'], - 'suspend' => $member['suspend'], - 'person' => $person, - 'role' => $role - ); - } - if(is_array($membersList)) { - // Member Pagination - $memberPagination = new Pbs_Pagination(); - $memberPagination->setPerPage(10) - ->setElement($membersList) - ->setRequestPage($this->_request->getParam('page')); - if($this->_request->getParam('groupID')) { - $memberPagination->setPageUrl('/user/group/show/groupID/' . $groupID . ((isset($this->view->search))?'/search/'.$this->view->search:'')); - } else { - $memberPagination->setPageUrl('/user/group/show'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - } - $this->view->membersList = $memberPagination->getElements(); - $this->view->memberPagination = $memberPagination->pagination(); - $this->view->page = $memberPagination->getRequestPage(); - } - } - } - $groupgroups = $this->groupGroupsMapper->findBy(array('groupID' => $groupID),true); - if(is_object($groupgroups)) { - $parentGroup = $this->groupMapper->find($groupgroups->getParentID()); - $this->view->$parentGroup = $parentGroup; - } - $group = $this->groupMapper->find($groupID); - $this->view->userIDsNamespace = $this->userIDsNamespace; - $this->view->group = $group; - $this->view->groupID = $groupID; - } - - public function linkAction() - { - if(!Pbs_Acl::checkRight('glk')) - $this->_redirect('/user'); - - $linkableGroups = $this->groupList; - $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); - $childs = array(); - $parents = array(); - $childs = $groupGroupsMapper->getChildGroups($this->membership->getGroupID()); - $parents = $groupGroupsMapper->getParentGroups($this->membership->getGroupID()); - #print_a($childs,$parents); - foreach($linkableGroups as $i => $group){ - #print_a($group->getID()); - if(isset($childs[1]) && in_array($group->getID(),$childs[1])){ - unset($linkableGroups[$i]); - } - if(count($parents) > 0){ - foreach($parents as $d){ - if(in_array($group->getID(),$d)){ - unset($linkableGroups[$i]); - } - } - } - } - #print_a($linkableGroups); - if (!isset($_POST["link"])){ - $linkForm = new user_Form_GroupLink(array('grouplist' => $linkableGroups)); - } else { - $linkForm = new user_Form_GroupLink(array('grouplist' => $linkableGroups),$_POST); - - if ($linkForm->isValid($_POST)) { - $groupgroups = new Application_Model_GroupGroups(); - if($_POST['superordinatedGroupID'] == $_POST['groupID'] || $_POST['groupID'] == 1) { - $this->_redirect('/user/group/index/page/'.$this->page.'/addresult/forbidden'); - } - $groupgroups->setParentID($this->membership->getGroupID()); - $groupgroups->setGroupID($_POST['groupID']); - try { - $this->groupGroupsMapper->save($groupgroups); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'group'); - return; - } - } - - $this->view->linkForm = $linkForm; - } - - public function deleteAction() - { - // ACL delete a group - if(!Pbs_Acl::checkRight('gd')) - $this->_redirect('/user'); - - $this->_helper->viewRenderer->setNoRender(); - $groupID = $this->_request->getParam('groupID'); - if(!isset($groupID)) { - if(count($this->userIDsNamespace) > 0) { - $groupID = $this->userIDsNamespace['groupID']; - } - } - if (isset($groupID)){ - $group = $this->groupMapper->find($groupID); - try { - $this->groupMapper->delete($group); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - if($_SERVER['HTTP_REFERER']) { - if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show') !== false && strpos($_SERVER['HTTP_REFERER'], '/groupID/') === false) { - $this->_helper->redirector('changemembership', 'person'); - } else { - $this->_redirect('/user/group/index/page/'.$this->page.'/deleteresult/ok'); - } - } else { - $this->_helper->redirector('', 'group'); - } - return; - } else { - $this->_redirect('/user/'); - return; - } - } - - public function grantpersonAction() - { - // ACL grant a membership to request - if(!Pbs_Acl::checkRight('gam')) - $this->_redirect('/user'); - - $this->_helper->viewRenderer->setNoRender(); - if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) { - $groupRequest = $this->groupRequestMapper->find($_POST['grouprequestID']); - try { - $this->groupRequestMapper->delete($groupRequest); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $membership = new Application_Model_Membership(); - $membership->setGroupID($groupRequest->getGroupID()) - ->setPersonID($groupRequest->getPersonID()) - ->setRoleID($_POST['roleID']) - ->setSuspend(0); - $apikey = randomString(32); - $membership->setApikey($apikey); - - - try { - $id = $this->membershipMapper->save($membership); - $membership->setID($id); - $newMember = new Pbs_NewMember(); - $newMember->createDefaults($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/user/group/show/groupID/" . $groupRequest->getGroupID()); - } - } - - public function revokepersonAction() - { - - $this->_helper->viewRenderer->setNoRender(); - $membershipID = $this->_request->getParam('membershipID'); - $rr = $this->membershipMapper->find($membershipID); - - if(($rr->getGroupID() == $this->membership->getGroupID() && Pbs_Acl::checkRight('gdmo') ) || ( $rr->getGroupID() != $this->membership->getGroupID() && Pbs_Acl::checkRight('gdmog'))){ - if(isset($membershipID)) { - $membership = $this->membershipMapper->find($membershipID); - if(isset($membership)) { - try { - $this->membershipMapper->delete($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/user/group/show/groupID/" . $membership->getGroupID()); - } - } - } - } - - public function declineAction() - { - if(!Pbs_Acl::checkRight('gdm')) { - $this->_redirect('/user'); - } - $this->_helper->viewRenderer->setNoRender(); - $grouprequestID = $this->_request->getParam('grouprequestID'); - if(isset($grouprequestID)) { - $groupRequest = $this->groupRequestMapper->find($grouprequestID); - if($groupRequest->getGroupID() != $this->userIDsNamespace['groupID']) { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Not allowed to decline this grouprequest', 'forbidden'); - return; - } - try { - $this->groupRequestMapper->delete($groupRequest); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/user/group/show/groupID"); - } - } - - public function suspendmembershipAction() - { - if(!Pbs_Acl::checkRight('gsm')) { - $this->_redirect('/user'); - } - $this->_helper->viewRenderer->setNoRender(); - $membershipID = $this->_request->getParam('membershipID'); - if(isset($membershipID)) { - $membership = $this->membershipMapper->find($membershipID); - $membership->setSuspend(1); - if(isset($membership)) { - if($membership->getGroupID() != $this->userIDsNamespace['groupID']) { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Not allowed to suspend this membership', 'forbidden'); - return; - } - try { - $this->membershipMapper->save($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/user/group/show/"); - } - } - } - - public function resumemembershipAction() - { - if(!Pbs_Acl::checkRight('gsm')) { - $this->_redirect('/user'); - } - $this->_helper->viewRenderer->setNoRender(); - $membershipID = $this->_request->getParam('membershipID'); - if(isset($membershipID)) { - $membership = $this->membershipMapper->find($membershipID); - $membership->setSuspend(0); - if(isset($membership)) { - if($membership->getGroupID() != $this->userIDsNamespace['groupID']) { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Not allowed to resume this membership', 'forbidden'); - return; - } - try { - $this->membershipMapper->save($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/user/group/show/"); - } - } - } +* 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 User_GroupController extends Zend_Controller_Action { + protected $groupMapper = null; + protected $groupGroupsMapper = null; + protected $membershipMapper = null; + protected $groupRequestMapper = null; + protected $personmapper = null; + protected $rolemapper = null; + protected $groupList = null; + protected $userIDsNamespace = null; + protected $membership; + protected $page; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $this->groupMapper = new Application_Model_GroupMapper(); + $this->groupGroupsMapper = new Application_Model_GroupGroupsMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); + $this->personmapper = new Application_Model_PersonMapper(); + $this->rolemapper = new Application_Model_RoleMapper(); + $this->groupList = $this->groupMapper->fetchAll(); + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + + $this->page = $this->_request->getParam('page'); + } else { + $this->_helper->redirector('login', 'auth'); + return; + } + } + + public function indexAction() { + // ACL show overview + if(!Pbs_Acl::checkRight('gso')) + { $this->_redirect('/user'); } + + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + + $this->view->groupList = $this->groupList; + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('group'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $this->view->groupList = $mySearch->search($this->view->groupList); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->view->groupList); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/group/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + + $this->view->groupList = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + $this->view->userIDsNamespace = $this->userIDsNamespace; + } + + public function searchAction() { + $this->_redirect('/user/group/index/search/'.($_GET['search'])); + } + + public function addAction() { + // ACL create new group + if(!Pbs_Acl::checkRight('gc')) + { $this->_redirect('/user'); } + + if (!isset($_POST["add"])) { + $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList)); + } else { + $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList), $_POST); + + if ($addForm->isValid($_POST)) { + $group = new Application_Model_Group($_POST); + + $db = $this->groupMapper->findBy(array('title' => $group->getTitle())); + if(count($db) >= 1) { + $this->_redirect('/user/group/index/page/'.$this->page.'/addresult/error'); + } + + try { + $this->groupMapper->save($group); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $groupID = $this->groupMapper->getDbTable()->getDefaultAdapter()->lastInsertId(); + $membership = $this->membershipMapper->find($this->userIDsNamespace['membershipID']); + // setting the actually used role in the new group + $roleID = $this->membership->getRoleID(); + $membership->setID(); + $membership->setGroupID($groupID); + $membership->setRoleID($roleID); + + try { + $this->membershipMapper->save($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + foreach($rightroleslist as $rightroles) { + $rightroles->setRoleID($roleID); + try { + $rightrolesMapper->save($rightroles); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } + if($_POST['superordinatedGroupID'] != -1) { + $groupgroups = new Application_Model_GroupGroups(); +#print_a($this->membership->getGroupID(),$this->membership); + $groupgroups->setParentID($this->membership->getGroupID()); + $groupgroups->setGroupID($groupID); + try { + $this->groupGroupsMapper->save($groupgroups); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + + } + $this->_redirect('/user/group/index/page/'.$this->page.'/addresult/ok'); + return; + } + } + + $this->view->addForm = $addForm; + } + + public function editAction() { + // ACL edit a group + if(!Pbs_Acl::checkRight('geo') && !Pbs_Acl::checkRight('ge')) + { $this->_redirect('/user'); } + + $groupID = $this->_request->getParam('groupID'); + if(!isset($groupID)) { + if(count($this->userIDsNamespace) > 0) { + $groupID = $this->userIDsNamespace['groupID']; + } + } + if(!isset($groupID)) { + $this->_helper->redirector('add', 'group'); + return; + } + if((!Pbs_Acl::checkRight('geo') && $groupID == $this->membership->getGroupID()) || ( !Pbs_Acl::checkRight('ge') && $groupID != $this->membership->getGroupID() )) + { $this->_redirect('/user/group/index/page/'.$this->page.'/modifyresult/forbidden'); } + if (!isset($_POST["save"])) { + $group = $this->groupMapper->find($groupID); + $_POST['title'] = $group->getTitle(); + $_POST['description'] = $group->getDescription(); + $editForm = new user_Form_GroupEdit(array('groupID' => $groupID)); + } else { + $editForm = new user_Form_GroupEdit(array('groupID' => $groupID), $_POST); + if ($editForm->isValid($_POST)) { + $group = new Application_Model_Group($_POST); + $group->setID($groupID); + try { + $this->groupMapper->save($group); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect('/user/group/index/page/'.$this->page.'/modifyresult/ok'); + return; + } + } + $this->view->editForm = $editForm; + } + + public function showAction() { + // ACL create new group + if(!Pbs_Acl::checkRight('gsdo') && !Pbs_Acl::checkRight('gsdog')) + { $this->_redirect('/user'); } + + $groupID = $this->_request->getParam('groupID'); + if($groupID == '' || !Pbs_Acl::checkRight('gsdog')) { + if(count($this->userIDsNamespace) > 0) { + $groupID = $this->userIDsNamespace['groupID']; + } + } + if($groupID == $this->membership->getGroupID() && !Pbs_Acl::checkRight('gsdo')) + { $this->_redirect('/user'); } + + $this->view->usergroup = $this->membership->getGroupID(); + $this->view->requestgroup = $groupID; + $groupRequests = $this->groupRequestMapper->findBy(array('groupID' => $groupID), true); + if(isset($groupRequests)) { + $groupRequestList = array(); + foreach($groupRequests as $groupRequest) { + $person = $this->personmapper->find($groupRequest['personID']); + $groupRequestList[] = array( + 'grouprequestID' => $groupRequest['grouprequestID'], + 'person' => $person + ); + } + if(count($groupRequestList) > 0) { + $this->view->groupRequestList = $groupRequestList; + } + // Search all inherit Roles + $roles = array(); + $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); + $parents = $groupGroupsMapper->getParentGroups($groupID); + $groupMapper = new Application_Model_GroupMapper(); + $crawled = array(); + foreach($parents as $p) { + foreach($p as $a) { + if(!in_array($a, $crawled)) { + $crawled[] = $a; + $group = $groupMapper->find($a); + if($groupID != $a) + { $r = $this->rolemapper->findBy(array('groupID' => $a, 'inheritance' => "1")); } + else + { $r = $this->rolemapper->findBy(array('groupID' => $a)); } + foreach($r as $d) { + $roles[$group->getTitle()][] = $d; + } + } + } + } + $this->view->roleList = $roles; + } + + if(Pbs_Acl::checkRight('gsmg') || Pbs_Acl::checkRight('gsmgo')) { + $members = $this->membershipMapper->findBy(array('groupID' => $groupID), true); + if(isset($members)) { + foreach($members as $member) { + $person = $this->personmapper->find($member['personID']); + $membership_tmp = $this->membershipMapper->find($member['membershipID']); + $role = $this->rolemapper->find($membership_tmp->getRoleID()); + $membersList[] = array( + 'membershipID' => $member['membershipID'], + 'suspend' => $member['suspend'], + 'person' => $person, + 'role' => $role + ); + } + if(is_array($membersList)) { + // Member Pagination + $memberPagination = new Pbs_Pagination(); + $memberPagination->setPerPage(10) + ->setElement($membersList) + ->setRequestPage($this->_request->getParam('page')); + if($this->_request->getParam('groupID')) { + $memberPagination->setPageUrl('/user/group/show/groupID/' . $groupID . ((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + } else { + $memberPagination->setPageUrl('/user/group/show'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + } + $this->view->membersList = $memberPagination->getElements(); + $this->view->memberPagination = $memberPagination->pagination(); + $this->view->page = $memberPagination->getRequestPage(); + } + } + } + $groupgroups = $this->groupGroupsMapper->findBy(array('groupID' => $groupID), true); + if(is_object($groupgroups)) { + $parentGroup = $this->groupMapper->find($groupgroups->getParentID()); + $this->view->$parentGroup = $parentGroup; + } + $group = $this->groupMapper->find($groupID); + $this->view->userIDsNamespace = $this->userIDsNamespace; + $this->view->group = $group; + $this->view->groupID = $groupID; + } + + public function linkAction() { + if(!Pbs_Acl::checkRight('glk')) + { $this->_redirect('/user'); } + + $linkableGroups = $this->groupList; + $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); + $childs = array(); + $parents = array(); + $childs = $groupGroupsMapper->getChildGroups($this->membership->getGroupID()); + $parents = $groupGroupsMapper->getParentGroups($this->membership->getGroupID()); +#print_a($childs,$parents); + foreach($linkableGroups as $i => $group) { +#print_a($group->getID()); + if(isset($childs[1]) && in_array($group->getID(), $childs[1])) { + unset($linkableGroups[$i]); + } + if(count($parents) > 0) { + foreach($parents as $d) { + if(in_array($group->getID(), $d)) { + unset($linkableGroups[$i]); + } + } + } + } +#print_a($linkableGroups); + if (!isset($_POST["link"])) { + $linkForm = new user_Form_GroupLink(array('grouplist' => $linkableGroups)); + } else { + $linkForm = new user_Form_GroupLink(array('grouplist' => $linkableGroups), $_POST); + + if ($linkForm->isValid($_POST)) { + $groupgroups = new Application_Model_GroupGroups(); + if($_POST['superordinatedGroupID'] == $_POST['groupID'] || $_POST['groupID'] == 1) { + $this->_redirect('/user/group/index/page/'.$this->page.'/addresult/forbidden'); + } + $groupgroups->setParentID($this->membership->getGroupID()); + $groupgroups->setGroupID($_POST['groupID']); + try { + $this->groupGroupsMapper->save($groupgroups); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'group'); + return; + } + } + + $this->view->linkForm = $linkForm; + } + + public function deleteAction() { + // ACL delete a group + if(!Pbs_Acl::checkRight('gd')) + { $this->_redirect('/user'); } + + $this->_helper->viewRenderer->setNoRender(); + $groupID = $this->_request->getParam('groupID'); + if(!isset($groupID)) { + if(count($this->userIDsNamespace) > 0) { + $groupID = $this->userIDsNamespace['groupID']; + } + } + if (isset($groupID)) { + $group = $this->groupMapper->find($groupID); + try { + $this->groupMapper->delete($group); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + if($_SERVER['HTTP_REFERER']) { + if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show') != = false && strpos($_SERVER['HTTP_REFERER'], '/groupID/') == = false) { + $this->_helper->redirector('changemembership', 'person'); + } else { + $this->_redirect('/user/group/index/page/'.$this->page.'/deleteresult/ok'); + } + } else { + $this->_helper->redirector('', 'group'); + } + return; + } else { + $this->_redirect('/user/'); + return; + } + } + + public function grantpersonAction() { + // ACL grant a membership to request + if(!Pbs_Acl::checkRight('gam')) + { $this->_redirect('/user'); } + + $this->_helper->viewRenderer->setNoRender(); + if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) { + $groupRequest = $this->groupRequestMapper->find($_POST['grouprequestID']); + try { + $this->groupRequestMapper->delete($groupRequest); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $membership = new Application_Model_Membership(); + $membership->setGroupID($groupRequest->getGroupID()) + ->setPersonID($groupRequest->getPersonID()) + ->setRoleID($_POST['roleID']) + ->setSuspend(0); + $apikey = randomString(32); + $membership->setApikey($apikey); + + + try { + $id = $this->membershipMapper->save($membership); + $membership->setID($id); + $newMember = new Pbs_NewMember(); + $newMember->createDefaults($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/user/group/show/groupID/" . $groupRequest->getGroupID()); + } + } + + public function revokepersonAction() { + + $this->_helper->viewRenderer->setNoRender(); + $membershipID = $this->_request->getParam('membershipID'); + $rr = $this->membershipMapper->find($membershipID); + + if(($rr->getGroupID() == $this->membership->getGroupID() && Pbs_Acl::checkRight('gdmo') ) || ( $rr->getGroupID() != $this->membership->getGroupID() && Pbs_Acl::checkRight('gdmog'))) { + if(isset($membershipID)) { + $membership = $this->membershipMapper->find($membershipID); + if(isset($membership)) { + try { + $this->membershipMapper->delete($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/user/group/show/groupID/" . $membership->getGroupID()); + } + } + } + } + + public function declineAction() { + if(!Pbs_Acl::checkRight('gdm')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $grouprequestID = $this->_request->getParam('grouprequestID'); + if(isset($grouprequestID)) { + $groupRequest = $this->groupRequestMapper->find($grouprequestID); + if($groupRequest->getGroupID() != $this->userIDsNamespace['groupID']) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Not allowed to decline this grouprequest', 'forbidden'); + return; + } + try { + $this->groupRequestMapper->delete($groupRequest); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/user/group/show/groupID"); + } + } + + public function suspendmembershipAction() { + if(!Pbs_Acl::checkRight('gsm')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $membershipID = $this->_request->getParam('membershipID'); + if(isset($membershipID)) { + $membership = $this->membershipMapper->find($membershipID); + $membership->setSuspend(1); + if(isset($membership)) { + if($membership->getGroupID() != $this->userIDsNamespace['groupID']) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Not allowed to suspend this membership', 'forbidden'); + return; + } + try { + $this->membershipMapper->save($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/user/group/show/"); + } + } + } + + public function resumemembershipAction() { + if(!Pbs_Acl::checkRight('gsm')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $membershipID = $this->_request->getParam('membershipID'); + if(isset($membershipID)) { + $membership = $this->membershipMapper->find($membershipID); + $membership->setSuspend(0); + if(isset($membership)) { + if($membership->getGroupID() != $this->userIDsNamespace['groupID']) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Not allowed to resume this membership', 'forbidden'); + return; + } + try { + $this->membershipMapper->save($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/user/group/show/"); + } + } + } } diff --git a/application/modules/user/controllers/IndexController.php b/application/modules/user/controllers/IndexController.php index a704261..4bbfe1d 100644 --- a/application/modules/user/controllers/IndexController.php +++ b/application/modules/user/controllers/IndexController.php @@ -1,38 +1,34 @@ -<?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 User_IndexController extends Zend_Controller_Action -{ - public function init() - { - /* Initialize action controller here */ - } +class User_IndexController extends Zend_Controller_Action { + public function init() { + /* Initialize action controller here */ + } - public function indexAction() - { - - if (!Zend_Auth::getInstance()->hasIdentity()) { - $this->view->text = 'Your not logged in, please log in first <a href="/user/auth/">here</a>.'; - } - else{ - $this->view->text = "You're Welcome"; - $links = array( - '/user/person' => 'Change your Details', - '/user/person/request' => 'Request Membership in a Group', - '/user/config' => 'Create your own Configuration', - '/user/bootmenu' => 'Create your Bootmenu', - ); - $this->view->links = $links; - } - } + public function indexAction() { + + if (!Zend_Auth::getInstance()->hasIdentity()) { + $this->view->text = 'Your not logged in, please log in first <a href="/user/auth/">here</a>.'; + } else { + $this->view->text = "You're Welcome"; + $links = array( + '/user/person' => 'Change your Details', + '/user/person/request' => 'Request Membership in a Group', + '/user/config' => 'Create your own Configuration', + '/user/bootmenu' => 'Create your Bootmenu', + ); + $this->view->links = $links; + } + } } diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index 168add9..195ad5a 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -1,529 +1,509 @@ -<?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 user_PersonController extends Zend_Controller_Action -{ +class user_PersonController extends Zend_Controller_Action { - protected $person = null; - protected $personmapper = null; - protected $membershipMapper = null; - protected $memberships = null; - protected $groupMapper = null; - protected $groups = null; - protected $groupRequestMapper = null; - protected $userIDsNamespace = null; + protected $person = null; + protected $personmapper = null; + protected $membershipMapper = null; + protected $memberships = null; + protected $groupMapper = null; + protected $groups = null; + protected $groupRequestMapper = null; + protected $userIDsNamespace = null; - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->personmapper = new Application_Model_PersonMapper(); - $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if(isset($this->userIDsNamespace['personID'])) { - $this->person = $this->personmapper->find($this->userIDsNamespace['personID']); - } else { - $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->groupMapper = new Application_Model_GroupMapper(); - $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->memberships = $this->membershipMapper->findBy(array("personID" => $this->person->getID()),true); - - $rightrolesMapper = new Application_Model_RightRolesMapper(); - $rightroles = new Application_Model_RightRoles(); - $role = new Application_Model_Role(); - $roleMapper = new Application_Model_RoleMapper(); - - $this->view->apikeys = array(); + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->personmapper = new Application_Model_PersonMapper(); + $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if(isset($this->userIDsNamespace['personID'])) { + $this->person = $this->personmapper->find($this->userIDsNamespace['personID']); + } else { + $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->groupMapper = new Application_Model_GroupMapper(); + $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->memberships = $this->membershipMapper->findBy(array("personID" => $this->person->getID()), true); - if(isset($this->memberships)) { - foreach($this->memberships as $membership) { - $group = $this->groupMapper->find($membership['groupID']); - list($rightroles) = $rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $membership['roleID'])); - $role = $roleMapper->find($membership['roleID']); - if($rightroles != null) - $this->view->apikeys[$group->getID()] = $membership['apikey']; - - $this->groups[] = array ( - 'groupID' => $group->getID(), - 'title' => $group->getTitle(), - 'description' => $group->getDescription(), - 'membershipID' => $membership['membershipID'], - 'role' => $role->getTitle() - ); - } - } - } else { - $this->_helper->redirector('login', 'auth'); - return; - } - } + $rightrolesMapper = new Application_Model_RightRolesMapper(); + $rightroles = new Application_Model_RightRoles(); + $role = new Application_Model_Role(); + $roleMapper = new Application_Model_RoleMapper(); - public function indexAction() - { - if(!Pbs_Acl::checkRight('pso')) { - $this->_redirect('/user'); - } - $this->view->showRight = true;//Pbs_Acl::checkRight('psod'); - $this->view->editRight = Pbs_Acl::checkRight('peod'); - $this->view->deleteRight = Pbs_Acl::checkRight('pdo'); - $this->view->showOtherRight = Pbs_Acl::checkRight('psood'); - $this->view->editOtherRight = Pbs_Acl::checkRight('peoa'); - $this->view->deleteOtherRight = Pbs_Acl::checkRight('pd'); - $this->view->suspendRight = Pbs_Acl::checkRight('psa'); - $this->view->userIDsNamespace = $this->userIDsNamespace; + $this->view->apikeys = array(); - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } + if(isset($this->memberships)) { + foreach($this->memberships as $membership) { + $group = $this->groupMapper->find($membership['groupID']); + list($rightroles) = $rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $membership['roleID'])); + $role = $roleMapper->find($membership['roleID']); + if($rightroles != null) + { $this->view->apikeys[$group->getID()] = $membership['apikey']; } + $this->groups[] = array ( + 'groupID' => $group->getID(), + 'title' => $group->getTitle(), + 'description' => $group->getDescription(), + 'membershipID' => $membership['membershipID'], + 'role' => $role->getTitle() + ); + } + } + } else { + $this->_helper->redirector('login', 'auth'); + return; + } + } - $this->view->personList = $this->personmapper->fetchAll(); + public function indexAction() { + if(!Pbs_Acl::checkRight('pso')) { + $this->_redirect('/user'); + } + $this->view->showRight = true;//Pbs_Acl::checkRight('psod'); + $this->view->editRight = Pbs_Acl::checkRight('peod'); + $this->view->deleteRight = Pbs_Acl::checkRight('pdo'); + $this->view->showOtherRight = Pbs_Acl::checkRight('psood'); + $this->view->editOtherRight = Pbs_Acl::checkRight('peoa'); + $this->view->deleteOtherRight = Pbs_Acl::checkRight('pd'); + $this->view->suspendRight = Pbs_Acl::checkRight('psa'); + $this->view->userIDsNamespace = $this->userIDsNamespace; - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('person'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->personList = $mySearch->search($this->view->personList); - } - $this->view->searchform = $mySearch->searchForm(); + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->view->personList); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/person/index/'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $this->view->personList = $pagination->getElements(); - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - } + $this->view->personList = $this->personmapper->fetchAll(); - public function owndetailsAction() - { - #if(!Pbs_Acl::checkRight('psod')) { - # $this->_redirect('/user'); - #} - $this->view->person = $this->person; - $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()),true); - if(isset($groupRequests)) { - $groupRequestList = array(); - foreach($groupRequests as $groupRequest) { - $group = $this->groupMapper->find($groupRequest['groupID']); - $groupRequestList[] = array( - 'grouprequestID' => $groupRequest['grouprequestID'], - 'group' => $group - ); - } - if(count($groupRequestList)> 0) { - $this->view->groupRequestList = $groupRequestList; - } - } - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->groups); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/person/index' .((isset($this->view->search))?'/search/'.$this->view->search:'')); + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('person'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $this->view->personList = $mySearch->search($this->view->personList); + } + $this->view->searchform = $mySearch->searchForm(); - $this->view->groups = $pagination->getElements(); - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - // This should be activated in case the person has no membership and no rights. - $this->view->groupRequestRight = true; - $this->view->editRight = Pbs_Acl::checkRight('peod'); - $this->view->leaveRight = Pbs_Acl::checkRight('gl'); - $this->view->suspendRight = Pbs_Acl::checkRight('psa'); - $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - } + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->view->personList); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/person/index/'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); - public function editAction() - { - if(!Pbs_Acl::checkRight('peod')) { - $this->_redirect('/user'); - } - $requestedUser = $this->_request->getParam('personID'); - if($requestedUser != "" && $this->person->getID() != $requestedUser) { - if(!is_numeric($requestedUser)){ - $this->_redirect('/user/person/index/page/'.$this->page.'/modifyresult/error'); - } - if(!Pbs_Acl::checkRight('peoa')) { - $this->_redirect('/user/person/index/page/'.$this->page.'/modifyresult/forbidden'); - } - $person = $this->personmapper->find($requestedUser); - $this->view->person = $person; - } else { - $this->view->person = $this->person; - } - if (!isset($_POST["save"])){ - $editForm = new user_Form_PersonEdit(); - } else { - $editForm = new user_Form_PersonEdit($_POST); - if ($editForm->isValid($_POST)) { - if($this->person->getID() == $requestedUser) { - $person->setOptions($_POST); - $this->person->setID($this->view->person->getID()); - if($_POST['newpassword'] != '') { - $person->setPassword($_POST['newpassword']); - $person->setPasswordSalt(MD5(microtime(true))); - $person->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$')); - $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); - } - try { - $this->personmapper->save($person); - } catch(Zend_Exception $e) - { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); - $this->view->registerForm = $registerForm; - return; - } - $this->_helper->redirector('', 'person'); - } else { - $this->person->setOptions($_POST); - $this->person->setID($this->view->person->getID()); - if($_POST['newpassword'] != '') { - $this->person->setPassword($_POST['newpassword']); - $this->person->setPasswordSalt(MD5(microtime(true))); - $this->person->setLoginPassword(crypt($this->person->getPassword(), '$6$'.randomString(8).'$')); - $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); - } - try { - $this->personmapper->save($this->person); - } catch(Zend_Exception $e) - { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); - $this->view->registerForm = $registerForm; - return; - } - $this->_helper->redirector('index', 'person'); - } - return; - } - } - $this->view->editForm = $editForm; - } + $this->view->personList = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + } - public function requestAction() - { - #if(!Pbs_Acl::checkRight('grm')) { - # $this->_redirect('/user'); - #} - $this->view->person = $this->person; - $allgroups = $this->groupMapper->fetchAll(); - $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()),true); - $count = 0; - foreach($allgroups as $group) { - foreach($groupRequests as $groupRequest) { - if($groupRequest['groupID'] == $group->getID()) { - $groupsFound[$count] = true; - } else { - $groupsFound[$count] = false; - } - } - foreach($this->memberships as $membership) { - if($membership['groupID'] == $group->getID()) { - $groupsFound[$count] = true; - } else { - if(isset($groupsFound[$count]) && $groupsFound[$count] != true) { - $groupsFound[$count] = false; - } - } - } - $count++; - } - if(count($groupsFound) > 0) { - foreach($groupsFound as $k => $v) { - if($v == true) { - unset($allgroups[$k]); - } - } - } - if (!isset($_POST["request"])){ - if(count($allgroups) <= 0) { - $this->_helper->redirector('owndetails', 'person'); - return; - } - $requestForm = new user_Form_GroupRequest(array('grouplist' => $allgroups)); - } else { - $requestForm = new user_Form_GroupRequest(array('grouplist' => $allgroups), $_POST); - if ($requestForm->isValid($_POST)) { - $groupRequestMapper = new Application_Model_GroupRequestMapper(); - $groupRequest = new Application_Model_GroupRequest(); - $groupRequest->setGroupID($_POST['groupID']); - $date = new DateTime(); - $groupRequest->setTime($date->getTimestamp()); - $groupRequest->setPersonID($this->person->getID()); - foreach($groupRequests as $groupRequestDB) { - if($groupRequestDB['groupID'] == $groupRequest->getGroupID()) { - $requestFound = true; - break; - } - } - if(!$requestFound) { - try { - $groupRequestMapper->save($groupRequest); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - } - $this->_helper->redirector('owndetails', 'person'); - return; - } - } - $this->view->requestForm = $requestForm; - } + public function owndetailsAction() { +#if(!Pbs_Acl::checkRight('psod')) { +# $this->_redirect('/user'); +#} + $this->view->person = $this->person; + $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()), true); + if(isset($groupRequests)) { + $groupRequestList = array(); + foreach($groupRequests as $groupRequest) { + $group = $this->groupMapper->find($groupRequest['groupID']); + $groupRequestList[] = array( + 'grouprequestID' => $groupRequest['grouprequestID'], + 'group' => $group + ); + } + if(count($groupRequestList) > 0) { + $this->view->groupRequestList = $groupRequestList; + } + } + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->groups); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/person/index' .((isset($this->view->search)) ? '/search/'.$this->view->search : '')); - public function leaveAction() - { - if(!Pbs_Acl::checkRight('gl')) { - $this->_redirect('/user'); - } - $this->_helper-> viewRenderer-> setNoRender(); - $this->view->person = $this->person; - $membershipID = $this->_request->getParam('membershipID'); - if(isset($membershipID)) { - $membership = $this->membershipMapper->find($membershipID); - try { - $this->membershipMapper->delete($membership); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('owndetails', 'person'); - return; - } - } + $this->view->groups = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + // This should be activated in case the person has no membership and no rights. + $this->view->groupRequestRight = true; + $this->view->editRight = Pbs_Acl::checkRight('peod'); + $this->view->leaveRight = Pbs_Acl::checkRight('gl'); + $this->view->suspendRight = Pbs_Acl::checkRight('psa'); + $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + } - public function selectmembershipAction() - { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if(isset($userIDsNamespace['membershipID'])) { - $this->_redirect('/user/'); - } 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('/user/'); - } 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('/user/'); - return; - } else { - $groupMapper = new Application_Model_GroupMapper(); - $roleMapper = new Application_Model_RoleMapper(); - if(isset($this->memberships)) { - $suspendlist = array(); - foreach($this->memberships as $membership) { - $group = $groupMapper->find($membership['groupID']); - $role = $roleMapper->find($membership['roleID']); - if($membership['suspend'] == 0){ - $membershipList[] = array( - 'membershipID' => $membership['membershipID'], - 'group' => $group->getTitle(), - 'role' => $role->getTitle() - ); - } - else{ - $suspendlist[] = array( - 'membershipID' => $membership['membershipID'], - 'group' => $group->getTitle(), - 'role' => $role->getTitle()); - } + public function editAction() { + if(!Pbs_Acl::checkRight('peod')) { + $this->_redirect('/user'); + } + $requestedUser = $this->_request->getParam('personID'); + if($requestedUser != "" && $this->person->getID() != $requestedUser) { + if(!is_numeric($requestedUser)) { + $this->_redirect('/user/person/index/page/'.$this->page.'/modifyresult/error'); + } + if(!Pbs_Acl::checkRight('peoa')) { + $this->_redirect('/user/person/index/page/'.$this->page.'/modifyresult/forbidden'); + } + $person = $this->personmapper->find($requestedUser); + $this->view->person = $person; + } else { + $this->view->person = $this->person; + } + if (!isset($_POST["save"])) { + $editForm = new user_Form_PersonEdit(); + } else { + $editForm = new user_Form_PersonEdit($_POST); + if ($editForm->isValid($_POST)) { + if($this->person->getID() == $requestedUser) { + $person->setOptions($_POST); + $this->person->setID($this->view->person->getID()); + if($_POST['newpassword'] != '') { + $person->setPassword($_POST['newpassword']); + $person->setPasswordSalt(MD5(microtime(true))); + $person->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$')); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + } + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); + $this->view->registerForm = $registerForm; + return; + } + $this->_helper->redirector('', 'person'); + } else { + $this->person->setOptions($_POST); + $this->person->setID($this->view->person->getID()); + if($_POST['newpassword'] != '') { + $this->person->setPassword($_POST['newpassword']); + $this->person->setPasswordSalt(MD5(microtime(true))); + $this->person->setLoginPassword(crypt($this->person->getPassword(), '$6$'.randomString(8).'$')); + $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); + } + try { + $this->personmapper->save($this->person); + } catch(Zend_Exception $e) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); + $this->view->registerForm = $registerForm; + return; + } + $this->_helper->redirector('index', 'person'); + } + return; + } + } + $this->view->editForm = $editForm; + } - } - if(count($suspendlist) >=1){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify("Actually ".count($suspendlist)." Memberships are suspended", 'error' ); - } - } - $membershipSelectForm = new user_Form_MembershipSelect(array('membershiplist' => $membershipList)); - $this->view->membershipSelectForm = $membershipSelectForm; - } - } else { - $this->_helper->redirector('request', 'person'); - } - } - } + public function requestAction() { +#if(!Pbs_Acl::checkRight('grm')) { +# $this->_redirect('/user'); +#} + $this->view->person = $this->person; + $allgroups = $this->groupMapper->fetchAll(); + $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()), true); + $count = 0; + foreach($allgroups as $group) { + foreach($groupRequests as $groupRequest) { + if($groupRequest['groupID'] == $group->getID()) { + $groupsFound[$count] = true; + } else { + $groupsFound[$count] = false; + } + } + foreach($this->memberships as $membership) { + if($membership['groupID'] == $group->getID()) { + $groupsFound[$count] = true; + } else { + if(isset($groupsFound[$count]) && $groupsFound[$count] != true) { + $groupsFound[$count] = false; + } + } + } + $count++; + } + if(count($groupsFound) > 0) { + foreach($groupsFound as $k => $v) { + if($v == true) { + unset($allgroups[$k]); + } + } + } + if (!isset($_POST["request"])) { + if(count($allgroups) <= 0) { + $this->_helper->redirector('owndetails', 'person'); + return; + } + $requestForm = new user_Form_GroupRequest(array('grouplist' => $allgroups)); + } else { + $requestForm = new user_Form_GroupRequest(array('grouplist' => $allgroups), $_POST); + if ($requestForm->isValid($_POST)) { + $groupRequestMapper = new Application_Model_GroupRequestMapper(); + $groupRequest = new Application_Model_GroupRequest(); + $groupRequest->setGroupID($_POST['groupID']); + $date = new DateTime(); + $groupRequest->setTime($date->getTimestamp()); + $groupRequest->setPersonID($this->person->getID()); + foreach($groupRequests as $groupRequestDB) { + if($groupRequestDB['groupID'] == $groupRequest->getGroupID()) { + $requestFound = true; + break; + } + } + if(!$requestFound) { + try { + $groupRequestMapper->save($groupRequest); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } + $this->_helper->redirector('owndetails', 'person'); + return; + } + } + $this->view->requestForm = $requestForm; + } - public function changemembershipAction() - { - $this->_helper-> viewRenderer-> setNoRender(); - Zend_Session::namespaceUnset('userIDs'); - $this->_helper->redirector('selectmembership', 'person'); - return; - } + public function leaveAction() { + if(!Pbs_Acl::checkRight('gl')) { + $this->_redirect('/user'); + } + $this->_helper-> viewRenderer-> setNoRender(); + $this->view->person = $this->person; + $membershipID = $this->_request->getParam('membershipID'); + if(isset($membershipID)) { + $membership = $this->membershipMapper->find($membershipID); + try { + $this->membershipMapper->delete($membership); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('owndetails', 'person'); + return; + } + } - public function searchAction() - { - if(!Pbs_Acl::checkRight('pso')) { - $this->_redirect('/user'); - } - $this->_redirect('/user/person/index/search/'.($_GET['search'])); - } + public function selectmembershipAction() { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if(isset($userIDsNamespace['membershipID'])) { + $this->_redirect('/user/'); + } 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('/user/'); + } + 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('/user/'); + return; + } else { + $groupMapper = new Application_Model_GroupMapper(); + $roleMapper = new Application_Model_RoleMapper(); + if(isset($this->memberships)) { + $suspendlist = array(); + foreach($this->memberships as $membership) { + $group = $groupMapper->find($membership['groupID']); + $role = $roleMapper->find($membership['roleID']); + if($membership['suspend'] == 0) { + $membershipList[] = array( + 'membershipID' => $membership['membershipID'], + 'group' => $group->getTitle(), + 'role' => $role->getTitle() + ); + } else { + $suspendlist[] = array( + 'membershipID' => $membership['membershipID'], + 'group' => $group->getTitle(), + 'role' => $role->getTitle()); + } - public function showAction() - { - if(!Pbs_Acl::checkRight('psood')) { - $this->_redirect('/user'); - } - $personID = $this->_request->getParam('personID'); - if($personID) { - $person = $this->personmapper->find($personID); - $memberships = $this->membershipMapper->findBy(array("personID" => $person->getID()),true); - if(isset($memberships)) { - foreach($memberships as $membership) { - $group = $this->groupMapper->find($membership['groupID']); - $groups[] = array ( - 'groupID' => $group->getID(), - 'title' => $group->getTitle(), - 'description' => $group->getDescription(), - 'membershipID' => $membership['membershipID'] - ); - } - } - $this->view->person = $person; - $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $person->getID()),true); - if(isset($groupRequests)) { - foreach($groupRequests as $groupRequest) { - $group = $this->groupMapper->find($groupRequest['groupID']); - $groupRequestList[] = array( - 'grouprequestID' => $groupRequest['grouprequestID'], - 'group' => $group - ); - } - if(is_array($groupRequestList)) { - $this->view->groupRequestList = $groupRequestList; - } - } - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($groups); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/person/show/personID/' . $personID .((isset($this->view->search))?'/search/'.$this->view->search:'')); + } + if(count($suspendlist) >= 1) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify("Actually ".count($suspendlist)." Memberships are suspended", 'error' ); + } + } + $membershipSelectForm = new user_Form_MembershipSelect(array('membershiplist' => $membershipList)); + $this->view->membershipSelectForm = $membershipSelectForm; + } + } + else { + $this->_helper->redirector('request', 'person'); + } + } + } - $this->view->groups = $pagination->getElements(); - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->personID = $personID; - $this->view->editRight = Pbs_Acl::checkRight('peoa'); - $this->view->deleteRight = Pbs_Acl::checkRight('pd'); - $this->view->suspendRight = Pbs_Acl::checkRight('psa'); - $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - } else { - $this->_helper->redirector('', 'person'); - return; - } - } + public function changemembershipAction() { + $this->_helper-> viewRenderer-> setNoRender(); + Zend_Session::namespaceUnset('userIDs'); + $this->_helper->redirector('selectmembership', 'person'); + return; + } - public function deleterequestAction() - { - if(!Pbs_Acl::checkRight('gdm')) { - $this->_redirect('/user'); - } - $grouprequestID = $this->_request->getParam('grouprequestID'); - $grouprequest = $this->groupRequestMapper->find($grouprequestID); - try { - $this->groupRequestMapper->delete($grouprequest); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('owndetails', 'person'); - return; - } + public function searchAction() { + if(!Pbs_Acl::checkRight('pso')) { + $this->_redirect('/user'); + } + $this->_redirect('/user/person/index/search/'.($_GET['search'])); + } - public function suspendAction() - { - if(!Pbs_Acl::checkRight('psa')) { - $this->_redirect('/user'); - } - $this->_helper->viewRenderer->setNoRender(); - $personID = $this->_request->getParam('personID'); - if(isset($personID)) { - $person = $this->personmapper->find($personID); - $person->setSuspend(1); - if(isset($person)) { - try { - $this->personmapper->save($person); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/user/person/"); - } - } - } + public function showAction() { + if(!Pbs_Acl::checkRight('psood')) { + $this->_redirect('/user'); + } + $personID = $this->_request->getParam('personID'); + if($personID) { + $person = $this->personmapper->find($personID); + $memberships = $this->membershipMapper->findBy(array("personID" => $person->getID()), true); + if(isset($memberships)) { + foreach($memberships as $membership) { + $group = $this->groupMapper->find($membership['groupID']); + $groups[] = array ( + 'groupID' => $group->getID(), + 'title' => $group->getTitle(), + 'description' => $group->getDescription(), + 'membershipID' => $membership['membershipID'] + ); + } + } + $this->view->person = $person; + $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $person->getID()), true); + if(isset($groupRequests)) { + foreach($groupRequests as $groupRequest) { + $group = $this->groupMapper->find($groupRequest['groupID']); + $groupRequestList[] = array( + 'grouprequestID' => $groupRequest['grouprequestID'], + 'group' => $group + ); + } + if(is_array($groupRequestList)) { + $this->view->groupRequestList = $groupRequestList; + } + } + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($groups); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/person/show/personID/' . $personID .((isset($this->view->search)) ? '/search/'.$this->view->search : '')); - public function resumeAction() - { - if(!Pbs_Acl::checkRight('psa')) { - $this->_redirect('/user'); - } - $this->_helper->viewRenderer->setNoRender(); - $personID = $this->_request->getParam('personID'); - if(isset($personID)) { - $person = $this->personmapper->find($personID); - $person->setSuspend(0); - if(isset($person)) { - try { - $this->personmapper->save($person); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_redirect("/user/person/"); - } - } - } + $this->view->groups = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + $this->view->personID = $personID; + $this->view->editRight = Pbs_Acl::checkRight('peoa'); + $this->view->deleteRight = Pbs_Acl::checkRight('pd'); + $this->view->suspendRight = Pbs_Acl::checkRight('psa'); + $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + } else { + $this->_helper->redirector('', 'person'); + return; + } + } + + public function deleterequestAction() { + if(!Pbs_Acl::checkRight('gdm')) { + $this->_redirect('/user'); + } + $grouprequestID = $this->_request->getParam('grouprequestID'); + $grouprequest = $this->groupRequestMapper->find($grouprequestID); + try { + $this->groupRequestMapper->delete($grouprequest); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('owndetails', 'person'); + return; + } + + public function suspendAction() { + if(!Pbs_Acl::checkRight('psa')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $personID = $this->_request->getParam('personID'); + if(isset($personID)) { + $person = $this->personmapper->find($personID); + $person->setSuspend(1); + if(isset($person)) { + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/user/person/"); + } + } + } + + public function resumeAction() { + if(!Pbs_Acl::checkRight('psa')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $personID = $this->_request->getParam('personID'); + if(isset($personID)) { + $person = $this->personmapper->find($personID); + $person->setSuspend(0); + if(isset($person)) { + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_redirect("/user/person/"); + } + } + } } diff --git a/application/modules/user/controllers/PoolController.php b/application/modules/user/controllers/PoolController.php index d85bfdc..0f6636d 100644 --- a/application/modules/user/controllers/PoolController.php +++ b/application/modules/user/controllers/PoolController.php @@ -1,354 +1,341 @@ -<?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 User_PoolController extends Zend_Controller_Action -{ - private $membership; - protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('No membershipID set','forbidden'); - } - - $membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - // ACL: is he allowed to see the pools of a group - if(!Pbs_Acl::checkRight('poo')) - $this->_redirect('/user'); - - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('linkresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('link',$result); - } - $result = $this->_request->getParam('unlinkresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('unlink',$result); - } - - // get all pools from this group - $poolMapper = new Application_Model_PoolMapper(); - $pools = $poolMapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - foreach($pools as $pool){ - $ff = new Application_Model_Pool(); - $ff->setOptions($pool); - $ff->setID($pool['poolID']); - $yourpools[] = $ff; - } - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search) ->setModule('pool'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $yourpools = $mySearch->search($yourpools); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10) - ->setElement($yourpools) - ->setRequestPage($this->_request->getParam('page')) - ->setPageUrl('/user/pool/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $yourpools = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->pools = $yourpools; - - - // Get all Clients from this group - $clientmapper = new Application_Model_ClientMapper(); - $clientsArray = $clientmapper->findBy(array('groupID' => $this->membership->getGroupID()),true); - - // Get all assigned Clients - $assignedclientmapper = new Application_Model_PoolEntriesMapper(); - $assignedclients = $assignedclientmapper->fetchAll(); - foreach($assignedclients as $c){ - $assignedclientsArray[] = $c->toArray(); - } - - $db = Zend_Db_Table::getDefaultAdapter(); - // extract the un-assigned clients from the clientlist of the group - $stmt = $db->query("SELECT c.clientID, c.groupID, macadress,hardwarehash,created - FROM pbs_poolentries pe RIGHT OUTER JOIN pbs_client c ON - c.clientID = pe.clientID - WHERE poolentriesID IS NULL - AND c.groupID = '".$this->membership->getGroupID()."'"); - - $freeclients = $stmt->fetchAll(); - // Format Time-String - foreach($freeclients as $k=>$cig){- - $freeclients[$k]['created'] = date(Zend_Registry::get('dateformat'),$cig['created']); - } - - if(Pbs_Acl::checkRight('posuc')) - $this->view->freeclients = $freeclients; - } - - public function searchAction(){ - $this->_redirect('/user/pool/index/search/'.($_GET['search'])); - } - - public function createpoolAction() - { - // ACL: is he allowed to create a pool? - if(!Pbs_Acl::checkRight('poc')) - $this->_redirect('/user'); - - if (!isset($_POST["add"])){ - $addfilterform = new user_Form_Pool(array( - 'buttontext' => 'Create Pool', - 'page' => $this->page)); - $this->view->addpool = $addfilterform; - }else { - $addpoolform = new user_Form_Pool(array( - 'buttontext' => 'Create Pool', - 'page' => $this->page),$_POST); - if ($addpoolform->isValid($_POST)) { - try{ - $pool = new Application_Model_Pool($_POST); - $pool->setGroupID($this->membership->getGroupID()); - $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->save($pool); - $this->_redirect('/user/pool/index/addresult/ok'); - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/pool/index/addresult/error'); - } - } - $this->view->addpool = $addpoolform; - } - } - - public function deletepoolAction() - { - $poolID = $this->_request->getParam('poolID'); - - // ACL: is he allowed to delete a pool? - if(!Pbs_Acl::checkRight('pod')) - $this->_redirect('/user'); - - if(is_numeric($poolID)){ - $poolmapper = new Application_Model_PoolMapper(); - $pool = new Application_Model_Pool(); - $poolmapper->find($poolID,$pool); - if($this->membership->getGroupID() == $pool->getGroupID()){ - $deletepool = new Application_Model_Pool(); - $deletepool->setID($poolID); - $poolmapper->delete($deletepool); - $this->_redirect('/user/pool/index/page/'.$this->page.'/deleteresult/ok'); - } - else{ - $this->_redirect('/user/pool/index/page/'.$this->page.'/deleteresult/forbidden'); - } - } - $this->_redirect('/user/pool/index/page/'.$this->page.'/deleteresult/error'); - } - - public function editpoolAction() - { - // ACL: is he allowed to edit a pool? - if(!Pbs_Acl::checkRight('poe')) - $this->_redirect('/user'); - - if (!isset($_POST["add"])){ - $poolID = $this->_request->getParam('poolID'); - $pool = new Application_Model_Pool(); - $poolmapper = new Application_Model_PoolMapper(); - $poolmapper->find($poolID,$pool); - if($pool->getGroupID() == $this->membership->getGroupID()){ - $poolArray = $pool->toArray(); - $editpool = new user_Form_Pool(array( - 'buttontext' => 'Edit Pool', - 'page' => $this->page)); - $editpool->populate($poolArray); - $this->view->editpool = $editpool; - } - else{ - $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/forbidden'); - } - }else { - $editpoolform = new user_Form_Pool(array( - 'buttontext' => 'Edit Pool', - 'page' => $this->page),$_POST); - if ($editpoolform->isValid($_POST)) { - try{ - $poolmapper = new Application_Model_PoolMapper(); - $poolID = $this->_request->getParam('poolID'); - $pooldb = new Application_Model_Pool(); - $poolmapper->find($poolID,$pooldb); - print_a($pooldb->getGroupID(), $this->membership->getGroupID()); - if($pooldb->getGroupID() == $this->membership->getGroupID()){ - $pool = new Application_Model_Pool($_POST); - $pool->setID($poolID) - ->setGroupID($this->membership->getGroupID()); - $poolmapper->save($pool); - $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/ok'); - } - else{ - $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/forbidden'); - } - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/error'); - } - } - $this->view->editpool = $editpoolform; - } - } - - public function linkclientAction() - { - $clientID = $this->_request->getParam('clientID'); - $poolID = $this->_request->getParam('poolID'); - - // ACL: Is he allowed to link clients to pools? - if(!Pbs_Acl::checkRight('polc')) - $this->_redirect('/user'); - - if(!isset($_POST['clientID']) && ($clientID == '')){ - $clientmapper = new Application_Model_ClientMapper(); - $clients = $clientmapper->findBy(array('groupID',$this->membership->getGroupID()),true); - $assignedclientmapper = new Application_Model_PoolEntriesMapper(); - $assignedclients = $assignedclientmapper->fetchAll(); - foreach($assignedclients as $c){ - $assignedclientsArray[] = $c->toArray(); - } - $freeclients = $this->arrayDiff($clients,$assignedclientsArray); - - $poolclient = new user_Form_PoolClient(array( - 'buttontext' => 'Link Client', - 'clients'=> $freeclients, - 'page' => $this->page)); - $this->view->poolclient = $poolclient; - }else { - $poolclient = new user_Form_PoolClient(array( - 'buttontext' => 'Link Client', - 'page' => $this->page),$_POST); - try{ - $poolID = $this->_request->getParam('poolID'); - $poolmapper = new Application_Model_PoolMapper(); - $pooldb = new Application_Model_Pool(); - $poolmapper->find($poolID,$pooldb); - $clientmapper = new Application_Model_ClientMapper(); - $clientdb = new Application_Model_Client(); - $clientmapper->find($clientID,$clientdb); - - if($pooldb->getGroupID() == $this->membership->getGroupID() && $clientdb->getGroupID() == $this->membership->getGroupID()){ - $poolentriesmapper = new Application_Model_PoolEntriesMapper(); - $poolentry = new Application_Model_PoolEntries($_POST); - $poolentry->setPoolID($poolID); - if($poolentry->getClientID() == ''){ - $poolentry->setClientID($clientID); - } - $poolentriesmapper->save($poolentry); - $this->_redirect('/user/pool/index/page/'.$this->page.'/linkresult/ok'); - } - else{ - $this->_redirect('/user/pool/index/page/'.$this->page.'/linkresult/forbidden'); - } - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - $this->_redirect('/user/pool/index/page/'.$this->page.'/linkresult/error'); - } - $this->view->poolclient = $poolclient; - } - } - - public function unlinkclientAction() - { - $poolentriesID = $this->_request->getParam('poolentriesID'); - - // ACL: Is he allowed to unlink clients from pools? - if(!Pbs_Acl::checkRight('pouc')) - $this->_redirect('/user'); - - if(is_numeric($poolentriesID)){ - $poolentriesMapper = new Application_Model_PoolEntriesMapper(); - $poolentry = new Application_Model_PoolEntries(); - $poolentriesMapper->find($poolentriesID,$poolentry); - $clientMapper = new Application_Model_ClientMapper(); - $client = new Application_Model_Client(); - - $poolMapper = new Application_Model_PoolMapper(); - $pool = new Application_Model_Pool(); - - $clientMapper->find($poolentry->getClientID(),$client); - $poolMapper->find($poolentry->getPoolID(),$pool); - - - if($pool->getGroupID() == $this->membership->getGroupID() && $client->getGroupID() == $this->membership->getGroupID()){ - $deletepoolentries = new Application_Model_PoolEntries(); - $deletepoolentries->setID($poolentriesID); - $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper(); - $deletepoolentriesmapper->delete($deletepoolentries); - $this->_redirect('/user/pool/index/page/'.$this->page.'/unlinkresult/ok'); - } - else{ - $this->_redirect('/user/pool/index/page/'.$this->page.'/unlinkresult/forbidden'); - } - } - else{ - $this->_redirect('/user/pool/index/page/'.$this->page.'/unlinkresult/error'); - } - } - - // creates an array of two arrays - // first parameter is the list of all clients - // second parameter is the list of clients which are already in a group - // return value is a list of all clients, which are in no group - private function arrayDiff($a, $b){ - foreach($a as $k1 => $i1){ - foreach($b as $k2 => $i2){ - if($i1['clientID'] == $i2['clientID']){ - unset($a[$k1]); - } - } - } - return $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 User_PoolController extends Zend_Controller_Action { + private $membership; + protected $page; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set', 'forbidden'); + } + + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + // ACL: is he allowed to see the pools of a group + if(!Pbs_Acl::checkRight('poo')) + { $this->_redirect('/user'); } + + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('linkresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('link', $result); + } + $result = $this->_request->getParam('unlinkresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('unlink', $result); + } + + // get all pools from this group + $poolMapper = new Application_Model_PoolMapper(); + $pools = $poolMapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + foreach($pools as $pool) { + $ff = new Application_Model_Pool(); + $ff->setOptions($pool); + $ff->setID($pool['poolID']); + $yourpools[] = $ff; + } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search) ->setModule('pool'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $yourpools = $mySearch->search($yourpools); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10) + ->setElement($yourpools) + ->setRequestPage($this->_request->getParam('page')) + ->setPageUrl('/user/pool/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $yourpools = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + $this->view->pools = $yourpools; + + + // Get all Clients from this group + $clientmapper = new Application_Model_ClientMapper(); + $clientsArray = $clientmapper->findBy(array('groupID' => $this->membership->getGroupID()), true); + + // Get all assigned Clients + $assignedclientmapper = new Application_Model_PoolEntriesMapper(); + $assignedclients = $assignedclientmapper->fetchAll(); + foreach($assignedclients as $c) { + $assignedclientsArray[] = $c->toArray(); + } + + $db = Zend_Db_Table::getDefaultAdapter(); + // extract the un-assigned clients from the clientlist of the group + $stmt = $db->query("SELECT c.clientID, c.groupID, macadress,hardwarehash,created + FROM pbs_poolentries pe RIGHT OUTER JOIN pbs_client c ON + c.clientID = pe.clientID + WHERE poolentriesID IS NULL + AND c.groupID = '".$this->membership->getGroupID()."'"); + + $freeclients = $stmt->fetchAll(); + // Format Time-String + foreach($freeclients as $k => $cig) { + - + $freeclients[$k]['created'] = date(Zend_Registry::get('dateformat'), $cig['created']); + } + + if(Pbs_Acl::checkRight('posuc')) + { $this->view->freeclients = $freeclients; } + } + + public function searchAction() { + $this->_redirect('/user/pool/index/search/'.($_GET['search'])); + } + + public function createpoolAction() { + // ACL: is he allowed to create a pool? + if(!Pbs_Acl::checkRight('poc')) + { $this->_redirect('/user'); } + + if (!isset($_POST["add"])) { + $addfilterform = new user_Form_Pool(array( + 'buttontext' => 'Create Pool', + 'page' => $this->page)); + $this->view->addpool = $addfilterform; + } else { + $addpoolform = new user_Form_Pool(array( + 'buttontext' => 'Create Pool', + 'page' => $this->page), $_POST); + if ($addpoolform->isValid($_POST)) { + try { + $pool = new Application_Model_Pool($_POST); + $pool->setGroupID($this->membership->getGroupID()); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->save($pool); + $this->_redirect('/user/pool/index/addresult/ok'); + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/pool/index/addresult/error'); + } + } + $this->view->addpool = $addpoolform; + } + } + + public function deletepoolAction() { + $poolID = $this->_request->getParam('poolID'); + + // ACL: is he allowed to delete a pool? + if(!Pbs_Acl::checkRight('pod')) + { $this->_redirect('/user'); } + + if(is_numeric($poolID)) { + $poolmapper = new Application_Model_PoolMapper(); + $pool = new Application_Model_Pool(); + $poolmapper->find($poolID, $pool); + if($this->membership->getGroupID() == $pool->getGroupID()) { + $deletepool = new Application_Model_Pool(); + $deletepool->setID($poolID); + $poolmapper->delete($deletepool); + $this->_redirect('/user/pool/index/page/'.$this->page.'/deleteresult/ok'); + } else { + $this->_redirect('/user/pool/index/page/'.$this->page.'/deleteresult/forbidden'); + } + } + $this->_redirect('/user/pool/index/page/'.$this->page.'/deleteresult/error'); + } + + public function editpoolAction() { + // ACL: is he allowed to edit a pool? + if(!Pbs_Acl::checkRight('poe')) + { $this->_redirect('/user'); } + + if (!isset($_POST["add"])) { + $poolID = $this->_request->getParam('poolID'); + $pool = new Application_Model_Pool(); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->find($poolID, $pool); + if($pool->getGroupID() == $this->membership->getGroupID()) { + $poolArray = $pool->toArray(); + $editpool = new user_Form_Pool(array( + 'buttontext' => 'Edit Pool', + 'page' => $this->page)); + $editpool->populate($poolArray); + $this->view->editpool = $editpool; + } else { + $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/forbidden'); + } + } else { + $editpoolform = new user_Form_Pool(array( + 'buttontext' => 'Edit Pool', + 'page' => $this->page), $_POST); + if ($editpoolform->isValid($_POST)) { + try { + $poolmapper = new Application_Model_PoolMapper(); + $poolID = $this->_request->getParam('poolID'); + $pooldb = new Application_Model_Pool(); + $poolmapper->find($poolID, $pooldb); + print_a($pooldb->getGroupID(), $this->membership->getGroupID()); + if($pooldb->getGroupID() == $this->membership->getGroupID()) { + $pool = new Application_Model_Pool($_POST); + $pool->setID($poolID) + ->setGroupID($this->membership->getGroupID()); + $poolmapper->save($pool); + $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/ok'); + } else { + $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/forbidden'); + } + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/pool/index/page/'.$this->page.'/modifyresult/error'); + } + } + $this->view->editpool = $editpoolform; + } + } + + public function linkclientAction() { + $clientID = $this->_request->getParam('clientID'); + $poolID = $this->_request->getParam('poolID'); + + // ACL: Is he allowed to link clients to pools? + if(!Pbs_Acl::checkRight('polc')) + { $this->_redirect('/user'); } + + if(!isset($_POST['clientID']) && ($clientID == '')) { + $clientmapper = new Application_Model_ClientMapper(); + $clients = $clientmapper->findBy(array('groupID', $this->membership->getGroupID()), true); + $assignedclientmapper = new Application_Model_PoolEntriesMapper(); + $assignedclients = $assignedclientmapper->fetchAll(); + foreach($assignedclients as $c) { + $assignedclientsArray[] = $c->toArray(); + } + $freeclients = $this->arrayDiff($clients, $assignedclientsArray); + + $poolclient = new user_Form_PoolClient(array( + 'buttontext' => 'Link Client', + 'clients' => $freeclients, + 'page' => $this->page)); + $this->view->poolclient = $poolclient; + } else { + $poolclient = new user_Form_PoolClient(array( + 'buttontext' => 'Link Client', + 'page' => $this->page), $_POST); + try { + $poolID = $this->_request->getParam('poolID'); + $poolmapper = new Application_Model_PoolMapper(); + $pooldb = new Application_Model_Pool(); + $poolmapper->find($poolID, $pooldb); + $clientmapper = new Application_Model_ClientMapper(); + $clientdb = new Application_Model_Client(); + $clientmapper->find($clientID, $clientdb); + + if($pooldb->getGroupID() == $this->membership->getGroupID() && $clientdb->getGroupID() == $this->membership->getGroupID()) { + $poolentriesmapper = new Application_Model_PoolEntriesMapper(); + $poolentry = new Application_Model_PoolEntries($_POST); + $poolentry->setPoolID($poolID); + if($poolentry->getClientID() == '') { + $poolentry->setClientID($clientID); + } + $poolentriesmapper->save($poolentry); + $this->_redirect('/user/pool/index/page/'.$this->page.'/linkresult/ok'); + } else { + $this->_redirect('/user/pool/index/page/'.$this->page.'/linkresult/forbidden'); + } + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + $this->_redirect('/user/pool/index/page/'.$this->page.'/linkresult/error'); + } + $this->view->poolclient = $poolclient; + } + } + + public function unlinkclientAction() { + $poolentriesID = $this->_request->getParam('poolentriesID'); + + // ACL: Is he allowed to unlink clients from pools? + if(!Pbs_Acl::checkRight('pouc')) + { $this->_redirect('/user'); } + + if(is_numeric($poolentriesID)) { + $poolentriesMapper = new Application_Model_PoolEntriesMapper(); + $poolentry = new Application_Model_PoolEntries(); + $poolentriesMapper->find($poolentriesID, $poolentry); + $clientMapper = new Application_Model_ClientMapper(); + $client = new Application_Model_Client(); + + $poolMapper = new Application_Model_PoolMapper(); + $pool = new Application_Model_Pool(); + + $clientMapper->find($poolentry->getClientID(), $client); + $poolMapper->find($poolentry->getPoolID(), $pool); + + + if($pool->getGroupID() == $this->membership->getGroupID() && $client->getGroupID() == $this->membership->getGroupID()) { + $deletepoolentries = new Application_Model_PoolEntries(); + $deletepoolentries->setID($poolentriesID); + $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper(); + $deletepoolentriesmapper->delete($deletepoolentries); + $this->_redirect('/user/pool/index/page/'.$this->page.'/unlinkresult/ok'); + } else { + $this->_redirect('/user/pool/index/page/'.$this->page.'/unlinkresult/forbidden'); + } + } else { + $this->_redirect('/user/pool/index/page/'.$this->page.'/unlinkresult/error'); + } + } + + // creates an array of two arrays + // first parameter is the list of all clients + // second parameter is the list of clients which are already in a group + // return value is a list of all clients, which are in no group + private function arrayDiff($a, $b) { + foreach($a as $k1 => $i1) { + foreach($b as $k2 => $i2) { + if($i1['clientID'] == $i2['clientID']) { + unset($a[$k1]); + } + } + } + return $a; + } } diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index b0b1077..6e22e78 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -1,267 +1,260 @@ -<?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 User_PrebootController extends Zend_Controller_Action -{ - - protected $prebootMapper; - protected $membershipMapper; - protected $membership; - protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $this->_redirect('/user/index'); - } - - $this->prebootMapper = new Application_Model_PreBootMapper(); - - $this->membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - - $this->db = Zend_Db_Table::getDefaultAdapter(); - } else { - $this->_helper->redirector('login', 'auth'); - } - $this->page = $this->_request->getParam('page'); - } - - - public function indexAction() - { - $result = $this->_request->getParam('addresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('create',$result); - } - $result = $this->_request->getParam('deleteresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('delete',$result); - } - $result = $this->_request->getParam('modifyresult'); - if($result != ""){ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('modify',$result); - } - - $groupID = $this->membership->getGroupID(); - - //ACL Darf er PrebootMenu sehen? - if(!Pbs_Acl::checkRight('pro')) - $this->_redirect('/user/index'); - - $this->view->prebootlist = $this->prebootMapper->findBy(array("groupID" => $groupID)); - foreach ($this->view->prebootlist as $preboot){ - $preboot->setCreated(date(Zend_Registry::get('dateformat'),$preboot->getCreated())); - } - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('preboot'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->prebootlist = $mySearch->search($this->view->prebootlist); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->view->prebootlist); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/preboot/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $this->view->prebootlist = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - - $this->view->page = $pagination->getRequestPage(); +* 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 User_PrebootController extends Zend_Controller_Action { + + protected $prebootMapper; + protected $membershipMapper; + protected $membership; + protected $page; + + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $this->_redirect('/user/index'); + } + + $this->prebootMapper = new Application_Model_PreBootMapper(); + + $this->membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + + $this->db = Zend_Db_Table::getDefaultAdapter(); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + + public function indexAction() { + $result = $this->_request->getParam('addresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create', $result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete', $result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != "") { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify', $result); + } + + $groupID = $this->membership->getGroupID(); + + //ACL Darf er PrebootMenu sehen? + if(!Pbs_Acl::checkRight('pro')) + { $this->_redirect('/user/index'); } + + $this->view->prebootlist = $this->prebootMapper->findBy(array("groupID" => $groupID)); + foreach ($this->view->prebootlist as $preboot) { + $preboot->setCreated(date(Zend_Registry::get('dateformat'), $preboot->getCreated())); + } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('preboot'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $this->view->prebootlist = $mySearch->search($this->view->prebootlist); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->view->prebootlist); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/preboot/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $this->view->prebootlist = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + + $this->view->page = $pagination->getRequestPage(); + + } + + public function searchAction() { + $this->_redirect('/user/preboot/index/search/'.($_GET['search'])); + } + + public function createprebootAction() { + + //ACL Is he allowed to create Preboots? + if(!Pbs_Acl::checkRight('prc')) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/forbidden'); } + + if (!isset($_POST["createpreboot"])) { + $prebootForm = new user_Form_Preboot(array( + 'action' => 'createpreboot', + 'page' => $this->page)); + } else { + + $prebootForm = new user_Form_Preboot(array( + 'action' => 'createpreboot', + 'page' => $this->page), $_POST); + + if ($prebootForm->isValid($_POST)) { + + $groupID = $this->membership->getGroupID(); + $source = $_SERVER['REMOTE_ADDR']; + + try { + if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != '') { + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/file'); + } + + + $preboot = new Application_Model_PreBoot($_POST); + + $preboot->setGroupID($groupID); + $preboot->setSource($source); + $preboot->setCreated(time()); + + $prebootID = $this->prebootMapper->save($preboot); + + $prebootpath = "../resources/bootmedium/".$prebootID."/"; + mkdir($prebootpath , 0777, true); + + if($_FILES['preboot']['name'] != '') { + move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip"); + } + + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/error'); + //TODO Delete folder + preboot in DB + + } + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->prebootForm = $prebootForm; + } + + public function editprebootAction() { + //ACL Is he allowed to edit Preboots? + if(!Pbs_Acl::checkRight('pre') && !Pbs_Acl::checkRight('prem')) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); } + + $prebootID = $this->_request->getParam('prebootID'); + + if (!is_numeric($prebootID)) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); } + + $preboot = new Application_Model_PreBoot(); + $this->prebootMapper->find($prebootID, $preboot); + + if($this->membership->getGroupID() != $preboot->getGroupID()) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); } + + if (!isset($_POST["editpreboot"])) { + + $prebootForm = new user_Form_Preboot(array( + 'action' => 'editpreboot', + 'page' => $this->page)); + $prebootForm->populate($preboot->toArray()); + + } else { + + $prebootForm = new user_Form_Preboot(array( + 'action' => 'editpreboot', + 'page' => $this->page), $_POST); + + if ($prebootForm->isValid($_POST)) { + + $prebootold = $preboot; + $source = $_SERVER['REMOTE_ADDR']; + + $preboot = new Application_Model_PreBoot($_POST); + $preboot->setGroupID($this->membership->getGroupID()); + $preboot->setID($prebootID); + $preboot->setSource($prebootold->getSource()); + $preboot->setCreated(time()); + + if($_FILES['preboot']['name'] != '') { + //ACL Is he allowed to edit other than Metadata? + if(!Pbs_Acl::checkRight('pre')) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); } + } + + if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != '') { + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/file'); + } + + $prebootpath = "../resources/bootmedium/$prebootID/"; + + mkdir($prebootpath , 0777, true); + + if($_FILES['preboot']['name'] != '') { + $preboot->setSource($source); + move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip"); + } + + try { + $this->prebootMapper->save($preboot); + + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); + //TODO Delete Folder + Preboot + } + + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/ok'); + } + } + + $this->view->prebootForm = $prebootForm; + } + + public function deleteprebootAction() { + + //ACL Is he allowed to delete Preboots? + if(!Pbs_Acl::checkRight('prd')) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); } + + try { + $prebootID = $this->_request->getParam('prebootID'); + if (!is_numeric($prebootID)) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); } + + $preboot = new Application_Model_PreBoot(); + $this->prebootMapper->find($prebootID, $preboot); + + if($this->membership->getGroupID() != $preboot->getGroupID()) + { $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); } + + $this->prebootMapper->delete($preboot); + exec("rm -r ../resources/bootmedium/".$prebootID); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/error'); } - - public function searchAction(){ - $this->_redirect('/user/preboot/index/search/'.($_GET['search'])); - } - - public function createprebootAction() - { - - //ACL Is he allowed to create Preboots? - if(!Pbs_Acl::checkRight('prc')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/forbidden'); - - if (!isset($_POST["createpreboot"])){ - $prebootForm = new user_Form_Preboot(array( - 'action' => 'createpreboot', - 'page' => $this->page)); - } else { - - $prebootForm = new user_Form_Preboot(array( - 'action' => 'createpreboot', - 'page' => $this->page),$_POST); - - if ($prebootForm->isValid($_POST)) { - - $groupID = $this->membership->getGroupID(); - $source = $_SERVER['REMOTE_ADDR']; - - try { - if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != ''){ - $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/file'); - } - - - $preboot = new Application_Model_PreBoot($_POST); - - $preboot->setGroupID($groupID); - $preboot->setSource($source); - $preboot->setCreated(time()); - - $prebootID = $this->prebootMapper->save($preboot); - - $prebootpath = "../resources/bootmedium/".$prebootID."/"; - mkdir($prebootpath ,0777, true); - - if($_FILES['preboot']['name'] != ''){ - move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip"); - } - - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/error'); - //TODO Delete folder + preboot in DB - - } - $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/ok'); - } - } - - $this->view->prebootForm = $prebootForm; - } - - public function editprebootAction() - { - //ACL Is he allowed to edit Preboots? - if(!Pbs_Acl::checkRight('pre') && !Pbs_Acl::checkRight('prem')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - - $prebootID = $this->_request->getParam('prebootID'); - - if (!is_numeric($prebootID)) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - - $preboot = new Application_Model_PreBoot(); - $this->prebootMapper->find($prebootID, $preboot); - - if($this->membership->getGroupID() != $preboot->getGroupID()) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - - if (!isset($_POST["editpreboot"])){ - - $prebootForm = new user_Form_Preboot(array( - 'action' => 'editpreboot', - 'page' => $this->page)); - $prebootForm->populate($preboot->toArray()); - - }else{ - - $prebootForm = new user_Form_Preboot(array( - 'action' => 'editpreboot', - 'page' => $this->page),$_POST); - - if ($prebootForm->isValid($_POST)) { - - $prebootold = $preboot; - $source = $_SERVER['REMOTE_ADDR']; - - $preboot = new Application_Model_PreBoot($_POST); - $preboot->setGroupID($this->membership->getGroupID()); - $preboot->setID($prebootID); - $preboot->setSource($prebootold->getSource()); - $preboot->setCreated(time()); - - if($_FILES['preboot']['name'] != ''){ - //ACL Is he allowed to edit other than Metadata? - if(!Pbs_Acl::checkRight('pre')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - } - - if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != ''){ - $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/file'); - } - - $prebootpath = "../resources/bootmedium/$prebootID/"; - - mkdir($prebootpath ,0777, true); - - if($_FILES['preboot']['name'] != ''){ - $preboot->setSource($source); - move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip"); - } - - try { - $this->prebootMapper->save($preboot); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); - //TODO Delete Folder + Preboot - } - - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/ok'); - } - } - - $this->view->prebootForm = $prebootForm; - } - - public function deleteprebootAction() - { - - //ACL Is he allowed to delete Preboots? - if(!Pbs_Acl::checkRight('prd')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); - - try{ - $prebootID = $this->_request->getParam('prebootID'); - if (!is_numeric($prebootID)) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); - - $preboot = new Application_Model_PreBoot(); - $this->prebootMapper->find($prebootID, $preboot); - - if($this->membership->getGroupID() != $preboot->getGroupID()) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); - - $this->prebootMapper->delete($preboot); - exec("rm -r ../resources/bootmedium/".$prebootID); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/ok'); - } + $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/ok'); + } } diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index 4a4640f..8d8c3c2 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -1,474 +1,458 @@ -<?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 User_RoleController extends Zend_Controller_Action -{ - protected $userIDsNamespace = null; - protected $membership; - protected $membershipMapper; +class User_RoleController extends Zend_Controller_Action { + protected $userIDsNamespace = null; + protected $membership; + protected $membershipMapper; - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($this->userIDsNamespace['roleID'] ==''){ - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('No roleID set','forbidden'); - } - $this->roleMapper = new Application_Model_RoleMapper(); - $this->rightMapper = new Application_Model_RightMapper(); - $this->rightRolesMapper = new Application_Model_RightRolesMapper(); - $this->membershipMapper = new Application_Model_MembershipMapper(); - - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - $this->membership = new Application_Model_Membership(); - $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - } else { - $this->_helper->redirector('login', 'auth'); - } - if($this->membership->getGroupID() == ''){ - $this->_helper->redirector('selectmembership', 'person'); - } - } + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($this->userIDsNamespace['roleID'] == '') { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No roleID set', 'forbidden'); + } + $this->roleMapper = new Application_Model_RoleMapper(); + $this->rightMapper = new Application_Model_RightMapper(); + $this->rightRolesMapper = new Application_Model_RightRolesMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); - public function indexAction() - { - if(!Pbs_Acl::checkRight('ro')) { - $this->_redirect('/user'); - } - $this->view->membership = $this->membership; - $groupID = $this->membership->getGroupID(); - $this->view->roleList = $this->roleMapper->findBy(array('groupID' => $groupID),true); - - $roles = array(); - $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); - $parents = $groupGroupsMapper->getParentGroups($groupID); - $groupMapper = new Application_Model_GroupMapper(); - $roleMapper = new Application_Model_RoleMapper(); - $crawled = array(); - foreach($parents as $p){ - foreach($p as $a){ - if(!in_array($a,$crawled)){ - $crawled[] = $a; - $group = $groupMapper->find($a); - if($groupID != $a) - $r = $roleMapper->findBy(array('groupID' => $a,'inheritance'=>"1")); - else - $r = $roleMapper->findBy(array('groupID' => $a)); - foreach($r as $d){ - $roles[$group->getTitle()][] = $d; - } - } - } - } - $this->view->roleList = $roles; - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('role'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->roleList = $mySearch->search($this->view->roleList); - } - $this->view->searchform = $mySearch->searchForm(); + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + } else { + $this->_helper->redirector('login', 'auth'); + } + if($this->membership->getGroupID() == '') { + $this->_helper->redirector('selectmembership', 'person'); + } + } - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); - $pagination->setElement($this->view->roleList); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/role/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); + public function indexAction() { + if(!Pbs_Acl::checkRight('ro')) { + $this->_redirect('/user'); + } + $this->view->membership = $this->membership; + $groupID = $this->membership->getGroupID(); + $this->view->roleList = $this->roleMapper->findBy(array('groupID' => $groupID), true); - $this->view->roleList = $pagination->getElements(); - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->addRight = Pbs_Acl::checkRight('ra'); - $this->view->editRight = Pbs_Acl::checkRight('re'); - $this->view->deleteRight = Pbs_Acl::checkRight('rd'); - $this->view->detailsRight = Pbs_Acl::checkRight('rdd'); - $this->view->userIDsNamespace = $this->userIDsNamespace; + $roles = array(); + $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); + $parents = $groupGroupsMapper->getParentGroups($groupID); + $groupMapper = new Application_Model_GroupMapper(); + $roleMapper = new Application_Model_RoleMapper(); + $crawled = array(); + foreach($parents as $p) { + foreach($p as $a) { + if(!in_array($a, $crawled)) { + $crawled[] = $a; + $group = $groupMapper->find($a); + if($groupID != $a) + { $r = $roleMapper->findBy(array('groupID' => $a, 'inheritance' => "1")); } + else + { $r = $roleMapper->findBy(array('groupID' => $a)); } + foreach($r as $d) { + $roles[$group->getTitle()][] = $d; + } + } + } + } + $this->view->roleList = $roles; - } + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('role'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $this->view->roleList = $mySearch->search($this->view->roleList); + } + $this->view->searchform = $mySearch->searchForm(); - public function searchAction(){ - if(!Pbs_Acl::checkRight('ro')) { - $this->_redirect('/user'); - } - $this->_redirect('/user/role/index/search/'.($_GET['search'])); - } + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); + $pagination->setElement($this->view->roleList); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/role/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); - public function addAction() - { - if(!Pbs_Acl::checkRight('ra')) { - $this->_redirect('/user'); - } + $this->view->roleList = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + $this->view->addRight = Pbs_Acl::checkRight('ra'); + $this->view->editRight = Pbs_Acl::checkRight('re'); + $this->view->deleteRight = Pbs_Acl::checkRight('rd'); + $this->view->detailsRight = Pbs_Acl::checkRight('rdd'); + $this->view->userIDsNamespace = $this->userIDsNamespace; - $roleID = $this->userIDsNamespace['roleID']; - $rights = $this->rightMapper->fetchAll(); - if(count($rights) > 0) { - $rightCategoryMapper = new Application_Model_RightCategoryMapper(); - foreach($rights as $right) { - $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); - $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); - } - } - if (!isset($_POST["add"])){ - $addForm = new user_Form_RoleAdd(array('rightlist' => $rightlist, 'inheritanceright' => Pbs_Acl::checkRight('rir'), 'addrighttoroleright' => Pbs_Acl::checkRight('rar'))); - } else { - $addForm = new user_Form_RoleAdd(array('rightlist' => $rightlist, 'inheritanceright' => Pbs_Acl::checkRight('rir'), 'addrighttoroleright' => Pbs_Acl::checkRight('rar')),$_POST); - if ($addForm->isValid($_POST)) { - $_POST['groupID'] = $this->userIDsNamespace['groupID']; - $role = new Application_Model_Role($_POST); - try { - $this->roleMapper->save($role); - $db = Zend_Db_Table::getDefaultAdapter(); - $insertedRoleID = $db->lastInsertId(); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - foreach($_POST['rights'] as $rightID => $bool) { - if($bool == 1) { - $rightrole = new Application_Model_RightRoles(); - $rightrole->setRightID($rightID); - $rightrole->setRoleID($insertedRoleID); - try { - $this->rightRolesMapper->save($rightrole); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - } - } - $this->_helper->redirector('', 'role'); - return; - } - } - $this->view->addForm = $addForm; - } + } - public function editAction() - { - if(!Pbs_Acl::checkRight('re')) { - $this->_redirect('/user'); - } - $roleID = $this->_request->getParam('roleID'); - if(!isset($roleID)) { - if(count($this->userIDsNamespace) > 0) { - $roleID = $this->userIDsNamespace['roleID']; - } - } - if(!isset($roleID)) { - $this->_helper->redirector('add', 'role'); - return; - } else { - $roleMapper = new Application_Model_RoleMapper(); - $role = $roleMapper->find($roleID); - $roleGroupID = $role->getGroupID(); - } - if($this->userIDsNamespace['groupID'] == $roleGroupID) { - if (!isset($_POST["save"])){ - $role = $this->roleMapper->find($roleID); - $_POST['title'] = $role->getTitle(); - $_POST['description'] = $role->getDescription(); - $_POST['groupID'] = $role->getGroupID(); - $_POST['inheritance'] = $role->getInheritance(); - $editForm = new user_Form_RoleEdit(array('roleID' => $roleID, 'inheritanceright' => Pbs_Acl::checkRight('rir'))); - } else { - $editForm = new user_Form_RoleEdit(array('roleID' => $roleID, 'inheritanceright' => Pbs_Acl::checkRight('rir')), $_POST); - if ($editForm->isValid($_POST)) { + public function searchAction() { + if(!Pbs_Acl::checkRight('ro')) { + $this->_redirect('/user'); + } + $this->_redirect('/user/role/index/search/'.($_GET['search'])); + } - $role = new Application_Model_Role($_POST); - $role->setID($roleID); - try { - $this->roleMapper->save($role); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - $this->_helper->redirector('', 'role'); - return; - } - } - $this->view->editForm = $editForm; - } else { - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('modify','forbidden'); - $this->_helper-> viewRenderer-> setNoRender(); - return; - } - } + public function addAction() { + if(!Pbs_Acl::checkRight('ra')) { + $this->_redirect('/user'); + } - public function showAction() - { - if(!Pbs_Acl::checkRight('rdd')) { - $this->_redirect('/user'); - } - $roleID = $this->_request->getParam('roleID'); - if(!isset($roleID)) { - if(count($this->userIDsNamespace) > 0) { - $roleID = $this->userIDsNamespace['roleID']; - } - } - $this->view->membership = $this->membership; - if($roleID) { - $roleMapper = new Application_Model_RoleMapper(); - $role = $roleMapper->find($roleID); - $roleGroupID = $role->getGroupID(); - if($this->userIDsNamespace['groupID'] == $roleGroupID || $role->getInheritance() == 1) { - $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID),true); - if(count($rightroles) > 0) { - foreach($rightroles as $rightrole) { - $right = $this->rightMapper->find($rightrole['rightID']); - $rightsList[$right->getRightcategoryID()][] = $right; - } - if(is_array($rightsList)) { - $this->view->rightsList = $rightsList; - } - } - $rightCategoryMapper = new Application_Model_RightCategoryMapper(); - $rightCategories = $rightCategoryMapper->fetchAll(); - if(count($rightCategories) > 0) { - foreach($rightCategories as $rightCategory) { - $rightcategorieslist[$rightCategory->getID()] = $rightCategory->getTitle(); - } - $this->view->rightcategorieslist = $rightcategorieslist; - } - $rights = $this->rightMapper->fetchAll(); - if(count($rights) == count($rightroles)) { - $this->view->rightsAvailable = false; - } else { - $this->view->rightsAvailable = true; - } - $this->view->editRight = Pbs_Acl::checkRight('re'); - $this->view->deleteRight = Pbs_Acl::checkRight('rd'); - $this->view->addRightToRoleRight = Pbs_Acl::checkRight('rar'); - $this->view->removeRightOfRoleRight = Pbs_Acl::checkRight('rrr'); - $this->view->role = $this->roleMapper->find($roleID); - $this->view->roleID = $roleID; - $this->view->userIDsNamespace = $this->userIDsNamespace; - } else { - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('view','forbidden'); - $this->_helper-> viewRenderer-> setNoRender(); - return; - } - } else { - $this->_helper->redirector('', 'role'); - return; - } - } + $roleID = $this->userIDsNamespace['roleID']; + $rights = $this->rightMapper->fetchAll(); + if(count($rights) > 0) { + $rightCategoryMapper = new Application_Model_RightCategoryMapper(); + foreach($rights as $right) { + $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); + $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); + } + } + if (!isset($_POST["add"])) { + $addForm = new user_Form_RoleAdd(array('rightlist' => $rightlist, 'inheritanceright' => Pbs_Acl::checkRight('rir'), 'addrighttoroleright' => Pbs_Acl::checkRight('rar'))); + } else { + $addForm = new user_Form_RoleAdd(array('rightlist' => $rightlist, 'inheritanceright' => Pbs_Acl::checkRight('rir'), 'addrighttoroleright' => Pbs_Acl::checkRight('rar')), $_POST); + if ($addForm->isValid($_POST)) { + $_POST['groupID'] = $this->userIDsNamespace['groupID']; + $role = new Application_Model_Role($_POST); + try { + $this->roleMapper->save($role); + $db = Zend_Db_Table::getDefaultAdapter(); + $insertedRoleID = $db->lastInsertId(); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + foreach($_POST['rights'] as $rightID => $bool) { + if($bool == 1) { + $rightrole = new Application_Model_RightRoles(); + $rightrole->setRightID($rightID); + $rightrole->setRoleID($insertedRoleID); + try { + $this->rightRolesMapper->save($rightrole); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } + } + $this->_helper->redirector('', 'role'); + return; + } + } + $this->view->addForm = $addForm; + } - public function deleteAction() - { - if(!Pbs_Acl::checkRight('rd')) { - $this->_redirect('/user'); - } - $this->_helper->viewRenderer->setNoRender(); - $roleID = $this->_request->getParam('roleID'); - if(!isset($roleID)) { - if(count($this->userIDsNamespace) > 0) { - $roleID = $this->userIDsNamespace['roleID']; - } - } - if (isset($roleID)){ - $roleMapper = new Application_Model_RoleMapper(); - $role = $roleMapper->find($roleID); - $roleGroupID = $role->getGroupID(); - if($this->userIDsNamespace['groupID'] == $roleGroupID) { - $role = $this->roleMapper->find($roleID); - try { - $this->roleMapper->delete($role); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - if($_SERVER['HTTP_REFERER']) { - if(strpos($_SERVER['HTTP_REFERER'], '/user/role/show') !== false && strpos($_SERVER['HTTP_REFERER'], '/roleID/') === false) { - $this->_helper->redirector('changemembership', 'person'); - } else { - $this->_helper->redirector('', 'role'); - } - } else { - $this->_helper->redirector('', 'role'); - } - return; - } else { - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('delete','forbidden'); - $this->_helper-> viewRenderer-> setNoRender(); - return; - } - } else { - $this->_helper->redirector('', 'role'); - return; - } - } + public function editAction() { + if(!Pbs_Acl::checkRight('re')) { + $this->_redirect('/user'); + } + $roleID = $this->_request->getParam('roleID'); + if(!isset($roleID)) { + if(count($this->userIDsNamespace) > 0) { + $roleID = $this->userIDsNamespace['roleID']; + } + } + if(!isset($roleID)) { + $this->_helper->redirector('add', 'role'); + return; + } else { + $roleMapper = new Application_Model_RoleMapper(); + $role = $roleMapper->find($roleID); + $roleGroupID = $role->getGroupID(); + } + if($this->userIDsNamespace['groupID'] == $roleGroupID) { + if (!isset($_POST["save"])) { + $role = $this->roleMapper->find($roleID); + $_POST['title'] = $role->getTitle(); + $_POST['description'] = $role->getDescription(); + $_POST['groupID'] = $role->getGroupID(); + $_POST['inheritance'] = $role->getInheritance(); + $editForm = new user_Form_RoleEdit(array('roleID' => $roleID, 'inheritanceright' => Pbs_Acl::checkRight('rir'))); + } else { + $editForm = new user_Form_RoleEdit(array('roleID' => $roleID, 'inheritanceright' => Pbs_Acl::checkRight('rir')), $_POST); + if ($editForm->isValid($_POST)) { - public function linkrightAction() - { - if(!Pbs_Acl::checkRight('rar')) { - $this->_redirect('/user'); - } - $roleID = $this->_request->getParam('roleID'); - if(!isset($roleID)) { - if(count($this->userIDsNamespace) > 0) { - $roleID = $this->userIDsNamespace['roleID']; - } - } - if(isset($roleID)) { - $roleMapper = new Application_Model_RoleMapper(); - $role = $roleMapper->find($roleID); - $roleGroupID = $role->getGroupID(); - if($this->userIDsNamespace['groupID'] == $roleGroupID) { - $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID),true); - $rights = $this->rightMapper->fetchAll(); - if(count($rightroles) > 0) { - if(count($rights) > 0) { - $rightCategoryMapper = new Application_Model_RightCategoryMapper(); - foreach($rights as $right) { - foreach($rightroles as $rightrole) { - if($right->getID() == $rightrole['rightID']) { - $found = true; - break; - } - } - if(!$found) { - $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); - $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); - } - $found = false; - } - } - } else { - $rightCategoryMapper = new Application_Model_RightCategoryMapper(); - foreach($rights as $right) { - $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); - $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); - } - } - if(count($rightlist) > 0) { - if (!isset($_POST["link"])){ - $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist)); - } else { - $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist, $_POST)); - if ($linkForm->isValid($_POST)) { - foreach($_POST['rights'] as $rightID => $bool) { - if($bool == 1) { - $rightroles = new Application_Model_RightRoles(); - $rightroles->setRightID($rightID); - $rightroles->setRoleID($roleID); + $role = new Application_Model_Role($_POST); + $role->setID($roleID); + try { + $this->roleMapper->save($role); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + $this->_helper->redirector('', 'role'); + return; + } + } + $this->view->editForm = $editForm; + } else { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('modify', 'forbidden'); + $this->_helper-> viewRenderer-> setNoRender(); + return; + } + } - try { - $this->rightRolesMapper->save($rightroles); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - } - } - $this->_redirect('/user/role/show/roleID/' . $roleID); - return; - } - } - $this->view->linkForm = $linkForm; - } else { - $this->_redirect('/user/role/show/roleID/' . $roleID); - return; - } + public function showAction() { + if(!Pbs_Acl::checkRight('rdd')) { + $this->_redirect('/user'); + } + $roleID = $this->_request->getParam('roleID'); + if(!isset($roleID)) { + if(count($this->userIDsNamespace) > 0) { + $roleID = $this->userIDsNamespace['roleID']; + } + } + $this->view->membership = $this->membership; + if($roleID) { + $roleMapper = new Application_Model_RoleMapper(); + $role = $roleMapper->find($roleID); + $roleGroupID = $role->getGroupID(); + if($this->userIDsNamespace['groupID'] == $roleGroupID || $role->getInheritance() == 1) { + $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID), true); + if(count($rightroles) > 0) { + foreach($rightroles as $rightrole) { + $right = $this->rightMapper->find($rightrole['rightID']); + $rightsList[$right->getRightcategoryID()][] = $right; + } + if(is_array($rightsList)) { + $this->view->rightsList = $rightsList; + } + } + $rightCategoryMapper = new Application_Model_RightCategoryMapper(); + $rightCategories = $rightCategoryMapper->fetchAll(); + if(count($rightCategories) > 0) { + foreach($rightCategories as $rightCategory) { + $rightcategorieslist[$rightCategory->getID()] = $rightCategory->getTitle(); + } + $this->view->rightcategorieslist = $rightcategorieslist; + } + $rights = $this->rightMapper->fetchAll(); + if(count($rights) == count($rightroles)) { + $this->view->rightsAvailable = false; + } else { + $this->view->rightsAvailable = true; + } + $this->view->editRight = Pbs_Acl::checkRight('re'); + $this->view->deleteRight = Pbs_Acl::checkRight('rd'); + $this->view->addRightToRoleRight = Pbs_Acl::checkRight('rar'); + $this->view->removeRightOfRoleRight = Pbs_Acl::checkRight('rrr'); + $this->view->role = $this->roleMapper->find($roleID); + $this->view->roleID = $roleID; + $this->view->userIDsNamespace = $this->userIDsNamespace; + } else { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('view', 'forbidden'); + $this->_helper-> viewRenderer-> setNoRender(); + return; + } + } else { + $this->_helper->redirector('', 'role'); + return; + } + } - } else { - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('link','forbidden'); - $this->_helper-> viewRenderer-> setNoRender(); - return; - } - } else { - $this->_helper->redirector('', 'role'); - return; - } - } + public function deleteAction() { + if(!Pbs_Acl::checkRight('rd')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $roleID = $this->_request->getParam('roleID'); + if(!isset($roleID)) { + if(count($this->userIDsNamespace) > 0) { + $roleID = $this->userIDsNamespace['roleID']; + } + } + if (isset($roleID)) { + $roleMapper = new Application_Model_RoleMapper(); + $role = $roleMapper->find($roleID); + $roleGroupID = $role->getGroupID(); + if($this->userIDsNamespace['groupID'] == $roleGroupID) { + $role = $this->roleMapper->find($roleID); + try { + $this->roleMapper->delete($role); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + if($_SERVER['HTTP_REFERER']) { + if(strpos($_SERVER['HTTP_REFERER'], '/user/role/show') != = false && strpos($_SERVER['HTTP_REFERER'], '/roleID/') == = false) { + $this->_helper->redirector('changemembership', 'person'); + } else { + $this->_helper->redirector('', 'role'); + } + } else { + $this->_helper->redirector('', 'role'); + } + return; + } else { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('delete', 'forbidden'); + $this->_helper-> viewRenderer-> setNoRender(); + return; + } + } else { + $this->_helper->redirector('', 'role'); + return; + } + } - public function unlinkrightAction() - { - if(!Pbs_Acl::checkRight('rrr')) { - $this->_redirect('/user'); - } - $this->_helper-> viewRenderer-> setNoRender(); - $rightRolesID = $this->_request->getParam('rightrolesID'); - if(isset($rightRolesID)) { - $rightRolesID = explode('-',$rightRolesID); - $roleID = $rightRolesID[0]; - if($rightRolesID[1] == 'all') { - $rightRolesMapper = new Application_Model_RightRolesMapper(); - $rightroleslist = $rightRolesMapper->findBy(array('roleID' => $roleID)); - foreach($rightroleslist as $rightroles) { - try { - $this->rightRolesMapper->delete($rightroles); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; - } - } - $this->_redirect('/user/role/show/roleID/' . $roleID); - return; - } else { - $rightID = $rightRolesID[1]; - if (isset($roleID) && isset($rightID)){ - $roleMapper = new Application_Model_RoleMapper(); - $role = $roleMapper->find($roleID); - $roleGroupID = $role->getGroupID(); - if($this->userIDsNamespace['groupID'] == $roleGroupID) { - $rightroles = new Application_Model_RightRoles(); - $rightroles->setRoleID($roleID); - $rightroles->setRightID($rightID); - try { - $this->rightRolesMapper->delete($rightroles); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - return; + public function linkrightAction() { + if(!Pbs_Acl::checkRight('rar')) { + $this->_redirect('/user'); + } + $roleID = $this->_request->getParam('roleID'); + if(!isset($roleID)) { + if(count($this->userIDsNamespace) > 0) { + $roleID = $this->userIDsNamespace['roleID']; + } + } + if(isset($roleID)) { + $roleMapper = new Application_Model_RoleMapper(); + $role = $roleMapper->find($roleID); + $roleGroupID = $role->getGroupID(); + if($this->userIDsNamespace['groupID'] == $roleGroupID) { + $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID), true); + $rights = $this->rightMapper->fetchAll(); + if(count($rightroles) > 0) { + if(count($rights) > 0) { + $rightCategoryMapper = new Application_Model_RightCategoryMapper(); + foreach($rights as $right) { + foreach($rightroles as $rightrole) { + if($right->getID() == $rightrole['rightID']) { + $found = true; + break; + } + } + if(!$found) { + $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); + $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); + } + $found = false; + } + } + } else { + $rightCategoryMapper = new Application_Model_RightCategoryMapper(); + foreach($rights as $right) { + $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); + $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); + } + } + if(count($rightlist) > 0) { + if (!isset($_POST["link"])) { + $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist)); + } else { + $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist, $_POST)); + if ($linkForm->isValid($_POST)) { + foreach($_POST['rights'] as $rightID => $bool) { + if($bool == 1) { + $rightroles = new Application_Model_RightRoles(); + $rightroles->setRightID($rightID); + $rightroles->setRoleID($roleID); - } - $this->_redirect('/user/role/show/roleID/' . $roleID); - return; - } else { - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('unlink','forbidden'); - $this->_helper-> viewRenderer-> setNoRender(); - return; - } - } - } - } else { - $this->_helper->redirector('', 'role'); - return; - } - } + try { + $this->rightRolesMapper->save($rightroles); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } + } + $this->_redirect('/user/role/show/roleID/' . $roleID); + return; + } + } + $this->view->linkForm = $linkForm; + } else { + $this->_redirect('/user/role/show/roleID/' . $roleID); + return; + } + + } else { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('link', 'forbidden'); + $this->_helper-> viewRenderer-> setNoRender(); + return; + } + } else { + $this->_helper->redirector('', 'role'); + return; + } + } + + public function unlinkrightAction() { + if(!Pbs_Acl::checkRight('rrr')) { + $this->_redirect('/user'); + } + $this->_helper-> viewRenderer-> setNoRender(); + $rightRolesID = $this->_request->getParam('rightrolesID'); + if(isset($rightRolesID)) { + $rightRolesID = explode('-', $rightRolesID); + $roleID = $rightRolesID[0]; + if($rightRolesID[1] == 'all') { + $rightRolesMapper = new Application_Model_RightRolesMapper(); + $rightroleslist = $rightRolesMapper->findBy(array('roleID' => $roleID)); + foreach($rightroleslist as $rightroles) { + try { + $this->rightRolesMapper->delete($rightroles); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } + $this->_redirect('/user/role/show/roleID/' . $roleID); + return; + } else { + $rightID = $rightRolesID[1]; + if (isset($roleID) && isset($rightID)) { + $roleMapper = new Application_Model_RoleMapper(); + $role = $roleMapper->find($roleID); + $roleGroupID = $role->getGroupID(); + if($this->userIDsNamespace['groupID'] == $roleGroupID) { + $rightroles = new Application_Model_RightRoles(); + $rightroles->setRoleID($roleID); + $rightroles->setRightID($rightID); + try { + $this->rightRolesMapper->delete($rightroles); + } catch(Zend_Exception $e) { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + + } + $this->_redirect('/user/role/show/roleID/' . $roleID); + return; + } else { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('unlink', 'forbidden'); + $this->_helper-> viewRenderer-> setNoRender(); + return; + } + } + } + } else { + $this->_helper->redirector('', 'role'); + return; + } + } } diff --git a/application/modules/user/controllers/SessionController.php b/application/modules/user/controllers/SessionController.php index 0e32e48..2d41f9e 100644 --- a/application/modules/user/controllers/SessionController.php +++ b/application/modules/user/controllers/SessionController.php @@ -1,119 +1,116 @@ -<?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 User_SessionController extends Zend_Controller_Action -{ - private $membership; - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($userIDsNamespace['membershipID'] ==''){ - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('No membershipID set','forbidden'); - } - - $membershipMapper = new Application_Model_MembershipMapper(); - $this->membership = new Application_Model_Membership(); - $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - } else { - $this->_helper->redirector('login', 'auth'); - } - - $this->page = $this->_request->getParam('page'); - } - - public function indexAction() - { - if(!Pbs_Acl::checkRight('so')) - $this->_redirect('/user/index'); - - $sessionMapper = new Application_Model_SessionMapper(); - $bootisoMapper = new Application_Model_BootIsoMapper(); - $bootosMapper = new Application_Model_BootOsMapper(); - $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); - $membershipMapper = new Application_Model_MembershipMapper(); - $personMapper = new Application_Model_PersonMapper(); - - $bootisos = $bootisoMapper->findBy(array('groupID'=>$this->membership->getGroupID())); - foreach($bootisos as $bootiso){ - $sessions = $sessionMapper->findBy(array('bootisoID'=>$bootiso->getID())); - foreach($sessions as $session){ - #echo $session->getBootosID(); - if($session->getBootosID() != ''){ - $bo = $bootosMapper->find($session->getBootosID()); - if($bo != null) - $session->setBootosID("[".$session->getBootosID()."] ".$bo->getTitle()); - } - - if($session->getBootmenuentryID() != ''){ - $bm = $bootmenuentriesMapper->find($session->getBootmenuentryID()); - if($bm != null) - $session->setBootmenuentryID("[".$session->getBootmenuentryID()."] ".$bm->getTitle()); - - } - - if($session->getBootisoID() != ''){ - $bi = $bootisoMapper->find($session->getBootisoID()); - if($bi != null) - $session->setBootisoID("[".$session->getBootisoID()."] ".$bi->getTitle()); - } - - if($session->getMembershipID() != ''){ - $personID = $membershipMapper->find($session->getMembershipID())->getPersonID(); - $p = new Application_Model_Person(); - $personMapper->find($personID,$p); - if($p != null) - $session->setMembershipID("[".$session->getMembershipID()."] ".$p->getFirstname()." ".$p->getName()); - } - $session->setTime(date(Zend_Registry::get('dateformat'),$session->getTime())); - $mySessions[] =$session; - } - } - // Sort after date/id - usort($mySessions, 'sortFunc'); - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('session'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $mySessions = $mySearch->search($mySessions); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10) - ->setElement($mySessions) - ->setRequestPage($this->_request->getParam('page')) - ->setPageUrl('/user/session/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $mySessions = $pagination->getElements(); - - $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - $this->view->sessions = $mySessions; - - } - - public function searchAction(){ - $this->_redirect('/user/session/index/search/'.($_GET['search'])); - } +* 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 User_SessionController extends Zend_Controller_Action { + private $membership; + public function init() { + if (Zend_Auth::getInstance()->hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] == '') { + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set', 'forbidden'); + } + + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($userIDsNamespace['membershipID'], $this->membership); + } else { + $this->_helper->redirector('login', 'auth'); + } + + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() { + if(!Pbs_Acl::checkRight('so')) + { $this->_redirect('/user/index'); } + + $sessionMapper = new Application_Model_SessionMapper(); + $bootisoMapper = new Application_Model_BootIsoMapper(); + $bootosMapper = new Application_Model_BootOsMapper(); + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $membershipMapper = new Application_Model_MembershipMapper(); + $personMapper = new Application_Model_PersonMapper(); + + $bootisos = $bootisoMapper->findBy(array('groupID' => $this->membership->getGroupID())); + foreach($bootisos as $bootiso) { + $sessions = $sessionMapper->findBy(array('bootisoID' => $bootiso->getID())); + foreach($sessions as $session) { +#echo $session->getBootosID(); + if($session->getBootosID() != '') { + $bo = $bootosMapper->find($session->getBootosID()); + if($bo != null) + { $session->setBootosID("[".$session->getBootosID()."] ".$bo->getTitle()); } + } + + if($session->getBootmenuentryID() != '') { + $bm = $bootmenuentriesMapper->find($session->getBootmenuentryID()); + if($bm != null) + { $session->setBootmenuentryID("[".$session->getBootmenuentryID()."] ".$bm->getTitle()); } + + } + + if($session->getBootisoID() != '') { + $bi = $bootisoMapper->find($session->getBootisoID()); + if($bi != null) + { $session->setBootisoID("[".$session->getBootisoID()."] ".$bi->getTitle()); } + } + + if($session->getMembershipID() != '') { + $personID = $membershipMapper->find($session->getMembershipID())->getPersonID(); + $p = new Application_Model_Person(); + $personMapper->find($personID, $p); + if($p != null) + { $session->setMembershipID("[".$session->getMembershipID()."] ".$p->getFirstname()." ".$p->getName()); } + } + $session->setTime(date(Zend_Registry::get('dateformat'), $session->getTime())); + $mySessions[] = $session; + } + } + // Sort after date/id + usort($mySessions, 'sortFunc'); + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('session'); + if($search != '') { + $this->view->search = $mySearch->getSearchTerm(); + $mySessions = $mySearch->search($mySessions); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10) + ->setElement($mySessions) + ->setRequestPage($this->_request->getParam('page')) + ->setPageUrl('/user/session/index'.((isset($this->view->search)) ? '/search/'.$this->view->search : '')); + $mySessions = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination(); + $this->view->page = $pagination->getRequestPage(); + $this->view->sessions = $mySessions; + + } + + public function searchAction() { + $this->_redirect('/user/session/index/search/'.($_GET['search'])); + } } function sortFunc($func_a, $func_b) { - if($func_a->getID() == $func_b->getID()) return 0; - return ($func_a->getID() < $func_b->getID()) ? 1 : -1; + if($func_a->getID() == $func_b->getID()) { return 0; } + return ($func_a->getID() < $func_b->getID()) ? 1 : -1; } diff --git a/application/modules/user/forms/Bootiso.php b/application/modules/user/forms/Bootiso.php index 091f448..1797e2d 100644 --- a/application/modules/user/forms/Bootiso.php +++ b/application/modules/user/forms/Bootiso.php @@ -1,161 +1,160 @@ -<?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 user_Form_Bootiso extends Zend_Form -{ - - private $prebootlist; - private $groupdepth; - private $action; - private $page; - - public function setAction($action){ - $this->action = $action; - } - public function setPrebootlist($prebootlist){ - $this->prebootlist = $prebootlist; +* 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 user_Form_Bootiso extends Zend_Form { + + private $prebootlist; + private $groupdepth; + private $action; + private $page; + + public function setAction($action) { + $this->action = $action; + } + public function setPrebootlist($prebootlist) { + $this->prebootlist = $prebootlist; + } + public function setGroupdepth($groupdepth) { + $this->groupdepth = $groupdepth; + } + public function setPage($p) { + $this->page = $p; + } + + public function init() { + $this->setName($this->action); + $this->setMethod('post'); + + if (!Pbs_Acl::checkRight('be') && $this->action == 'editbootiso') + { $meta = true; } + else + { $meta = null; } + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Description:', + )); + + $prebootfield = $this->createElement('select', 'prebootID'); + $prebootfield->setLabel('Preboot:'); + $prebootfield->setAttrib('readOnly', $meta); + + if(count($this->prebootlist) > 0) { + foreach($this->prebootlist as $preboot => $p) { + $prebootfield->addMultiOption($p->getID(), $p->getTitle()); + } } - public function setGroupdepth($groupdepth){ - $this->groupdepth = $groupdepth; + $prebootfield->setRegisterInArrayValidator(false); + $this->addElement($prebootfield); + + $serial = time(); + for($i = 2; $i < 14; $i += 3) + { $serial = substr($serial, 0, $i) .'-'. substr($serial, $i, strlen($serial)); } + + $this->addElement('text', 'serialnumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Serialnumber:', + 'readOnly' => $meta, + 'value' => $serial + )); + + $date = new DateTime(); + $date->add(new DateInterval('P1Y')); + $this->addElement('text', 'expires', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Expires:', + 'readOnly' => $meta, + 'value' => $date->format('Y-m-d'), + )); + + $publicfield = $this->createElement('select', 'public'); + $publicfield->setLabel('Public:'); + $publicfield->addMultiOption(-1, 'X. Not Visible'); + $publicfield->addMultiOption(0, '0. Eigene Gruppe'); + $publicfield->setAttrib('readOnly', $meta); + $publicfield->setAttrib('id', 'depth'); + $publicfield->setAttrib('onchange', "$('#groups .v1').show();changeDepth();"); + + for($i = 1; $i < $this->groupdepth; $i++) { + $publicfield->addMultiOption($i, "$i. Untergruppe"); } - public function setPage($p){ - $this->page = $p; - } - - public function init() - { - $this->setName($this->action); - $this->setMethod('post'); - - if (!Pbs_Acl::checkRight('be') && $this->action == 'editbootiso') - $meta = true; - else - $meta = null; - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Description:', - )); - - $prebootfield = $this->createElement('select','prebootID'); - $prebootfield->setLabel('Preboot:'); - $prebootfield->setAttrib('readOnly', $meta); - - if(count($this->prebootlist)>0){ - foreach($this->prebootlist as $preboot => $p){ - $prebootfield->addMultiOption($p->getID(), $p->getTitle()); - } - } - $prebootfield->setRegisterInArrayValidator(false); - $this->addElement($prebootfield); - - $serial = time(); - for($i=2; $i<14; $i+=3) - $serial = substr($serial,0,$i) .'-'. substr($serial,$i,strlen($serial)); - - $this->addElement('text', 'serialnumber', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Serialnumber:', - 'readOnly' => $meta, - 'value' => $serial - )); - - $date = new DateTime(); - $date->add(new DateInterval('P1Y')); - $this->addElement('text', 'expires', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Expires:', - 'readOnly' => $meta, - 'value' => $date->format('Y-m-d'), - )); - - $publicfield = $this->createElement('select','public'); - $publicfield->setLabel('Public:'); - $publicfield->addMultiOption(-1, 'X. Not Visible'); - $publicfield->addMultiOption(0, '0. Eigene Gruppe'); - $publicfield->setAttrib('readOnly', $meta); - $publicfield->setAttrib('id', 'depth'); - $publicfield->setAttrib('onchange', "$('#groups .v1').show();changeDepth();"); - - for($i=1; $i<$this->groupdepth; $i++){ - $publicfield->addMultiOption($i, "$i. Untergruppe"); - } - - $publicfield->setRegisterInArrayValidator(false); - $this->addElement($publicfield); - - if($this->action == "createbootiso") - $label = "Create BootMedium"; - else - $label = "Edit BootMedium"; - - $this->addElement('submit', $this->action, array( - 'required' => false, - 'ignore' => true, - 'label' => $label, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootiso/index/page/'.$this->page.'"' - )); - ?> - - <script type="text/javascript"> - $(document).ready(function(){ - changeDepth(); - $('#groups .v1').show(); - }); - function changeDepth(){ - i = $("#depth option:selected").val(); - $('#depthimg').attr('src','/stats/graphgroup/level/' + i); - } - </script> - - <div id='groups' style='text-align: center;'> - <div class='v1'> - <img alt='Please select a public level' id='depthimg' src='/stats/graphgroup/level/0' /> - </div> - </div> - - - -<?php + + $publicfield->setRegisterInArrayValidator(false); + $this->addElement($publicfield); + + if($this->action == "createbootiso") + { $label = "Create BootMedium"; } + else + { $label = "Edit BootMedium"; } + + $this->addElement('submit', $this->action, array( + 'required' => false, + 'ignore' => true, + 'label' => $label, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/bootiso/index/page/'.$this->page.'"' + )); + ? > + + < script type = "text/javascript" > + $(document).ready(function() { + changeDepth(); + $('#groups .v1').show(); + }); + function changeDepth() { + i = $("#depth option:selected").val(); + $('#depthimg').attr('src', '/stats/graphgroup/level/' + i); } + < / script > + + < div id = 'groups' style = 'text-align: center;' > + < div class = 'v1' > + < img alt = 'Please select a public level' id = 'depthimg' + src = '/stats/graphgroup/level/0' / > + < / div > + < / div > + + + + <? php + } + - } -?> + ? > diff --git a/application/modules/user/forms/Bootmenu.php b/application/modules/user/forms/Bootmenu.php index 0a827d9..5a47313 100644 --- a/application/modules/user/forms/Bootmenu.php +++ b/application/modules/user/forms/Bootmenu.php @@ -1,80 +1,78 @@ -<?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 user_Form_Bootmenu extends Zend_Form -{ - private $action; - private $page; - private $type; - - public function setAction($action){ - $this->action = $action; - - } - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - } - - public function setPage($page){ - $this->page = $page; - } - public function setType($type){ - $this->type = $type; - } - - public function init() - { - $this->setName($this->action); - $this->setMethod('post'); - - if (!Pbs_Acl::checkRight('booee') && $this->action == 'editbootmenu') - $meta = true; - else - $meta = null; +class user_Form_Bootmenu extends Zend_Form { + private $action; + private $page; + private $type; - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - $this->addElement('text', 'startcounter', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('Int'), - ), - 'required' => true, - 'label' => 'Startcounter:', - )); - - if($this->action == "createbootmenu") - $label = "Create Bootmenu"; - else - $label = "Edit Bootmenu"; - - $this->addElement('submit', $this->action, array( - 'required' => false, - 'ignore' => true, - 'label' => $label, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'"' - )); + public function setAction($action) { + $this->action = $action; - } + } + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + } + + public function setPage($page) { + $this->page = $page; + } + public function setType($type) { + $this->type = $type; + } + + public function init() { + $this->setName($this->action); + $this->setMethod('post'); + + if (!Pbs_Acl::checkRight('booee') && $this->action == 'editbootmenu') + { $meta = true; } + else + { $meta = null; } + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + $this->addElement('text', 'startcounter', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('Int'), + ), + 'required' => true, + 'label' => 'Startcounter:', + )); + + if($this->action == "createbootmenu") + { $label = "Create Bootmenu"; } + else + { $label = "Edit Bootmenu"; } + + $this->addElement('submit', $this->action, array( + 'required' => false, + 'ignore' => true, + 'label' => $label, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'"' + )); + + } } diff --git a/application/modules/user/forms/BootmenuEntries.php b/application/modules/user/forms/BootmenuEntries.php index 93e3206..8c92cb1 100644 --- a/application/modules/user/forms/BootmenuEntries.php +++ b/application/modules/user/forms/BootmenuEntries.php @@ -1,176 +1,174 @@ -<?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 user_Form_BootmenuEntries extends Zend_Form -{ - private $bootoslist; - private $bootosanzeige; - private $configlist; - private $maxorder; - private $action; - private $page; - private $type; - - public function setAction($action){ - $this->action = $action; - - } +* 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 user_Form_BootmenuEntries extends Zend_Form { + private $bootoslist; + private $bootosanzeige; + private $configlist; + private $maxorder; + private $action; + private $page; + private $type; + + public function setAction($action) { + $this->action = $action; + + } + + public function setBootoslist($bootoslist) { + $this->bootoslist = $bootoslist; + } + public function setBootosanzeige($bootosanzeige) { + $this->bootosanzeige = $bootosanzeige; + } + + public function setMaxorder($maxorder) { + $this->maxorder = $maxorder; + + } + + public function setConfiglist($configlist) { + $this->configlist = $configlist; + } + + public function setType($type) { + $this->type = $type; + } + + public function setPage($page) { + $this->page = $page; + } + + + public function init() { + + if(!isset($_POST['bootosID'])) { + list($key) = array_keys($this->bootoslist); + $firstbootos = $this->bootoslist[$key]; + $_POST['bootosID'] = $firstbootos->getID(); - public function setBootoslist($bootoslist){ - $this->bootoslist = $bootoslist; - } - public function setBootosanzeige($bootosanzeige){ - $this->bootosanzeige = $bootosanzeige; } - - public function setMaxorder($maxorder){ - $this->maxorder = $maxorder; - + + $this->setName($this->action); + $this->setMethod('post'); + + if (!Pbs_Acl::checkRight('booee') && $this->action == 'editbootmenuentry') + { $meta = true; } + else + { $meta = null; } + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $bootosfield = $this->createElement('select', 'bootosID'); + $bootosfield ->setLabel('BootOs:'); + $bootosfield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); + $bootosfield->setAttrib('readOnly', $meta); + $bootosfield->addMultiOptions($this->bootosanzeige); + $bootosfield->setRegisterInArrayValidator(false); + $this->addElement($bootosfield); + + $kclactive = $this->createElement('checkbox', 'kcl'); + $kclactive->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); + $kclactive->setLabel('Use default KCL:'); + $kclactive->setValue($_POST['kcl']); + $this->addElement($kclactive); + + + if($_POST['kcl']) { + $this->addElement('textarea', 'defaultkcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'cols' => 50, + 'rows' => 5, + 'label' => 'KCL:', + 'readOnly' => true, + 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl() + + )); } - - public function setConfiglist($configlist){ - $this->configlist = $configlist; + + if($_POST['kcl']) + { $kcllength = 175 - strlen($this->bootoslist[$_POST['bootosID']]->getDefaultkcl()); } + else + { $kcllength = 175; } + + $this->addElement('textarea', 'kclappend', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, $kcllength)), + ), + 'required' => false, + 'cols' => 50, + 'rows' => 5, + 'label' => 'KCL-Append:', + 'readOnly' => $meta, + 'description' => 'Chars left: ' . $kcllength + )); + + $configfield = $this->createElement('select', 'configID'); + $configfield->setLabel('Config:'); + $configfield->setAttrib('readOnly', $meta); + + $options = array('Preset' => array(), 'Custom' => array()); + + if(count($this->configlist) > 0) { + foreach($this->configlist as $k => $v) { + foreach($v[$_POST['bootosID']] as $c) + $options[$k][$c->getID()] = $c->getTitle(); + } } - - public function setType($type){ - $this->type = $type; - } - - public function setPage($page){ - $this->page = $page; - } - - - public function init() - { - - if(!isset($_POST['bootosID'])){ - list($key) = array_keys($this->bootoslist); - $firstbootos = $this->bootoslist[$key]; - $_POST['bootosID'] = $firstbootos->getID(); - - } - - $this->setName($this->action); - $this->setMethod('post'); - - if (!Pbs_Acl::checkRight('booee') && $this->action == 'editbootmenuentry') - $meta = true; - else - $meta = null; - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $bootosfield = $this->createElement('select','bootosID'); - $bootosfield ->setLabel('BootOs:'); - $bootosfield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); - $bootosfield->setAttrib('readOnly', $meta); - $bootosfield->addMultiOptions($this->bootosanzeige); - $bootosfield->setRegisterInArrayValidator(false); - $this->addElement($bootosfield); - - $kclactive = $this->createElement('checkbox','kcl'); - $kclactive->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); - $kclactive->setLabel('Use default KCL:'); - $kclactive->setValue($_POST['kcl']); - $this->addElement($kclactive); - - - if($_POST['kcl']){ - $this->addElement('textarea', 'defaultkcl', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'cols' => 50, - 'rows' => 5, - 'label' => 'KCL:', - 'readOnly' => true, - 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl() - - )); - } - - if($_POST['kcl']) - $kcllength = 175 - strlen($this->bootoslist[$_POST['bootosID']]->getDefaultkcl()); - else - $kcllength = 175; - - $this->addElement('textarea', 'kclappend', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, $kcllength)), - ), - 'required' => false, - 'cols' => 50, - 'rows' => 5, - 'label' => 'KCL-Append:', - 'readOnly' => $meta, - 'description' => 'Chars left: ' . $kcllength - )); - - $configfield = $this->createElement('select','configID'); - $configfield->setLabel('Config:'); - $configfield->setAttrib('readOnly', $meta); - - $options = array('Preset' => array(), 'Custom' => array()); - - if(count($this->configlist)>0){ - foreach($this->configlist as $k => $v){ - foreach($v[$_POST['bootosID']] as $c) - $options[$k][$c->getID()] = $c->getTitle(); - } - } - $configfield->addMultiOptions($options); - $configfield->setRegisterInArrayValidator(false); - $this->addElement($configfield); - - $orderfield = $this->createElement('select','order'); - $orderfield ->setLabel('Position:'); - $orderfield->setAttrib('readOnly', $meta); - - for ($i = 0; $i <= $this->maxorder; $i++) { - $orderfield->addMultiOption($i, $i+1); - } - $orderfield->setRegisterInArrayValidator(false); - $this->addElement($orderfield); - - - if($this->action == "addbootmenuentry") - $label = "Add Bootmenuentry"; - else - $label = "Edit Bootmenuentry"; - - $this->addElement('submit', $this->action, array( - 'required' => false, - 'ignore' => true, - 'label' => $label, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'"' - )); + $configfield->addMultiOptions($options); + $configfield->setRegisterInArrayValidator(false); + $this->addElement($configfield); + $orderfield = $this->createElement('select', 'order'); + $orderfield ->setLabel('Position:'); + $orderfield->setAttrib('readOnly', $meta); + + for ($i = 0; $i <= $this->maxorder; $i++) { + $orderfield->addMultiOption($i, $i + 1); } - - + $orderfield->setRegisterInArrayValidator(false); + $this->addElement($orderfield); + + + if($this->action == "addbootmenuentry") + { $label = "Add Bootmenuentry"; } + else + { $label = "Edit Bootmenuentry"; } + + $this->addElement('submit', $this->action, array( + 'required' => false, + 'ignore' => true, + 'label' => $label, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/bootmenu/index/type/'.$this->type.'/page/'.$this->page.'"' + )); + + } + + } diff --git a/application/modules/user/forms/Bootos.php b/application/modules/user/forms/Bootos.php index 432f0c7..02d865b 100644 --- a/application/modules/user/forms/Bootos.php +++ b/application/modules/user/forms/Bootos.php @@ -1,207 +1,205 @@ -<?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 user_Form_Bootos extends Zend_Form -{ - - private $configlist; - private $action; - private $groupdepth; - private $page; - - public function setAction($action){ - $this->action = $action; - - } - public function setConfiglist($configlist){ - $this->configlist = $configlist; - - } - public function setGroupdepth($groupdepth){ - $this->groupdepth = $groupdepth; - } - public function setPage($page){ - $this->page = $page; - } - - public function init() - { - $this->setName("BootOsCreate"); - $this->setMethod('post'); - $this->setEnctype("multipart/form-data"); - - if (!Pbs_Acl::checkRight('boe') && $this->action == 'editbootos') - $meta = true; - else - $meta = null; - - if($this->action == 'editbootos') - $filereq = false; - else - $filereq = true; - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Description:', - )); - - $this->addElement('textarea', 'defaultkcl', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 175)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'readOnly' => $meta, - 'label' => 'Default-KCL:', - )); - - $this->addElement('text', 'distro', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'readOnly' => $meta, - 'label' => 'Distro:', - )); - - $this->addElement('text', 'distroversion', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'readOnly' => $meta, - 'label' => 'Distroversion:', - )); - - $this->addElement('text', 'shortname', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'readOnly' => $meta, - 'label' => 'Shortname:', - )); - - $this->addElement('text', 'share', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'readOnly' => $meta, - 'label' => 'Share:', - )); - - $this->addElement('file', 'kernel', array( - 'readOnly' => $meta, - 'label' => 'Kernel:', - )); - - $this->addElement('file', 'init', array( - 'readOnly' => $meta, - 'label' => 'Initramfs:', - )); - - $this->addElement('file', 'config', array( - 'validators' => array(array('Extension', false, array('tgz'))), - 'readOnly' => $meta, - 'label' => 'Config:', - )); - - $date = new DateTime(); - $date->add(new DateInterval('P1Y')); - $this->addElement('text', 'expires', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Expires:', - 'readOnly' => $meta, - 'value' => $date->format('Y-m-d'), - )); - - $publicfield = $this->createElement('select','public'); - $publicfield->setLabel('Public:'); - $publicfield->addMultiOption(-1, 'X. Not Visible'); - $publicfield->addMultiOption(0, '0. Own Group'); - $publicfield->setAttrib('readOnly', $meta); - $publicfield->setAttrib('id', 'depth'); - $publicfield->setAttrib('onchange', "$('#groups .v1').show();changeDepth();"); - - for($i=1; $i<$this->groupdepth; $i++){ - $publicfield->addMultiOption($i, "$i. Untergruppe"); - } - - $publicfield->setRegisterInArrayValidator(false); - $this->addElement($publicfield); - - if($this->action == "createbootos") - $label = "Create Bootos"; - else - $label = "Edit Bootos"; - - $this->addElement('submit', $this->action, array( - 'required' => false, - 'ignore' => true, - 'label' => $label, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootos/index/page/'.$this->page.'"' - )); - - ?> - - <script type="text/javascript"> - $(document).ready(function(){ - changeDepth(); - $('#groups .v1').show(); - }); - function changeDepth(){ - i = $("#depth option:selected").val(); - $('#depthimg').attr('src','/stats/graphgroup/level/' + i); - }</script> - - <div id='groups' style='text-align: center;'> - <div class='v1' > - <img id=depthimg src='/stats/graphgroup/'/> - </div> - </div> - -<?php +* 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 user_Form_Bootos extends Zend_Form { + + private $configlist; + private $action; + private $groupdepth; + private $page; + + public function setAction($action) { + $this->action = $action; + + } + public function setConfiglist($configlist) { + $this->configlist = $configlist; + + } + public function setGroupdepth($groupdepth) { + $this->groupdepth = $groupdepth; + } + public function setPage($page) { + $this->page = $page; + } + + public function init() { + $this->setName("BootOsCreate"); + $this->setMethod('post'); + $this->setEnctype("multipart/form-data"); + + if (!Pbs_Acl::checkRight('boe') && $this->action == 'editbootos') + { $meta = true; } + else + { $meta = null; } + + if($this->action == 'editbootos') + { $filereq = false; } + else + { $filereq = true; } + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Description:', + )); + + $this->addElement('textarea', 'defaultkcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 175)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'readOnly' => $meta, + 'label' => 'Default-KCL:', + )); + + $this->addElement('text', 'distro', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'readOnly' => $meta, + 'label' => 'Distro:', + )); + + $this->addElement('text', 'distroversion', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'readOnly' => $meta, + 'label' => 'Distroversion:', + )); + + $this->addElement('text', 'shortname', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'readOnly' => $meta, + 'label' => 'Shortname:', + )); + + $this->addElement('text', 'share', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'readOnly' => $meta, + 'label' => 'Share:', + )); + + $this->addElement('file', 'kernel', array( + 'readOnly' => $meta, + 'label' => 'Kernel:', + )); + + $this->addElement('file', 'init', array( + 'readOnly' => $meta, + 'label' => 'Initramfs:', + )); + + $this->addElement('file', 'config', array( + 'validators' => array(array('Extension', false, array('tgz'))), + 'readOnly' => $meta, + 'label' => 'Config:', + )); + + $date = new DateTime(); + $date->add(new DateInterval('P1Y')); + $this->addElement('text', 'expires', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Expires:', + 'readOnly' => $meta, + 'value' => $date->format('Y-m-d'), + )); + + $publicfield = $this->createElement('select', 'public'); + $publicfield->setLabel('Public:'); + $publicfield->addMultiOption(-1, 'X. Not Visible'); + $publicfield->addMultiOption(0, '0. Own Group'); + $publicfield->setAttrib('readOnly', $meta); + $publicfield->setAttrib('id', 'depth'); + $publicfield->setAttrib('onchange', "$('#groups .v1').show();changeDepth();"); + + for($i = 1; $i < $this->groupdepth; $i++) { + $publicfield->addMultiOption($i, "$i. Untergruppe"); } - + $publicfield->setRegisterInArrayValidator(false); + $this->addElement($publicfield); + + if($this->action == "createbootos") + { $label = "Create Bootos"; } + else + { $label = "Edit Bootos"; } + + $this->addElement('submit', $this->action, array( + 'required' => false, + 'ignore' => true, + 'label' => $label, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/bootos/index/page/'.$this->page.'"' + )); + + ? > + + < script type = "text/javascript" > + $(document).ready(function() { + changeDepth(); + $('#groups .v1').show(); + }); + function changeDepth() { + i = $("#depth option:selected").val(); + $('#depthimg').attr('src', '/stats/graphgroup/level/' + i); + } < / script > + + < div id = 'groups' style = 'text-align: center;' > + < div class = 'v1' > + < img id = depthimg src = '/stats/graphgroup/' / > + < / div > + < / div > + + <? php + } + + } -?> + ? > diff --git a/application/modules/user/forms/BootosUser.php b/application/modules/user/forms/BootosUser.php index d5700d5..e986104 100644 --- a/application/modules/user/forms/BootosUser.php +++ b/application/modules/user/forms/BootosUser.php @@ -1,161 +1,161 @@ - <?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 user_Form_BootosUser extends Zend_Form -{ - - private $action; - private $type; - private $configID; - private $hometype; - - public function setAction($action){ - $this->action = $action; - } - public function setType($type){ - $this->type = $type; - } - public function setConfigID($configID){ - $this->configID = $configID; - } - public function setHometype($hometype){ - $this->hometype = $hometype; - } - - - public function init() - { - $this->setName($this->action); - $this->setMethod('post'); - - if (!Pbs_Acl::checkRight('ce') && $this->action == 'editbootosuser') - $meta = true; - else - $meta = null; - - if(!isset($_POST['hometypeID'])){ - $_POST['hometypeID'] = '0'; - } - - $this->addElement('text', 'login', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Login-Name:', - 'value' => $_POST['login'], - 'description' => 'Tip: Use %username% as a Wildcard' - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(6)), - ), - 'required' => true, - 'label' => 'Password:', - 'errorMessages' => array('Please enter a password with more than 6 characters') - )); - - $this->addElement('password', 'repeat_password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(6)), - ), - 'required' => true, - 'label' => 'Repeat Password:', - 'errorMessages' => array('Please repeat the password correctly'), - 'description' => 'Tip: Use %password% as a Wildcard' - )); - - - - $hometypefield = $this->createElement('select','hometypeID'); - $hometypefield->setLabel('Hometype:'); - $hometypefield->setAttrib('readOnly', $meta); - $hometypefield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); - $hometypefield->setValue($_POST['hometypeID']); - foreach($this->hometype as $k => $ht){ - $hometypefield->addMultiOption($ht->getID(), $ht->getName()); - } - - $this->addElement($hometypefield); - - if($_POST['hometypeID'] == 0){ - $this->addElement('text', 'homepath', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Home-Path:', - 'size' => '30', - 'readOnly' => true, - 'value' => '/home/%login-name%' - )); - }elseif($_POST['hometypeID'] == 1){ - $this->addElement('text', 'homepath', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Home-Path:', - 'size' => '30', - 'readOnly' => true, - 'value' => 'usbstick://home/%login-name%' - )); - }else{ - $this->addElement('text', 'homepath', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'size' => '30', - 'required' => true, - 'label' => 'Home-Path:', - 'readOnly' => $meta - )); - } - - if($this->action == "addbootosuser") - $label = "Add User"; - else - $label = "Edit User"; - - $this->addElement('submit', $this->action, array( - 'required' => false, - 'ignore' => true, - 'label' => $label - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/config/showconfig/type/'.$this->type.'/configID/'.$this->configID.'"' - )); - - - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('Use <b>%username%</b> and <b>%password%</b> as Wildcards for Login and Password.','info'); +* 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 user_Form_BootosUser extends Zend_Form { + + private $action; + private $type; + private $configID; + private $hometype; + + public function setAction($action) { + $this->action = $action; + } + public function setType($type) { + $this->type = $type; + } + public function setConfigID($configID) { + $this->configID = $configID; + } + public function setHometype($hometype) { + $this->hometype = $hometype; + } + + + public function init() { + $this->setName($this->action); + $this->setMethod('post'); + + if (!Pbs_Acl::checkRight('ce') && $this->action == 'editbootosuser') + { $meta = true; } + else + { $meta = null; } + + if(!isset($_POST['hometypeID'])) { + $_POST['hometypeID'] = '0'; + } + + $this->addElement('text', 'login', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Login-Name:', + 'value' => $_POST['login'], + 'description' => 'Tip: Use %username% as a Wildcard' + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(6)), + ), + 'required' => true, + 'label' => 'Password:', + 'errorMessages' => array('Please enter a password with more than 6 characters') + )); + + $this->addElement('password', 'repeat_password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(6)), + ), + 'required' => true, + 'label' => 'Repeat Password:', + 'errorMessages' => array('Please repeat the password correctly'), + 'description' => 'Tip: Use %password% as a Wildcard' + )); + + + + $hometypefield = $this->createElement('select', 'hometypeID'); + $hometypefield->setLabel('Hometype:'); + $hometypefield->setAttrib('readOnly', $meta); + $hometypefield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); + $hometypefield->setValue($_POST['hometypeID']); + foreach($this->hometype as $k => $ht) { + $hometypefield->addMultiOption($ht->getID(), $ht->getName()); + } + + $this->addElement($hometypefield); + + if($_POST['hometypeID'] == 0) { + $this->addElement('text', 'homepath', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Home-Path:', + 'size' => '30', + 'readOnly' => true, + 'value' => '/home/%login-name%' + )); + } + elseif($_POST['hometypeID'] == 1) { + $this->addElement('text', 'homepath', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Home-Path:', + 'size' => '30', + 'readOnly' => true, + 'value' => 'usbstick://home/%login-name%' + )); + } + else { + $this->addElement('text', 'homepath', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'size' => '30', + 'required' => true, + 'label' => 'Home-Path:', + 'readOnly' => $meta + )); } - - public function isValid($data) - { + + if($this->action == "addbootosuser") + { $label = "Add User"; } + else + { $label = "Edit User"; } + + $this->addElement('submit', $this->action, array( + 'required' => false, + 'ignore' => true, + 'label' => $label + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/config/showconfig/type/'.$this->type.'/configID/'.$this->configID.'"' + )); + + + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('Use <b>%username%</b> and <b>%password%</b> as Wildcards for Login and Password.', 'info'); + } + + public function isValid($data) { $this->getElement('repeat_password')-> - addValidator(new Zend_Validate_Identical($data['password'])); - + addValidator(new Zend_Validate_Identical($data['password'])); + return parent::isValid($data); } } -?> +? > diff --git a/application/modules/user/forms/Client.php b/application/modules/user/forms/Client.php index 33a6cf1..8e37d94 100644 --- a/application/modules/user/forms/Client.php +++ b/application/modules/user/forms/Client.php @@ -1,74 +1,72 @@ -<?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 user_Form_Client extends Zend_Form -{ +class user_Form_Client extends Zend_Form { - private $buttontext = 'Save'; - private $groups; - private $page; - - public function setButtontext($v){ - $this->buttontext = $v; - } - public function setPage($page){ - $this->page = $page; - } - - public function init() - { - $this->setName("pool"); - $this->setMethod('post'); - - $mac = $this->createElement('text', 'macadress', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array( - 'regex', - false, - array( - '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", - Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'label' => 'MacAdress:', - )); - $this->addElement($mac); - - - $this->addElement('text', 'hardwarehash', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(32, 32)), - ), - 'required' => true, - 'label' => 'Hardwarehash:', - )); + private $buttontext = 'Save'; + private $groups; + private $page; - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/client/index/page/'.$this->page.'"' - )); - - } + public function setButtontext($v) { + $this->buttontext = $v; + } + public function setPage($page) { + $this->page = $page; + } + + public function init() { + $this->setName("pool"); + $this->setMethod('post'); + + $mac = $this->createElement('text', 'macadress', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array( + 'regex', + false, + array( + '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", + Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'label' => 'MacAdress:', + )); + $this->addElement($mac); + + + $this->addElement('text', 'hardwarehash', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(32, 32)), + ), + 'required' => true, + 'label' => 'Hardwarehash:', + )); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/client/index/page/'.$this->page.'"' + )); + + } } diff --git a/application/modules/user/forms/Config.php b/application/modules/user/forms/Config.php index 3b961b9..1d07e5a 100644 --- a/application/modules/user/forms/Config.php +++ b/application/modules/user/forms/Config.php @@ -1,86 +1,85 @@ - <?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 user_Form_Config extends Zend_Form -{ +class user_Form_Config extends Zend_Form { - private $action; - private $page; - private $type; - - public function setAction($action){ - $this->action = $action; - } - public function setPage($p){ - $this->page = $p; - } - public function setType($type){ - $this->type = $type; - } - - public function init() - { - $this->setName($this->action); - $this->setMethod('post'); - - if (!Pbs_Acl::checkRight('ce') && $this->action == 'editconfig') - $meta = true; - else - $meta = null; + private $action; + private $page; + private $type; + + public function setAction($action) { + $this->action = $action; + } + public function setPage($p) { + $this->page = $p; + } + public function setType($type) { + $this->type = $type; + } + + public function init() { + $this->setName($this->action); + $this->setMethod('post'); + + if (!Pbs_Acl::checkRight('ce') && $this->action == 'editconfig') + { $meta = true; } + else + { $meta = null; } - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Description:', - )); - - if($this->type == 'group'){ - $visible = $this->createElement('checkbox','visible'); - $visible->setLabel('Visible:'); - $visible->setAttrib('readOnly', $meta); - $this->addElement($visible); - } - - if($this->action == "createconfig") - $label = "Create Config"; - else - $label = "Edit Config"; - - $this->addElement('submit', $this->action, array( - 'required' => false, - 'ignore' => true, - 'label' => $label - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/config/index/type/'.$this->type.'/page/'.$this->page.'"' - )); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Description:', + )); + + if($this->type == 'group') { + $visible = $this->createElement('checkbox', 'visible'); + $visible->setLabel('Visible:'); + $visible->setAttrib('readOnly', $meta); + $this->addElement($visible); } + if($this->action == "createconfig") + { $label = "Create Config"; } + else + { $label = "Edit Config"; } + + $this->addElement('submit', $this->action, array( + 'required' => false, + 'ignore' => true, + 'label' => $label + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/config/index/type/'.$this->type.'/page/'.$this->page.'"' + )); + + } + } -?> +? > diff --git a/application/modules/user/forms/ConfirmDeleteAccount.php b/application/modules/user/forms/ConfirmDeleteAccount.php index 70b261c..5fd3e82 100644 --- a/application/modules/user/forms/ConfirmDeleteAccount.php +++ b/application/modules/user/forms/ConfirmDeleteAccount.php @@ -1,36 +1,34 @@ -<?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 user_Form_ConfirmDeleteAccount extends Zend_Form -{ +class user_Form_ConfirmDeleteAccount extends Zend_Form { - public function init() - { - $this->setName("ConfirmDeleteAccount"); - $this->setMethod('post'); - - $this->addElement('submit', 'confirmdelete', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Confirm', - )); + public function init() { + $this->setName("ConfirmDeleteAccount"); + $this->setMethod('post'); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + $this->addElement('submit', 'confirmdelete', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Confirm', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/user/forms/Filter.php b/application/modules/user/forms/Filter.php index 5eabd60..f535cf1 100644 --- a/application/modules/user/forms/Filter.php +++ b/application/modules/user/forms/Filter.php @@ -1,98 +1,94 @@ -<?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 user_Form_Filter extends Zend_Form -{ - - private $bootmenus; - - public function init() - { - $this->setName("Add Filter"); - $this->setMethod('post'); - - if(stristr($_SERVER['REQUEST_URI'],'addfilter')){ - $edit = null; - } - else{ - if(!Pbs_Acl::checkRight('fe') && Pbs_Acl::checkRight('fefp') ){ - $edit = 'true'; - } - else{ - $edit = null; - } - } - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'readOnly' => $edit, - 'label' => 'Title:', - )); - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'required' => false, - 'readOnly' => $edit, - 'label' => 'Description:', - )); - - $bootmenufield = $this->createElement('select','bootmenuID'); - $bootmenufield->setLabel('Bootmenu:'); - $bootmenufield->setAttrib('readOnly', $edit); - - if(count($this->bootmenus)>0){ - foreach($this->bootmenus as $g){ - $bootmenufield->addMultiOption($g->getID(), $g->getTitle()); - - } - } - - $bootmenufield->setRegisterInArrayValidator(false); - $this->addElement($bootmenufield); - - $this->addElement('text', 'priority', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Priority:', - )); - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"' - )); - - $this->addElement('hidden', 'created', array( - 'required' => false, - 'ignore' => true - )); +* 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 user_Form_Filter extends Zend_Form { + + private $bootmenus; + + public function init() { + $this->setName("Add Filter"); + $this->setMethod('post'); + + if(stristr($_SERVER['REQUEST_URI'], 'addfilter')) { + $edit = null; + } else { + if(!Pbs_Acl::checkRight('fe') && Pbs_Acl::checkRight('fefp') ) { + $edit = 'true'; + } else { + $edit = null; + } } - function setBootmenus($val){ - $this->bootmenus = $val; - return; - } - private $buttontext = 'Save'; - function setButtontext($v){ - $this->buttontext = $v; - } + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'readOnly' => $edit, + 'label' => 'Title:', + )); + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'required' => false, + 'readOnly' => $edit, + 'label' => 'Description:', + )); + + $bootmenufield = $this->createElement('select', 'bootmenuID'); + $bootmenufield->setLabel('Bootmenu:'); + $bootmenufield->setAttrib('readOnly', $edit); + + if(count($this->bootmenus) > 0) { + foreach($this->bootmenus as $g) { + $bootmenufield->addMultiOption($g->getID(), $g->getTitle()); + + } + } + + $bootmenufield->setRegisterInArrayValidator(false); + $this->addElement($bootmenufield); + + $this->addElement('text', 'priority', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Priority:', + )); + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"' + )); + + $this->addElement('hidden', 'created', array( + 'required' => false, + 'ignore' => true + )); + } + function setBootmenus($val) { + $this->bootmenus = $val; + return; + } + private $buttontext = 'Save'; + function setButtontext($v) { + $this->buttontext = $v; + } diff --git a/application/modules/user/forms/FilterEntry.php b/application/modules/user/forms/FilterEntry.php index 12fd00c..bdadf59 100644 --- a/application/modules/user/forms/FilterEntry.php +++ b/application/modules/user/forms/FilterEntry.php @@ -1,424 +1,422 @@ -<?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 user_Form_FilterEntry extends Zend_Form -{ +class user_Form_FilterEntry extends Zend_Form { - private $filterID = 0; - private $data ; - private $buttontext = 'Save'; - private $selectData; - private $page; + private $filterID = 0; + private $data ; + private $buttontext = 'Save'; + private $selectData; + private $page; - public function setButtontext($v){ - $this->buttontext = $v; - } - public function setData($v){ - $this->data = $v; - } - public function setFilterID($v){ - $this->filterID = $v; - } - public function setSelectData($v){ - $this->selectData = $v; - } - public function setPage($page){ - $this->page = $page; - } + public function setButtontext($v) { + $this->buttontext = $v; + } + public function setData($v) { + $this->data = $v; + } + public function setFilterID($v) { + $this->filterID = $v; + } + public function setSelectData($v) { + $this->selectData = $v; + } + public function setPage($page) { + $this->page = $page; + } - public function init() - { - $this->setName("Add Filterentry"); - $this->setMethod('post'); - $this->setAttrib('id','filterentryform'); - #print_a($this->data); - #print_a($this->selectData); - try{ - $filtertypemapper = new Application_Model_FilterTypeMapper(); - $filtertype = $filtertypemapper->fetchAll(); - - $filtertypes = $this->createElement('select','filtertypeID'); - $filtertypes ->setLabel('Type:'); - $filtertypes ->setAttrib('id','filtertype'); - $filtertypes->addMultiOption('',''); - foreach($filtertype as $f){ - $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename()); - } - $filterentry = $filtertypes->getMultiOption($this->data['filtertypeID']); - $filterentryID = $this->data['filtertypeID']; - }catch (Zend_Exception $e) { - echo "Error message 1: " . $e->getMessage() . "\n"; - } - switch($filterentryID){ - default: - $desc = "Select the filtertype"; - $label1 = 'Value 1:'; - $label2 = 'Value 2:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'id' => 'val2' - )); - break; - case "1": - $desc = "You can set one IP or an IP-Range"; - $label1 = 'Start:'; - $label2 = 'End:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^(([0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([[0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", - Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", - Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - break; - case "2": - $desc = "You can set one Mac-Adress or an Mac-Range"; - $label1 = 'Start:'; - $label2 = 'End:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", - Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", - Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - break; - case "3": - $desc = "Select your Pool"; - $label1 = 'PoolID:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['pools'])>0){ - foreach($this->selectData['pools'] as $id => $g){ - $filtervalue1->addMultiOption($g['poolID'], $g['title']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "4": - $desc = "Select your BootIso"; - $label1 = 'BootIsoID:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['bootisos'])>0){ - foreach($this->selectData['bootisos'] as $id => $g){ - $filtervalue1->addMultiOption($g['bootisoID'], $g['title']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - - break; - case "5": - $desc = "Select a Membership"; - $label1 = 'Membership:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['memberships'])>0){ - $personMapper = new Application_Model_PersonMapper(); - foreach($this->selectData['memberships'] as $id => $g){ - // Display full name of Person - $person = new Application_Model_Person(); - $personMapper->find($g['personID'],$person); - $filtervalue1->addMultiOption($g['membershipID'], $person->getName().", ".$person->getFirstname()); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "6": - $desc = "For all members in this Group"; - $label1 = 'Group:'; - // TODO: insert the child Groups - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['groups'])>0){ - foreach($this->selectData['groups'] as $id => $g){ - $filtervalue1->addMultiOption($g['groupID'], $g['title']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "7": - $desc = "Specify a time-range"; - $label1 = 'Start:'; - $label2 = 'End:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM", - Zend_Validate_Regex::INVALID => 'Time contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM", - Zend_Validate_Regex::INVALID => 'Time contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - echo '<script type="text/javascript"> - $(function() { - $( "#val1" ).timepicker({ - showPeriod: false, - showPeriodLabels: false - }); - $( "#val2" ).timepicker({ - showPeriod: false, - showPeriodLabels: false - }); - }); - </script>'; - break; - case "8": - $desc = "Select a Client"; - $label1 = 'Client:'; - - $filtervalue1 = $this->createElement('select','filtervalue'); - $filtervalue1 ->setLabel($label1); - if(count($this->selectData['clients'])>0){ - foreach($this->selectData['clients'] as $id => $g){ - $filtervalue1->addMultiOption($g['clientID'], $g['macadress']." - ".$g['hardwarehash']); - } - } - $filtervalue1->setRegisterInArrayValidator(false); - break; - case "9": - $desc = "Define a Hardwarehash"; - $label1 = 'Hardwarehash:'; - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(32, 32)), - ), - 'required' => true, - 'id' => 'val1' - )); - break; - case "10": - $desc = "Specify the Weekday (Monday:1, Tuesday:2 ... Sunday:7) or a range"; - $label1 = 'Start Day:'; - $label2 = 'End Day:'; - - - - $filtervalue1 = $this->createElement('select','filtervalue', array( - 'label' => $label1, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([1-7])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7", - Zend_Validate_Regex::INVALID => 'Day contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val1' - )); - $filtervalue1->addMultiOption(1, "Monday") - ->addMultiOption(2, "Tuesday") - ->addMultiOption(3, "Wednesday") - ->addMultiOption(4, "Thursday") - ->addMultiOption(5, "Friday") - ->addMultiOption(6, "Saturday") - ->addMultiOption(7, "Sunday"); - - - $filtervalue2 = $this->createElement('select', 'filtervalue2', array( - 'label' => $label2, - 'validators' => array( - array( - 'regex', - false, - array( - '/^([1-7])$/i', - 'messages' => array( - Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7", - Zend_Validate_Regex::INVALID => 'Day contains invalid characters.' - ) - ) - ) - ), - 'required' => true, - 'id' => 'val2' - )); - $filtervalue2->addMultiOption(1, "Monday") - ->addMultiOption(2, "Tuesday") - ->addMultiOption(3, "Wednesday") - ->addMultiOption(4, "Thursday") - ->addMultiOption(5, "Friday") - ->addMultiOption(6, "Saturday") - ->addMultiOption(7, "Sunday"); - break; - case "11": - $desc = "Specify the date or a day range of the filter"; - $label1 = 'Start Date:'; - $label2 = 'End Date:'; - - $filtervalue1 = $this->createElement('text', 'filtervalue', array( - 'label' => $label1, - 'required' => true, - 'id' => 'val1' - )); - $filtervalue1->addValidator('Date',false, array('format'=>'dd.MM.yyyy')); - - $filtervalue2 = $this->createElement('text', 'filtervalue2', array( - 'label' => $label2, - 'required' => true, - 'id' => 'val2' - )); - $filtervalue2->addValidator('Date',false, array('format'=>'dd.MM.yyyy')); - echo '<script type="text/javascript"> - $(function() { - $( "#val1" ).datepicker({ dateFormat: "dd.mm.yy"}); - $( "#val2" ).datepicker({ dateFormat: "dd.mm.yy"}); - }); - </script>'; - break; - } - $filtertypes->setDescription($desc); - $this->addElement($filtertypes); - - - - $this->addElement($filtervalue1); - if(isset($filtervalue2 )){ - $this->addElement($filtervalue2); - } + public function init() { + $this->setName("Add Filterentry"); + $this->setMethod('post'); + $this->setAttrib('id', 'filterentryform'); +#print_a($this->data); +#print_a($this->selectData); + try { + $filtertypemapper = new Application_Model_FilterTypeMapper(); + $filtertype = $filtertypemapper->fetchAll(); - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"' - )); - - $this->addElement('hidden', 'filterID', array( - 'value' => $this->filterID - )); - - + $filtertypes = $this->createElement('select', 'filtertypeID'); + $filtertypes ->setLabel('Type:'); + $filtertypes ->setAttrib('id', 'filtertype'); + $filtertypes->addMultiOption('', ''); + foreach($filtertype as $f) { + $filtertypes->addMultiOption($f->getID(), $f->getFiltertypename()); + } + $filterentry = $filtertypes->getMultiOption($this->data['filtertypeID']); + $filterentryID = $this->data['filtertypeID']; + } catch (Zend_Exception $e) { + echo "Error message 1: " . $e->getMessage() . "\n"; } + switch($filterentryID) { + default: + $desc = "Select the filtertype"; + $label1 = 'Value 1:'; + $label2 = 'Value 2:'; + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'id' => 'val2' + )); + break; + case "1": + $desc = "You can set one IP or an IP-Range"; + $label1 = 'Start:'; + $label2 = 'End:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'validators' => array( + array( + 'regex', + false, + array( + '/^(([0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([[0-9]|[1-9][0-9]|0[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", + Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'validators' => array( + array( + 'regex', + false, + array( + '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid IP-Adress", + Zend_Validate_Regex::INVALID => 'IP-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val2' + )); + break; + case "2": + $desc = "You can set one Mac-Adress or an Mac-Range"; + $label1 = 'Start:'; + $label2 = 'End:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'validators' => array( + array( + 'regex', + false, + array( + '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", + Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'validators' => array( + array( + 'regex', + false, + array( + '/^[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Mac-Adress", + Zend_Validate_Regex::INVALID => 'Mac-Adress contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val2' + )); + break; + case "3": + $desc = "Select your Pool"; + $label1 = 'PoolID:'; + + $filtervalue1 = $this->createElement('select', 'filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['pools']) > 0) { + foreach($this->selectData['pools'] as $id => $g) { + $filtervalue1->addMultiOption($g['poolID'], $g['title']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); + break; + case "4": + $desc = "Select your BootIso"; + $label1 = 'BootIsoID:'; + + $filtervalue1 = $this->createElement('select', 'filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['bootisos']) > 0) { + foreach($this->selectData['bootisos'] as $id => $g) { + $filtervalue1->addMultiOption($g['bootisoID'], $g['title']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); + + break; + case "5": + $desc = "Select a Membership"; + $label1 = 'Membership:'; + + $filtervalue1 = $this->createElement('select', 'filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['memberships']) > 0) { + $personMapper = new Application_Model_PersonMapper(); + foreach($this->selectData['memberships'] as $id => $g) { + // Display full name of Person + $person = new Application_Model_Person(); + $personMapper->find($g['personID'], $person); + $filtervalue1->addMultiOption($g['membershipID'], $person->getName().", ".$person->getFirstname()); + } + } + $filtervalue1->setRegisterInArrayValidator(false); + break; + case "6": + $desc = "For all members in this Group"; + $label1 = 'Group:'; + // TODO: insert the child Groups + $filtervalue1 = $this->createElement('select', 'filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['groups']) > 0) { + foreach($this->selectData['groups'] as $id => $g) { + $filtervalue1->addMultiOption($g['groupID'], $g['title']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); + break; + case "7": + $desc = "Specify a time-range"; + $label1 = 'Start:'; + $label2 = 'End:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'validators' => array( + array( + 'regex', + false, + array( + '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM", + Zend_Validate_Regex::INVALID => 'Time contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val1' + )); + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'validators' => array( + array( + 'regex', + false, + array( + '/^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Time-Format, It must be HH:MM", + Zend_Validate_Regex::INVALID => 'Time contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val2' + )); + echo '<script type="text/javascript"> + $(function() { + $( "#val1" ).timepicker({ + showPeriod: false, + showPeriodLabels: false + }); + $( "#val2" ).timepicker({ + showPeriod: false, + showPeriodLabels: false + }); + }); + </script>'; + break; + case "8": + $desc = "Select a Client"; + $label1 = 'Client:'; + + $filtervalue1 = $this->createElement('select', 'filtervalue'); + $filtervalue1 ->setLabel($label1); + if(count($this->selectData['clients']) > 0) { + foreach($this->selectData['clients'] as $id => $g) { + $filtervalue1->addMultiOption($g['clientID'], $g['macadress']." - ".$g['hardwarehash']); + } + } + $filtervalue1->setRegisterInArrayValidator(false); + break; + case "9": + $desc = "Define a Hardwarehash"; + $label1 = 'Hardwarehash:'; + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(32, 32)), + ), + 'required' => true, + 'id' => 'val1' + )); + break; + case "10": + $desc = "Specify the Weekday (Monday:1, Tuesday:2 ... Sunday:7) or a range"; + $label1 = 'Start Day:'; + $label2 = 'End Day:'; + + + + $filtervalue1 = $this->createElement('select', 'filtervalue', array( + 'label' => $label1, + 'validators' => array( + array( + 'regex', + false, + array( + '/^([1-7])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7", + Zend_Validate_Regex::INVALID => 'Day contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val1' + )); + $filtervalue1->addMultiOption(1, "Monday") + ->addMultiOption(2, "Tuesday") + ->addMultiOption(3, "Wednesday") + ->addMultiOption(4, "Thursday") + ->addMultiOption(5, "Friday") + ->addMultiOption(6, "Saturday") + ->addMultiOption(7, "Sunday"); + + + $filtervalue2 = $this->createElement('select', 'filtervalue2', array( + 'label' => $label2, + 'validators' => array( + array( + 'regex', + false, + array( + '/^([1-7])$/i', + 'messages' => array( + Zend_Validate_Regex::NOT_MATCH => "'%value%' is not a valid Day-Format, It must be betweeen 1 and 7", + Zend_Validate_Regex::INVALID => 'Day contains invalid characters.' + ) + ) + ) + ), + 'required' => true, + 'id' => 'val2' + )); + $filtervalue2->addMultiOption(1, "Monday") + ->addMultiOption(2, "Tuesday") + ->addMultiOption(3, "Wednesday") + ->addMultiOption(4, "Thursday") + ->addMultiOption(5, "Friday") + ->addMultiOption(6, "Saturday") + ->addMultiOption(7, "Sunday"); + break; + case "11": + $desc = "Specify the date or a day range of the filter"; + $label1 = 'Start Date:'; + $label2 = 'End Date:'; + + $filtervalue1 = $this->createElement('text', 'filtervalue', array( + 'label' => $label1, + 'required' => true, + 'id' => 'val1' + )); + $filtervalue1->addValidator('Date', false, array('format' => 'dd.MM.yyyy')); + + $filtervalue2 = $this->createElement('text', 'filtervalue2', array( + 'label' => $label2, + 'required' => true, + 'id' => 'val2' + )); + $filtervalue2->addValidator('Date', false, array('format' => 'dd.MM.yyyy')); + echo '<script type="text/javascript"> + $(function() { + $( "#val1" ).datepicker({ dateFormat: "dd.mm.yy"}); + $( "#val2" ).datepicker({ dateFormat: "dd.mm.yy"}); + }); + </script>'; + break; + } + $filtertypes->setDescription($desc); + $this->addElement($filtertypes); + + + + $this->addElement($filtervalue1); + if(isset($filtervalue2 )) { + $this->addElement($filtervalue2); + } + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"' + )); + + $this->addElement('hidden', 'filterID', array( + 'value' => $this->filterID + )); + + + } } -?> -<script type="text/javascript"> - $('#filtertype').change(function(){ - //alert($("#filtertype option:selected").val()); - $('#filterentryform').submit(); - }); - $('#val1').focusout(function(){ - if($("#filtertype option:selected").val() == 1 && $('#val2').val() == ""){ - $('#val2').val($('#val1').val()); - } - if($("#filtertype option:selected").val() == 2 && $('#val2').val() == ""){ - $('#val2').val($('#val1').val()); - } - }); -</script> +? > +< script type = "text/javascript" > +$('#filtertype').change(function() { + //alert($("#filtertype option:selected").val()); + $('#filterentryform').submit(); +}); +$('#val1').focusout(function() { + if($("#filtertype option:selected").val() == 1 && $('#val2').val() == "") { + $('#val2').val($('#val1').val()); + } + if($("#filtertype option:selected").val() == 2 && $('#val2').val() == "") { + $('#val2').val($('#val1').val()); + } +}); +< / script > diff --git a/application/modules/user/forms/GroupAdd.php b/application/modules/user/forms/GroupAdd.php index 9bf1e81..8ad3364 100644 --- a/application/modules/user/forms/GroupAdd.php +++ b/application/modules/user/forms/GroupAdd.php @@ -1,74 +1,72 @@ -<?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 user_Form_GroupAdd extends Zend_Form -{ - private $grouplist; +class user_Form_GroupAdd extends Zend_Form { + private $grouplist; - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + } - public function init() - { - $this->setName("GroupAdd"); - $this->setMethod('post'); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); + public function init() { + $this->setName("GroupAdd"); + $this->setMethod('post'); - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - )); - /* - $groupfield = $this->createElement('select','superordinatedGroupID'); - $groupfield ->setLabel('superordinated Group:'); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); - $groupfield->addMultiOption('-1', '---- none ----'); + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + )); + /* + $groupfield = $this->createElement('select','superordinatedGroupID'); + $groupfield ->setLabel('superordinated Group:'); - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - */ - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add', - )); + $groupfield->addMultiOption('-1', '---- none ----'); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + if(count($this->grouplist)>0){ + foreach($this->grouplist as $group => $g){ + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + */ + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/user/forms/GroupEdit.php b/application/modules/user/forms/GroupEdit.php index 41924c3..d428f23 100644 --- a/application/modules/user/forms/GroupEdit.php +++ b/application/modules/user/forms/GroupEdit.php @@ -1,60 +1,58 @@ -<?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 user_Form_GroupEdit extends Zend_Form -{ - private $groupID; - - public function setGroupID($groupID){ - $this->groupID = $groupID; - - } - - public function init() - { - $this->setName("GroupEdit"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - 'value' => $_POST['title'], - )); - - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - 'value' => $_POST['description'], - )); - - $this->addElement('submit', 'save', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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 user_Form_GroupEdit extends Zend_Form { + private $groupID; + + public function setGroupID($groupID) { + $this->groupID = $groupID; + + } + + public function init() { + $this->setName("GroupEdit"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + 'value' => $_POST['title'], + )); + + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + 'value' => $_POST['description'], + )); + + $this->addElement('submit', 'save', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } }
\ No newline at end of file diff --git a/application/modules/user/forms/GroupLink.php b/application/modules/user/forms/GroupLink.php index 9ff2fa2..0b82ed3 100644 --- a/application/modules/user/forms/GroupLink.php +++ b/application/modules/user/forms/GroupLink.php @@ -1,67 +1,65 @@ -<?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 user_Form_GroupLink extends Zend_Form -{ - private $grouplist; +class user_Form_GroupLink extends Zend_Form { + private $grouplist; - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; - public function init() - { - $this->setName("GroupLink"); - $this->setMethod('post'); - -/* - $groupfield1 = $this->createElement('select','superordinatedGroupID'); - $groupfield1 ->setLabel('Parent Group:'); + } + + public function init() { + $this->setName("GroupLink"); + $this->setMethod('post'); + + /* + $groupfield1 = $this->createElement('select','superordinatedGroupID'); + $groupfield1 ->setLabel('Parent Group:'); - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield1->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield1->setRegisterInArrayValidator(false); - $this->addElement($groupfield1); - */ + if(count($this->grouplist)>0){ + foreach($this->grouplist as $group => $g){ + $groupfield1->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield1->setRegisterInArrayValidator(false); + $this->addElement($groupfield1); + */ - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - $groupfield->setAttrib('onchange', "reloadGraph();"); + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + $groupfield->setAttrib('onchange', "reloadGraph();"); - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); - $this->addElement('submit', 'link', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Link', - )); + $this->addElement('submit', 'link', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Link', + )); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/user/forms/GroupRequest.php b/application/modules/user/forms/GroupRequest.php index 8cf033c..a5fe5ab 100644 --- a/application/modules/user/forms/GroupRequest.php +++ b/application/modules/user/forms/GroupRequest.php @@ -1,59 +1,57 @@ -<?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 user_Form_GroupRequest extends Zend_Form -{ - private $grouplist; - - public function setGrouplist($grouplist){ - $this->grouplist = $grouplist; - - } - - public function getGrouplist(){ - return $this->grouplist; - } - - public function init() - { - $this->setName("GroupRequest"); - $this->setMethod('post'); - - $groupfield = $this->createElement('select','groupID'); - $groupfield ->setLabel('Group:'); - - if(count($this->grouplist)>0){ - foreach($this->grouplist as $group => $g){ - $groupfield->addMultiOption($g->getID(), $g->getTitle()); - } - } - - $groupfield->setRegisterInArrayValidator(false); - $this->addElement($groupfield); - - $this->addElement('submit', 'request', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Request', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - - } +* 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 user_Form_GroupRequest extends Zend_Form { + private $grouplist; + + public function setGrouplist($grouplist) { + $this->grouplist = $grouplist; + + } + + public function getGrouplist() { + return $this->grouplist; + } + + public function init() { + $this->setName("GroupRequest"); + $this->setMethod('post'); + + $groupfield = $this->createElement('select', 'groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist) > 0) { + foreach($this->grouplist as $group => $g) { + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('submit', 'request', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Request', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + + } } diff --git a/application/modules/user/forms/LinkRight.php b/application/modules/user/forms/LinkRight.php index 80d0402..ad4585b 100644 --- a/application/modules/user/forms/LinkRight.php +++ b/application/modules/user/forms/LinkRight.php @@ -1,75 +1,73 @@ -<?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 user_Form_LinkRight extends Zend_Form -{ - private $rightlist; +class user_Form_LinkRight extends Zend_Form { + private $rightlist; - public function setRightlist($rightlist){ - $this->rightlist = $rightlist; - } + public function setRightlist($rightlist) { + $this->rightlist = $rightlist; + } - public function init() - { - $this->setName("LinkRights"); - $this->setMethod('post'); + public function init() { + $this->setName("LinkRights"); + $this->setMethod('post'); - $sform = new Zend_Form_SubForm(array('legend' => 'Rights:')); - - $sform->addElement('button', 'checkAll', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Check All', - 'class' => 'leftbutton', - 'onclick' => "checkAllCheckBoxes();", - )); - - $sform->addElement('button', 'uncheckAll', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Uncheck All', - 'onclick' => "uncheckAllCheckBoxes();", - )); - - if(count($this->rightlist) > 0) { - foreach($this->rightlist as $rightcategory => $rights) { - foreach($rights as $rightID => $rightTitle) { - $element = $this->createElement('checkbox', "$rightID", array( - 'label' => $rightTitle . ':', - 'belongsTo' => 'rights', - )); - $elements[] = $rightID; - $sform->addElement($element); - } - $sform->addDisplayGroup($elements, "$rightcategory", array("legend" => $rightcategory . ":")); - unset($elements); - } - } - - $this->addSubForm($sform, 'rights'); + $sform = new Zend_Form_SubForm(array('legend' => 'Rights:')); - $this->addElement('submit', 'link', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add Rights', - )); + $sform->addElement('button', 'checkAll', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Check All', + 'class' => 'leftbutton', + 'onclick' => "checkAllCheckBoxes();", + )); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + $sform->addElement('button', 'uncheckAll', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Uncheck All', + 'onclick' => "uncheckAllCheckBoxes();", + )); + + if(count($this->rightlist) > 0) { + foreach($this->rightlist as $rightcategory => $rights) { + foreach($rights as $rightID => $rightTitle) { + $element = $this->createElement('checkbox', "$rightID", array( + 'label' => $rightTitle . ':', + 'belongsTo' => 'rights', + )); + $elements[] = $rightID; + $sform->addElement($element); + } + $sform->addDisplayGroup($elements, "$rightcategory", array("legend" => $rightcategory . ":")); + unset($elements); + } + } + + $this->addSubForm($sform, 'rights'); + + $this->addElement('submit', 'link', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add Rights', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/user/forms/Login.php b/application/modules/user/forms/Login.php index d2dbd63..736841b 100644 --- a/application/modules/user/forms/Login.php +++ b/application/modules/user/forms/Login.php @@ -1,47 +1,45 @@ -<?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 user_Form_Login extends Zend_Form -{ - - public function init() - { - $this->setName("LoginForm"); - $this->setMethod('post'); - - $this->addElement('text', 'email', array( - 'filters' => array('StringTrim', 'StringToLower'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'E-Mail:', - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Password:', - )); - - $this->addElement('submit', 'login', array( - 'required' => false, - '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 user_Form_Login extends Zend_Form { + + public function init() { + $this->setName("LoginForm"); + $this->setMethod('post'); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'E-Mail:', + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'login', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Login', + )); + } } diff --git a/application/modules/user/forms/MembershipSelect.php b/application/modules/user/forms/MembershipSelect.php index ea2804c..39ee52b 100644 --- a/application/modules/user/forms/MembershipSelect.php +++ b/application/modules/user/forms/MembershipSelect.php @@ -1,51 +1,49 @@ -<?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 user_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, - '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 user_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, + 'ignore' => true, + 'label' => 'Select', + )); + } } diff --git a/application/modules/user/forms/NewPassword.php b/application/modules/user/forms/NewPassword.php index 915620d..3d84406 100644 --- a/application/modules/user/forms/NewPassword.php +++ b/application/modules/user/forms/NewPassword.php @@ -1,47 +1,45 @@ -<?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 user_Form_NewPassword extends Zend_Form -{ - private $personID; - - public function setPersonID($personID){ - $this->personID = $personID; - } - - public function init() - { - $this->setName("NewPassword"); - $this->setMethod('post'); - - $this->addElement('hidden', 'personID', array( - 'value' => $this->personID - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Password:', - )); - - $this->addElement('submit', 'savePassword', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); - } +* 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 user_Form_NewPassword extends Zend_Form { + private $personID; + + public function setPersonID($personID) { + $this->personID = $personID; + } + + public function init() { + $this->setName("NewPassword"); + $this->setMethod('post'); + + $this->addElement('hidden', 'personID', array( + 'value' => $this->personID + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'savePassword', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + } } diff --git a/application/modules/user/forms/PersonEdit.php b/application/modules/user/forms/PersonEdit.php index 09d090a..2a5f40a 100644 --- a/application/modules/user/forms/PersonEdit.php +++ b/application/modules/user/forms/PersonEdit.php @@ -1,126 +1,124 @@ -<?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 user_Form_PersonEdit extends Zend_Form -{ - - public function init() - { - $this->setName("PersonEdit"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - 'value' => $this->getView()->person->getTitle(), - )); - - - $this->addElement('text', 'name', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Name:', - 'value' => $this->getView()->person->getName(), - )); - - $this->addElement('text', 'firstname', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Firstname:', - 'value' => $this->getView()->person->getFirstname(), - )); - - $this->addElement('text', 'street', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Street:', - 'value' => $this->getView()->person->getStreet(), - )); - - $this->addElement('text', 'housenumber', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Housenumber:', - 'value' => $this->getView()->person->getHousenumber(), - )); - - $this->addElement('text', 'city', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'City:', - 'value' => $this->getView()->person->getCity(), - )); - - $this->addElement('text', 'postalcode', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Postalcode:', - 'value' => $this->getView()->person->getPostalcode(), - )); - - $this->addElement('text', 'email', array( - 'filters' => array('StringTrim', 'StringToLower'), - 'validators' => array( - array('StringLength', false, array(0, 50)),array('EmailAddress', "deep" => true, "mx" => true), - ), - 'required' => true, - 'label' => 'Email:', - 'value' => $this->getView()->person->getEmail(), - )); - - $this->addElement('password', 'newpassword', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(5, 50)), - ), - 'required' => false, - 'label' => 'Neues Password:', - )); - - $this->addElement('submit', 'save', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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 user_Form_PersonEdit extends Zend_Form { + + public function init() { + $this->setName("PersonEdit"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + 'value' => $this->getView()->person->getTitle(), + )); + + + $this->addElement('text', 'name', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Name:', + 'value' => $this->getView()->person->getName(), + )); + + $this->addElement('text', 'firstname', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Firstname:', + 'value' => $this->getView()->person->getFirstname(), + )); + + $this->addElement('text', 'street', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Street:', + 'value' => $this->getView()->person->getStreet(), + )); + + $this->addElement('text', 'housenumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Housenumber:', + 'value' => $this->getView()->person->getHousenumber(), + )); + + $this->addElement('text', 'city', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'City:', + 'value' => $this->getView()->person->getCity(), + )); + + $this->addElement('text', 'postalcode', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Postalcode:', + 'value' => $this->getView()->person->getPostalcode(), + )); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + array('StringLength', false, array(0, 50)), array('EmailAddress', "deep" => true, "mx" => true), + ), + 'required' => true, + 'label' => 'Email:', + 'value' => $this->getView()->person->getEmail(), + )); + + $this->addElement('password', 'newpassword', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(5, 50)), + ), + 'required' => false, + 'label' => 'Neues Password:', + )); + + $this->addElement('submit', 'save', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/user/forms/Pool.php b/application/modules/user/forms/Pool.php index 4b30c9c..2fa05e1 100644 --- a/application/modules/user/forms/Pool.php +++ b/application/modules/user/forms/Pool.php @@ -1,68 +1,66 @@ -<?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 user_Form_Pool extends Zend_Form -{ - private $buttontext = 'Save'; - private $page; - - public function setButtontext($v){ - $this->buttontext = $v; - } - public function setPage($page){ - $this->page = $page; - } +class user_Form_Pool extends Zend_Form { + private $buttontext = 'Save'; + private $page; - public function init() - { - $this->setName("pool"); - $this->setMethod('post'); + public function setButtontext($v) { + $this->buttontext = $v; + } + public function setPage($page) { + $this->page = $page; + } - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 30)), - ), - 'required' => true, - 'label' => 'Title:', - )); - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - )); + public function init() { + $this->setName("pool"); + $this->setMethod('post'); - $this->addElement('text', 'location', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 30)), - ), - 'required' => true, - 'label' => 'Location:', - )); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 30)), + ), + 'required' => true, + 'label' => 'Title:', + )); + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + )); - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => $this->buttontext, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/pool/index/page/'.$this->page.'"' - )); - } + $this->addElement('text', 'location', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 30)), + ), + 'required' => true, + 'label' => 'Location:', + )); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => $this->buttontext, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/pool/index/page/'.$this->page.'"' + )); + } } diff --git a/application/modules/user/forms/PoolClient.php b/application/modules/user/forms/PoolClient.php index 9acf21b..17b8ae8 100644 --- a/application/modules/user/forms/PoolClient.php +++ b/application/modules/user/forms/PoolClient.php @@ -1,53 +1,51 @@ -<?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 user_Form_PoolClient extends Zend_Form -{ - private $clients; - private $page; - private $buttontext = 'Save'; - - function setButtontext($v){ - $this->buttontext = $v; - } - public function setClients($clients){ - $this->clients = $clients; - return $this; - } - public function setPage($page){ - $this->page = $page; - } - - public function init() - { - $this->setName("addClientToPool"); - $this->setMethod('post'); - - $clientfield = $this->createElement('select','clientID'); - $clientfield ->setLabel('Client:'); - foreach($this->clients as $c){ - $clientfield->addMultiOption($c['clientID'],$c['macadress']." - ".$c['hardwarehash']); - } - $this->addElement($clientfield); - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"' - )); +class user_Form_PoolClient extends Zend_Form { + private $clients; + private $page; + private $buttontext = 'Save'; + + function setButtontext($v) { + $this->buttontext = $v; + } + public function setClients($clients) { + $this->clients = $clients; + return $this; + } + public function setPage($page) { + $this->page = $page; + } + + public function init() { + $this->setName("addClientToPool"); + $this->setMethod('post'); + + $clientfield = $this->createElement('select', 'clientID'); + $clientfield ->setLabel('Client:'); + foreach($this->clients as $c) { + $clientfield->addMultiOption($c['clientID'], $c['macadress']." - ".$c['hardwarehash']); } - + $this->addElement($clientfield); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/filter/index/page/'.$this->page.'"' + )); + } + } diff --git a/application/modules/user/forms/Preboot.php b/application/modules/user/forms/Preboot.php index f1a609f..a862fdf 100644 --- a/application/modules/user/forms/Preboot.php +++ b/application/modules/user/forms/Preboot.php @@ -1,89 +1,87 @@ -<?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 user_Form_Preboot extends Zend_Form -{ - - private $action; - private $page; - - public function setAction($action){ - $this->action = $action; - } - public function setPage($p){ - $this->page = $p; - } - - public function init() - { - $this->setName($this->action); - $this->setMethod('post'); - $this->setEnctype("multipart/form-data"); - - if (!Pbs_Acl::checkRight('pre') && $this->action == 'editpreboot') - $meta = true; - else - $meta = null; - - if($this->action == 'editpreboot') - $filereq = false; - else - $filereq = true; - - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $this->addElement('textarea', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'rows' => 5, - 'cols' => 50, - 'label' => 'Description:', - )); - - $this->addElement('file', 'preboot', array( - 'validators' => array(array('Extension', false, array('zip'))), - 'required' => $filereq, - 'readOnly' => $meta, - 'label' => 'Preboot:', - )); - - if($this->action == "createpreboot") - $label = "Create Preboot"; - else - $label = "Edit Preboot"; - - $this->addElement('submit', $this->action, array( - 'required' => false, - 'ignore' => true, - 'label' => $label, - )); - - $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/preboot/index/page/'.$this->page.'"' - )); - - } - - +* 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 user_Form_Preboot extends Zend_Form { + + private $action; + private $page; + + public function setAction($action) { + $this->action = $action; + } + public function setPage($p) { + $this->page = $p; + } + + public function init() { + $this->setName($this->action); + $this->setMethod('post'); + $this->setEnctype("multipart/form-data"); + + if (!Pbs_Acl::checkRight('pre') && $this->action == 'editpreboot') + { $meta = true; } + else + { $meta = null; } + + if($this->action == 'editpreboot') + { $filereq = false; } + else + { $filereq = true; } + + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'rows' => 5, + 'cols' => 50, + 'label' => 'Description:', + )); + + $this->addElement('file', 'preboot', array( + 'validators' => array(array('Extension', false, array('zip'))), + 'required' => $filereq, + 'readOnly' => $meta, + 'label' => 'Preboot:', + )); + + if($this->action == "createpreboot") + { $label = "Create Preboot"; } + else + { $label = "Edit Preboot"; } + + $this->addElement('submit', $this->action, array( + 'required' => false, + 'ignore' => true, + 'label' => $label, + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/user/preboot/index/page/'.$this->page.'"' + )); + + } + + } diff --git a/application/modules/user/forms/RecoverPassword.php b/application/modules/user/forms/RecoverPassword.php index 0e064b0..28ce336 100644 --- a/application/modules/user/forms/RecoverPassword.php +++ b/application/modules/user/forms/RecoverPassword.php @@ -1,37 +1,35 @@ -<?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 user_Form_RecoverPassword extends Zend_Form -{ +class user_Form_RecoverPassword extends Zend_Form { - public function init() - { - $this->setName("RecoverPassword"); - $this->setMethod('post'); + public function init() { + $this->setName("RecoverPassword"); + $this->setMethod('post'); - $this->addElement('text', 'email', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 30)), - ), - 'required' => true, - 'label' => 'Email:', - )); - $this->addElement('submit', 'recoverPassword', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Recover', - )); - } + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 30)), + ), + 'required' => true, + 'label' => 'Email:', + )); + $this->addElement('submit', 'recoverPassword', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Recover', + )); + } } diff --git a/application/modules/user/forms/Register.php b/application/modules/user/forms/Register.php index 0808088..baa7cdd 100644 --- a/application/modules/user/forms/Register.php +++ b/application/modules/user/forms/Register.php @@ -1,113 +1,111 @@ -<?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 user_Form_Register extends Zend_Form -{ - - public function init() - { - $this->setName("Register"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - - $this->addElement('text', 'name', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Name:', - )); - - $this->addElement('text', 'firstname', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Firstname:', - )); - - $this->addElement('text', 'street', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Street:', - )); - - $this->addElement('text', 'housenumber', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Housenumber:', - )); - - $this->addElement('text', 'city', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'City:', - )); - - $this->addElement('text', 'postalcode', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Postalcode:', - )); - - $this->addElement('text', 'email', array( - 'filters' => array('StringTrim', 'StringToLower'), - 'validators' => array( - array('StringLength', false, array(0, 50)),array('EmailAddress', "deep" => true, "mx" => true), - ), - 'required' => true, - 'label' => 'Email:', - )); - - $this->addElement('password', 'password', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(5, 50)), - ), - 'required' => true, - 'label' => 'Password:', - )); - - $this->addElement('submit', 'register', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Register', - )); - - - } +* 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 user_Form_Register extends Zend_Form { + + public function init() { + $this->setName("Register"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + + $this->addElement('text', 'name', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Name:', + )); + + $this->addElement('text', 'firstname', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Firstname:', + )); + + $this->addElement('text', 'street', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Street:', + )); + + $this->addElement('text', 'housenumber', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Housenumber:', + )); + + $this->addElement('text', 'city', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'City:', + )); + + $this->addElement('text', 'postalcode', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Postalcode:', + )); + + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim', 'StringToLower'), + 'validators' => array( + array('StringLength', false, array(0, 50)), array('EmailAddress', "deep" => true, "mx" => true), + ), + 'required' => true, + 'label' => 'Email:', + )); + + $this->addElement('password', 'password', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(5, 50)), + ), + 'required' => true, + 'label' => 'Password:', + )); + + $this->addElement('submit', 'register', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Register', + )); + + + } diff --git a/application/modules/user/forms/RoleAdd.php b/application/modules/user/forms/RoleAdd.php index e44c2a3..36f602e 100644 --- a/application/modules/user/forms/RoleAdd.php +++ b/application/modules/user/forms/RoleAdd.php @@ -1,120 +1,118 @@ -<?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 user_Form_RoleAdd extends Zend_Form -{ - private $rightlist; - private $inheritanceright; - private $addrighttoroleright; - - public function setRightlist($rightlist){ - $this->rightlist = $rightlist; - } - - public function setAddrighttoroleright($addrighttoroleright){ - $this->addrighttoroleright = $addrighttoroleright; - } - - public function setInheritanceright($inheritanceright){ - $this->inheritanceright = $inheritanceright; - } - - public function init() - { - $this->setName("RoleAdd"); - $this->setMethod('post'); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - )); - - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => false, - 'label' => 'Title:', - )); - - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - 'value' => $_POST['description'], - )); - - if($this->addrighttoroleright) { - $sform = new Zend_Form_SubForm(array('legend' => 'Rights:')); - $sform->addElement('button', 'checkAll', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Check All', - 'class' => 'leftbutton', - 'onclick' => "checkAllCheckBoxes(new Array('inheritance'));", - )); - - $sform->addElement('button', 'uncheckAll', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Uncheck All', - 'onclick' => "uncheckAllCheckBoxes(new Array('inheritance'));", - )); - - if(count($this->rightlist) > 0) { - foreach($this->rightlist as $rightcategory => $rights) { - foreach($rights as $rightID => $rightTitle) { - $element = $this->createElement('checkbox', "$rightID", array( - 'label' => $rightTitle . ':', - 'belongsTo' => 'rights', - )); - $elements[] = $rightID; - $sform->addElement($element); - } - $sform->addDisplayGroup($elements, "$rightcategory", array("legend" => $rightcategory . ":")); - unset($elements); - } - } - - $this->addSubForm($sform, 'rights'); - } - - if($this->inheritanceright) { - $this->addElement('checkbox', 'inheritance', array( - 'label' => 'Inheritance:', - )); - } - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add', - )); - - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } +* 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 user_Form_RoleAdd extends Zend_Form { + private $rightlist; + private $inheritanceright; + private $addrighttoroleright; + + public function setRightlist($rightlist) { + $this->rightlist = $rightlist; + } + + public function setAddrighttoroleright($addrighttoroleright) { + $this->addrighttoroleright = $addrighttoroleright; + } + + public function setInheritanceright($inheritanceright) { + $this->inheritanceright = $inheritanceright; + } + + public function init() { + $this->setName("RoleAdd"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Title:', + )); + + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + 'value' => $_POST['description'], + )); + + if($this->addrighttoroleright) { + $sform = new Zend_Form_SubForm(array('legend' => 'Rights:')); + $sform->addElement('button', 'checkAll', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Check All', + 'class' => 'leftbutton', + 'onclick' => "checkAllCheckBoxes(new Array('inheritance'));", + )); + + $sform->addElement('button', 'uncheckAll', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Uncheck All', + 'onclick' => "uncheckAllCheckBoxes(new Array('inheritance'));", + )); + + if(count($this->rightlist) > 0) { + foreach($this->rightlist as $rightcategory => $rights) { + foreach($rights as $rightID => $rightTitle) { + $element = $this->createElement('checkbox', "$rightID", array( + 'label' => $rightTitle . ':', + 'belongsTo' => 'rights', + )); + $elements[] = $rightID; + $sform->addElement($element); + } + $sform->addDisplayGroup($elements, "$rightcategory", array("legend" => $rightcategory . ":")); + unset($elements); + } + } + + $this->addSubForm($sform, 'rights'); + } + + if($this->inheritanceright) { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + } + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add', + )); + + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } diff --git a/application/modules/user/forms/RoleEdit.php b/application/modules/user/forms/RoleEdit.php index 1505e78..68a740d 100644 --- a/application/modules/user/forms/RoleEdit.php +++ b/application/modules/user/forms/RoleEdit.php @@ -1,83 +1,81 @@ -<?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 user_Form_RoleEdit extends Zend_Form -{ - private $roleID; - private $inheritanceright; +class user_Form_RoleEdit extends Zend_Form { + private $roleID; + private $inheritanceright; - public function setRoleID($roleID){ - $this->roleID = $roleID; - } + public function setRoleID($roleID) { + $this->roleID = $roleID; + } - public function setInheritanceright($inheritanceright){ - $this->inheritanceright = $inheritanceright; - } + public function setInheritanceright($inheritanceright) { + $this->inheritanceright = $inheritanceright; + } - public function init() - { - $this->setName("RoleEdit"); - $this->setMethod('post'); + public function init() { + $this->setName("RoleEdit"); + $this->setMethod('post'); - $this->addElement('text', 'title', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'Title:', - 'value' => $_POST['title'], - )); + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + 'value' => $_POST['title'], + )); - $this->addElement('text', 'description', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 140)), - ), - 'required' => false, - 'label' => 'Description:', - 'value' => $_POST['description'], - )); + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + 'value' => $_POST['description'], + )); - if($this->inheritanceright) { - if($_POST['inheritance'] == 1) { - $this->addElement('checkbox', 'inheritance', array( - 'label' => 'Inheritance:', - 'checked' => 'checked', - )); - } else { - $this->addElement('checkbox', 'inheritance', array( - 'label' => 'Inheritance:', - )); - } - } + if($this->inheritanceright) { + if($_POST['inheritance'] == 1) { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + 'checked' => 'checked', + )); + } else { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + } + } - $this->addElement('hidden', 'groupID', array( - 'value' => $_POST['groupID'], - )); + $this->addElement('hidden', 'groupID', array( + 'value' => $_POST['groupID'], + )); - $this->addElement('submit', 'save', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Save', - )); + $this->addElement('submit', 'save', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); - $this->addElement('button', 'cancel', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Cancel', - 'onclick' => 'location.href="javascript:history.back();"', - )); - } + $this->addElement('button', 'cancel', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Cancel', + 'onclick' => 'location.href="javascript:history.back();"', + )); + } } |