diff options
author | Sebastian Schmelzer | 2012-01-11 14:36:35 +0100 |
---|---|---|
committer | Sebastian Schmelzer | 2012-01-11 14:36:35 +0100 |
commit | fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e (patch) | |
tree | 6e6aaf749f34db8c7c7153c23ef85c57187430bb /application/modules/user | |
parent | API: mit addBootos kann man nun auch editieren (diff) | |
download | pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.gz pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.xz pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.zip |
format source files
Diffstat (limited to 'application/modules/user')
41 files changed, 7286 insertions, 7510 deletions
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();"', + )); + } } |