summaryrefslogtreecommitdiffstats
path: root/application/modules/user/controllers/BootosController.php
diff options
context:
space:
mode:
authormichael pereira2011-04-01 13:57:24 +0200
committermichael pereira2011-04-01 13:57:24 +0200
commit1fb3a11a72f1d27aba069a9b5d4cf88d1daf30d0 (patch)
tree36680922a92f94715ef26b80f4021de1b0ef18a9 /application/modules/user/controllers/BootosController.php
parentMerge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff)
parentpagination in Bootos & Bootiso (diff)
downloadpbs2-1fb3a11a72f1d27aba069a9b5d4cf88d1daf30d0.tar.gz
pbs2-1fb3a11a72f1d27aba069a9b5d4cf88d1daf30d0.tar.xz
pbs2-1fb3a11a72f1d27aba069a9b5d4cf88d1daf30d0.zip
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'application/modules/user/controllers/BootosController.php')
-rw-r--r--application/modules/user/controllers/BootosController.php66
1 files changed, 45 insertions, 21 deletions
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');
}