summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/models/ConfigMapper.php16
-rw-r--r--application/modules/user/controllers/BootisoController.php4
-rw-r--r--application/modules/user/controllers/BootosController.php95
-rw-r--r--application/modules/user/forms/Bootiso.php18
-rw-r--r--application/modules/user/forms/Bootos.php49
-rw-r--r--application/modules/user/layouts/user.phtml2
6 files changed, 118 insertions, 66 deletions
diff --git a/application/models/ConfigMapper.php b/application/models/ConfigMapper.php
index 341a3f8..fd6760c 100644
--- a/application/models/ConfigMapper.php
+++ b/application/models/ConfigMapper.php
@@ -5,7 +5,7 @@ class Application_Model_ConfigMapper
protected $_dbTable;
- public function findBy($criteria, $value)
+ public function findBy($criteria, $value, $array=false)
{
try{
$db = Zend_Db_Table::getDefaultAdapter();
@@ -14,7 +14,19 @@ class Application_Model_ConfigMapper
->where($criteria . ' = ?', $value);
$stmt = $select->query();
$result = $stmt->fetchAll();
- return $result;
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Config($row);
+ $entry->setID($row['configID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
diff --git a/application/modules/user/controllers/BootisoController.php b/application/modules/user/controllers/BootisoController.php
index 73462eb..8f61838 100644
--- a/application/modules/user/controllers/BootisoController.php
+++ b/application/modules/user/controllers/BootisoController.php
@@ -140,10 +140,10 @@ class user_BootisoController extends Zend_Controller_Action
$prebootlist = $prebootMapper->findBy("groupID", $groupID);
if (!isset($_POST["createbootiso"])){
- $bootisoForm = new user_Form_Bootiso(array('action' => 'createbootiso','prebootlist' => $prebootlist, 'groupdepth' => $childgroups));
+ $bootisoForm = new user_Form_Bootiso(array('action' => 'createbootiso','prebootlist' => $prebootlist, 'groupdepth' => $childgroups, 'rights' => null));
} else {
- $bootisoForm = new user_Form_Bootiso(array('action' => 'createbootiso','prebootlist' => $prebootlist, 'groupdepth' => $childgroups),$_POST);
+ $bootisoForm = new user_Form_Bootiso(array('action' => 'createbootiso','prebootlist' => $prebootlist, 'groupdepth' => $childgroups, 'rights' => null),$_POST);
if ($bootisoForm->isValid($_POST)) {
diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php
index 8daa96c..ecc29d7 100644
--- a/application/modules/user/controllers/BootosController.php
+++ b/application/modules/user/controllers/BootosController.php
@@ -83,41 +83,48 @@ class user_BootosController extends Zend_Controller_Action
//TODO ACL Darf er BootISOs erstellen?
if(false)
- $this->_redirect('/user/bootiso/index/addresult/forbidden');
+ $this->_redirect('/user/bootos/index/addresult/forbidden');
- $groupMapper = new Application_Model_GroupMapper();
- $configMapper = new Application_Model_ConfigMapper();
+ $groupID = $this->membership->getGroupID();
+
+ $groupgroupsMapper = new Application_Model_GroupGroupsMapper();
+ $childgroups = count($groupgroupsMapper->getChildGroups($groupID));
+
+ $configMapper = new Application_Model_ConfigMapper();
+ $configlist = $configMapper->findBy("groupID", $groupID);
if (!isset($_POST["createbootos"])){
- try{
- $createbootosForm = new user_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()));
- }catch(Zend_Exception $e){
- print_a($e);
- }
+ $bootosForm = new user_Form_Bootos(array('action' => 'createbootos', 'groupdepth' => $childgroups, 'configlist'=>$configlist, 'rights' => 'all'));
} else {
- $createbootosForm = new user_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()),$_POST);
+ $bootosForm = new user_Form_Bootos(array('action' => 'createbootos', 'groupdepth' => $childgroups, 'configlist'=>$configlist, 'rights' => 'all'),$_POST);
- if ($createbootosForm->isValid($_POST)) {
+ if ($bootosForm->isValid($_POST)) {
$bootos = new Application_Model_BootOs($_POST);
- $bootos->setMembershipID('1');
- if($bootos->getConfigID() == '')
- $bootos->setConfigID(NULL);
- $bootosmapper = new Application_Model_BootOsMapper();
+ $bootos->setMembershipID($this->membership->getID());
+ $bootos->setGroupID($this->membership->getGroupID());
$bootos->setCreated(time());
try {
- exec("wget --spider ".$bootos->getPath_kernel()." 2>&1 | grep 'Remote file exists.'", $exists_kernel);
- exec("wget --spider ".$bootos->getPath_init()." 2>&1 | grep 'Remote file exists.'" , $exists_init);
-
- if(!array_pop($exists_init) || !array_pop($exists_kernel)){
- $this->view->createbootosForm = $createbootosForm;
+
+ $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);
+
+ if(!array_pop($status) || !array_pop($status2)){
+ $this->view->bootosForm = $bootosForm;
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('The Resource was not found on the specified path','error');
+
return;
}
- $bootosID = $bootosmapper->save($bootos);
+ $bootosID = $this->bootosMapper->save($bootos);
$initpath = "../resources/bootos/".$bootosID."/initramfs/";
$kernelpath = "../resources/bootos/".$bootosID."/kernel/";
@@ -125,45 +132,49 @@ class user_BootosController extends Zend_Controller_Action
mkdir($initpath ,0777, true);
mkdir($kernelpath ,0777, true);
- exec("wget -O '".$kernelpath."kernel' ".$bootos->getPath_kernel());
- exec("wget -O '".$initpath."initramfs' ".$bootos->getPath_init());
-
-
+ exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel");
+ exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs");
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "<br/>";
echo "Message: " . $e->getMessage() . "<br/>";
+ $this->_redirect('/user/bootos/index/addresult/error');
+ //TODO Delete File & delete bootiso from DB
}
- $this->_redirect('/user/bootos');
+ $this->_redirect('/user/bootos/index/addresult/ok');
}
}
- $this->view->createbootosForm = $createbootosForm;
+ $this->view->bootosForm = $bootosForm;
}
public function checkupdateAction($bootos)
{
+
+ //TODO ACL Is he allowed to update Preboots?
+ if(false)
+ $this->_redirect('/user/preboot/index/updateresult/forbidden');
+
+ $bootosID = $bootos->getID();
+
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);
$kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate))));
- $kernelname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/kernel/"));
-
- if($kernelname != "." && $kernelname != "..")
- $kernelolddate = filemtime("../resources/bootos/".$bootos->getID()."/kernel/".$kernelname);
- else
- $kernelolddate = false;
-
$initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate))));
- $initname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/initramfs/"));
- if($initname != "." && $initname != "..")
- $initolddate = filemtime("../resources/bootos/".$bootos->getID()."/initramfs/".$initname);
+ if(is_file("../resources/bootmedium/$bootosID/kernel") && is_file("../resources/bootmedium/$bootosID/initramfs")){
+ $kernelolddate = filemtime("../resources/bootos/".$bootosID."/kernel/kernel");
+ $initolddate = filemtime("../resources/bootos/".$bootosID."/initramfs/initramfs");
+ }
else
- $initolddate = false;
+ {
+ $kernelolddate = false;
+ $initolddate = false;
+ }
//print_a($kernelname,$kerneldate,$kernelolddate,$initname,$initdate,$initolddate);
@@ -205,13 +216,13 @@ class user_BootosController extends Zend_Controller_Action
$bootosmapper = new Application_Model_BootOsMapper();
$bootos = $bootosmapper->find($bootosID);
- $editbootosForm = new user_Form_BootosEdit(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()));
- $editbootosForm->populate($bootos->toArray());
+ $bootosForm = new user_Form_Bootos(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()));
+ $bootosForm->populate($bootos->toArray());
}
}else{
- $editbootosForm = new user_Form_BootosEdit(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()),$_POST);
+ $bootosForm = new user_Form_Bootos(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()),$_POST);
- if ($editbootosForm->isValid($_POST)) {
+ if ($bootosForm->isValid($_POST)) {
//TODO: Check for new URL and download new files.
$bootos = new Application_Model_BootOs($_POST);
@@ -235,7 +246,7 @@ class user_BootosController extends Zend_Controller_Action
}
- $this->view->editbootosForm = $editbootosForm;
+ $this->view->bootosForm = $bootosForm;
}
diff --git a/application/modules/user/forms/Bootiso.php b/application/modules/user/forms/Bootiso.php
index f7bfb47..3bf2775 100644
--- a/application/modules/user/forms/Bootiso.php
+++ b/application/modules/user/forms/Bootiso.php
@@ -84,8 +84,8 @@ class user_Form_Bootiso extends Zend_Form
$publicfield->setLabel('Public:');
$publicfield->addMultiOption(0, '0. Eigene Gruppe');
$publicfield->setAttrib('readOnly', $meta);
- $publicfield->setAttrib('onmouseover', "$('#groups .v1').show();");
- $publicfield->setAttrib('onmouseout', "$('#groups .v1').hide();");
+ $publicfield->setAttrib('id', 'depth');
+ $publicfield->setAttrib('onchange', "$('#groups .v1').show();changeDepth();");
for($i=1; $i<$this->groupdepth; $i++){
$publicfield->addMultiOption($i, "$i. Untergruppe");
@@ -109,13 +109,21 @@ class user_Form_Bootiso extends Zend_Form
'onclick' => 'self.location="/user/bootiso"'
));
?>
-
- <div id='groups' style='text-align: center;'>
+
+ <div id='groups' style='text-align: center;'>
<div class='v1'>
- <img src='/stats/graphgroup/' />
+ <img id='depthimg' src='/stats/graphgroup/' />
</div>
</div>
+ <script>changeDepth();
+ function changeDepth(){
+ i = $("#depth option:selected").val();
+ $('#depthimg').attr('src','/stats/graphgroup/level/' + i);
+ }</script>
+
+
+
<?php
}
diff --git a/application/modules/user/forms/Bootos.php b/application/modules/user/forms/Bootos.php
index 5597f49..f56761b 100644
--- a/application/modules/user/forms/Bootos.php
+++ b/application/modules/user/forms/Bootos.php
@@ -27,9 +27,11 @@ class user_Form_Bootos extends Zend_Form
{
$this->setName("BootOsCreate");
$this->setMethod('post');
-
- if ($this->rights == 'meta')
+
+ if ($this->rights == "meta")
$meta = true;
+ else
+ $meta = null;
$this->addElement('text', 'title', array(
'filters' => array('StringTrim'),
@@ -39,6 +41,17 @@ class user_Form_Bootos extends Zend_Form
'required' => true,
'label' => 'Title:',
));
+
+ $this->addElement('textarea', 'description', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => false,
+ 'rows' => 5,
+ 'cols' => 50,
+ 'label' => 'Description:',
+ ));
$configfield = $this->createElement('select','configID');
$configfield ->setLabel('Config:');
@@ -49,6 +62,7 @@ class user_Form_Bootos extends Zend_Form
$configfield->addMultiOption($c->getID(), $c->getTitle());
}
}
+
$configfield->setRegisterInArrayValidator(false);
$this->addElement($configfield);
@@ -86,17 +100,6 @@ class user_Form_Bootos extends Zend_Form
'label' => 'Default-KCL:',
));
- $this->addElement('textarea', 'description', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 50)),
- ),
- 'required' => false,
- 'rows' => 5,
- 'cols' => 50,
- 'label' => 'Description:',
- ));
-
$date = new DateTime();
$date->add(new DateInterval('P1Y'));
$this->addElement('text', 'expires', array(
@@ -114,6 +117,8 @@ class user_Form_Bootos extends Zend_Form
$publicfield->setLabel('Public:');
$publicfield->addMultiOption(0, '0. Eigene Gruppe');
$publicfield->setAttrib('readOnly', $meta);
+ $publicfield->setAttrib('id', 'depth');
+ $publicfield->setAttrib('onchange', "$('#groups .v1').show();changeDepth();");
for($i=1; $i<$this->groupdepth; $i++){
$publicfield->addMultiOption($i, "$i. Untergruppe");
@@ -137,8 +142,24 @@ class user_Form_Bootos extends Zend_Form
'onclick' => 'self.location="/user/bootos"'
));
- }
+ ?>
+ <script>changeDepth();
+ function changeDepth(){
+ i = $("#depth option:selected").val();
+ $('#depthimg').attr('src','/stats/graphgroup/level/' + i);
+ }</script>
+ <div id='groups' style='text-align: center;'>
+ <div class='v1' >
+ <img id=depthimg src='/stats/graphgroup/'/>
+ </div>
+ </div>
+
+<?php
+ }
+
+
}
+?>
diff --git a/application/modules/user/layouts/user.phtml b/application/modules/user/layouts/user.phtml
index 671c258..73234e8 100644
--- a/application/modules/user/layouts/user.phtml
+++ b/application/modules/user/layouts/user.phtml
@@ -93,7 +93,7 @@ if(Zend_Auth::getInstance()->hasIdentity()){
}
if(isset($userIDsNamespace['roleID'])){
echo " in der Rolle ";
-
+
$role = new Application_Model_Role();
$roleMapper = new Application_Model_RoleMapper();
$role = $roleMapper->find($userIDsNamespace['roleID']);