diff options
Diffstat (limited to 'application/modules')
6 files changed, 114 insertions, 47 deletions
diff --git a/application/modules/user/controllers/BootisoController.php b/application/modules/user/controllers/BootisoController.php index 1b7f1c4..ba2ef91 100644 --- a/application/modules/user/controllers/BootisoController.php +++ b/application/modules/user/controllers/BootisoController.php @@ -78,6 +78,23 @@ class user_BootisoController extends Zend_Controller_Action $this->view->bootisolist = array_reverse($this->view->bootisolist); + // Pagination + $perpage = 10; + $req_page = $this->_request->getParam('page'); + $all = count($this->view->bootisolist); + $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/bootiso/index',$req_page,$numpages); + $this->view->page = $req_page; + $this->view->bootisolist = array_slice($this->view->bootisolist,$startitem,$perpage); + + $prebootMapper = new Application_Model_PreBootMapper(); $this->view->prebootlist = array(); @@ -91,21 +108,24 @@ class user_BootisoController extends Zend_Controller_Action public function downloadbootisoAction() { + $page = $this->_request->getParam('page'); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); + $page = $this->_request->getParam('page'); + //TODO ACL Darf er BootISOs downloaden? if(false) - $this->_redirect('/user/bootiso/index/downloadresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/downloadresult/forbidden'); $prebootID = $this->_request->getParam('prebootID'); $bootisoID = $this->_request->getParam('bootisoID'); if(!is_dir("../resources/bootmedium/$prebootID/")) - $this->_redirect('/user/bootiso/index/downloadresult/404'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/downloadresult/404'); if(!is_numeric($prebootID) || !is_numeric($bootisoID)) - $this->_redirect('/user/bootiso/index/downloadresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/downloadresult/forbidden'); chdir("../resources/bootmedium/$prebootID/"); @@ -127,9 +147,10 @@ class user_BootisoController extends Zend_Controller_Action public function createbootisoAction() { + $page = $this->_request->getParam('page'); //TODO ACL Darf er BootISOs erstellen? if(false) - $this->_redirect('/user/bootiso/index/addresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/addresult/forbidden'); $groupgroupsMapper = new Application_Model_GroupGroupsMapper(); $groupID = $this->membership->getGroupID(); @@ -173,11 +194,11 @@ class user_BootisoController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootiso/index/addresult/error'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/addresult/error'); //TODO Delete File & delete bootiso from DB } - $this->_redirect('/user/bootiso/index/addresult/ok'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/addresult/ok'); } } @@ -186,13 +207,14 @@ class user_BootisoController extends Zend_Controller_Action public function editbootisoAction() { + $page = $this->_request->getParam('page'); //TODO ACL Darf er BootISOs editieren? if(false) - $this->_redirect('/user/bootiso/index/modifyresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/modifyresult/forbidden'); $bootisoID = $this->_request->getParam('bootisoID'); if (!is_numeric($bootisoID)) - $this->_redirect('/user/bootiso/index/modifyresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/modifyresult/forbidden'); $groupID = $this->membership->getGroupID(); @@ -208,7 +230,7 @@ class user_BootisoController extends Zend_Controller_Action $this->bootisoMapper->find($bootisoID, $bootiso); if($this->membership->getGroupID() != $bootiso->getGroupID()) - $this->_redirect('/user/bootiso/index/modifyresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/modifyresult/forbidden'); $bootisoForm = new user_Form_Bootiso(array('action' => 'editbootiso','prebootlist' => $prebootlist, 'groupdepth' => $childgroups, 'rights' => 'meta')); $bootisoForm->populate($bootiso->toArray()); @@ -234,7 +256,7 @@ class user_BootisoController extends Zend_Controller_Action $bootiso->getSerialnumber() != $bootisoold->getSerialnumber()){ //TODO ACL Is he allowed to edit other than Metadata? if(false) - $this->_redirect('/user/bootiso/index/modifyresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/modifyresult/forbidden'); } @@ -253,11 +275,11 @@ class user_BootisoController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootiso/index/modifyresult/error'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/modifyresult/error'); //TODO Redo Serial in Files... } - $this->_redirect('/user/bootiso/index/modifyresult/ok'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/modifyresult/ok'); } } @@ -267,30 +289,32 @@ class user_BootisoController extends Zend_Controller_Action public function deletebootisoAction() { + $page = $this->_request->getParam('page'); + //TODO ACL Darf er BootISOs löschen? if(false) - $this->_redirect('/user/bootiso/index/deleteresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/deleteresult/forbidden'); try{ $bootisoID = $this->_request->getParam('bootisoID'); if (!is_numeric($bootisoID)) - $this->_redirect('/user/bootiso/index/deleteresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/deleteresult/forbidden'); $bootiso = new Application_Model_BootIso(); $this->bootisoMapper->find($bootisoID,$bootiso); if($this->membership->getGroupID() != $bootiso->getGroupID()) - $this->_redirect('/user/bootiso/index/deleteresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/deleteresult/forbidden'); $this->bootisoMapper->delete($bootiso); }catch(Zend_Exception $e){ echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootiso/index/deleteresult/error'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/deleteresult/error'); } - $this->_redirect('/user/bootiso/index/deleteresult/ok'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/deleteresult/ok'); } } diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index f026e67..eae0dcf 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -64,6 +64,24 @@ class user_BootosController extends Zend_Controller_Action $this->view->bootoslist = $this->bootosMapper->findBy("groupID", $groupID); $this->view->update = array(); + + // Pagination + $perpage = 5; + $req_page = $this->_request->getParam('page'); + $all = count($this->view->bootoslist); + $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/bootos/index',$req_page,$numpages); + $this->view->page = $req_page; + $this->view->bootoslist = array_slice($this->view->bootoslist,$startitem,$perpage); + + $update = $this->_request->getParam('checkupdate'); if(count($this->view->bootoslist)>0){ @@ -80,10 +98,11 @@ class user_BootosController extends Zend_Controller_Action public function createbootosAction() { + $page = $this->_request->getParam('page'); //TODO ACL Darf er BootISOs erstellen? if(false) - $this->_redirect('/user/bootos/index/addresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/addresult/forbidden'); $groupID = $this->membership->getGroupID(); @@ -140,12 +159,12 @@ class user_BootosController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/addresult/error'); + $this->_redirect('/user/bootos/index/page/'.$page.'/addresult/error'); //TODO Delete File & delete bootiso from DB } - $this->_redirect('/user/bootos/index/addresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/addresult/ok'); } } @@ -154,10 +173,11 @@ class user_BootosController extends Zend_Controller_Action public function checkupdateAction($bootos) { + $page = $this->_request->getParam('page'); //TODO ACL Is he allowed to update Preboots? if(false) - $this->_redirect('/user/preboot/index/updateresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$page.'/updateresult/forbidden'); $bootosID = $bootos->getID(); @@ -191,19 +211,20 @@ class user_BootosController extends Zend_Controller_Action public function updatebootosAction() { + $page = $this->_request->getParam('page'); //TODO ACL Is he allowed to update Preboots? if(false) - $this->_redirect('/user/bootiso/index/updateresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/updateresult/forbidden'); $bootosID = $this->_request->getParam('bootosID'); if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/updateresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/forbidden'); $bootos = $this->bootosMapper->find($bootosID); if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/updateresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/forbidden'); $initpath = "../resources/bootos/".$bootosID."/initramfs/"; $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; @@ -214,25 +235,27 @@ class user_BootosController extends Zend_Controller_Action exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); if(!array_pop($status) || !array_pop($status2)){ - $this->_redirect('/user/bootos/index/updateresult/404'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/404'); //TODO Delete Files in tmp } exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); - $this->_redirect('/user/bootos/index/updateresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/ok'); } public function editbootosAction() { + $page = $this->_request->getParam('page'); + //TODO ACL Is he allowed to edit Preboots? if(false) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $bootosID = $this->_request->getParam('bootosID'); if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $groupID = $this->membership->getGroupID(); @@ -248,7 +271,7 @@ class user_BootosController extends Zend_Controller_Action $bootos = $this->bootosMapper->find($bootosID); if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $bootosForm = new user_Form_Bootos(array('action' => 'editbootos', 'groupdepth' => $childgroups, 'configlist'=>$configlist, 'rights' => 'meta')); $bootosForm->populate($bootos->toArray()); @@ -275,13 +298,13 @@ class user_BootosController extends Zend_Controller_Action $bootos->getPublic() != $bootosold->getPublic() ){ //TODO ACL Is he allowed to edit this? if(false) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); } if($bootos->getPath_kernel() != $bootosold->getPath_kernel() || $bootos->getPath_init() != $bootosold->getPath_init()){ //TODO ACL Is he allowed to edit the Kernel/Init Path? if(false) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $path_tmp = "../resources/bootos/"; @@ -315,11 +338,11 @@ class user_BootosController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/modifyresult/error'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/error'); //TODO Delete Folder + Preboot } - $this->_redirect('/user/bootos/index/modifyresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/ok'); } } @@ -330,21 +353,22 @@ class user_BootosController extends Zend_Controller_Action public function deletebootosAction() { + $page = $this->_request->getParam('page'); //TODO ACL Is he allowed to delete Bootos? if(false) - $this->_redirect('/user/bootos/index/deleteresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/forbidden'); try{ $bootosID = $this->_request->getParam('bootosID'); if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/deleteresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/forbidden'); $bootos = new Application_Model_BootOs(); $this->bootosMapper->find($bootosID, $bootos); if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/deleteresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/forbidden'); $this->bootosMapper->delete($bootos); exec("rm -r ../resources/bootos/".$bootosID); @@ -352,9 +376,9 @@ class user_BootosController extends Zend_Controller_Action }catch(Zend_Exception $e){ echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/deleteresult/error'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/error'); } - $this->_redirect('/user/bootos/index/deleteresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/ok'); } diff --git a/application/modules/user/forms/Bootiso.php b/application/modules/user/forms/Bootiso.php index 7c472c0..d080ac2 100644 --- a/application/modules/user/forms/Bootiso.php +++ b/application/modules/user/forms/Bootiso.php @@ -7,6 +7,7 @@ class user_Form_Bootiso extends Zend_Form private $groupdepth; private $action; private $rights; + private $page; public function setRights($rights){ $this->rights = $rights; @@ -20,6 +21,9 @@ class user_Form_Bootiso extends Zend_Form public function setGroupdepth($groupdepth){ $this->groupdepth = $groupdepth; } + public function setPage($page){ + $this->page = $page; + } public function init() @@ -108,9 +112,12 @@ class user_Form_Bootiso extends Zend_Form )); $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootiso"' + 'onclick' => 'self.location="/user/bootiso/page/'.$this->page.'"' )); + $this->addElement('hidden','page', array( + 'value' => $this->page + )); ?> <script> diff --git a/application/modules/user/forms/Bootos.php b/application/modules/user/forms/Bootos.php index 5fa890a..3e45f05 100644 --- a/application/modules/user/forms/Bootos.php +++ b/application/modules/user/forms/Bootos.php @@ -7,6 +7,7 @@ class user_Form_Bootos extends Zend_Form private $action; private $rights; private $groupdepth; + private $page; public function setRights($rights){ $this->rights = $rights; @@ -22,6 +23,9 @@ class user_Form_Bootos extends Zend_Form public function setGroupdepth($groupdepth){ $this->groupdepth = $groupdepth; } + public function setPage($page){ + $this->page = $page; + } public function init() { @@ -139,7 +143,7 @@ class user_Form_Bootos extends Zend_Form )); $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootos"' + 'onclick' => 'self.location="/user/bootos/page/'.$this->page.'"' )); ?> diff --git a/application/modules/user/views/scripts/bootiso/index.phtml b/application/modules/user/views/scripts/bootiso/index.phtml index 4e1d15d..c41d8d2 100644 --- a/application/modules/user/views/scripts/bootiso/index.phtml +++ b/application/modules/user/views/scripts/bootiso/index.phtml @@ -35,7 +35,8 @@ 'controller' => 'bootiso', 'action' => 'downloadbootiso', 'prebootID' => $bootiso->getprebootID(), - 'bootisoID' => $bootiso->getID() + 'bootisoID' => $bootiso->getID(), + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/download.png' alt='Download BootMedium' /></a></td> @@ -44,7 +45,8 @@ 'module' => 'user', 'controller' => 'bootiso', 'action' => 'editbootiso', - 'bootisoID' => $bootiso->getID() + 'bootisoID' => $bootiso->getID(), + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/edit.png' alt='Edit BootISO' /></a></td> @@ -53,13 +55,15 @@ 'module' => 'user', 'controller' => 'bootiso', 'action' => 'deletebootiso', - 'bootisoID' => $bootiso->getID() + 'bootisoID' => $bootiso->getID(), + 'page' => $this->page ), 'default', true) ?>"><img src='/media/img/delete.png' alt='Delete BootISO'/></a></td> </tr> <?php endforeach; ?> </table> +<?php echo $this->pagination; ?> diff --git a/application/modules/user/views/scripts/bootos/index.phtml b/application/modules/user/views/scripts/bootos/index.phtml index 53d219f..92e6bbb 100644 --- a/application/modules/user/views/scripts/bootos/index.phtml +++ b/application/modules/user/views/scripts/bootos/index.phtml @@ -1,7 +1,7 @@ <h1>BootOS</h1> <?php if($this->notification != ''){echo $this->notification;} ?> <?php echo $this->formButton('checkupdate', 'Check for Updates', array( - 'onclick' => 'self.location="/user/bootos/index/checkupdate/true"', + 'onclick' => 'self.location="/user/bootos/index/page/'.$this->page.'/checkupdate/true"', 'class' => 'updatebutton', ))?> <?php echo $this->formButton('createbootos', 'Create BootOS', array( @@ -47,7 +47,8 @@ 'module' => 'user', 'controller' => 'bootos', 'action' => 'updatebootos', - 'bootosID' => $bootos->getID() + 'bootosID' => $bootos->getID(), + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/update.png' alt='Updates available' /></a></td> @@ -60,7 +61,8 @@ 'module' => 'user', 'controller' => 'bootos', 'action' => 'editbootos', - 'bootosID' => $bootos->getID() + 'bootosID' => $bootos->getID(), + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/edit.png' alt='Edit BootOS' /></a></td> @@ -70,13 +72,15 @@ 'module' => 'user', 'controller' => 'bootos', 'action' => 'deletebootos', - 'bootosID' => $bootos->getID() + 'bootosID' => $bootos->getID(), + 'page' => $this->page ), 'default', true) ?>"><img src='/media/img/delete.png' alt='Delete BootOS' /></a></td> </tr> <?php endforeach; ?> </table> +<?php echo $this->pagination; ?> |