diff options
Diffstat (limited to 'application/modules/user/controllers/PrebootController.php')
-rw-r--r-- | application/modules/user/controllers/PrebootController.php | 82 |
1 files changed, 56 insertions, 26 deletions
diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index 4a0a95a..f8c8ba7 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -6,6 +6,7 @@ class User_PrebootController extends Zend_Controller_Action protected $prebootMapper; protected $membershipMapper; protected $membership; + protected $page; public function init() { @@ -25,6 +26,7 @@ class User_PrebootController extends Zend_Controller_Action } else { $this->_helper->redirector('login', 'auth'); } + $this->page = $this->_request->getParam('page'); } @@ -62,6 +64,24 @@ class User_PrebootController extends Zend_Controller_Action $this->view->prebootlist = $this->prebootMapper->findBy("groupID", $groupID); + // Pagination + $perpage = 2; + $req_page = $this->_request->getParam('page'); + $all = count($this->view->prebootlist); + $numpages = ceil($all/$perpage); + if($req_page < 0 || !is_numeric($req_page) ) + $req_page = 0; + if($req_page >= $numpages) + $req_page = $numpages-1; + $startitem = $req_page * $perpage; + + $pagination = new Pbs_Pagination(); + $this->view->pagination = $pagination->pagination('/user/preboot/index',$req_page,$numpages); + $this->view->page = $req_page; + $this->view->prebootlist = array_slice($this->view->prebootlist,$startitem,$perpage); + + + $this->view->update = array(); $update = $this->_request->getParam('checkupdate'); @@ -78,13 +98,17 @@ class User_PrebootController extends Zend_Controller_Action //TODO ACL Is he allowed to create Preboots? if(false) - $this->_redirect('/user/preboot/index/addresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/forbidden'); if (!isset($_POST["createpreboot"])){ - $prebootForm = new user_Form_Preboot(array('action' => 'createpreboot')); + $prebootForm = new user_Form_Preboot(array( + 'action' => 'createpreboot', + 'page' => $this->page)); } else { - $prebootForm = new user_Form_Preboot(array('action' => 'createpreboot'),$_POST); + $prebootForm = new user_Form_Preboot(array( + 'action' => 'createpreboot', + 'page' => $this->page),$_POST); if ($prebootForm->isValid($_POST)) { @@ -119,11 +143,11 @@ class User_PrebootController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/addresult/error'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/error'); //TODO Delete folder + preboot in DB } - $this->_redirect('/user/preboot/index/addresult/ok'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/ok'); } } @@ -135,7 +159,7 @@ class User_PrebootController extends Zend_Controller_Action //TODO ACL Is he allowed to update Preboots? if(false) - $this->_redirect('/user/preboot/index/updateresult/forbidden'); + $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); @@ -166,17 +190,17 @@ class User_PrebootController extends Zend_Controller_Action { //TODO ACL Is he allowed to update Preboots? if(false) - $this->_redirect('/user/preboot/index/updateresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); $prebootID = $this->_request->getParam('prebootID'); if (!is_numeric($prebootID)) - $this->_redirect('/user/preboot/index/updateresult/forbidden'); + $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/updateresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); $path_preboot = "../resources/bootmedium/$prebootID/"; @@ -184,7 +208,7 @@ class User_PrebootController extends Zend_Controller_Action 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/updateresult/404'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/404'); } try{ @@ -214,23 +238,23 @@ class User_PrebootController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/modifyresult/error'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); //TODO Delete Folder + Preboot } - $this->_redirect('/user/preboot/index/modifyresult/ok'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/ok'); } public function editprebootAction() { //TODO ACL Is he allowed to edit Preboots? if(false) - $this->_redirect('/user/preboot/index/modifyresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); $prebootID = $this->_request->getParam('prebootID'); if (!is_numeric($prebootID)) - $this->_redirect('/user/preboot/index/modifyresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); if (!isset($_POST["editpreboot"])){ @@ -238,14 +262,20 @@ class User_PrebootController extends Zend_Controller_Action $this->prebootMapper->find($prebootID, $preboot); if($this->membership->getGroupID() != $preboot->getGroupID()) - $this->_redirect('/user/preboot/index/modifyresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); - $prebootForm = new user_Form_Preboot(array('action' => 'editpreboot', 'rights' => 'meta')); + $prebootForm = new user_Form_Preboot(array( + 'action' => 'editpreboot', + 'rights' => 'meta', + 'page' => $this->page)); $prebootForm->populate($preboot->toArray()); }else{ - $prebootForm = new user_Form_Preboot(array('action' => 'editpreboot', 'rights' => 'meta'),$_POST); + $prebootForm = new user_Form_Preboot(array( + 'action' => 'editpreboot', + 'rights' => 'meta', + 'page' => $this->page),$_POST); if ($prebootForm->isValid($_POST)) { @@ -263,7 +293,7 @@ class User_PrebootController extends Zend_Controller_Action //TODO ACL Is he allowed to edit the Preboot Path? if(false) - $this->_redirect('/user/preboot/index/modifyresult/forbidden'); + $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)){ @@ -300,7 +330,7 @@ class User_PrebootController extends Zend_Controller_Action }catch(Zend_Exception $e){ echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/modifyresult/error'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); } } @@ -310,11 +340,11 @@ class User_PrebootController extends Zend_Controller_Action }catch(Zend_Exception $e){ echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/modifyresult/error'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/error'); //TODO Delete Folder + Preboot } - $this->_redirect('/user/preboot/index/modifyresult/ok'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/ok'); } } @@ -326,18 +356,18 @@ class User_PrebootController extends Zend_Controller_Action //TODO ACL Is he allowed to delete Preboots? if(false) - $this->_redirect('/user/preboot/index/deleteresult/forbidden'); + $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/deleteresult/forbidden'); + $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/deleteresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); $this->prebootMapper->delete($preboot); exec("rm -r ../resources/bootmedium/".$prebootID); @@ -345,9 +375,9 @@ class User_PrebootController extends Zend_Controller_Action }catch(Zend_Exception $e){ echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/preboot/index/deleteresult/error'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/error'); } - $this->_redirect('/user/preboot/index/deleteresult/ok'); + $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/ok'); } |