summaryrefslogtreecommitdiffstats
path: root/application/modules/user
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/user')
-rw-r--r--application/modules/user/controllers/BootosController.php97
-rw-r--r--application/modules/user/controllers/PrebootController.php42
-rw-r--r--application/modules/user/forms/Preboot.php10
-rw-r--r--application/modules/user/views/scripts/preboot/index.phtml32
4 files changed, 76 insertions, 105 deletions
diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php
index 5d69527..06eb60c 100644
--- a/application/modules/user/controllers/BootosController.php
+++ b/application/modules/user/controllers/BootosController.php
@@ -25,9 +25,8 @@ class user_BootosController extends Zend_Controller_Action
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);
@@ -61,7 +60,7 @@ class user_BootosController extends Zend_Controller_Action
$pbsNotifier = new Pbs_Notifier();
$this->view->notification = $pbsNotifier->notify('update',$result);
}
-
+
$groupID = $this->membership->getGroupID();
//ACL Darf er BootOs sehen?
@@ -69,11 +68,11 @@ class user_BootosController extends Zend_Controller_Action
$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));
@@ -84,13 +83,13 @@ class user_BootosController extends Zend_Controller_Action
$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){
foreach ($this->view->bootoslist as $bootos){
$this->view->update[$bootos->getID()] = $update && $this->checkupdateAction($bootos);
@@ -98,7 +97,7 @@ class user_BootosController extends Zend_Controller_Action
$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()));
+ $bootos->setExpires(date(Zend_Registry::get('dateformat'),$bootos->getExpires()));
}
}
@@ -112,7 +111,7 @@ class user_BootosController extends Zend_Controller_Action
$this->view->bootoslist = $mySearch->search($this->view->bootoslist);
}
$this->view->searchform = $mySearch->searchForm();
-
+
// Pagination
$pagination = new Pbs_Pagination();
$pagination->setPerPage(10);
@@ -123,8 +122,7 @@ class user_BootosController extends Zend_Controller_Action
$this->view->pagination = $pagination->pagination();
$this->view->page = $pagination->getRequestPage();
-
-
+
}
public function searchAction(){
$this->_redirect('/user/bootos/index/search/'.($_GET['search']));
@@ -132,23 +130,23 @@ class user_BootosController extends Zend_Controller_Action
public function createbootosAction()
{
-
+
//ACL Darf er BootISOs erstellen?
if(!Pbs_Acl::checkRight('boc'))
$this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/forbidden');
-
+
$groupID = $this->membership->getGroupID();
$groupgroupsMapper = new Application_Model_GroupGroupsMapper();
$childgroups = count($groupgroupsMapper->getChildGroups($groupID));
-
+
if (!isset($_POST["createbootos"])){
$bootosForm = new user_Form_Bootos(array(
'action' => 'createbootos',
'groupdepth' => $childgroups,
'page' => $this->page));
} else {
-
+
$bootosForm = new user_Form_Bootos(array(
'action' => 'createbootos',
'groupdepth' => $childgroups,
@@ -169,7 +167,7 @@ class user_BootosController extends Zend_Controller_Action
$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);
+ exec("wget -O '".$path_tmp."default".$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;
@@ -191,7 +189,8 @@ class user_BootosController extends Zend_Controller_Action
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");
+ exec("mv ../resources/bootos/config$hash $configpath"."default.tgz");
+
}catch(Zend_Exception $e)
{
@@ -199,7 +198,7 @@ class user_BootosController extends Zend_Controller_Action
echo "Message: " . $e->getMessage() . "<br/>";
$this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/error');
//TODO Delete File & delete bootiso from DB
-
+
}
$this->_redirect('/user/bootos/index/page/'.$this->page.'/addresult/ok');
@@ -211,17 +210,18 @@ class user_BootosController extends Zend_Controller_Action
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");
+ $configolddate = filemtime("../resources/bootos/".$bootosID."/config/default.tgz");
+
}
else
{
@@ -229,17 +229,17 @@ class user_BootosController extends Zend_Controller_Action
$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;
@@ -251,25 +251,25 @@ class user_BootosController extends Zend_Controller_Action
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);
@@ -282,8 +282,8 @@ class user_BootosController extends Zend_Controller_Action
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");
-
+ exec("mv ../resources/bootos/config$hash $initpath"."default.tgz");
+
$this->_redirect('/user/bootos/index/page/'.$this->page.'/updateresult/ok');
}
@@ -293,7 +293,7 @@ class user_BootosController extends Zend_Controller_Action
//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');
@@ -302,13 +302,12 @@ class user_BootosController extends Zend_Controller_Action
$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(
@@ -317,7 +316,7 @@ class user_BootosController extends Zend_Controller_Action
'page' => $this->page));
$bootosForm->populate($bootos->toArray());
-
+
}else{
$bootosForm = new user_Form_Bootos(array(
'action' => 'editbootos',
@@ -345,14 +344,15 @@ class user_BootosController extends Zend_Controller_Action
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);
@@ -365,18 +365,19 @@ class user_BootosController extends Zend_Controller_Action
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");
+ exec("mv ../resources/bootos/config$hash $initpath"."default.tgz");
+
}
try {
@@ -392,11 +393,11 @@ class user_BootosController extends Zend_Controller_Action
$this->_redirect('/user/bootos/index/page/'.$this->page.'/modifyresult/ok');
}
-
+
}
-
+
$this->view->bootosForm = $bootosForm;
-
+
}
public function deletebootosAction()
@@ -404,7 +405,7 @@ class user_BootosController extends Zend_Controller_Action
//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))
@@ -412,10 +413,10 @@ class user_BootosController extends Zend_Controller_Action
$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->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden');
+
$this->bootosMapper->delete($bootos);
exec("rm -r ../resources/bootos/".$bootosID);
diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php
index f3eac39..2b2955d 100644
--- a/application/modules/user/controllers/PrebootController.php
+++ b/application/modules/user/controllers/PrebootController.php
@@ -57,21 +57,19 @@ class User_PrebootController extends Zend_Controller_Action
$pbsNotifier = new Pbs_Notifier();
$this->view->notification = $pbsNotifier->notify('modify',$result);
}
- $result = $this->_request->getParam('updateresult');
- if($result != ""){
- $pbsNotifier = new Pbs_Notifier();
- $this->view->notification = $pbsNotifier->notify('update',$result);
- }
-
- $groupID = $this->membership->getGroupID();
-
- //ACL Darf er 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));
+ foreach ($this->view->prebootlist as $preboot){
+ $preboot->setCreated(date(Zend_Registry::get('dateformat'),$preboot->getCreated()));
+ }
+
+ // Search
$search = $this->_request->getParam('search');
$mySearch = new Pbs_Search();
$mySearch->setSearchTerm($search);
@@ -91,18 +89,12 @@ class User_PrebootController extends Zend_Controller_Action
$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);
- }
- }
+ $this->view->page = $pagination->getRequestPage();
- public function searchAction(){
+ }
+
+ public function searchAction(){
$this->_redirect('/user/preboot/index/search/'.($_GET['search']));
}
diff --git a/application/modules/user/forms/Preboot.php b/application/modules/user/forms/Preboot.php
index 49faf0d..0b69c12 100644
--- a/application/modules/user/forms/Preboot.php
+++ b/application/modules/user/forms/Preboot.php
@@ -42,17 +42,13 @@ class user_Form_Preboot extends Zend_Form
'label' => 'Title:',
));
- $this->addElement('text', 'path_preboot', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 240)),
- ),
+ $this->addElement('file', 'prebootfile', array(
'required' => true,
- 'size' => 50,
'readOnly' => $meta,
- 'label' => 'Path to Preboot:',
+ 'label' => 'Preboot:',
));
+
if($this->action == "createpreboot")
$label = "Create Preboot";
else
diff --git a/application/modules/user/views/scripts/preboot/index.phtml b/application/modules/user/views/scripts/preboot/index.phtml
index 0a7a3d3..b714b75 100644
--- a/application/modules/user/views/scripts/preboot/index.phtml
+++ b/application/modules/user/views/scripts/preboot/index.phtml
@@ -1,13 +1,7 @@
<h1>Preboot</h1>
<?php if($this->notification != ''){echo $this->notification;} ?>
<?php echo $this->searchform; ?>
-
-<?php if(Pbs_Acl::checkRight('pru')): ?>
-<?php echo $this->formButton('checkupdate', 'Check for Updates', array(
- 'onclick' => 'self.location="/user/preboot/index/checkupdate/true/page/'.$this->page.'"',
- 'class' => 'updatebutton',
- ))?>
-<?php endif;?>
+
<?php if(Pbs_Acl::checkRight('prc')): ?>
<?php echo $this->formButton('createpreboot', 'Create PreBoot', array(
'onclick' => 'self.location="/user/preboot/createpreboot/page/'.$this->page.'"',
@@ -17,7 +11,8 @@
<div class='head'>Available searchfilter:</div>
<div class='code'>prebootID</div>
<div class='code'>title</div>
- <div class='code'>path_preboot</div>
+ <div class='code'>created</div>
+ <div class='code'>source</div>
</div>
<div class='listelement'>
@@ -31,21 +26,6 @@
</div>
<div class='content'>
<div class='actions'>
- <?php if(Pbs_Acl::checkRight('pru')): ?>
- <?php if($this->update[$preboot->getID()]==true): ?><a href="<?php echo $this->url(
- array(
- 'module' => 'user',
- 'controller' => 'preboot',
- 'action' => 'updatepreboot',
- 'prebootID' => $preboot->getID(),
- 'page' => $this->page
- ),
- 'default',
- true, false) ?>"><img src='/media/img/update.png' alt='Updates available' /></a>
- <?php else: ?>
- <a><img src='/media/img/update_grey.png' alt='No updates available' /></a>
- <?php endif; ?>
- <?php endif; ?>
<?php if(Pbs_Acl::checkRight('pre') || Pbs_Acl::checkRight('prem')): ?>
<a href="<?php echo $this->url(
array(
@@ -75,8 +55,10 @@
<div class='details'>
<label>PrebootID</label>
<div class='item'><?php echo $this->escape($preboot->getID()); ?></div>
- <label>Prebootpath</label>
- <div class='item'><?php echo $this->escape($preboot->getPath_preboot()); ?></div>
+ <label>Source</label>
+ <div class='item'><?php echo $this->escape($preboot->getSource()); ?></div>
+ <label>Changed</label>
+ <div class='item'><?php echo $this->escape($preboot->getCreated()); ?></div>
</div>
</div>
<div class='clear'></div>