From e205bff25c5716ce1788d39a0803fa439928ff3c Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 19 Apr 2011 14:34:10 +0200 Subject: Notices und Warnings weggemacht --- application/modules/fbgui/controllers/IndexController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'application/modules/fbgui/controllers/IndexController.php') diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index fb8282a..d537e0b 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -17,6 +17,8 @@ class Fbgui_IndexController extends Zend_Controller_Action public function init() { /* Initialize action controller here */ + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); @@ -84,13 +86,14 @@ class Fbgui_IndexController extends Zend_Controller_Action $_SESSION['alphasessionID'] = $session->getAlphasessionID(); } else{ + print_a('session wiedergefunden'); $session = new Application_Model_Session(); $sessionMapper = new Application_Model_SessionMapper(); $sessions = $sessionMapper->findBy(array('alphasessionID'=>$_SESSION['alphasessionID'])); $session = $sessions[0]; if($this->membership->getID() != ''){ $session->setMembershipID($this->membership->getID()); - $session->save(); + $sessionMapper->save($session); } } // Request Bootmenu -- cgit v1.2.3-55-g7522 From f2564dd358bf6664cb0c00f718afbfc48053f1f3 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 19 Apr 2011 14:37:22 +0200 Subject: Debugmeldung entfernt --- application/modules/fbgui/controllers/IndexController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'application/modules/fbgui/controllers/IndexController.php') diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index d537e0b..398bdf1 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -85,13 +85,12 @@ class Fbgui_IndexController extends Zend_Controller_Action $session = $n->createSession($session); $_SESSION['alphasessionID'] = $session->getAlphasessionID(); } - else{ - print_a('session wiedergefunden'); + else{ $session = new Application_Model_Session(); $sessionMapper = new Application_Model_SessionMapper(); $sessions = $sessionMapper->findBy(array('alphasessionID'=>$_SESSION['alphasessionID'])); $session = $sessions[0]; - if($this->membership->getID() != ''){ + if($this->membership->getID() != '' && $session->getMembershipID() == ''){ $session->setMembershipID($this->membership->getID()); $sessionMapper->save($session); } -- cgit v1.2.3-55-g7522 From c31d8e9959efade437fb0a661f6f44329cc74664 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 19 Apr 2011 15:43:00 +0200 Subject: Code autoformatiert --- application/controllers/IndexController.php | 40 +- application/controllers/ResourceController.php | 122 ++- application/controllers/StatsController.php | 34 +- .../modules/fbgui/controllers/IndexController.php | 167 ++-- .../modules/user/controllers/AuthController.php | 57 +- .../modules/user/controllers/BootisoController.php | 514 +++++------ .../user/controllers/BootmenuController.php | 950 ++++++++++----------- .../modules/user/controllers/BootosController.php | 672 +++++++-------- .../modules/user/controllers/ClientController.php | 40 +- .../modules/user/controllers/ConfigController.php | 380 ++++----- .../modules/user/controllers/FilterController.php | 86 +- .../modules/user/controllers/GroupController.php | 42 +- .../modules/user/controllers/IndexController.php | 20 +- .../modules/user/controllers/PersonController.php | 25 +- .../modules/user/controllers/PoolController.php | 58 +- .../modules/user/controllers/PrebootController.php | 590 ++++++------- .../modules/user/controllers/RoleController.php | 182 ++-- .../modules/user/controllers/SessionController.php | 4 +- 18 files changed, 1982 insertions(+), 2001 deletions(-) (limited to 'application/modules/fbgui/controllers/IndexController.php') diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index c6e6eba..65ef480 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -13,31 +13,31 @@ class IndexController extends Zend_Controller_Action { - public function init() - { - /* Initialize action controller here */ - } - - public function indexAction() - { - if(stristr($_SERVER['HTTP_USER_AGENT'],'prebootGUI')){ - $mySession =new Zend_Session_Namespace('pbs'); - if(!isset($mySession->postdata)){ - $mySession->postdata = $_POST; + public function init() + { + /* Initialize action controller here */ + } + + public function indexAction() + { + if(stristr($_SERVER['HTTP_USER_AGENT'],'prebootGUI')){ + $mySession =new Zend_Session_Namespace('pbs'); + if(!isset($mySession->postdata)){ + $mySession->postdata = $_POST; } - + $d = new Pbs_Debug(); $d->debug(array('MainIndexController',$_SERVER['REMOTE_ADDR'],implode("\t",$mySession->postdata))); - - $this->_redirect("/fbgui/index/index"); - } - - // action body - - } + $this->_redirect("/fbgui/index/index"); + } + + // action body + + + } + - } diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php index bf9de06..91cd290 100644 --- a/application/controllers/ResourceController.php +++ b/application/controllers/ResourceController.php @@ -21,27 +21,27 @@ class ResourceController extends Zend_Controller_Action { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - + $session = new Application_Model_Session(); $sm = new Application_Model_SessionMapper(); - + //TODO Error Messages if something failed $alpha = $this->_request->getParam('alpha'); $apikey = $this->_request->getParam('apikey'); - + if($apikey != ""){ $membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); $rightrolesMapper = new Application_Model_RightRolesMapper(); - $rightroles = new Application_Model_RightRoles(); + $rightroles = new Application_Model_RightRoles(); @list($this->membership) = $membershipMapper->findBy(array('apikey' => $apikey)); if($this->membership == null){ - header('HTTP/1.0 401 Member not found'); + header('HTTP/1.0 401 Member not found'); die(); } @list($rightroles) = $rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $this->membership->getRoleID())); if($rightroles == null){ - header('HTTP/1.0 403 No Right to Create Bootos'); + header('HTTP/1.0 403 No Right to Create Bootos'); die(); } } @@ -49,23 +49,24 @@ class ResourceController extends Zend_Controller_Action $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); $this->page = $this->_request->getParam('page'); - if(!is_numeric($bootmenuentryID)) + if(!is_numeric($bootmenuentryID)){ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/json/error'); - + } + $bootmenuentry = new Application_Model_BootMenuEntries(); $bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper(); $bootosMapper = new Application_Model_BootOsMapper(); $bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); - + $session->setBootosID($bootmenuentry->getBootosID()) ->setBootmenuentryID($bootmenuentry->getID()) ->setTime(time()) ->setMembershipID($bootosMapper->find($bootmenuentry->getBootmenuID())->getMembershipID()) ->setIp($_SERVER['REMOTE_ADDR']) ->setAlphasessionID('0'); - - $this->thisSession = $session; - + + $this->thisSession = $session; + } elseif($alpha != ""){ $alphasessionID = $alpha; @@ -79,15 +80,15 @@ class ResourceController extends Zend_Controller_Action public function indexAction() { - - + + } - + public function addbootosAction() { $apikey = $this->_request->getParam('apikey'); if($apikey == ""){ - header('HTTP/1.0 400 No API-Key'); + header('HTTP/1.0 400 No API-Key'); die(); } @@ -96,10 +97,10 @@ class ResourceController extends Zend_Controller_Action header('HTTP/1.0 400 Title must be set'); die(); } - + $bootos = new Application_Model_BootOs(); $bootosMapper = new Application_Model_BootOsMapper(); - + $bootos->setOptions($params); $bootos->setGroupID($this->membership->getGroupID()); $bootos->setSource($_SERVER['REMOTE_ADDR']); @@ -109,16 +110,16 @@ class ResourceController extends Zend_Controller_Action $bootos->setCreated(time()); $bootos->setPublic('-1'); $bootosID = $bootosMapper->save($bootos); - + print_a($bootos); - $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); - + $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(isset($_FILES['config'])){ move_uploaded_file($_FILES['config']['tmp_name'], $configpath."config.tgz"); } @@ -128,9 +129,9 @@ class ResourceController extends Zend_Controller_Action if(isset($_FILES['init'])){ move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs"); } - + header('HTTP/1.0 201 Bootos created'); - + } public function getinitramfsAction() @@ -139,19 +140,18 @@ class ResourceController extends Zend_Controller_Action $bootosID = $this->thisSession->getBootosID(); if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){ - header('Content-Type: application/x-gzip'); $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; header('Content-Disposition: ' . $content_disp . '; filename="initramfs"'); header('Pragma: no-cache'); header('Expires: 0'); - + // create file. chdir("../resources/bootos/$bootosID/initramfs/"); $initname = array_pop(scandir("./")); - + header("Content-Length: ".filesize(getcwd()."/".$initname)); - + passthru( "cat ".$initname); }else{ header('HTTP/1.0 404 Not Found'); @@ -160,29 +160,28 @@ class ResourceController extends Zend_Controller_Action public function getconfigAction() { - + $bootmenuentryID = $this->thisSession->getBootmenuentryID(); $bootmenuentry = new Application_Model_BootMenuEntries(); $bmm = new Application_Model_BootMenuEntriesMapper(); $bmm->find($bootmenuentryID,$bootmenuentry); - + $configID = $bootmenuentry->getConfigID(); if(is_dir("../resources/config/$configID/")){ - + header('Content-Type: application/x-gzip'); $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; header('Content-Disposition: ' . $content_disp . '; filename="default.tgz"'); header('Pragma: no-cache'); header('Expires: 0'); - + if($this->thisSession->getMembershipID() != null){ $path_userconf = "../resources/config/$configID/".$this->thisSession->getMembershipID()."/"; - - if(!is_dir($path_userconf)){ + if(!is_dir($path_userconf)){ $person = new Application_Model_Person(); $personMapper = new Application_Model_PersonMapper(); $membershipMapper = new Application_Model_MembershipMapper(); @@ -190,7 +189,7 @@ class ResourceController extends Zend_Controller_Action $person = $personMapper->find($personID); $loginname = strtolower($person->getName()); $loginname = preg_replace("!\s!","",$loginname); - + mkdir($path_userconf ,0777, true); exec("tar -C $path_userconf -xvf ../resources/config/$configID/default.tgz"); exec("cp ../resources/config/loginfiles/* $path_userconf/rootfs/etc/"); @@ -205,70 +204,68 @@ class ResourceController extends Zend_Controller_Action passthru( "tar cz *"); }else { chdir("../resources/config/$configID/"); - passthru( "cat default.tgz"); - } + passthru( "cat default.tgz"); + } }else{ header('HTTP/1.0 404 Not Found'); - } + } } public function getkernelAction() { - + $bootosID = $this->thisSession->getBootosID(); if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){ - header('Content-Type: application/x-gzip'); $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; header('Content-Disposition: ' . $content_disp . '; filename="kernel"'); header('Pragma: no-cache'); header('Expires: 0'); - + // create the gzipped tarfile. chdir("../resources/bootos/$bootosID/kernel/"); $kernelname = array_pop(scandir("./")); - + header("Content-Length: ".filesize(getcwd()."/".$kernelname)); - + passthru( "cat ". $kernelname); }else{ header('HTTP/1.0 404 Not Found'); } - + } public function getkclAction() { - + $bmeID = $this->thisSession->getBootmenuentryID(); if(is_numeric($bmeID)){ - $bmemapper = new Application_Model_BootMenuEntriesMapper(); $bme = new Application_Model_BootMenuEntries(); $bootosmapper = new Application_Model_BootOsMapper(); $bmemapper->find($bmeID,$bme); - + header('Content-Type: text/html'); $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"'); header('Pragma: no-cache'); header('Expires: 0'); - + $kcl = $bootosmapper->find($bme->getBootosID())->getDefaultkcl(); - - if($bme->getKcl() && $kcl != null){ + + if($bme->getKcl() && $kcl != null){ $result = $kcl . " alpha=" . $this->_request->getParam('alpha') . " file=http://".$_SERVER['HTTP_HOST']."/resource/getconfig/alpha/".$this->_request->getParam('alpha')."/file/default.tgz ".$bme->getKclappend(); }else{ $result = "alpha=" . $this->_request->getParam('alpha') . " file=http://".$_SERVER['HTTP_HOST']."/resource/getconfig/alpha/".$this->_request->getParam('alpha')."/file/default.tgz ".$bme->getKclappend(); } - + header("Content-Length: ".(strlen($result))); - + echo $result; - + } @@ -280,7 +277,7 @@ class ResourceController extends Zend_Controller_Action // after selecting the BootOS it will be saved in session // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction // can be called with session-identifier - + $return_val = array( 'info' => 'This function is for debugging purpose only', @@ -289,20 +286,19 @@ class ResourceController extends Zend_Controller_Action 'kcl' => $this->generateURL('getkcl', 'alpha', $this->thisSession->getAlphasessionID(), "kcl.txt"), 'config' => $this->generateURL('getconfig', 'alpha', $this->thisSession->getAlphasessionID(), 'default.tgz') ); - + $result = $return_val; $result2 = ""; $result2 .= ""; $result2 .= ""; $result2 .= ""; $result2 .= ""; - $result2 .= ""; - $result2 .= "
info: ".$result['info']."
kernel: ".$result['kernel']."
initramfs: ".$result['initramfs']."
kcl: ".$result['kcl']."
config: ".$result['config']."
"; + $result2 .= "config: ".$result['config'].""; + $result2 .= ""; echo $result2; } private function generateURL($action, $varname, $varvalue, $filename){ - $path = '/resource/'. $action .'/' . $varname .'/' . $varvalue .'/bootmenuentryID/'.$this->thisSession->getBootmenuentryID().'/file/' . $filename ; $path = "http://" . $_SERVER['SERVER_NAME'] . $path; return $path; diff --git a/application/controllers/StatsController.php b/application/controllers/StatsController.php index 0b180e7..05762a4 100644 --- a/application/controllers/StatsController.php +++ b/application/controllers/StatsController.php @@ -13,39 +13,39 @@ class StatsController extends Zend_Controller_Action { - public function init() - { - $this->_helper->layout->disableLayout(); + public function init() + { + $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - } - - public function graphgroupAction(){ - - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - + } + + public function graphgroupAction(){ + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if(isset($userIDsNamespace['groupID'])){ header("Content-Type: image/png"); - header("Expires: 0"); + header("Expires: 0"); $n = new Pbs_Graph(); - + $level = $this->_request->getParam('level'); if(is_numeric($level) && $level != ''){ $n->setHiglightLevel($level); } $groupID = $userIDsNamespace['groupID']; - + $group = $this->_request->getParam('group'); if((Pbs_Acl::checkRight('gsdo') || Pbs_Acl::checkRight('gsdog')) && is_numeric($group)){ $groupID = $group; } - + $child = $this->_request->getParam('child'); if(Pbs_Acl::checkRight('glk') && $child != ''){ $n->newChild($child); } - - echo $n->graph($groupID); - } - } + + echo $n->graph($groupID); + } + } } diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index 398bdf1..26f12fb 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -13,67 +13,68 @@ class Fbgui_IndexController extends Zend_Controller_Action { protected $membership; - - public function init() - { - /* Initialize action controller here */ - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - - $membershipMapper = new Application_Model_MembershipMapper(); + + public function init() + { + /* Initialize action controller here */ + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + + $membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); - } + } - public function errorAction() - { - $result = $this->_request->getParam('serialresult'); + public function errorAction() + { + $result = $this->_request->getParam('serialresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('serial',$result); - } - } - - public function indexAction() - { + } + } + + public function indexAction() + { $mySession = new Zend_Session_Namespace('pbs'); - - if(count($mySession->postdata)<=0) + + if(count($mySession->postdata)<=0){ $mySession->postdata = $_POST; - + } + $d = new Pbs_Debug(); $d->debug(array('FBGuiIndexController',$_SERVER['REMOTE_ADDR'],implode("\t",$mySession->postdata))); - if(isset($mySession->postdata['bootisoID']) || isset($mySession->postdata['serialnumber'])){ - // Create a session - $n = new Pbs_Session(); - - $bootisomapper = new Application_Model_BootIsoMapper(); - $bootiso = new Application_Model_BootIso(); - if(isset($mySession->postdata['bootisoID'])){ - $bootisomapper->find($mySession->postdata['bootisoID'],$bootiso); - $groupID = $bootiso->getGroupID(); - } - elseif(isset($mySession->postdata['serialnumber'])){ - $results = $bootisomapper->findBy(array('serialnumber' => $mySession->postdata['serialnumber']),true); + if(isset($mySession->postdata['bootisoID']) || isset($mySession->postdata['serialnumber'])){ + // Create a session + $n = new Pbs_Session(); + + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso = new Application_Model_BootIso(); + if(isset($mySession->postdata['bootisoID'])){ + $bootisomapper->find($mySession->postdata['bootisoID'],$bootiso); + $groupID = $bootiso->getGroupID(); + } + elseif(isset($mySession->postdata['serialnumber'])){ + $results = $bootisomapper->findBy(array('serialnumber' => $mySession->postdata['serialnumber']),true); if(count($results) == 0){ $this->_redirect('/fbgui/index/error/serialresult/noserial2'); } - $bootiso->setOptions($results[0]); - $bootiso->setID($results[0]['bootisoID']); - $groupID = $bootiso->getGroupID(); - - } - - $client = new Application_Model_Client(); - $client->setMacadress($mySession->postdata['mac']); - $client->setHardwarehash($mySession->postdata['hardwarehash']); + $bootiso->setOptions($results[0]); + $bootiso->setID($results[0]['bootisoID']); + $groupID = $bootiso->getGroupID(); + + } + + $client = new Application_Model_Client(); + $client->setMacadress($mySession->postdata['mac']); + $client->setHardwarehash($mySession->postdata['hardwarehash']); $client->setGroupID($groupID); $client = $n->createClient($client); $clientID = $client->getID(); - - $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - - if(!isset($_SESSION['alphasessionID'])){ + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + + if(!isset($_SESSION['alphasessionID'])){ $session = new Application_Model_Session(); $session->setBootisoID($bootiso->getID()); $session->setClientID($clientID); @@ -81,11 +82,11 @@ class Fbgui_IndexController extends Zend_Controller_Action if($this->membership->getID() != ''){ $session->setMembershipID($this->membership->getID()); } - $session->setIp($_SERVER['REMOTE_ADDR']); + $session->setIp($_SERVER['REMOTE_ADDR']); $session = $n->createSession($session); - $_SESSION['alphasessionID'] = $session->getAlphasessionID(); + $_SESSION['alphasessionID'] = $session->getAlphasessionID(); } - else{ + else{ $session = new Application_Model_Session(); $sessionMapper = new Application_Model_SessionMapper(); $sessions = $sessionMapper->findBy(array('alphasessionID'=>$_SESSION['alphasessionID'])); @@ -100,74 +101,72 @@ class Fbgui_IndexController extends Zend_Controller_Action $bootmenuID = $pbsFilter->evaluate(); if($bootmenuID != null){ $this->view->alphasessionID = $_SESSION['alphasessionID']; -// print_a('Debug Output', -// 'Session is now set', -// 'Your sessionID is '.$session->getID(), -// 'Your alphasessionID is '.$session->getAlphasessionID(), -// 'Your client is '.$session->getClientID(), -// 'goto bootmenu '.$bootmenuID); - + // print_a('Debug Output', + // 'Session is now set', + // 'Your sessionID is '.$session->getID(), + // 'Your alphasessionID is '.$session->getAlphasessionID(), + // 'Your client is '.$session->getClientID(), + // 'goto bootmenu '.$bootmenuID); + $bootmenuMapper = new Application_Model_BootMenuMapper(); $bm = $bootmenuMapper->find($bootmenuID); $this->view->title = $bm->getTitle(); - + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); $this->view->entries = $res; - #print_a(Zend_Auth::getInstance()->hasIdentity(),$bm->MembershipID ,$this->membership->getID()); - if (!Zend_Auth::getInstance()->hasIdentity()) { - # $pbsNotifier = new Pbs_Notifier(); - # $this->view->notification = $pbsNotifier->notify("This is not your Bootmenu. You have to login to get your own Bootmenu.
Click here to
login",'info'); + + if (!Zend_Auth::getInstance()->hasIdentity()) { $this->view->loginmenu = true; } - if(Zend_Auth::getInstance()->hasIdentity()){ + + if(Zend_Auth::getInstance()->hasIdentity()){ if($bm->MembershipID != '' && $bm->MembershipID == $this->membership->getID()){} else{ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify("This is not your Bootmenu. There is currently a BootMenu with a higher priority active.",'info'); + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify("This is not your Bootmenu. There is currently a BootMenu with a higher priority active.",'info'); } } } else{ - -// print_a('Debug Output', -// 'Session is now set', -// 'Your sessionID is '.$session->getID(), -// 'Your alphasessionID is '.$session->getAlphasessionID(), -// 'Your client is '.$session->getClientID(), -// 'there is no bootmenu for you'); - + // print_a('Debug Output', + // 'Session is now set', + // 'Your sessionID is '.$session->getID(), + // 'Your alphasessionID is '.$session->getAlphasessionID(), + // 'Your client is '.$session->getClientID(), + // 'there is no bootmenu for you'); + $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify("There is no BootMenu to show. Please log in to get your BootMenu.
Click here to login",'error'); - + $this->view->notification = $pbsNotifier->notify("There is no BootMenu to show. Please log in to get your BootMenu.
Click here to login",'error'); + } } else{ - #$this->_redirect('/fbgui/index/error/serialresult/noserial'); - } - - } + #$this->_redirect('/fbgui/index/error/serialresult/noserial'); + } + + } public function startAction(){ $bootmenuntryID = $this->_request->getParam('bme'); $a = $_SESSION['alphasessionID']; $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); $bootmenuentry = new Application_Model_BootMenuEntries(); $bootmenuentriesMapper->find($bootmenuntryID,$bootmenuentry); - + $sessionMapper = new Application_Model_SessionMapper(); - $session_k = $sessionMapper->findBy(array('alphasessionID' => $a),true); - - $session = new Application_Model_Session(); + $session_k = $sessionMapper->findBy(array('alphasessionID' => $a),true); + + $session = new Application_Model_Session(); $session->setOptions($session_k[0]); $session->setID($session_k[0]['sessionID']); - #print_a($bootmenuentry); + $session->setBootmenuentryID($bootmenuntryID); $session->setBootosID($bootmenuentry->getBootosID()); $sessionMapper->save($session); - - + + $this->view->host = '132.230.4.27'; - $this->view->alphasessionID = $a; + $this->view->alphasessionID = $a; } } diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php index 7fc199a..4a5bcf4 100644 --- a/application/modules/user/controllers/AuthController.php +++ b/application/modules/user/controllers/AuthController.php @@ -41,39 +41,32 @@ class User_AuthController extends Zend_Controller_Action $auth = Zend_Auth::getInstance(); - $adapter = new Zend_Auth_Adapter_DbTable( - $this->db, - 'pbs_person', - 'email', - 'password', - 'MD5(CONCAT(?, password_salt))' - ); - + $adapter = new Zend_Auth_Adapter_DbTable( $this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); + + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); - $adapter->setIdentity($loginForm->getValue('email')); - $adapter->setCredential($loginForm->getValue('password')); + $result = $auth->authenticate($adapter); - $result = $auth->authenticate($adapter); - - if ($result->isValid()) { - $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $person = new Application_Model_Person($result[0]); - $person->setID($result[0]['personID']); - $date = new DateTime(); - $person->setLogindate($date->getTimestamp()); - if($person->getSuspended()) { - $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'); - } + if ($result->isValid()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $date = new DateTime(); + $person->setLogindate($date->getTimestamp()); + if($person->getSuspended()) { + $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; @@ -235,7 +228,7 @@ class User_AuthController extends Zend_Controller_Action $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

Passwort ändern'; + $mailbody = 'Um das Passwort zu ändern klicken Sie auf folgenden Link

Passwort ändern'; $mail = new Zend_Mail(); $mail->setBodyHtml($mailbody, 'utf8'); $mail->getBodyHtml()->getContent(); diff --git a/application/modules/user/controllers/BootisoController.php b/application/modules/user/controllers/BootisoController.php index 532cbe2..18472a9 100644 --- a/application/modules/user/controllers/BootisoController.php +++ b/application/modules/user/controllers/BootisoController.php @@ -15,19 +15,19 @@ class user_BootisoController extends Zend_Controller_Action protected $bootisoMapper; protected $membershipMapper; - protected $membership; + protected $membership; protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { + + 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); @@ -36,12 +36,12 @@ class user_BootisoController extends Zend_Controller_Action } else { $this->_helper->redirector('login', 'auth'); } - $this->page = $this->_request->getParam('page'); - } + $this->page = $this->_request->getParam('page'); + } - public function indexAction() - { - $result = $this->_request->getParam('addresult'); + public function indexAction() + { + $result = $this->_request->getParam('addresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('create',$result); @@ -56,297 +56,297 @@ class user_BootisoController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('modify',$result); } - $result = $this->_request->getParam('downloadresult'); + $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())); - @$bootiso->setExpires(date(Zend_Registry::get('dateformat'),$bootiso->getExpires())); - } - - // Search + + + $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())); + @$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->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 + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($this->view->bootisolist); - $pagination->setRequestPage($this->_request->getParam('page')); + $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->bootisolist = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); - } - - public function searchAction(){ + } + + public function searchAction(){ $this->_redirect('/user/bootiso/index/search/'.($_GET['search'])); } - - public function downloadbootisoAction() - { - $this->_helper->layout->disableLayout(); + + 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'); - - $prebootID = $this->bootisoMapper->find($bootisoID)->getPrebootID(); - - - if(!is_dir("../resources/bootmedium/$prebootID/")) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/404'); - - chdir("../resources/bootmedium/$prebootID/"); - - header("X-Sendfile: $bootisoID".".zip"); + $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'); + + $prebootID = $this->bootisoMapper->find($bootisoID)->getPrebootID(); + + + if(!is_dir("../resources/bootmedium/$prebootID/")) + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/downloadresult/404'); + + chdir("../resources/bootmedium/$prebootID/"); + + header("X-Sendfile: $bootisoID".".zip"); header('Content-Type: application/x-gzip'); $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; header('Content-Disposition: ' . $content_disp . '; filename="preboot.zip"'); header('Pragma: no-cache'); - header('Expires: 0'); + header('Expires: 0'); - $handle = fopen($bootisoID.".zip", 'r'); + $handle = fopen($bootisoID.".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( + + } + + 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( + } 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()); - - $prebootID = $bootiso->getPrebootID(); - - try { - - $bootisoID = $this->bootisoMapper->save($bootiso); - - copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/tmp/serial", $bootiso->getSerialnumber()); - $zip->close(); - } - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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( + + if ($bootisoForm->isValid($_POST)) { + + $bootiso = new Application_Model_BootIso($_POST); + + $bootiso->setGroupID($this->membership->getGroupID()); + $bootiso->setCreated(time()); + + $prebootID = $bootiso->getPrebootID(); + + try { + + $bootisoID = $this->bootisoMapper->save($bootiso); + + copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res === true){ + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/tmp/serial", $bootiso->getSerialnumber()); + $zip->close(); + } + + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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( + $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 { - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/serial", $bootiso->getSerialnumber()); - $zip->close(); - } - - $this->bootisoMapper->save($bootiso); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/deleteresult/ok'); - } - + + 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 { + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res === true){ + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/serial", $bootiso->getSerialnumber()); + $zip->close(); + } + + $this->bootisoMapper->save($bootiso); + + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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 f4b0d0f..1eeb19b 100644 --- a/application/modules/user/controllers/BootmenuController.php +++ b/application/modules/user/controllers/BootmenuController.php @@ -12,43 +12,43 @@ 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()) { + + 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'); - } + $this->page = $this->_request->getParam('page'); + } - public function indexAction() - { - - $result = $this->_request->getParam('addresult'); + public function indexAction() + { + + $result = $this->_request->getParam('addresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('create',$result); @@ -62,301 +62,301 @@ class user_BootmenuController extends Zend_Controller_Action if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('modify',$result); - } - $result = $this->_request->getParam('json'); + } + $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(); - - 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(!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(); + + 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()); $bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->gettitle()); - } - } - }else{ + } + } + }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()); + $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()); $bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->gettitle()); - } - } - } - - // Search + } + } + } + + // Search $search = $this->_request->getParam('search'); $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); + $mySearch->setSearchTerm($search); $mySearch->setType($this->type); $mySearch->setModule('bootmenu'); if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $bootmenu = $mySearch->search($bootmenu); + $this->view->search = $mySearch->getSearchTerm(); + $bootmenu = $mySearch->search($bootmenu); } $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($bootmenu); - $pagination->setRequestPage($this->_request->getParam('page')); + $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(); - + $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->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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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()); - - try { - $this->bootmenuMapper->save($bootmenu); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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); + + 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($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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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); - - 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 = array('Preset' => array(), 'Custom' => Array()); - $configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID)); - $configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID())); - - $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( + 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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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()); + + try { + $this->bootmenuMapper->save($bootmenu); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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); + + 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 = array('Preset' => array(), 'Custom' => Array()); + $configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID)); + $configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID())); + + $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, @@ -364,16 +364,16 @@ class user_BootmenuController extends Zend_Controller_Action '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( + )); + + $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, @@ -381,96 +381,96 @@ class user_BootmenuController extends Zend_Controller_Action '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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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 = array('Preset' => array(), 'Custom' => Array()); - $configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID)); - $configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID())); - - $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'); - } - - 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( + ),$_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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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 = array('Preset' => array(), 'Custom' => Array()); + $configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID)); + $configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID())); + + $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'); + } + + 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, @@ -478,19 +478,19 @@ class user_BootmenuController extends Zend_Controller_Action 'page' => $this->page, 'type' => $this->type, 'action' => 'editbootmenuentry', - )); + )); - if(!isset($_POST['configID'])){ - $bootmenuentryForm->populate($bootmenuentry->toArray()); + if(!isset($_POST['configID'])){ + $bootmenuentryForm->populate($bootmenuentry->toArray()); + } + else{ + unset($_POST['defaultkcl']); + unset($_POST['configID']); + $bootmenuentryForm->populate($_POST); } - else{ - unset($_POST['defaultkcl']); - unset($_POST['configID']); - $bootmenuentryForm->populate($_POST); - } - - }else{ - $bootmenuentryForm = new user_Form_BootmenuEntries(array( + + }else{ + $bootmenuentryForm = new user_Form_BootmenuEntries(array( 'bootoslist'=> $bootoslist, 'bootosanzeige' => $bootosanzeige, 'maxorder'=> $maxorder-1, @@ -498,83 +498,83 @@ class user_BootmenuController extends Zend_Controller_Action '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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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'); - } + + 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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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 a247de9..5d69527 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -17,17 +17,17 @@ class user_BootosController extends Zend_Controller_Action protected $membershipMapper; protected $membership; protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { + + 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); @@ -36,12 +36,12 @@ class user_BootosController extends Zend_Controller_Action } else { $this->_helper->redirector('login', 'auth'); } - $this->page = $this->_request->getParam('page'); - } + $this->page = $this->_request->getParam('page'); + } - public function indexAction() - { - $result = $this->_request->getParam('addresult'); + public function indexAction() + { + $result = $this->_request->getParam('addresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('create',$result); @@ -56,378 +56,378 @@ class user_BootosController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('modify',$result); } - $result = $this->_request->getParam('updateresult'); + $result = $this->_request->getParam('updateresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('update',$result); } - - $groupID = $this->membership->getGroupID(); - + + $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); + 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->update = array(); - $update = $this->_request->getParam('checkupdate'); - $groupMapper = new Application_Model_GroupMapper(); - - if(count($this->view->bootoslist)>0){ + $update = $this->_request->getParam('checkupdate'); + $groupMapper = new Application_Model_GroupMapper(); + + if(count($this->view->bootoslist)>0){ foreach ($this->view->bootoslist as $bootos){ - $this->view->update[$bootos->getID()] = $update && $this->checkupdateAction($bootos); - if($bootos->getDefaultkcl() == null) - $bootos->setDefaultkcl("none (edit Bootos to set KCL)"); - $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())); + $this->view->update[$bootos->getID()] = $update && $this->checkupdateAction($bootos); + if($bootos->getDefaultkcl() == null) + $bootos->setDefaultkcl("none (edit Bootos to set KCL)"); + $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->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 + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($this->view->bootoslist); - $pagination->setRequestPage($this->_request->getParam('page')); + $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->bootoslist = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - - - } - public function searchAction(){ + $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( + 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( + } 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()); - - try { - - $path_tmp = "../resources/bootos/"; - mkdir($path_tmp ,0777, true); - - $hash = md5(microtime(1)); - exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); - exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); - exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); - - if(!array_pop($status) && $bootos->getPath_kernel() != null || !array_pop($status2) && $bootos->getPath_init() != null || !array_pop($status3) && $bootos->getPath_config() != null ){ - $this->view->bootosForm = $bootosForm; - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); + + if ($bootosForm->isValid($_POST)) { + + $bootos = new Application_Model_BootOs($_POST); + + $bootos->setGroupID($this->membership->getGroupID()); + $bootos->setCreated(time()); + + try { + + $path_tmp = "../resources/bootos/"; + mkdir($path_tmp ,0777, true); + + $hash = md5(microtime(1)); + exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); + exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); + exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); + + if(!array_pop($status) && $bootos->getPath_kernel() != null || !array_pop($status2) && $bootos->getPath_init() != null || !array_pop($status3) && $bootos->getPath_config() != null ){ + $this->view->bootosForm = $bootosForm; + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); - return; - } - - $bootosID = $this->bootosMapper->save($bootos); + return; + } + + $bootosID = $this->bootosMapper->save($bootos); + + $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); + + exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); + exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); + exec("mv ../resources/bootos/config$hash $configpath"."config.tgz"); + + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/error'); + //TODO Delete File & delete bootiso from DB - $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); - - exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); - exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); - exec("mv ../resources/bootos/config$hash $configpath"."config.tgz"); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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 checkupdateAction($bootos) - { - - //ACL Is he allowed to update Preboots? - if(!Pbs_Acl::checkRight('bou')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); - - $bootosID = $bootos->getID(); - - if(is_file("../resources/bootos/$bootosID/kernel/kernel") && is_file("../resources/bootos/$bootosID/initramfs/initramfs") && is_file("../resources/bootos/$bootosID/config/config.tgz")){ - $kernelolddate = filemtime("../resources/bootos/".$bootosID."/kernel/kernel"); - $initolddate = filemtime("../resources/bootos/".$bootosID."/initramfs/initramfs"); - $configolddate = filemtime("../resources/bootos/".$bootosID."/config/config.tgz"); - } - else - { - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); - return true; - } - - exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_kernel())."' 2>&1 | grep 'Last-Modified:'", $kerneldate); - exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_init())."' 2>&1 | grep 'Last-Modified:'", $initdate); - exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_config())."' 2>&1 | grep 'Last-Modified:'", $configdate); - - $kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate)))); - $initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate)))); - $configdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($configdate)))); - - //print_a($bootos->getPath_kernel(),$kerneldate,$kernelolddate,$initname,$initdate,$initolddate); - - if($kerneldate > $kernelolddate || $initdate > $initolddate || $configdate > $configolddate){ - $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); - return true; - }else{ - return false; - } - - } - - public function updatebootosAction() - { - - //ACL Is he allowed to update Preboots? - if(!Pbs_Acl::checkRight('bou')) - $this->_redirect('/user/bootiso/index/page/'.$this->page.'/updateresult/forbidden'); - - $bootosID = $this->_request->getParam('bootosID'); - if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/forbidden'); - - $bootos = $this->bootosMapper->find($bootosID); - - if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/forbidden'); - - $initpath = "../resources/bootos/".$bootosID."/initramfs/"; - $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; - $configpath = "../resources/bootos/".$bootosID."/config/"; - $path_tmp = "../resources/bootos/"; - - $hash = md5(microtime(1)); - exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); - exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); - exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); - + } + + $this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/ok'); + } + } + + $this->view->bootosForm = $bootosForm; + } + + public function checkupdateAction($bootos) + { + + //ACL Is he allowed to update Preboots? + if(!Pbs_Acl::checkRight('bou')) + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); + + $bootosID = $bootos->getID(); + + if(is_file("../resources/bootos/$bootosID/kernel/kernel") && is_file("../resources/bootos/$bootosID/initramfs/initramfs") && is_file("../resources/bootos/$bootosID/config/config.tgz")){ + $kernelolddate = filemtime("../resources/bootos/".$bootosID."/kernel/kernel"); + $initolddate = filemtime("../resources/bootos/".$bootosID."/initramfs/initramfs"); + $configolddate = filemtime("../resources/bootos/".$bootosID."/config/config.tgz"); + } + else + { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); + return true; + } + + exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_kernel())."' 2>&1 | grep 'Last-Modified:'", $kerneldate); + exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_init())."' 2>&1 | grep 'Last-Modified:'", $initdate); + exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_config())."' 2>&1 | grep 'Last-Modified:'", $configdate); + + $kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate)))); + $initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate)))); + $configdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($configdate)))); + + //print_a($bootos->getPath_kernel(),$kerneldate,$kernelolddate,$initname,$initdate,$initolddate); + + if($kerneldate > $kernelolddate || $initdate > $initolddate || $configdate > $configolddate){ + $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); + return true; + }else{ + return false; + } + + } + + public function updatebootosAction() + { + + //ACL Is he allowed to update Preboots? + if(!Pbs_Acl::checkRight('bou')) + $this->_redirect('/user/bootiso/index/page/'.$this->page.'/updateresult/forbidden'); + + $bootosID = $this->_request->getParam('bootosID'); + if (!is_numeric($bootosID)) + $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/forbidden'); + + $bootos = $this->bootosMapper->find($bootosID); + + if($this->membership->getGroupID() != $bootos->getGroupID()) + $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/forbidden'); + + $initpath = "../resources/bootos/".$bootosID."/initramfs/"; + $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + $configpath = "../resources/bootos/".$bootosID."/config/"; + $path_tmp = "../resources/bootos/"; + + $hash = md5(microtime(1)); + exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); + exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); + exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); + if(!array_pop($status) || !array_pop($status2) || !array_pop($status3)){ - $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/404'); - //TODO Delete Files in tmp + $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/404'); + //TODO Delete Files in tmp } - + exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); - exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); - exec("mv ../resources/bootos/config$hash $initpath"."config.tgz"); - - $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/ok'); - } - - public function editbootosAction() - { - - //ACL Is he allowed to edit Preboots? - 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( + exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); + exec("mv ../resources/bootos/config$hash $initpath"."config.tgz"); + + $this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/ok'); + } + + public function editbootosAction() + { + + //ACL Is he allowed to edit Preboots? + 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( + $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->setCreated(time()); - $bootos->setID($bootosID); - - if( $bootos->getSource() != $bootosold->getSource() || - $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($bootos->getPath_config() != $bootosold->getPath_config() || $bootos->getPath_kernel() != $bootosold->getPath_kernel() || $bootos->getPath_init() != $bootosold->getPath_init()){ - //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'); - - $path_tmp = "../resources/bootos/"; - - $hash = md5(microtime(1)); - exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); - exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); - exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); - - if(!array_pop($status) && $bootos->getPath_kernel() != null || !array_pop($status2) && $bootos->getPath_init() != null || !array_pop($status3) && $bootos->getPath_config() != null ){ - $this->view->bootosForm = $bootosForm; - $pbsNotifier = new Pbs_Notifier(); + + if ($bootosForm->isValid($_POST)) { + + $bootosold = $bootos; + + $bootos = new Application_Model_BootOs($_POST); + $bootos->setGroupID($this->membership->getGroupID()); + $bootos->setCreated(time()); + $bootos->setID($bootosID); + + if( $bootos->getSource() != $bootosold->getSource() || + $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($bootos->getPath_config() != $bootosold->getPath_config() || $bootos->getPath_kernel() != $bootosold->getPath_kernel() || $bootos->getPath_init() != $bootosold->getPath_init()){ + //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'); + + $path_tmp = "../resources/bootos/"; + + $hash = md5(microtime(1)); + exec("wget -O '".$path_tmp."kernel".$hash."' ".escapeshellcmd($bootos->getPath_kernel())." 2>&1 | grep 'saved'", $status); + exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); + exec("wget -O '".$path_tmp."config".$hash."' ".escapeshellcmd($bootos->getPath_config())." 2>&1 | grep 'saved'", $status3); + + if(!array_pop($status) && $bootos->getPath_kernel() != null || !array_pop($status2) && $bootos->getPath_init() != null || !array_pop($status3) && $bootos->getPath_config() != null ){ + $this->view->bootosForm = $bootosForm; + $pbsNotifier = new Pbs_Notifier(); echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); - return; - } - - $initpath = "../resources/bootos/".$bootosID."/initramfs/"; - $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; + return; + } + + $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); + + exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); + exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); + exec("mv ../resources/bootos/config$hash $initpath"."config.tgz"); + } - mkdir($initpath ,0777, true); - mkdir($kernelpath ,0777, true); - mkdir($configpath ,0777, true); - - exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); - exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); - exec("mv ../resources/bootos/config$hash $initpath"."config.tgz"); - } - - try { - $this->bootosMapper->save($bootos); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/error'); - //TODO Delete Folder + Preboot - } - + try { + $this->bootosMapper->save($bootos); + + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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 087a7b6..687e910 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -14,7 +14,7 @@ class User_ClientController extends Zend_Controller_Action { private $membership; protected $page; - + public function init() { if (Zend_Auth::getInstance()->hasIdentity()) { @@ -30,14 +30,14 @@ class User_ClientController extends Zend_Controller_Action } else { $this->_helper->redirector('login', 'auth'); } - $this->page = $this->_request->getParam('page'); + $this->page = $this->_request->getParam('page'); } public function indexAction() { // ACL: is he authorized to see this ? if(!Pbs_Acl::checkRight('clo')) - $this->_redirect('/user'); + $this->_redirect('/user'); // Get the Clients which booted with a bootiso of this group $result = $this->_request->getParam('deleteresult'); @@ -58,26 +58,26 @@ class User_ClientController extends Zend_Controller_Action $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->search = $mySearch->getSearchTerm(); + $clientsInGroup = $mySearch->search($clientsInGroup); } $this->view->searchform = $mySearch->searchForm(); - + // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($clientsInGroup); - $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setRequestPage($this->_request->getParam('page')); $pagination->setPageUrl('/user/client/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $clientsInGroup = $pagination->getElements(); - + $clientsInGroup = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); $this->view->clients = $clientsInGroup; @@ -94,7 +94,7 @@ class User_ClientController extends Zend_Controller_Action // ACL: is he authorized to create new clients? if(!Pbs_Acl::checkRight('cla')) - $this->_redirect('/user'); + $this->_redirect('/user'); if (!isset($_POST["add"])){ $addclient = new user_Form_Client(array( @@ -102,7 +102,7 @@ class User_ClientController extends Zend_Controller_Action 'page' => $this->page)); $this->view->addclient = $addclient; } - else{ + else{ $addclient = new user_Form_Client(array( 'buttontext' => 'Create Client', 'page' => $this->page),$_POST); @@ -124,11 +124,11 @@ class User_ClientController extends Zend_Controller_Action public function removeclientAction() { $clientID = $this->_request->getParam('clientID'); - + // ACL: is he authorized to delete clients? if(!Pbs_Acl::checkRight('cld')) - $this->_redirect('/user'); - + $this->_redirect('/user'); + $clientMapper = new Application_Model_ClientMapper(); if(is_numeric($clientID)){ $client = new Application_Model_Client(); @@ -148,14 +148,14 @@ class User_ClientController extends Zend_Controller_Action public function editclientAction(){ // ACL: Is he authorized to edit clients ? if(!Pbs_Acl::checkRight('cle')) - $this->_redirect('/user'); + $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', @@ -173,7 +173,7 @@ class User_ClientController extends Zend_Controller_Action 'page' => $this->page),$_POST); if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { $client = new Application_Model_Client($_POST); - $client->setID($this->_request->getParam('clientID')); + $client->setID($this->_request->getParam('clientID')); $dbclient = new Application_Model_Client(); $clientMapper = new Application_Model_ClientMapper(); diff --git a/application/modules/user/controllers/ConfigController.php b/application/modules/user/controllers/ConfigController.php index 7f752a8..aba51f7 100644 --- a/application/modules/user/controllers/ConfigController.php +++ b/application/modules/user/controllers/ConfigController.php @@ -19,33 +19,33 @@ class user_ConfigController extends Zend_Controller_Action protected $page; protected $config; protected $type; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { + + 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->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'); - } + $this->page = $this->_request->getParam('page'); + } - public function indexAction() - { - $result = $this->_request->getParam('addresult'); + public function indexAction() + { + $result = $this->_request->getParam('addresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('create',$result); @@ -60,200 +60,200 @@ class user_ConfigController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('modify',$result); } - - $groupID = $this->membership->getGroupID(); - + + $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(); - - if($this->type =='own' && Pbs_Acl::checkRight('csui')){ - $this->view->type = 'own'; - $this->view->configlist = $this->configMapper->findBy(array('membershipID' => $this->membership->getID())); - }else{ - $this->view->type = 'group'; - $this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID())); - } - - foreach ($this->view->configlist as $config){ - $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated())); - } - - // Search + if(!Pbs_Acl::checkRight('csai') && !Pbs_Acl::checkRight('csui')) + $this->_redirect('/user/index'); + + $this->configMapper = new Application_Model_ConfigMapper(); + + if($this->type =='own' && Pbs_Acl::checkRight('csui')){ + $this->view->type = 'own'; + $this->view->configlist = $this->configMapper->findBy(array('membershipID' => $this->membership->getID())); + }else{ + $this->view->type = 'group'; + $this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID())); + } + + foreach ($this->view->configlist as $config){ + $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated())); + } + + // 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->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 + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($this->view->configlist); - $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setRequestPage($this->_request->getParam('page')); $pagination->setPageUrl('/user/config/index/type/'.$this->type.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $this->view->configlist = $pagination->getElements(); - + $this->view->configlist = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); - - } - - public function searchAction(){ + + } + + 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'); - - 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()); - - 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->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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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 addUserAction(){ - - } - - 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()); - - if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null) - $config->setGroupID($this->membership->getGroupID()); - elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null) - $config->setMembershipID($this->membership->getID()); - else - $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); - - $config->setID($configID); - - if($configold->getShellscript() != $config->getShellscript()){ - //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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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'); - } + 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'); + + 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()); + + 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->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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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 addUserAction(){ + + } + + 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()); + + if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null) + $config->setGroupID($this->membership->getGroupID()); + elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null) + $config->setMembershipID($this->membership->getID()); + else + $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error'); + + $config->setID($configID); + + if($configold->getShellscript() != $config->getShellscript()){ + //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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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 703bd7d..f9a4724 100644 --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -33,14 +33,14 @@ class User_FilterController extends Zend_Controller_Action } else { $this->_helper->redirector('login', 'auth'); } - $this->page = $this->_request->getParam('page'); + $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'); + $this->_redirect('/user'); $result = $this->_request->getParam('addresult'); if($result != ""){ @@ -68,33 +68,33 @@ class User_FilterController extends Zend_Controller_Action $ff->setCreated(date(Zend_Registry::get('dateformat'),$ff->getCreated())); $allFilter[] = $ff; } - - // Search + + // Search $search = $this->_request->getParam('search'); $mySearch = new Pbs_Search(); $mySearch->setSearchTerm($search); $mySearch->setModule('filter'); if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $allFilter = $mySearch->search($allFilter); + $this->view->search = $mySearch->getSearchTerm(); + $allFilter = $mySearch->search($allFilter); } $this->view->searchform = $mySearch->searchForm(); - + // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($allFilter); - $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setRequestPage($this->_request->getParam('page')); $pagination->setPageUrl('/user/filter/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $allFilter = $pagination->getElements(); - + $allFilter = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); - $this->view->filters = $allFilter; - + $this->view->filters = $allFilter; + } - - public function searchAction(){ + + public function searchAction(){ $this->_redirect('/user/filter/index/search/'.($_GET['search'])); } @@ -102,21 +102,21 @@ class User_FilterController extends Zend_Controller_Action { // ACL: Is he allowed to add a Filter if(!Pbs_Acl::checkRight('fa')) - $this->_redirect('/user'); + $this->_redirect('/user'); $bmmapper = new Application_Model_BootMenuMapper(); - $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true); + $result = $bmmapper->findBy(array('groupID' => $this->membership->getGroupID()),true); print_a($result); - + 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"])){ @@ -161,10 +161,10 @@ class User_FilterController extends Zend_Controller_Action { $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'); + $this->_redirect('/user'); if(is_numeric($filterID)){ $filter = new Application_Model_Filter(); @@ -194,12 +194,12 @@ class User_FilterController extends Zend_Controller_Action $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"])){ + $this->_redirect('/user'); + + if (!isset($_POST["add"])){ $filterID = $this->_request->getParam('filterID'); $filter = new Application_Model_Filter(); @@ -218,7 +218,7 @@ class User_FilterController extends Zend_Controller_Action $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/forbidden'); } } else{ - try{ + try{ $filterID = $this->_request->getParam('filterID'); $filter = new Application_Model_Filter(); $filtermapper = new Application_Model_FilterMapper(); @@ -230,17 +230,17 @@ class User_FilterController extends Zend_Controller_Action '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')); $newfilterentry->setGroupID($this->membership->getGroupID()); $newfilterentry->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); @@ -251,7 +251,7 @@ class User_FilterController extends Zend_Controller_Action } } // ACL: he is allowed to edit the filter - elseif(Pbs_Acl::checkRight('fe')){ + elseif(Pbs_Acl::checkRight('fe')){ $filtermapper->save($newfilterentry); $this->_redirect('/user/filter/index/page/'.$this->page.'/modifyresult/ok'); } @@ -276,8 +276,8 @@ class User_FilterController extends Zend_Controller_Action $bootisos = $bootisoMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); $membershipMapper = new Application_Model_MembershipMapper(); - $memberships = $membershipMapper->findBy(array('groupID'=>$this->membership->getGroupID()),true); - + $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); @@ -298,8 +298,8 @@ class User_FilterController extends Zend_Controller_Action { // ACL: is he allowed to create a new filterentry? if(!Pbs_Acl::checkRight('ffa')) - $this->_redirect('/user'); - + $this->_redirect('/user'); + $filterID = $this->_request->getParam('filterID'); $filterMapper = new Application_Model_FilterMapper(); $filter = new Application_Model_Filter(); @@ -310,7 +310,7 @@ class User_FilterController extends Zend_Controller_Action if($filter->getGroupID() == $this->membership->getGroupID()){ if (!isset($_POST["add"])){ try{ - $addform = new user_Form_FilterEntry(array( + $addform = new user_Form_FilterEntry(array( 'buttontext' => 'Add Filterentry', 'filterID' => $filterID, 'selectData' => $selectData, @@ -365,7 +365,7 @@ class User_FilterController extends Zend_Controller_Action { //ACL: is he allowed to edit filterentrys ? if(!Pbs_Acl::checkRight('ffe')) - $this->_redirect('/user'); + $this->_redirect('/user'); $selectData = $this->prepareFormData(); if (!isset($_POST["add"])){ try{ @@ -433,12 +433,12 @@ class User_FilterController extends Zend_Controller_Action 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'); @@ -456,7 +456,7 @@ class User_FilterController extends Zend_Controller_Action { //ACL: is he autohorized to delete a filterentry? if(!Pbs_Acl::checkRight('ffd')) - $this->_redirect('/user'); + $this->_redirect('/user'); $filterentriesID = $this->_request->getParam('filterentriesID'); if(is_numeric($filterentriesID)){ @@ -473,11 +473,11 @@ class User_FilterController extends Zend_Controller_Action 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'); diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php index b1cee5c..3f7fde0 100644 --- a/application/modules/user/controllers/GroupController.php +++ b/application/modules/user/controllers/GroupController.php @@ -38,7 +38,7 @@ class User_GroupController extends Zend_Controller_Action $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'); @@ -51,7 +51,7 @@ class User_GroupController extends Zend_Controller_Action // ACL show overview if(!Pbs_Acl::checkRight('gso')) $this->_redirect('/user'); - + $result = $this->_request->getParam('deleteresult'); if($result != ""){ $pbsNotifier = new Pbs_Notifier(); @@ -126,7 +126,7 @@ class User_GroupController extends Zend_Controller_Action $membership->setID(); $membership->setGroupID($groupID); $membership->setRoleID($roleID); - + try { $this->membershipMapper->save($membership); } catch(Zend_Exception $e) @@ -173,7 +173,7 @@ class User_GroupController extends Zend_Controller_Action { // ACL edit a group if(!Pbs_Acl::checkRight('geo') && !Pbs_Acl::checkRight('ge')) - $this->_redirect('/user'); + $this->_redirect('/user'); $groupID = $this->_request->getParam('groupID'); if(!isset($groupID)) { @@ -186,7 +186,7 @@ class User_GroupController extends Zend_Controller_Action 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.'/deleteresult/forbidden'); + $this->_redirect('/user/group/index/page/'.$this->page.'/deleteresult/forbidden'); if (!isset($_POST["save"])){ $group = $this->groupMapper->find($groupID); $_POST['title'] = $group->getTitle(); @@ -194,9 +194,9 @@ class User_GroupController extends Zend_Controller_Action $editForm = new user_Form_GroupEdit(array('groupID' => $groupID)); } else { $editForm = new user_Form_GroupEdit(array('groupID' => $groupID), $_POST); - if ($editForm->isValid($_POST)) { + if ($editForm->isValid($_POST)) { $group = new Application_Model_Group($_POST); - $group->setID($groupID); + $group->setID($groupID); try { $this->groupMapper->save($group); } catch(Zend_Exception $e) @@ -225,7 +225,7 @@ class User_GroupController extends Zend_Controller_Action } } if($groupID == $this->membership->getGroupID() && !Pbs_Acl::checkRight('gsdo')) - $this->_redirect('/user'); + $this->_redirect('/user'); $this->view->usergroup = $this->membership->getGroupID(); $this->view->requestgroup = $groupID; @@ -248,15 +248,15 @@ class User_GroupController extends Zend_Controller_Action $parents = $groupGroupsMapper->getParentGroups($groupID); $groupMapper = new Application_Model_GroupMapper(); $crawled = array(); - foreach($parents as $p){ + 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")); + $r = $this->rolemapper->findBy(array('groupID' => $a,'inheritance'=>"1")); else - $r = $this->rolemapper->findBy(array('groupID' => $a)); + $r = $this->rolemapper->findBy(array('groupID' => $a)); foreach($r as $d){ $roles[$group->getTitle()][] = $d; } @@ -266,7 +266,7 @@ class User_GroupController extends Zend_Controller_Action $this->view->roleList = $roles; } - if(Pbs_Acl::checkRight('gsmg') || Pbs_Acl::checkRight('gsmgo')){ + if(Pbs_Acl::checkRight('gsmg') || Pbs_Acl::checkRight('gsmgo')){ $members = $this->membershipMapper->findBy(array('groupID' => $groupID),true); if(isset($members)) { foreach($members as $member) { @@ -311,12 +311,12 @@ class User_GroupController extends Zend_Controller_Action public function linkAction() { if(!Pbs_Acl::checkRight('glk')) - $this->_redirect('/user'); + $this->_redirect('/user'); $linkableGroups = $this->groupList; - $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); + $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); $childs = array(); - $parents = array(); + $parents = array(); $childs = $groupGroupsMapper->getChildGroups($this->membership->getGroupID()); $parents = $groupGroupsMapper->getParentGroups($this->membership->getGroupID()); #print_a($childs,$parents); @@ -366,7 +366,7 @@ class User_GroupController extends Zend_Controller_Action { // ACL delete a group if(!Pbs_Acl::checkRight('gd')) - $this->_redirect('/user'); + $this->_redirect('/user'); $this->_helper->viewRenderer->setNoRender(); $groupID = $this->_request->getParam('groupID'); @@ -405,7 +405,7 @@ class User_GroupController extends Zend_Controller_Action { // ACL grant a membership to request if(!Pbs_Acl::checkRight('gam')) - $this->_redirect('/user'); + $this->_redirect('/user'); $this->_helper->viewRenderer->setNoRender(); if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) { @@ -420,13 +420,13 @@ class User_GroupController extends Zend_Controller_Action } $membership = new Application_Model_Membership(); $membership->setGroupID($groupRequest->getGroupID()); - $membership->setPersonID($groupRequest->getPersonID()); + $membership->setPersonID($groupRequest->getPersonID()); $membership->setRoleID($_POST['roleID']); - $membership->setSuspended(0); + $membership->setSuspended(0); $apikey = randomString(32); $membership->setApikey($apikey); - - + + try { $id = $this->membershipMapper->save($membership); diff --git a/application/modules/user/controllers/IndexController.php b/application/modules/user/controllers/IndexController.php index 350d0e5..a704261 100644 --- a/application/modules/user/controllers/IndexController.php +++ b/application/modules/user/controllers/IndexController.php @@ -12,15 +12,15 @@ class User_IndexController extends Zend_Controller_Action { - public function init() - { - /* Initialize action controller here */ - } + public function init() + { + /* Initialize action controller here */ + } - public function indexAction() - { - - if (!Zend_Auth::getInstance()->hasIdentity()) { + public function indexAction() + { + + if (!Zend_Auth::getInstance()->hasIdentity()) { $this->view->text = 'Your not logged in, please log in first here.'; } else{ @@ -32,7 +32,7 @@ class User_IndexController extends Zend_Controller_Action '/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 ba4be8e..5cb8d09 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -14,19 +14,12 @@ 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; public function init() @@ -45,22 +38,22 @@ class user_PersonController extends Zend_Controller_Action $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(); + $rightroles = new Application_Model_RightRoles(); $role = new Application_Model_Role(); $roleMapper = new Application_Model_RoleMapper(); - - $this->view->apikeys = array(); + $this->view->apikeys = array(); + 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->view->apikeys[$group->getID()] = $membership['apikey']; + $this->groups[] = array ( 'groupID' => $group->getID(), 'title' => $group->getTitle(), @@ -347,8 +340,8 @@ class user_PersonController extends Zend_Controller_Action 'membershipID' => $membership['membershipID'], 'group' => $group->getTitle(), 'role' => $role->getTitle()); - } - + } + } if(count($suspendlist) >=1){ $pbsNotifier = new Pbs_Notifier(); @@ -439,7 +432,7 @@ class user_PersonController extends Zend_Controller_Action { if(!Pbs_Acl::checkRight('gdm')) { $this->_redirect('/user'); - } + } $grouprequestID = $this->_request->getParam('grouprequestID'); $grouprequest = $this->groupRequestMapper->find($grouprequestID); try { diff --git a/application/modules/user/controllers/PoolController.php b/application/modules/user/controllers/PoolController.php index b793d80..3d6c0a7 100644 --- a/application/modules/user/controllers/PoolController.php +++ b/application/modules/user/controllers/PoolController.php @@ -14,7 +14,7 @@ class User_PoolController extends Zend_Controller_Action { private $membership; protected $page; - + public function init() { if (Zend_Auth::getInstance()->hasIdentity()) { @@ -30,14 +30,14 @@ class User_PoolController extends Zend_Controller_Action } else { $this->_helper->redirector('login', 'auth'); } - $this->page = $this->_request->getParam('page'); + $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'); + $this->_redirect('/user'); $result = $this->_request->getParam('deleteresult'); if($result != ""){ @@ -74,30 +74,30 @@ class User_PoolController extends Zend_Controller_Action $ff->setID($pool['poolID']); $yourpools[] = $ff; } - - // Search + + // Search $search = $this->_request->getParam('search'); $mySearch = new Pbs_Search(); $mySearch->setSearchTerm($search); $mySearch->setModule('pool'); if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $yourpools = $mySearch->search($yourpools); + $this->view->search = $mySearch->getSearchTerm(); + $yourpools = $mySearch->search($yourpools); } $this->view->searchform = $mySearch->searchForm(); - + // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($yourpools); - $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setRequestPage($this->_request->getParam('page')); $pagination->setPageUrl('/user/pool/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - $yourpools = $pagination->getElements(); - + $yourpools = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); - $this->view->pools = $yourpools; - + $this->view->pools = $yourpools; + // Get all Clients from this group $clientmapper = new Application_Model_ClientMapper(); @@ -113,11 +113,11 @@ class User_PoolController extends Zend_Controller_Action // extract the un-assigned clients from the clientlist of the group $freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray); - if(Pbs_Acl::checkRight('posuc')) - $this->view->freeclients = $freeclients; + if(Pbs_Acl::checkRight('posuc')) + $this->view->freeclients = $freeclients; } - - public function searchAction(){ + + public function searchAction(){ $this->_redirect('/user/pool/index/search/'.($_GET['search'])); } @@ -125,8 +125,8 @@ class User_PoolController extends Zend_Controller_Action { // ACL: is he allowed to create a pool? if(!Pbs_Acl::checkRight('poc')) - $this->_redirect('/user'); - + $this->_redirect('/user'); + if (!isset($_POST["add"])){ $addfilterform = new user_Form_Pool(array( 'buttontext' => 'Create Pool', @@ -155,10 +155,10 @@ class User_PoolController extends Zend_Controller_Action public function deletepoolAction() { $poolID = $this->_request->getParam('poolID'); - + // ACL: is he allowed to delete a pool? if(!Pbs_Acl::checkRight('pod')) - $this->_redirect('/user'); + $this->_redirect('/user'); if(is_numeric($poolID)){ $poolmapper = new Application_Model_PoolMapper(); @@ -181,10 +181,10 @@ class User_PoolController extends Zend_Controller_Action { // ACL: is he allowed to edit a pool? if(!Pbs_Acl::checkRight('poe')) - $this->_redirect('/user'); - + $this->_redirect('/user'); + if (!isset($_POST["add"])){ - $poolID = $this->_request->getParam('poolID'); + $poolID = $this->_request->getParam('poolID'); $pool = new Application_Model_Pool(); $poolmapper = new Application_Model_PoolMapper(); $poolmapper->find($poolID,$pool); @@ -236,8 +236,8 @@ class User_PoolController extends Zend_Controller_Action // ACL: Is he allowed to link clients to pools? if(!Pbs_Acl::checkRight('polc')) - $this->_redirect('/user'); - + $this->_redirect('/user'); + if(!isset($_POST['clientID']) && ($clientID == '')){ $clientmapper = new Application_Model_ClientMapper(); $clients = $clientmapper->findBy(array('groupID',$this->membership->getGroupID()),true); @@ -293,7 +293,7 @@ class User_PoolController extends Zend_Controller_Action // ACL: Is he allowed to unlink clients from pools? if(!Pbs_Acl::checkRight('pouc')) - $this->_redirect('/user'); + $this->_redirect('/user'); if(is_numeric($poolentriesID)){ $poolentriesMapper = new Application_Model_PoolEntriesMapper(); diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index ee2a684..f3eac39 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -12,22 +12,22 @@ class User_PrebootController extends Zend_Controller_Action { - + protected $prebootMapper; protected $membershipMapper; protected $membership; protected $page; - - public function init() - { - if (Zend_Auth::getInstance()->hasIdentity()) { + + 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); @@ -35,14 +35,14 @@ class User_PrebootController extends Zend_Controller_Action $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'); + } + $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); @@ -57,272 +57,272 @@ class User_PrebootController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('modify',$result); } - $result = $this->_request->getParam('updateresult'); + $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 PrebootMenu sehen? - if(!Pbs_Acl::checkRight('pro')) - $this->_redirect('/user/index'); - - $this->view->prebootlist = $this->prebootMapper->findBy(array("groupID" => $groupID)); - - // Search + + $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)); + + // 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->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 + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(10); $pagination->setElement($this->view->prebootlist); - $pagination->setRequestPage($this->_request->getParam('page')); + $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->prebootlist = $pagination->getElements(); + $this->view->pagination = $pagination->pagination(); - $this->view->page = $pagination->getRequestPage(); - - $this->view->update = array(); - - $update = $this->_request->getParam('checkupdate'); - - foreach ($this->view->prebootlist as $preboot){ - $this->view->update[$preboot->getID()] = $update && $this->checkupdateAction($preboot); - } - } - - public function searchAction(){ + $this->view->page = $pagination->getRequestPage(); + + $this->view->update = array(); + + $update = $this->_request->getParam('checkupdate'); + + foreach ($this->view->prebootlist as $preboot){ + $this->view->update[$preboot->getID()] = $update && $this->checkupdateAction($preboot); + } + } + + 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( + + 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( + } else { + + $prebootForm = new user_Form_Preboot(array( 'action' => 'createpreboot', 'page' => $this->page),$_POST); - - if ($prebootForm->isValid($_POST)) { - - $preboot = new Application_Model_PreBoot($_POST); - $preboot->setGroupID($this->membership->getGroupID()); - - try { - - $path_tmp = "../resources/bootmedium/"; - mkdir($path_tmp ,0777, true); - - $hash = md5(microtime(1)); - exec("wget -O '".$path_tmp."preboot.zip".$hash."' ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'saved'", $status); - - if(!array_pop($status)){ - $this->view->prebootForm = $prebootForm; - $pbsNotifier = new Pbs_Notifier(); - echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); + + if ($prebootForm->isValid($_POST)) { + + $preboot = new Application_Model_PreBoot($_POST); + $preboot->setGroupID($this->membership->getGroupID()); + + try { + + $path_tmp = "../resources/bootmedium/"; + mkdir($path_tmp ,0777, true); + + $hash = md5(microtime(1)); + exec("wget -O '".$path_tmp."preboot.zip".$hash."' ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'saved'", $status); + + if(!array_pop($status)){ + $this->view->prebootForm = $prebootForm; + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); - return; - } - - $prebootID = $this->prebootMapper->save($preboot); - - $path_preboot = "../resources/bootmedium/$prebootID/"; - mkdir($path_preboot ,0777, true); - - exec("mv ../resources/bootmedium/preboot.zip$hash ../resources/bootmedium/$prebootID/preboot.zip"); - - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $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 checkupdateAction($preboot) - { - - //ACL Is he allowed to update Preboots? - if(!Pbs_Acl::checkRight('pru')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); - - $prebootID = $preboot->getID(); - exec("wget --server-response --spider ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'Last-Modified:'", $prebootdate); - - //print_a($prebootdate); - - $prebootdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($prebootdate)))); - - if(is_file("../resources/bootmedium/$prebootID/preboot.zip")){ - $prebootolddate = filemtime("../resources/bootmedium/".$prebootID."/preboot.zip"); - }else{ - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); - return true; - } - - //print_a($prebootname,$prebootdate,$prebootolddate); - - $pbsNotifier = new Pbs_Notifier(); - - if($prebootdate > $prebootolddate){ + return; + } + + $prebootID = $this->prebootMapper->save($preboot); + + $path_preboot = "../resources/bootmedium/$prebootID/"; + mkdir($path_preboot ,0777, true); + + exec("mv ../resources/bootmedium/preboot.zip$hash ../resources/bootmedium/$prebootID/preboot.zip"); + + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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 checkupdateAction($preboot) + { + + //ACL Is he allowed to update Preboots? + if(!Pbs_Acl::checkRight('pru')) + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); + + $prebootID = $preboot->getID(); + exec("wget --server-response --spider ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'Last-Modified:'", $prebootdate); + + //print_a($prebootdate); + + $prebootdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($prebootdate)))); + + if(is_file("../resources/bootmedium/$prebootID/preboot.zip")){ + $prebootolddate = filemtime("../resources/bootmedium/".$prebootID."/preboot.zip"); + }else{ + $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); return true; - } - else - return false; - - } - - public function updateprebootAction() - { - //ACL Is he allowed to update Preboots? - if(!Pbs_Acl::checkRight('pru')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); - - $prebootID = $this->_request->getParam('prebootID'); - if (!is_numeric($prebootID)) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/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.'/updateresult/forbidden'); - - - $path_preboot = "../resources/bootmedium/$prebootID/"; - + } + + //print_a($prebootname,$prebootdate,$prebootolddate); + + $pbsNotifier = new Pbs_Notifier(); + + if($prebootdate > $prebootolddate){ + $this->view->notification = $pbsNotifier->notify('There are updates available','ok'); + return true; + } + else + return false; + + } + + public function updateprebootAction() + { + //ACL Is he allowed to update Preboots? + if(!Pbs_Acl::checkRight('pru')) + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); + + $prebootID = $this->_request->getParam('prebootID'); + if (!is_numeric($prebootID)) + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/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.'/updateresult/forbidden'); + + + $path_preboot = "../resources/bootmedium/$prebootID/"; + exec("wget -O '".$path_preboot."preboot.zip' ".escapeshellcmd($preboot->getPath_preboot())." 2>&1 | grep 'saved'", $status); - + if(!array_pop($status)){ - $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/404'); - } - + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/404'); + } + try{ $filelist = array(); $filelist = scandir($path_preboot); - + $bootisoMapper = new Application_Model_BootIsoMapper(); - - //TODO Lock preboot - + + //TODO Lock preboot + foreach($filelist as $file){ if($file == preg_match('![0-9]+\.zip!')){ $bootisoID = str_replace('.zip', '', $file); $serialnumber = $bootisoMapper->find($bootisoID)->getSerialnumber(); - + copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); - $zip->close(); - } - } + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res === true){ + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); + $zip->close(); + } + } } }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); - //TODO Delete Folder + Preboot - } - - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/ok'); - } - - 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( + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); + //TODO Delete Folder + Preboot + } + + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/ok'); + } + + 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( + $prebootForm->populate($preboot->toArray()); + + }else{ + + $prebootForm = new user_Form_Preboot(array( 'action' => 'editpreboot', 'page' => $this->page),$_POST); - - if ($prebootForm->isValid($_POST)) { - - $prebootold = $preboot; - - $preboot = new Application_Model_PreBoot($_POST); - $preboot->setGroupID($this->membership->getGroupID()); - $preboot->setID($prebootID); - - $path_preboot = "../resources/bootmedium/$prebootID/"; - - if($preboot->getPath_preboot() != $prebootold->getPath_preboot()){ - - //ACL Is he allowed to edit the Preboot Path? - if(!Pbs_Acl::checkRight('pre')) - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - - exec("wget -O '".$path_preboot."preboot.zip' ".escapeshellcmd($preboot->getPath_preboot()) ." 2>&1 | grep 'saved'" , $status); - if(!array_pop($status)){ - $this->view->prebootForm = $prebootForm; - $pbsNotifier = new Pbs_Notifier(); + + if ($prebootForm->isValid($_POST)) { + + $prebootold = $preboot; + + $preboot = new Application_Model_PreBoot($_POST); + $preboot->setGroupID($this->membership->getGroupID()); + $preboot->setID($prebootID); + + $path_preboot = "../resources/bootmedium/$prebootID/"; + + if($preboot->getPath_preboot() != $prebootold->getPath_preboot()){ + + //ACL Is he allowed to edit the Preboot Path? + if(!Pbs_Acl::checkRight('pre')) + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); + + exec("wget -O '".$path_preboot."preboot.zip' ".escapeshellcmd($preboot->getPath_preboot()) ." 2>&1 | grep 'saved'" , $status); + if(!array_pop($status)){ + $this->view->prebootForm = $prebootForm; + $pbsNotifier = new Pbs_Notifier(); echo $pbsNotifier->notify('The Resource was not found on the specified path','error'); - return; - } - - try{ - $filelist = array(); + return; + } + + try{ + $filelist = array(); $filelist = scandir($path_preboot); $bootisoMapper = new Application_Model_BootIsoMapper(); - //TODO Lock preboot + //TODO Lock preboot foreach($filelist as $file){ if(preg_match('![0-9]+\.zip!',$file)){ @@ -330,70 +330,70 @@ class User_PrebootController extends Zend_Controller_Action $serialnumber = $bootisoMapper->find($bootisoID)->getSerialnumber(); copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); - $zip = new ZipArchive(); - $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); - if($res === true){ - $rootdir = $zip->getNameIndex(0); - $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); - $zip->close(); - } - } + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res === true){ + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/serial", $serialnumber); + $zip->close(); + } + } } - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); - } - } - - try { - $this->prebootMapper->save($preboot); - - }catch(Zend_Exception $e){ - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); - //TODO Delete Folder + Preboot - } - + }catch(Zend_Exception $e){ + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); + } + } + + try { + $this->prebootMapper->save($preboot); + + }catch(Zend_Exception $e){ + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/error'); - } - $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/error'); + } + $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 312a647..4a4640f 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -28,7 +28,7 @@ class User_RoleController extends Zend_Controller_Action $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); @@ -45,60 +45,60 @@ class User_RoleController extends Zend_Controller_Action 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->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; - } + $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; + } + $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(); + // 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(); + + // 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:'')); - // 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:'')); + $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; - $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; - } public function searchAction(){ @@ -113,53 +113,53 @@ class User_RoleController extends Zend_Controller_Action if(!Pbs_Acl::checkRight('ra')) { $this->_redirect('/user'); } - - $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(); - } + + $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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - 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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; - } + } + 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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + 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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + return; } } - $this->_helper->redirector('', 'role'); - return; } + $this->_helper->redirector('', 'role'); + return; } - $this->view->addForm = $addForm; + } + $this->view->addForm = $addForm; } public function editAction() @@ -377,7 +377,7 @@ class User_RoleController extends Zend_Controller_Action $rightroles = new Application_Model_RightRoles(); $rightroles->setRightID($rightID); $rightroles->setRoleID($roleID); - + try { $this->rightRolesMapper->save($rightroles); } catch(Zend_Exception $e) diff --git a/application/modules/user/controllers/SessionController.php b/application/modules/user/controllers/SessionController.php index 4260a82..91b6dbd 100644 --- a/application/modules/user/controllers/SessionController.php +++ b/application/modules/user/controllers/SessionController.php @@ -59,7 +59,7 @@ class User_SessionController extends Zend_Controller_Action $bm = $bootmenuentriesMapper->find($session->getBootmenuentryID()); if($bm != null) $session->setBootmenuentryID("[".$session->getBootmenuentryID()."] ".$bm->getTitle()); - + } if($session->getBootisoID() != ''){ @@ -92,7 +92,7 @@ class User_SessionController extends Zend_Controller_Action $mySessions = $mySearch->search($mySessions); } $this->view->searchform = $mySearch->searchForm(); - + // Pagination $pagination = new Pbs_Pagination(); $pagination->setPerPage(10); -- cgit v1.2.3-55-g7522 From 4223800a7a62eaa6148d7e96e87593e8913150cf Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 19 Apr 2011 17:25:09 +0200 Subject: Logout in der FBGui eingebaut --- .../modules/fbgui/controllers/AuthController.php | 51 ++++++------ .../modules/fbgui/controllers/IndexController.php | 6 +- .../modules/fbgui/views/scripts/index/index.phtml | 92 +++++++++++++++++++--- 3 files changed, 106 insertions(+), 43 deletions(-) (limited to 'application/modules/fbgui/controllers/IndexController.php') diff --git a/application/modules/fbgui/controllers/AuthController.php b/application/modules/fbgui/controllers/AuthController.php index c811b06..936aa61 100644 --- a/application/modules/fbgui/controllers/AuthController.php +++ b/application/modules/fbgui/controllers/AuthController.php @@ -39,35 +39,29 @@ class Fbgui_AuthController extends Zend_Controller_Action $auth = Zend_Auth::getInstance(); - $adapter = new Zend_Auth_Adapter_DbTable( - $this->db, - 'pbs_person', - 'email', - 'password', - 'MD5(CONCAT(?, password_salt))' - ); + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); - $adapter->setIdentity($loginForm->getValue('email')); - $adapter->setCredential($loginForm->getValue('password')); - - $result = $auth->authenticate($adapter); - - // TODO: erweiterte fehlerbeschreibung des Users - - if ($result->isValid()) { - $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $person = new Application_Model_Person($result[0]); - $person->setID($result[0]['personID']); - $date = new DateTime(); - $person->setLogindate($date->getTimestamp()); - $this->personmapper->save($person); - $this->_helper->redirector('selectmembership', 'person'); - return; - } else { - echo "Wrong Email or Password."; - } + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); + + $result = $auth->authenticate($adapter); + + // TODO: erweiterte fehlerbeschreibung des Users + + if ($result->isValid()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $date = new DateTime(); + $person->setLogindate($date->getTimestamp()); + $this->personmapper->save($person); + $this->_helper->redirector('selectmembership', 'person'); + return; + } else { + echo "Wrong Email or Password."; + } } } $this->view->loginForm = $loginForm; @@ -81,7 +75,8 @@ class Fbgui_AuthController extends Zend_Controller_Action $auth->clearIdentity(); Zend_Session::namespaceUnset('userIDs'); Zend_Session::forgetMe(); - $this->_helper->redirector('login', 'auth'); + $this->_redirect('/fbgui/index'); +# $this->_helper->redirector('fbgui', 'index'); return; } } diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index 26f12fb..ab146d3 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -135,9 +135,9 @@ class Fbgui_IndexController extends Zend_Controller_Action // 'Your alphasessionID is '.$session->getAlphasessionID(), // 'Your client is '.$session->getClientID(), // 'there is no bootmenu for you'); - - $pbsNotifier = new Pbs_Notifier(); - $this->view->notification = $pbsNotifier->notify("There is no BootMenu to show. Please log in to get your BootMenu.
Click here to login",'error'); + $this->view->nobootmenu = true; + #$pbsNotifier = new Pbs_Notifier(); + #$this->view->notification = $pbsNotifier->notify("There is no BootMenu to show. Please log in to get your BootMenu.
Click here to login",'error'); } } diff --git a/application/modules/fbgui/views/scripts/index/index.phtml b/application/modules/fbgui/views/scripts/index/index.phtml index a141add..2454d45 100644 --- a/application/modules/fbgui/views/scripts/index/index.phtml +++ b/application/modules/fbgui/views/scripts/index/index.phtml @@ -1,12 +1,82 @@ notification != ''){echo $this->notification;} ?> -loginmenu):?> -
-
Login
- This is not your Bootmenu. Select this to get your own Bootmenu. - -
+ +nobootmenu === true):?> +
+
Login
+ There is no BootMenu to show. Please login to get your BootMenu. + +
+ + + +
entries)):?> + loginmenu):?> +
+
Login
+ This is not your Bootmenu. Select this to get your own Bootmenu. + +
+ +
+
Logout
+ Select this to logout and get to the default BootMenu. + +
+

title;?>

+ entries) > 0): ?> +
Starting in startcounter; ?> seconds
+
@@ -149,7 +200,7 @@
- +