diff options
21 files changed, 769 insertions, 60 deletions
diff --git a/.zfproject.xml b/.zfproject.xml index 539aaa9..87bdf17 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -113,6 +113,9 @@ <actionMethod actionName="linkright"/> <actionMethod actionName="unlinkright"/> </controllerFile> + <controllerFile controllerName="Preboot"> + <actionMethod actionName="index"/> + </controllerFile> </controllersDirectory> <formsDirectory> <formFile formName="AuthLogin"/> @@ -166,6 +169,7 @@ <dbTableFile dbTableName="RightRoles"/> <dbTableFile dbTableName="Role"/> <dbTableFile dbTableName="Session"/> + <dbTableFile dbTableName="PreBoot"/> </dbTableDirectory> <modelFile modelName="BootIsoMapper"/> <modelFile modelName="BootMenuMapper"/> @@ -211,6 +215,8 @@ <modelFile modelName="Session"/> <modelFile modelName="GroupRequest"/> <modelFile modelName="Group"/> + <modelFile modelName="PreBoot"/> + <modelFile modelName="PreBootMapper"/> </modelsDirectory> <modulesDirectory> <moduleDirectory moduleName="user"> @@ -616,6 +622,12 @@ <viewControllerScriptsDirectory forControllerName="Resource"> <viewScriptFile forActionName="getkcl"/> </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Preboot"> + <viewScriptFile forActionName="index"/> + </viewControllerScriptsDirectory> + <viewControllerScriptsDirectory forControllerName="Preboot"> + <viewScriptFile forActionName="index"/> + </viewControllerScriptsDirectory> </viewScriptsDirectory> <viewHelpersDirectory/> <viewFiltersDirectory enabled="false"/> @@ -676,6 +688,7 @@ <testApplicationControllerFile filesystemName="ConfigControllerTest.php"/> <testApplicationControllerFile filesystemName="FilterControllerTest.php"/> <testApplicationControllerFile filesystemName="PoolControllerTest.php"/> + <testApplicationControllerFile filesystemName="PrebootControllerTest.php"/> </testApplicationControllerDirectory> </testApplicationDirectory> <testLibraryDirectory> diff --git a/application/models/BootIso.php b/application/models/BootIso.php index 6354d7c..fdcc6b5 100644 --- a/application/models/BootIso.php +++ b/application/models/BootIso.php @@ -4,7 +4,7 @@ class Application_Model_BootIso { protected $_bootisoID; protected $_title; - protected $_path_fbgui; + protected $_prebootID; protected $_membershipID; protected $_groupID; protected $_serialnumber; @@ -89,13 +89,13 @@ class Application_Model_BootIso $this->_title = $_title; return $this; } - public function getPath_fbgui() + public function getPrebootID() { - return $this->_path_fbgui; + return $this->_prebootID; } - public function setPath_fbgui($_path_fbgui) + public function setPrebootID($_prebootID) { - $this->_path_fbgui = $_path_fbgui; + $this->_prebootID = $_prebootID; return $this; } public function getSerialnumber() diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php index bccc851..9e5b3db 100644 --- a/application/models/BootIsoMapper.php +++ b/application/models/BootIsoMapper.php @@ -47,7 +47,7 @@ class Application_Model_BootIsoMapper public function save(Application_Model_BootIso $botiso) { - $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'path_fbgui'=> $botiso->getPath_fbgui() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() ); + $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'prebootID'=> $botiso->getPrebootID() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() ); if (null === ($id = $botiso->getID()) ) { unset($data['bootisoID']); @@ -75,7 +75,7 @@ class Application_Model_BootIsoMapper $row = $result->current(); - $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_fbgui($row->path_fbgui)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); } public function fetchAll() @@ -85,7 +85,7 @@ class Application_Model_BootIsoMapper foreach ($resultSet as $row) { $entry = new Application_Model_BootIso(); - $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_fbgui($row->path_fbgui)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); $entries[] = $entry; } diff --git a/application/models/DbTable/PreBoot.php b/application/models/DbTable/PreBoot.php new file mode 100644 index 0000000..1bff7bb --- /dev/null +++ b/application/models/DbTable/PreBoot.php @@ -0,0 +1,10 @@ +<?php + +class Application_Model_DbTable_PreBoot extends Zend_Db_Table_Abstract +{ + + protected $_name = 'pbs_preboot'; + + +} + diff --git a/application/models/PreBoot.php b/application/models/PreBoot.php new file mode 100644 index 0000000..19047bc --- /dev/null +++ b/application/models/PreBoot.php @@ -0,0 +1,137 @@ +<?php + +class Application_Model_PreBoot +{ + protected $_prebootID; + protected $_title; + protected $_path_preboot; + protected $_membershipID; + protected $_groupID; + + + public function __construct(array $options = null) + { + if (is_array($options)) { + $this->setOptions($options); + } + } + + public function __set($name, $value) + { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid preboot property'); + } + $this->$method($value); + } + + public function __get($name) + { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid preboot property'); + } + return $this->$method(); + } + + public function setOptions(array $options) + { + $methods = get_class_methods($this); + foreach ($options as $key => $value) { + $method = 'set' . ucfirst($key); + if (in_array($method, $methods)) { + $this->$method($value); + } + } + return $this; + } + + public function getID() + { + return $this->_prebootID; + } + public function setID($_prebootID) + { + $this->_prebootID = $_prebootID; + return $this; + } + + public function getMembershipID() + { + return $this->_membershipID; + } + + public function setMembershipID($_membershipID) + { + $this->_membershipID = $_membershipID; + return $this; + } + + public function getGroupID() + { + return $this->_groupID; + } + + public function setGroupID($_groupID) + { + $this->_groupID = $_groupID; + return $this; + } + public function getTitle() + { + return $this->_title; + } + public function setTitle($_title) + { + $this->_title = $_title; + return $this; + } + public function getPath_preboot() + { + return $this->_path_preboot; + } + + public function setPath_preboot($_path_preboot) + { + $this->_path_preboot = $_path_preboot; + return $this; + } + + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } +} + + + diff --git a/application/models/PreBootMapper.php b/application/models/PreBootMapper.php new file mode 100644 index 0000000..5ff760d --- /dev/null +++ b/application/models/PreBootMapper.php @@ -0,0 +1,105 @@ +<?php + +class Application_Model_PreBootMapper +{ + + protected $_dbTable; + + public function findBy($criteria, $value) + { + try{ + $db = Zend_Db_Table::getDefaultAdapter(); + $select = $this->getDbTable()->select() + ->from($this->_dbTable) + ->where($criteria . ' = ?', $value); + $stmt = $select->query(); + $result = $stmt->fetchAll(); + return $result; + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + public function setDbTable($dbTable) + { + if (is_string($dbTable)) { + $dbTable = new $dbTable(); + } + + if (!$dbTable instanceof Zend_Db_Table_Abstract) { + throw new Exception('Invalid table data gateway provided'); + } + + $this->_dbTable = $dbTable; + + return $this; + } + + public function getDbTable() + { + if (null === $this->_dbTable) { + $this->setDbTable('Application_Model_DbTable_PreBoot'); + } + + return $this->_dbTable; + } + + 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() ); + + if (null === ($id = $preboot->getID()) ) { + unset($data['prebootID']); + return $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('prebootID = ?' => $id)); + } + + } + + public function delete(Application_Model_PreBoot $preboot) + { + if (null === ($id = $preboot->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('prebootID = ?' => $id)); + } + } + + public function find($id, Application_Model_PreBoot $preboot = null) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + 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); + return $preboot; + }else{ + $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID); + } + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + 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); + + $entries[] = $entry; + } + return $entries; + } + + + +} + diff --git a/application/modules/dev/controllers/BootisoController.php b/application/modules/dev/controllers/BootisoController.php index 86454cd..7390c95 100644 --- a/application/modules/dev/controllers/BootisoController.php +++ b/application/modules/dev/controllers/BootisoController.php @@ -14,25 +14,57 @@ class dev_BootisoController extends Zend_Controller_Action $groupmapper = new Application_Model_GroupMapper(); $membershipmapper = new Application_Model_MembershipMapper(); $personmapper = new Application_Model_PersonMapper(); + $prebootmapper = new Application_Model_PreBootMapper(); $this->view->bootisolist = $bootisomapper->fetchAll(); + $this->view->prebootlist = array(); + foreach ($this->view->bootisolist as $bootiso){ + $this->view->prebootlist[$bootiso->getID()] = $prebootmapper->find($bootiso->getPrebootID())->getTitle(); $bootiso->setGroupID("[".$bootiso->getGroupID()."] ".$groupmapper->find($bootiso->getGroupID())->getTitle()); $bootiso->setMembershipID("[".$bootiso->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootiso->getMembershipID())->getPersonID())->getFirstname()); } } + + public function downloadbootisoAction() + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $prebootID = $this->_request->getParams('prebootID'); + + // if(is_dir("../resources/bootmedium/$prebootID/") && is_numeric($prebootID)){ + + 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="preboot.tar.gz"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + // create the gzipped tarfile. + chdir(APPLICATION_PATH . "/resources/bootmedium/$prebootID/"); + passthru( "tar cz ./"); + + $this->_redirect('/dev/bootiso'); + //} + + + + + } public function createbootisoAction() { $groupmapper = new Application_Model_GroupMapper(); + $prebootmapper = new Application_Model_PreBootMapper(); if (!isset($_POST["createbootiso"])){ - $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll())); + $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll())); } else { - $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll()),$_POST); + $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()),$_POST); if ($createbootisoForm->isValid($_POST)) { @@ -43,21 +75,8 @@ class dev_BootisoController extends Zend_Controller_Action try { - exec("wget --spider ".$bootiso->getPath_fbgui()." 2>&1 | grep 'Remote file exists.'", $exists_fbgui); - - if(!array_pop($exists_fbgui)){ - $this->view->createbootisoForm = $createbootisoForm; - return; - } - $bootisomapper->save($bootiso); - - $path_fbgui = "../resources/bootmedium/fbgui/"; - - exec("wget -P ".$path_fbgui." -N ".$bootiso->getPath_fbgui()); - - - + }catch(Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "<br/>"; @@ -75,6 +94,8 @@ class dev_BootisoController extends Zend_Controller_Action { $bootisoID = $this->_request->getParam('bootisoID'); $groupmapper = new Application_Model_GroupMapper(); + $prebootmapper = new Application_Model_PreBootMapper(); + if (!isset($_POST["editbootiso"])){ $bootisoID = $this->_request->getParam('bootisoID'); @@ -85,11 +106,11 @@ class dev_BootisoController extends Zend_Controller_Action $bootisomapper = new Application_Model_BootIsoMapper(); $bootisomapper->find($bootisoID, $bootiso); - $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll())); + $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll())); $editbootisoForm->populate($bootiso->toArray()); } }else{ - $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll()),$_POST); + $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()),$_POST); if ($editbootisoForm->isValid($_POST)) { diff --git a/application/modules/dev/controllers/PrebootController.php b/application/modules/dev/controllers/PrebootController.php new file mode 100644 index 0000000..e319058 --- /dev/null +++ b/application/modules/dev/controllers/PrebootController.php @@ -0,0 +1,170 @@ +<?php + +class dev_PrebootController extends Zend_Controller_Action +{ + + public function init() + { + $db = Zend_Db_Table::getDefaultAdapter(); + } + + public function indexAction() + { + $prebootmapper = new Application_Model_PreBootMapper(); + $groupmapper = new Application_Model_GroupMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $personmapper = new Application_Model_PersonMapper(); + + $this->view->prebootlist = $prebootmapper->fetchAll(); + $this->view->update = array(); + + foreach ($this->view->prebootlist as $preboot){ + $this->view->update[$preboot->getID()] = $this->checkupdateAction($preboot); + $preboot->setGroupID("[".$preboot->getGroupID()."] ".$groupmapper->find($preboot->getGroupID())->getTitle()); + $preboot->setMembershipID("[".$preboot->getMembershipID()."] ".$personmapper->find($membershipmapper->find($preboot->getMembershipID())->getPersonID())->getFirstname()); + } + } + + public function createprebootAction() + { + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["createpreboot"])){ + $createprebootForm = new dev_Form_PrebootCreate(array('grouplist' => $groupmapper->fetchAll())); + } else { + + $createprebootForm = new dev_Form_PrebootCreate(array('grouplist' => $groupmapper->fetchAll()),$_POST); + + if ($createprebootForm->isValid($_POST)) { + + $preboot = new Application_Model_PreBoot($_POST); + $preboot->setMembershipID('1'); + $prebootmapper = new Application_Model_PreBootMapper(); + + try { + + exec("wget --spider ".$preboot->getPath_preboot()." 2>&1 | grep 'Remote file exists.'", $exists_preboot); + + if(!array_pop($exists_preboot)){ + $this->view->createprebootForm = $createprebootForm; + return; + } + + $prebootID = $prebootmapper->save($preboot); + + $path_preboot = "../resources/bootmedium/$prebootID/"; + + exec("wget -P ".$path_preboot." -r -nH --cut-dirs=1 -np -R '*.html*' -N ".$preboot->getPath_preboot()); + + + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/dev/preboot'); + } + } + + $this->view->createprebootForm = $createprebootForm; + } + + public function checkupdateAction($preboot) + { + exec("wget --server-response --spider ".escapeshellcmd($preboot->getPath_preboot())."changed 2>&1 | grep 'Last-Modified:'", $prebootdate); + + //print_a($prebootdate); + + $prebootdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($prebootdate)))); + $prebootname = array_pop(scandir("../resources/bootmedium/".$preboot->getID()."/")); + + if($prebootname != "." && $prebootname != "..") + $prebootolddate = filemtime("../resources/bootmedium/".$preboot->getID()."/".$prebootname); + else + $prebootolddate = false; + + //print_a($prebootname,$prebootdate,$prebootolddate); + + + if($prebootdate > $prebootolddate) + return true; + else + return false; + + } + + public function updateprebootAction() + { + $prebootID = $this->_request->getParam('prebootID'); + $prebootmapper = new Application_Model_PreBootMapper(); + $preboot = new Application_Model_PreBoot(); + $prebootmapper->find($prebootID,$preboot); + + $path_preboot = "../resources/bootmedium/$prebootID/"; + + exec("wget -P ".$path_preboot." -r -nH --cut-dirs=1 -np -R '*.html*' -N ".$preboot->getPath_preboot()); + + $this->_redirect('/dev/preboot'); + } + + public function editprebootAction() + { + $prebootID = $this->_request->getParam('prebootID'); + $groupmapper = new Application_Model_GroupMapper(); + + if (!isset($_POST["editpreboot"])){ + $prebootID = $this->_request->getParam('prebootID'); + if (!isset($prebootID) || !is_numeric($prebootID)){ + $this->_redirect('/dev/preboot'); + } else { + $preboot = new Application_Model_PreBoot(); + $prebootmapper = new Application_Model_PreBootMapper(); + $prebootmapper->find($prebootID, $preboot); + + $editprebootForm = new dev_Form_PrebootEdit(array('grouplist' => $groupmapper->fetchAll())); + $editprebootForm->populate($preboot->toArray()); + } + }else{ + $editprebootForm = new dev_Form_PrebootEdit(array('grouplist' => $groupmapper->fetchAll()),$_POST); + + if ($editprebootForm->isValid($_POST)) { + + $preboot = new Application_Model_PreBoot($_POST); + $preboot->setMembershipID('1'); + $prebootmapper = new Application_Model_PreBootMapper(); + $preboot->setID($prebootID); + + try { + $prebootmapper->save($preboot); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/dev/preboot'); + } + + } + + $this->view->editprebootForm = $editprebootForm; + } + + public function deleteprebootAction() + { + $prebootID = $this->_request->getParam('prebootID'); + if (!isset($prebootID)){ + $this->_redirect('/dev/preboot'); + } else { + $preboot = new Application_Model_PreBoot(); + $preboot->setID($prebootID); + $prebootmapper = new Application_Model_PreBootMapper(); + $prebootmapper->delete($preboot); + } + $this->_redirect('/dev/preboot'); + } + + +} + diff --git a/application/modules/dev/forms/BootisoCreate.php b/application/modules/dev/forms/BootisoCreate.php index 2ecc2d2..097d781 100644 --- a/application/modules/dev/forms/BootisoCreate.php +++ b/application/modules/dev/forms/BootisoCreate.php @@ -4,11 +4,17 @@ class dev_Form_BootisoCreate extends Zend_Form { private $grouplist; + private $prebootlist; public function setGrouplist($grouplist){ $this->grouplist = $grouplist; } + public function setPrebootlist($prebootlist){ + $this->prebootlist = $prebootlist; + + } + public function init() { @@ -35,15 +41,20 @@ class dev_Form_BootisoCreate extends Zend_Form $groupfield->setRegisterInArrayValidator(false); $this->addElement($groupfield); - $this->addElement('text', 'path_fbgui', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Path to FbGui:', - )); + $prebootfield = $this->createElement('select','prebootID'); + $prebootfield ->setLabel('Preboot:'); + + if(count($this->prebootlist)>0){ + foreach($this->prebootlist as $preboot => $p){ + $prebootfield->addMultiOption($p->getID(), $p->getTitle()); + } + } + $prebootfield->setRegisterInArrayValidator(false); + $this->addElement($prebootfield); + + $serial = time(); + for($i=2; $i<14; $i+=3) + $serial = substr($serial,0,$i) .'-'. substr($serial,$i,strlen($serial)); $this->addElement('text', 'serialnumber', array( 'filters' => array('StringTrim'), @@ -53,7 +64,11 @@ class dev_Form_BootisoCreate extends Zend_Form 'required' => true, 'size' => 50, 'label' => 'Serialnumber:', + 'value' => $serial )); + + + $date = new DateTime(); $date->add(new DateInterval('P1Y')); @@ -84,7 +99,7 @@ class dev_Form_BootisoCreate extends Zend_Form )); $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/bootiso"' + 'onclick' => 'self.location="/dev/bootiso"' )); } diff --git a/application/modules/dev/forms/BootisoEdit.php b/application/modules/dev/forms/BootisoEdit.php index b1e2fd2..f6a4c48 100644 --- a/application/modules/dev/forms/BootisoEdit.php +++ b/application/modules/dev/forms/BootisoEdit.php @@ -3,16 +3,23 @@ class dev_Form_BootisoEdit extends Zend_Form { + private $grouplist; + private $prebootlist; public function setGrouplist($grouplist){ $this->grouplist = $grouplist; } + public function setPrebootlist($prebootlist){ + $this->prebootlist = $prebootlist; + + } + public function init() { - $this->setName("BootIsoEdit"); + $this->setName("BootIsoCreate"); $this->setMethod('post'); $this->addElement('text', 'title', array( @@ -32,19 +39,19 @@ class dev_Form_BootisoEdit extends Zend_Form $groupfield->addMultiOption($g->getID(), $g->getTitle()); } } - $groupfield->setRegisterInArrayValidator(false); $this->addElement($groupfield); - $this->addElement('text', 'path', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'size' => 50, - 'label' => 'Path:', - )); + $prebootfield = $this->createElement('select','prebootID'); + $prebootfield ->setLabel('Preboot:'); + + if(count($this->prebootlist)>0){ + foreach($this->prebootlist as $preboot => $p){ + $prebootfield->addMultiOption($p->getID(), $p->getTitle()); + } + } + $prebootfield->setRegisterInArrayValidator(false); + $this->addElement($prebootfield); $this->addElement('text', 'serialnumber', array( 'filters' => array('StringTrim'), @@ -75,8 +82,10 @@ class dev_Form_BootisoEdit extends Zend_Form ), 'required' => true, 'label' => 'Public-Level:', + 'value' => '0' )); + $this->addElement('submit', 'editbootiso', array( 'required' => false, 'ignore' => true, @@ -84,7 +93,7 @@ class dev_Form_BootisoEdit extends Zend_Form )); $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/bootiso"' + 'onclick' => 'self.location="/dev/bootiso"' )); } diff --git a/application/modules/dev/forms/PrebootCreate.php b/application/modules/dev/forms/PrebootCreate.php new file mode 100644 index 0000000..6d803f2 --- /dev/null +++ b/application/modules/dev/forms/PrebootCreate.php @@ -0,0 +1,62 @@ +<?php + +class dev_Form_PrebootCreate extends Zend_Form +{ + + private $grouplist; + + public function setGrouplist($grouplist){ + $this->grouplist = $grouplist; + + } + + public function init() + { + $this->setName("PreBootCreate"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $groupfield = $this->createElement('select','groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist)>0){ + foreach($this->grouplist as $group => $g){ + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('text', 'path_preboot', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 240)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Path to Preboot:', + )); + + $this->addElement('submit', 'createpreboot', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Create Preboot', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/preboot"' + )); + + } + + +} + diff --git a/application/modules/dev/forms/PrebootEdit.php b/application/modules/dev/forms/PrebootEdit.php new file mode 100644 index 0000000..6a66458 --- /dev/null +++ b/application/modules/dev/forms/PrebootEdit.php @@ -0,0 +1,59 @@ +<?php + +class dev_Form_PrebootEdit extends Zend_Form +{ + private $grouplist; + + public function setGrouplist($grouplist){ + $this->grouplist = $grouplist; + + } + + public function init() + { + $this->setName("PreBootEdit"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $groupfield = $this->createElement('select','groupID'); + $groupfield ->setLabel('Group:'); + + if(count($this->grouplist)>0){ + foreach($this->grouplist as $group => $g){ + $groupfield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $groupfield->setRegisterInArrayValidator(false); + $this->addElement($groupfield); + + $this->addElement('text', 'path_preboot', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 240)), + ), + 'required' => true, + 'size' => 50, + 'label' => 'Path to Preboot:', + )); + + $this->addElement('submit', 'editpreboot', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit Preboot', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/dev/preboot"' + )); + + } +} + diff --git a/application/modules/dev/layouts/dev.phtml b/application/modules/dev/layouts/dev.phtml index b911944..a1a2897 100644 --- a/application/modules/dev/layouts/dev.phtml +++ b/application/modules/dev/layouts/dev.phtml @@ -22,7 +22,7 @@ echo $this->headScript()."\n"; <div id='sidepannel'> <div id="logo"><div id="logo-bar-gray"></div></div> <div id="sidepannel-top"> - <h1><a href=/><</a> <a href=/dev/>dev</a></h1> + <h1><a href=/><</a> <a href=/dev>dev</a></h1> <ul> <li>Controller: <ul> @@ -30,6 +30,7 @@ echo $this->headScript()."\n"; <li><a href='/dev/group'>Group</a></li> <li><a href='/dev/role'>Role</a></li> <li><a href='/dev/bootiso'>BootIso</a></li> + <li><a href='/dev/preboot'>Preboot</a></li> <li><a href='/dev/bootmenu'>BootMenu</a></li> <li><a href='/dev/config'>Config</a></li> <li><a href='/dev/bootos'>BootOs</a></li> @@ -51,7 +52,6 @@ echo $this->headScript()."\n"; </li> </ul> -</ul> </div> </div> <div id='main'> diff --git a/application/modules/dev/views/scripts/bootiso/index.phtml b/application/modules/dev/views/scripts/bootiso/index.phtml index 453f316..cb06be6 100644 --- a/application/modules/dev/views/scripts/bootiso/index.phtml +++ b/application/modules/dev/views/scripts/bootiso/index.phtml @@ -1,4 +1,4 @@ -<h1>BootISO</h1> +<h1>BootMedien</h1> <?php echo $this->formButton('createbootiso', 'Create BootISO', array( 'onclick' => 'self.location="/dev/bootiso/createbootiso"', 'class' => 'addbutton'))?> @@ -8,22 +8,22 @@ <th>Title</th> <th>GroupID</th> <th>MembershipID</th> - <th>FbGui Path</th> + <th>PrebootID</th> <th>Serialnumber</th> <th>Created</th> <th>Expires</th> <th>Public</th> - <th colspan=2>Actions</th> + <th colspan=3>Actions</th> </tr> <?php if(count($this->bootisolist)==0) - echo "</table> There are no BootISO's entries for the Bootmenuto display." ?> + echo "</table> There are no BootISO's entries to display." ?> <?php foreach ($this->bootisolist as $bootiso): ?> <tr class=entry> <td><?php echo $this->escape($bootiso->getID()); ?></td> <td><?php echo $this->escape($bootiso->getTitle()); ?></td> <td><?php echo $this->escape($bootiso->getGroupID()); ?></td> <td><?php echo $this->escape($bootiso->getMembershipID()); ?></td> - <td><?php echo $this->escape($bootiso->getPath_fbgui()); ?></td> + <td><?php echo "[" . $this->escape($bootiso->getPrebootID()) . "] " . $this->prebootlist[$bootiso->getID()]; ?></td> <td><?php echo $this->escape($bootiso->getSerialnumber()); ?></td> <td><?php echo $this->escape(date('Y-m-d H:i:s', $bootiso->getCreated())); ?></td> <td><?php echo $this->escape($bootiso->getExpires()); ?></td> @@ -32,6 +32,15 @@ array( 'module' => 'dev', 'controller' => 'bootiso', + 'action' => 'downloadbootiso', + 'prebootID' => $bootiso->getprebootID() + ), + 'default', + true, false) ?>"><img src='/media/img/download.png' alt='Download BootMedium' /></a></td> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'dev', + 'controller' => 'bootiso', 'action' => 'editbootiso', 'bootisoID' => $bootiso->getID() ), @@ -51,8 +60,6 @@ </table> - - diff --git a/application/modules/dev/views/scripts/bootos/index.phtml b/application/modules/dev/views/scripts/bootos/index.phtml index f76938d..2f7f86f 100644 --- a/application/modules/dev/views/scripts/bootos/index.phtml +++ b/application/modules/dev/views/scripts/bootos/index.phtml @@ -36,7 +36,7 @@ <td><?php echo $this->escape($bootos->getExpires()); ?></td> <td><?php echo $this->escape($bootos->getPublic()); ?></td> <?php if($this->update[$bootos->getID()]==true): ?> - <td class='action'><a + <td class='action'><a href="<?php echo $this->url( array( 'module' => 'dev', diff --git a/application/modules/dev/views/scripts/preboot/createpreboot.phtml b/application/modules/dev/views/scripts/preboot/createpreboot.phtml new file mode 100644 index 0000000..19d1595 --- /dev/null +++ b/application/modules/dev/views/scripts/preboot/createpreboot.phtml @@ -0,0 +1,4 @@ +<?php +$this->createprebootForm->setAction($this->url()); +echo $this->createprebootForm; +?> diff --git a/application/modules/dev/views/scripts/preboot/editpreboot.phtml b/application/modules/dev/views/scripts/preboot/editpreboot.phtml new file mode 100644 index 0000000..a8f9c42 --- /dev/null +++ b/application/modules/dev/views/scripts/preboot/editpreboot.phtml @@ -0,0 +1,4 @@ +<?php +$this->editprebootForm->setAction($this->url()); +echo $this->editprebootForm; +?> diff --git a/application/modules/dev/views/scripts/preboot/index.phtml b/application/modules/dev/views/scripts/preboot/index.phtml new file mode 100644 index 0000000..eec8f1b --- /dev/null +++ b/application/modules/dev/views/scripts/preboot/index.phtml @@ -0,0 +1,57 @@ +<h1>Preboot</h1> +<?php echo $this->formButton('createpreboot', 'Create PreBoot', array( + 'onclick' => 'self.location="/dev/preboot/createpreboot"', + 'class' => 'addbutton'))?> + +<table> + <tr> + <th>ID</th> + <th>Title</th> + <th>GroupID</th> + <th>MembershipID</th> + <th>Preboot Path</th> + <th colspan=3>Actions</th> + </tr> + <?php if(count($this->prebootlist)==0) + echo "</table> There are no Preboot entries to display." ?> + <?php foreach ($this->prebootlist as $preboot): ?> + <tr class=entry> + <td><?php echo $this->escape($preboot->getID()); ?></td> + <td><?php echo $this->escape($preboot->getTitle()); ?></td> + <td><?php echo $this->escape($preboot->getGroupID()); ?></td> + <td><?php echo $this->escape($preboot->getMembershipID()); ?></td> + <td><?php echo $this->escape($preboot->getPath_preboot()); ?></td> + <?php if($this->update[$preboot->getID()]==true): ?> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'dev', + 'controller' => 'preboot', + 'action' => 'updatepreboot', + 'prebootID' => $preboot->getID() + ), + 'default', + true, false) ?>"><img src='/media/img/update.png' alt='Updates available' /></a></td> + <?php else: ?> + <td class='action'><img src='/media/img/update_grey.png' alt='No updates available' /></td> + <?php endif; ?> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'dev', + 'controller' => 'preboot', + 'action' => 'editpreboot', + 'prebootID' => $preboot->getID() + ), + 'default', + true, false) ?>"><img src='/media/img/edit.png' alt='Edit Preboot' /></a></td> + <td class='action'><a href="<?php echo $this->url( + array( + 'module' => 'dev', + 'controller' => 'preboot', + 'action' => 'deletepreboot', + 'prebootID' => $preboot->getID() + ), + 'default', + true) ?>"><img src='/media/img/delete.png' alt='Delete Preboot'/></a></td> + </tr> + <?php endforeach; ?> +</table>
\ No newline at end of file @@ -188,7 +188,7 @@ CREATE TABLE IF NOT EXISTS `pbs_bootiso` ( `title` varchar(30) NOT NULL, `membershipID` int(11), `groupID` int(11) NOT NULL, - `path_fbgui` varchar(30) NOT NULL, + `prebootID` int(11) NOT NULL, `serialnumber` int(11) NOT NULL, `created` VARCHAR(14) NOT NULL, `expires` VARCHAR(14), @@ -200,8 +200,24 @@ CREATE TABLE IF NOT EXISTS `pbs_bootiso` ( ALTER TABLE `pbs_bootiso` ADD CONSTRAINT `pbs_bootiso_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE SET NULL, - ADD CONSTRAINT `pbs_bootiso_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE; + ADD CONSTRAINT `pbs_bootiso_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE, + ADD CONSTRAINT `pbs_bootiso_ibfk_3` FOREIGN KEY (`prebootID`) REFERENCES `pbs_preboot` (`prebootID`) ON DELETE CASCADE; +CREATE TABLE IF NOT EXISTS `pbs_preboot` ( + `prebootID` int(11) NOT NULL AUTO_INCREMENT, + `title` varchar(30) NOT NULL, + `membershipID` int(11), + `groupID` int(11) NOT NULL, + `path_preboot` varchar(30) NOT NULL, + PRIMARY KEY (`prebootID`), + KEY `membershipID` (`membershipID`), + KEY `groupID` (`groupID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; + +ALTER TABLE `pbs_preboot` + ADD CONSTRAINT `pbs_preboot_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE SET NULL, + ADD CONSTRAINT `pbs_preboot_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE; + CREATE TABLE IF NOT EXISTS `pbs_client` ( `clientID` int(11) NOT NULL AUTO_INCREMENT, `macadress` varchar(17) NOT NULL, diff --git a/public/media/img/download.png b/public/media/img/download.png Binary files differnew file mode 100644 index 0000000..cd526b2 --- /dev/null +++ b/public/media/img/download.png diff --git a/tests/application/controllers/PrebootControllerTest.php b/tests/application/controllers/PrebootControllerTest.php new file mode 100644 index 0000000..16c893a --- /dev/null +++ b/tests/application/controllers/PrebootControllerTest.php @@ -0,0 +1,20 @@ +<?php + +require_once 'PHPUnit/Framework/TestCase.php'; + +class PrebootControllerTest extends PHPUnit_Framework_TestCase +{ + + public function setUp() + { + /* Setup Routine */ + } + + public function tearDown() + { + /* Tear Down Routine */ + } + + +} + |