summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api_bootos_test.html15
-rw-r--r--api_preboot_test.html6
-rw-r--r--application/controllers/ResourceController.php354
-rw-r--r--application/models/PreBoot.php22
-rw-r--r--application/models/PreBootMapper.php8
-rw-r--r--application/modules/user/controllers/BootosController.php674
-rw-r--r--application/modules/user/controllers/PrebootController.php15
-rw-r--r--application/modules/user/forms/Preboot.php10
-rw-r--r--application/modules/user/views/scripts/preboot/index.phtml32
-rw-r--r--pbs-newdata.sql8
-rw-r--r--pbs.sql3
11 files changed, 685 insertions, 462 deletions
diff --git a/api_bootos_test.html b/api_bootos_test.html
new file mode 100644
index 0000000..e48fb21
--- /dev/null
+++ b/api_bootos_test.html
@@ -0,0 +1,15 @@
+<form enctype='multipart/form-data' action='http://127.0.0.2/resource/addbootos/apikey/apikey1' method='POST'>
+Title:<input name='title' type='text'/>
+Description:<input name='description' type='text'/>
+Expires:<input name='expires' type='text'/>
+KCL:<input name='defaultkcl' type='text'/>
+Distro:<input name='distro' type='text'/>
+Distro-Version:<input name='distroversion' type='text'/>
+Share:<input name='share' type='text'/>
+Shortname:<input name='shortname' type='text'/>
+Config File:<input name='config' type='file'/>
+Kernel File:<input name='kernel' type='file'/>
+Init File:<input name='init' type='file'/>
+<input type='submit' value='Upload'/>
+</form>
+<style>input{display:block}</style>
diff --git a/api_preboot_test.html b/api_preboot_test.html
new file mode 100644
index 0000000..05f4fd2
--- /dev/null
+++ b/api_preboot_test.html
@@ -0,0 +1,6 @@
+<form enctype='multipart/form-data' action='http://127.0.0.2/resource/addpreboot/apikey/apikey1' method='POST'>
+Title:<input name='title' type='text'/>
+Preboot File:<input name='preboot' type='file'/>
+<input type='submit' value='Upload'/>
+</form>
+<style>input{display:block}</style>
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
index 2af7f92..e94d9c7 100644
--- a/application/controllers/ResourceController.php
+++ b/application/controllers/ResourceController.php
@@ -16,56 +16,53 @@ class ResourceController extends Zend_Controller_Action
private $thisSession;
private $page;
private $membership;
+ private $rightrolesMapper;
public function init()
{
$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();
+ $this->rightrolesMapper = new Application_Model_RightRolesMapper();
+ $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');
- 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 401 Member not found');
die();
}
+
}
elseif($alpha == "0"){
$bootmenuentryID = $this->_request->getParam('bootmenuentryID');
$this->page = $this->_request->getParam('page');
if(!is_numeric($bootmenuentryID))
- $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/json/error');
-
+ $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,46 +76,137 @@ class ResourceController extends Zend_Controller_Action
public function indexAction()
{
-
-
+
+
}
-
+
public function addbootosAction()
{
+
+ @list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null){
+ header('HTTP/1.0 403 No Right to Create Bootos');
+ die();
+ }
+
$apikey = $this->_request->getParam('apikey');
if($apikey == ""){
- header('HTTP/1.0 400 No API-Key');
+ header('HTTP/1.0 400 No API-Key');
die();
}
$params = $this->_request->getParams();
- if(!isset($params['title'])){
- header('HTTP/1.0 400 Title must be set');
+ $source = $_SERVER['REMOTE_ADDR'];
+
+ if($params['title'] == '' || $params['distro'] == '' || $params['distroversion'] == '' || $params['share'] == '' || $source == ''){
+ header('HTTP/1.0 400 Title, Distro, Distroversion and Share must be set');
die();
}
+
- $bootos = new Application_Model_BootOs();
+ if($_FILES['config']['size'] == 0 && $_FILES['config']['name'] != '' || $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != ''|| $_FILES['init']['size'] == 0 && $_FILES['init']['name'] != ''){
+ header('HTTP/1.0 400 File must be larger than 0 bytes');
+ die();
+ }
+
$bootosMapper = new Application_Model_BootOsMapper();
+ $groupID = $this->membership->getGroupID();
+
+ @list($bootos) = $bootosMapper->findBy(array('groupid' => $groupID, 'title' => $params['title'], 'distro' => $params['distro'], 'distroversion' => $params['distroversion'], 'source' => $source, 'share' => $params['share']));
+ if($bootos != null){
+ header('HTTP/1.0 400 Bootos already exists');
+ die();
+ }
+ $bootos = new Application_Model_BootOs();
$bootos->setOptions($params);
- $bootos->setGroupID($this->membership->getGroupID());
- $bootos->setSource($_SERVER['REMOTE_ADDR']);
+ $bootos->setGroupID($groupID);
+ $bootos->setSource($source);
$bootos->setPath_config($_FILES['config']['name']);
$bootos->setPath_init($_FILES['init']['name']);
$bootos->setPath_kernel($_FILES['kernel']['name']);
$bootos->setCreated(time());
$bootos->setPublic('-1');
$bootosID = $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);
+
+ if(isset($_FILES['config'])){
+ move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
+ }
+ if(isset($_FILES['kernel'])){
+ move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
+ }
+ if(isset($_FILES['init'])){
+ move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
+ }
+
+ header('HTTP/1.0 201 Bootos created');
+
+ }
+
+ public function editbootosAction()
+ {
+
+ @list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '58', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null){
+ header('HTTP/1.0 403 No Right to Edit Bootos');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == ""){
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $source = $_SERVER['REMOTE_ADDR'];
+
+ if($params['title'] == '' || $params['distro'] == '' || $params['distroversion'] == '' || $params['share'] == '' || $source == ''){
+ header('HTTP/1.0 400 Title, Distro, Distroversion and Share must be set');
+ die();
+ }
- 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);
+ $bootos = new Application_Model_BootOs();
+ $bootosMapper = new Application_Model_BootOsMapper();
+ $groupID = $this->membership->getGroupID();
+
+ @list($bootos) = $bootosMapper->findBy(array('groupid' => $groupID, 'title' => $params['title'], 'distro' => $params['distro'], 'distroversion' => $params['distroversion'], 'source' => $source, 'share' => $params['share']));
+
+ if($bootos == null){
+ header('HTTP/1.0 400 Bootos not found');
+ die();
+ }
+ $bootosID = $bootos->getID();
+
+ $bootos->setOptions($params);
+ $bootos->setID($bootosID);
+ $bootos->setGroupID($groupID);
+ $bootos->setSource($_SERVER['REMOTE_ADDR']);
+ $bootos->setPath_config($_FILES['config']['name']);
+ $bootos->setPath_init($_FILES['init']['name']);
+ $bootos->setPath_kernel($_FILES['kernel']['name']);
+ $bootos->setCreated(time());
+ $bootos->setPublic('-1');
+
+ $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);
+
if(isset($_FILES['config'])){
move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
}
@@ -128,8 +216,127 @@ 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 edited');
+ }
+
+ public function addprebootAction()
+ {
- header('HTTP/1.0 201 Bootos created');
+ @list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '40', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null){
+ header('HTTP/1.0 403 No Right to Create Preboots');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == ""){
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $source = $_SERVER['REMOTE_ADDR'];
+
+ if($params['title'] == ''){
+ header('HTTP/1.0 400 Title must be set');
+ die();
+ }
+
+
+ if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != ''){
+ header('HTTP/1.0 400 File must be larger than 0 bytes');
+ die();
+ }
+
+ $prebootMapper = new Application_Model_PreBootMapper();
+ $groupID = $this->membership->getGroupID();
+
+ @list($preboot) = $prebootMapper->findBy(array('groupid' => $groupID, 'title' => $params['title']));
+ if($preboot != null){
+ header('HTTP/1.0 400 Preboot already exists');
+ die();
+ }
+
+ $preboot = new Application_Model_PreBoot();
+
+ $preboot->setOptions($params);
+ $preboot->setGroupID($groupID);
+ $preboot->setSource($source);
+ $preboot->setPath_preboot($_FILES['preboot']['name']);
+ $preboot->setCreated(time());
+
+ $prebootID = $prebootMapper->save($preboot);
+
+ $prebootpath = "../resources/bootmedium/".$prebootID."/";
+ mkdir($prebootpath ,0777, true);
+
+ if(isset($_FILES['preboot'])){
+ move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip");
+ }
+
+ header('HTTP/1.0 201 Preboot created');
+
+
+ }
+
+ public function editprebootAction()
+ {
+
+ @list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '41', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null){
+ header('HTTP/1.0 403 No Right to Edit Preboot');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == ""){
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $source = $_SERVER['REMOTE_ADDR'];
+
+ if($params['title'] == ''){
+ header('HTTP/1.0 400 Title must be set');
+ die();
+ }
+
+ if($_FILES['preboot']['size'] == 0 && $_FILES['preboot']['name'] != ''){
+ header('HTTP/1.0 400 File must be larger than 0 bytes');
+ die();
+ }
+
+ $prebootMapper = new Application_Model_PreBootMapper();
+ $groupID = $this->membership->getGroupID();
+ $preboot = new Application_Model_PreBoot();
+
+ @list($preboot) = $prebootMapper->findBy(array('groupid' => $groupID, 'title' => $params['title']));
+
+ if($preboot == null){
+ header('HTTP/1.0 400 Preboot not found');
+ die();
+ }
+
+ $prebootID = $preboot->getID();
+
+ $preboot->setOptions($params);
+ $preboot->setGroupID($groupID);
+ $preboot->setSource($source);
+ $preboot->setPath_preboot($_FILES['preboot']['name']);
+ $preboot->setCreated(time());
+
+ $prebootMapper->save($preboot);
+
+ $prebootpath = "../resources/bootmedium/".$prebootID."/";
+ mkdir($prebootpath ,0777, true);
+
+ if(isset($_FILES['preboot'])){
+ move_uploaded_file($_FILES['preboot']['tmp_name'], $prebootpath."preboot.zip");
+ }
+
+ header('HTTP/1.0 201 Preboot edited');
}
@@ -139,19 +346,19 @@ 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 +367,30 @@ 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();
$bootosID = $this->thisSession->getBootosID();
if(is_dir("../resources/bootos/$bootosID/config/")){
-
+
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($this->thisSession->getMembershipID() != null){
+ if($configID == null)
+ $configID = 'default';
+ $path_userconf = "../resources/config/$bootosID/".$this->thisSession->getMembershipID()."/$configID/";
+ if(!is_dir($path_userconf)){
+
$person = new Application_Model_Person();
$personMapper = new Application_Model_PersonMapper();
$membershipMapper = new Application_Model_MembershipMapper();
@@ -190,7 +398,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/");
@@ -204,71 +412,73 @@ class ResourceController extends Zend_Controller_Action
chdir($path_userconf);
passthru( "tar cz *");
}else {
- chdir("../resources/bootos/$bootosID/config/");
- passthru( "cat default.tgz");
- }
+ if($configID == null)
+ $configID = 'default';
+ chdir("../resources/config/$bootosID/$configID/");
+ 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 +490,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 +499,20 @@ 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 = "<table class='json'>";
$result2 .= "<tr><td><b>info</b>: </td><td>".$result['info']."</td></tr>";
$result2 .= "<tr><td><b>kernel</b>: </td><td><a href=".$result['kernel'].">".$result['kernel']."<a></td></tr>";
$result2 .= "<tr><td><b>initramfs</b>: </td><td><a href=".$result['initramfs'].">".$result['initramfs']."<a></td></tr>";
$result2 .= "<tr><td><b>kcl</b>: </td><td><a href=".$result['kcl'].">".$result['kcl']."<a></td></tr>";
- $result2 .= "<tr><td><b>config</b>: </td><td><a href=".$result['config'].">".$result['config']."<a></td></tr>";
- $result2 .= "</table>";
+ $result2 .= "<tr><td><b>config</b>: </td><td><a href=".$result['config'].">".$result['config']."<a></td></tr>";
+ $result2 .= "</table>";
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/models/PreBoot.php b/application/models/PreBoot.php
index c8d0b43..57a622d 100644
--- a/application/models/PreBoot.php
+++ b/application/models/PreBoot.php
@@ -17,6 +17,8 @@ class Application_Model_PreBoot
protected $_path_preboot;
protected $_membershipID;
protected $_groupID;
+ protected $_source;
+ protected $_created;
public function __construct(array $options = null)
@@ -106,6 +108,26 @@ class Application_Model_PreBoot
$this->_path_preboot = $_path_preboot;
return $this;
}
+ public function getCreated()
+ {
+ return $this->_created;
+ }
+
+ public function setCreated($_created)
+ {
+ $this->_created = $_created;
+ return $this;
+ }
+ public function getSource()
+ {
+ return $this->_source;
+ }
+
+ public function setSource($_source)
+ {
+ $this->_source = $_source;
+ return $this;
+ }
/**
* Returns current data as associative array using ReflectionClass
diff --git a/application/models/PreBootMapper.php b/application/models/PreBootMapper.php
index 7d59142..564fd49 100644
--- a/application/models/PreBootMapper.php
+++ b/application/models/PreBootMapper.php
@@ -86,7 +86,7 @@ class Application_Model_PreBootMapper
public function save(Application_Model_PreBoot $preboot)
{
- $data = array('prebootID'=> $preboot->getID() ,'membershipID'=> $preboot->getMembershipID() ,'title'=> $preboot->getTitle() ,'path_preboot'=> $preboot->getPath_preboot() ,'groupID'=> $preboot->getGroupID() );
+ $data = array('prebootID'=> $preboot->getID() ,'membershipID'=> $preboot->getMembershipID() ,'title'=> $preboot->getTitle() ,'path_preboot'=> $preboot->getPath_preboot() ,'groupID'=> $preboot->getGroupID(), 'created' => $preboot->getCreated(), 'source' => $preboot->getSource() );
if (null === ($id = $preboot->getID()) ) {
unset($data['prebootID']);
@@ -117,10 +117,10 @@ class Application_Model_PreBootMapper
if($preboot == null){
$preboot = new Application_Model_PreBoot();
- $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID);
+ $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created);
return $preboot;
}else{
- $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID);
+ $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created);
}
}
@@ -131,7 +131,7 @@ class Application_Model_PreBootMapper
foreach ($resultSet as $row) {
$entry = new Application_Model_PreBoot();
- $entry->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID);
+ $entry->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created);
$entries[] = $entry;
}
diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php
index d93f0cf..6330899 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."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;
- $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."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;
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('The Resource was not found on the specified path','error');
- 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"."default.tgz");
-
- }catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- 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');
- }
- }
-
- $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/default.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);
-
+ 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"."default.tgz");
+
+ }catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ 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');
+ }
+ }
+
+ $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/default.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"."default.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"."default.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"."default.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"."default.tgz");
- }
-
- try {
- $this->bootosMapper->save($bootos);
-
- }catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- $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) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ $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) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- $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) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ $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/PrebootController.php b/application/modules/user/controllers/PrebootController.php
index ee2a684..7e082d3 100644
--- a/application/modules/user/controllers/PrebootController.php
+++ b/application/modules/user/controllers/PrebootController.php
@@ -57,11 +57,6 @@ 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();
@@ -70,6 +65,9 @@ class User_PrebootController extends Zend_Controller_Action
$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');
@@ -93,13 +91,6 @@ class User_PrebootController extends Zend_Controller_Action
$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(){
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>
diff --git a/pbs-newdata.sql b/pbs-newdata.sql
index 0c1fffb..3cc9cd5 100644
--- a/pbs-newdata.sql
+++ b/pbs-newdata.sql
@@ -107,10 +107,10 @@ INSERT INTO `pbs_bootos` (`bootosID`, `path_config`, `groupID`, `membershipID`,
-- Adding preboot
-INSERT INTO `pbs_preboot` (`prebootID`, `title`, `membershipID`, `groupID`, `path_preboot`) VALUES
-(1, 'Preboot 1', 1, 1, 'path 1'),
-(2, 'Preboot 2', 1, 1, 'path 2'),
-(3, 'Preboot 3', 1, 1, 'path 3');
+INSERT INTO `pbs_preboot` (`prebootID`, `title`, `membershipID`, `groupID`, `path_preboot`, `created`, `source`) VALUES
+(1, 'Preboot 1', 1, 1, 'path 1', '1299694422', 'source1'),
+(2, 'Preboot 2', 1, 1, 'path 2', '1299694422', 'source1'),
+(3, 'Preboot 3', 1, 1, 'path 3', '1299694422', 'source1');
-- Adding bootiso
INSERT INTO `pbs_bootiso` (`bootisoID`, `title`, `membershipID`, `groupID`, `prebootID`, `serialnumber`, `created`, `expires`, `public`) VALUES
diff --git a/pbs.sql b/pbs.sql
index 02e6135..8fbbe67 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -154,7 +154,6 @@ CREATE TABLE IF NOT EXISTS `pbs_bootosuser` (
ALTER TABLE `pbs_bootosuser`
ADD CONSTRAINT `pbs_bootosuser_ibfk_1` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`) ON DELETE CASCADE;
-
CREATE TABLE IF NOT EXISTS `pbs_bootos` (
`bootosID` int(11) NOT NULL AUTO_INCREMENT,
`groupID` int(11) NOT NULL,
@@ -223,6 +222,8 @@ CREATE TABLE IF NOT EXISTS `pbs_preboot` (
`membershipID` int(11),
`groupID` int(11) NOT NULL,
`path_preboot` varchar(140) NOT NULL,
+ `source` varchar(140),
+ `created` VARCHAR(14) NOT NULL,
PRIMARY KEY (`prebootID`),
KEY `membershipID` (`membershipID`),
KEY `groupID` (`groupID`)