summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/modules/user/controllers/BootmenuController.php225
-rw-r--r--application/modules/user/forms/BootmenuEntries.php24
-rw-r--r--application/modules/user/views/scripts/bootmenu/index.phtml4
3 files changed, 168 insertions, 85 deletions
diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php
index ea8cfd3..f20c093 100644
--- a/application/modules/user/controllers/BootmenuController.php
+++ b/application/modules/user/controllers/BootmenuController.php
@@ -4,7 +4,7 @@ class user_BootmenuController extends Zend_Controller_Action
{
protected $bootmenuMapper;
- protected $bootmenuentriesMapper;
+ protected $bootmenuentryMapper;
protected $membershipMapper;
protected $membership;
protected $page;
@@ -18,6 +18,8 @@ class user_BootmenuController extends Zend_Controller_Action
}
$this->bootmenuMapper = new Application_Model_BootMenuMapper();
+ $this->bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper();
+
$this->membershipMapper = new Application_Model_MembershipMapper();
$this->membership = new Application_Model_Membership();
@@ -48,6 +50,12 @@ class user_BootmenuController extends Zend_Controller_Action
$pbsNotifier = new Pbs_Notifier();
$this->view->notification = $pbsNotifier->notify('modify',$result);
}
+ $result = $this->_request->getParam('json');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('json',$result);
+ }
+
//TODO ACL Darf er BootOsMenu sehen?
if(false)
@@ -194,9 +202,9 @@ class user_BootmenuController extends Zend_Controller_Action
public function deletebootmenuAction()
{
- //TODO ACL Is he allowed to delete Bootos?
+ //TODO ACL Is he allowed to delete Bootmenu?
if(false)
- $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden');
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden');
try{
$bootmenuID = $this->_request->getParam('bootmenuID');
@@ -221,140 +229,205 @@ class user_BootmenuController extends Zend_Controller_Action
public function addbootmenuentryAction()
{
+
+ //TODO ACL Darf er BootMenuEntries erstellen?
+ if(false)
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/forbidden');
+
$bootmenuID = $this->_request->getParam('bootmenuID');
- $bootosmapper = new Application_Model_BootOsMapper();
- $configmapper = new Application_Model_ConfigMapper();
-
+ $maxorder = $this->_request->getParam('maxorder');
+
+ if (!is_numeric($bootmenuID) || !is_numeric($maxorder))
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error');
+
+ $bootosMapper = new Application_Model_BootOsMapper();
+ $configMapper = new Application_Model_ConfigMapper();
+ $bootoslist = $bootosMapper->fetchAll();
+ $configlist = $configMapper->fetchAll();
+
if (!isset($_POST["addbootmenuentry"])){
- $addbootmenuentryForm = new user_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(),'page' => $this->page));
- $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder')));
+
+ $bootmenuentryForm = new user_Form_BootmenuEntries(array(
+ 'bootoslist'=> $bootoslist,
+ 'maxorder'=> $maxorder,
+ 'configlist'=> $configlist,
+ 'page' => $this->page,
+ 'action' => 'addbootmenuentry',
+ 'rights' => 'meta'
+ ));
+
+ $bootmenuentryForm->populate(array('order' => $maxorder));
unset($_POST['kcl']);
unset($_POST['configID']);
- $addbootmenuentryForm->populate($_POST);
+ $bootmenuentryForm->populate($_POST);
+
} else {
- $addbootmenuentryForm = new user_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(),'page' => $this->page),$_POST);
+ $bootmenuentryForm = new user_Form_BootmenuEntries(array(
+ 'bootoslist'=>$bootoslist,
+ 'maxorder'=> $maxorder,
+ 'configlist'=>$configlist,
+ 'page' => $this->page,
+ 'action' => 'addbootmenuentry',
+ 'rights' => 'meta'),$_POST);
- if ($addbootmenuentryForm->isValid($_POST)) {
+ if ($bootmenuentryForm->isValid($_POST)) {
$bootmenuentry = new Application_Model_BootMenuEntries($_POST);
$bootmenuentry->setBootmenuID($bootmenuID);
- $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper();
-
try {
- if($bootmenuentry->getOrder() < $this->_request->getParam('maxorder')){
+ if($bootmenuentry->getOrder() < $maxorder){
$bootmenuentry->setOrder($bootmenuentry->getOrder());
- $bootmenuentrymapper->order($bootmenuentry);
+ $this->bootmenuentryMapper->order($bootmenuentry);
}
//print_a($bootmenuentry);
- $bootmenuentrymapper->save($bootmenuentry);
+ $this->bootmenuentryMapper->save($bootmenuentry);
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "<br/>";
echo "Message: " . $e->getMessage() . "<br/>";
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/error');
}
- $this->_redirect('/user/bootmenu');
- }
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/ok');
+ }
}
- $this->view->addbootmenuentryForm = $addbootmenuentryForm;
+ $this->view->bootmenuentryForm = $bootmenuentryForm;
}
public function editbootmenuentryAction()
{
- $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
- $bootmenuID = $this->_request->getParam('bootmenuID');
- $bootosmapper = new Application_Model_BootOsMapper();
- $configmapper = new Application_Model_ConfigMapper();
+ //TODO ACL Is he allowed to edit BootMenus?
+ if(false)
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
+
+ $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
+ $maxorder = $this->_request->getParam('maxorder');
+ $oldorder = $this->_request->getParam('oldorder');
+ if (!is_numeric($bootmenuentryID) || !is_numeric($maxorder) || !is_numeric($oldorder))
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error');
+
+ $bootosMapper = new Application_Model_BootOsMapper();
+ $configMapper = new Application_Model_ConfigMapper();
+ $bootoslist = $bootosMapper->fetchAll();
+ $configlist = $configMapper->fetchAll();
+
$bootmenuentry = new Application_Model_BootMenuEntries();
- $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper();
+ $bootmenu = new Application_Model_BootMenu();
+ $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry);
+ $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu);
+
+ if($this->membership->getGroupID() != $bootmenu->getGroupID())
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
if (!isset($_POST["editbootmenuentry"])){
- $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
- if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){
- $this->_redirect('/user/bootmenu');
- } else {
-
- $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry);
-
- $editbootmenuentryForm = new user_Form_BootmenuEntries(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl(),'page' => $this->page));
-
- if(!isset($_POST['configID'])){
- $editbootmenuentryForm->populate($bootmenuentry->toArray());
- }
- else{
- unset($_POST['kcl']);
- unset($_POST['configID']);
- $editbootmenuentryForm->populate($_POST);
- }
+
+ $bootmenuentryForm = new user_Form_BootmenuEntries(array(
+ 'bootoslist'=> $bootoslist,
+ 'maxorder'=> $maxorder-1,
+ 'configlist'=> $configlist,
+ 'kcl' => $bootmenuentry->getKcl(),
+ 'page' => $this->page,
+ 'action' => 'editbootmenuentry',
+ 'rights' => 'all'
+ ));
+
+ if(!isset($_POST['configID'])){
+ $bootmenuentryForm->populate($bootmenuentry->toArray());
+ }
+ else{
+ unset($_POST['kcl']);
+ unset($_POST['configID']);
+ $bootmenuentryForm->populate($_POST);
}
+
}else{
- $editbootmenuentryForm = new user_Form_BootmenuEntries(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl(),'page' => $this->page),$_POST);
+ $bootmenuentryForm = new user_Form_BootmenuEntries(array(
+ 'bootoslist'=> $bootoslist,
+ 'maxorder'=> $maxorder-1,
+ 'configlist'=> $configlist,
+ 'kcl' => $bootmenuentry->getKcl(),
+ 'page' => $this->page,
+ 'action' => 'editbootmenuentry',
+ 'rights' => 'all'),$_POST);
- if ($editbootmenuentryForm->isValid($_POST)) {
+ if ($bootmenuentryForm->isValid($_POST)) {
- $bootmenuentry = new Application_Model_BootMenuEntries($_POST);
+ $bootmenuentryold= $bootmenuentry;
- $bootmenuentry->setBootmenuID($bootmenuID);
+ $bootmenuentry = new Application_Model_BootMenuEntries($_POST);
+ $bootmenuentry->setBootmenuID($bootmenu->getID());
$bootmenuentry->setID($bootmenuentryID);
-
- $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper();
-
+
+ if( $bootmenuentryold->getBootosID() != $bootmenuentry->getBootosID() ||
+ $bootmenuentryold->getConfigID() != $bootmenuentry->getConfigID() ||
+ $bootmenuentryold->getKcl() != $bootmenuentry->getKcl() ||
+ $bootmenuentryold->getKclappend() != $bootmenuentry->getKclappend()){
+ //TODO ACL Is he allowed to edit this?
+ if(false)
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
+ }
+
try {
- if($bootmenuentry->getOrder() < $this->_request->getParam('oldorder'))
- $bootmenuentrymapper->orderbefore($bootmenuentry, $this->_request->getParam('oldorder'));
+ if($bootmenuentry->getOrder() < $oldorder)
+ $this->bootmenuentryMapper->orderbefore($bootmenuentry, $oldorder);
else
- $bootmenuentrymapper->orderafter($bootmenuentry, $this->_request->getParam('oldorder'));
+ $this->bootmenuentryMapper->orderafter($bootmenuentry, $oldorder);
- $bootmenuentrymapper->save($bootmenuentry);
+ $this->bootmenuentryMapper->save($bootmenuentry);
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "<br/>";
echo "Message: " . $e->getMessage() . "<br/>";
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error');
+
}
- $this->_redirect('/user/bootmenu');
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/ok');
}
}
- $this->view->editbootmenuentryForm = $editbootmenuentryForm;
+ $this->view->bootmenuentryForm = $bootmenuentryForm;
}
public function removebootmenuentryAction()
{
- $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
- if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){
- $this->_redirect('/bootmenu');
- } else {
- $bootmenuentry = new Application_Model_BootMenuEntries();
- $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper();
- $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry);
- $bootmenuentrymapper->delete($bootmenuentry);
- $bootmenuentrymapper->orderremove($bootmenuentry);
+ //TODO ACL Is he allowed to delete Bootos?
+ if(false)
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden');
+
+ try{
+ $bootmenuentryID = $this->_request->getParam('bootmenuentryID');
+ if (!is_numeric($bootmenuentryID))
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden');
+
+ $bootmenuentry = new Application_Model_BootMenuEntries();
+ $bootmenu = new Application_Model_BootMenu();
+ $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry);
+ $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu);
+
+ if($this->membership->getGroupID() != $bootmenu->getGroupID())
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden');
+
+ $this->bootmenuentryMapper->delete($bootmenuentry);
+ $this->bootmenuentryMapper->orderremove($bootmenuentry);
+
+ }catch(Zend_Exception $e){
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/error');
}
- $this->_redirect('/user/bootmenu');
+ $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/ok');
}
- private function arrayDiff($a, $b){
- foreach($a as $k1 => $i1){
- foreach($b as $k2 => $i2){
- if($i1->getID() == $i2->getBootosID()){
- unset($a[$k1]);
- }
- }
- }
- return $a;
- }
-
-
}
diff --git a/application/modules/user/forms/BootmenuEntries.php b/application/modules/user/forms/BootmenuEntries.php
index 447f09e..c31668c 100644
--- a/application/modules/user/forms/BootmenuEntries.php
+++ b/application/modules/user/forms/BootmenuEntries.php
@@ -8,7 +8,12 @@ class user_Form_BootmenuEntries extends Zend_Form
private $action;
private $rights;
private $page;
+ private $kcl;
+
+ public function setKcl($kcl){
+ $this->kcl = $kcl;
+ }
public function setRights($rights){
$this->rights = $rights;
}
@@ -41,7 +46,10 @@ class user_Form_BootmenuEntries extends Zend_Form
if(!isset($_POST['bootosID'])){
$firstbootos = array_slice($this->bootoslist,0,1);
$_POST['bootosID'] = $firstbootos[0]->getID();
- $_POST['kclactive'] = true;
+ if(isset($this->kcl))
+ $_POST['kclactive'] = true;
+ else
+ $_POST['kclactive'] = false;
}
$this->setName($this->action);
@@ -63,7 +71,8 @@ class user_Form_BootmenuEntries extends Zend_Form
$bootosfield = $this->createElement('select','bootosID');
$bootosfield ->setLabel('BootOs:');
- $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();");
+ $bootosfield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();");
+ $bootosfield->setAttrib('readOnly', $meta);
if(count($this->bootoslist)>0){
foreach($this->bootoslist as $bootos => $b){
@@ -75,9 +84,9 @@ class user_Form_BootmenuEntries extends Zend_Form
$this->addElement($bootosfield);
$kclactive = $this->createElement('checkbox','kclactive');
- $kclactive->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();");
+ $kclactive->setAttrib('onChange', "document.getElementById('".$this->action."').submit();");
$kclactive->setLabel('Use default KCL:');
- $kclactive->setValue(true);
+ $kclactive->setValue($_POST['kclactive']);
$this->addElement($kclactive);
@@ -111,6 +120,7 @@ class user_Form_BootmenuEntries extends Zend_Form
'cols' => 50,
'rows' => 5,
'label' => 'KCL-Append:',
+ 'readOnly' => $meta,
'description' => 'Chars left: ' . $kcllength
));
@@ -118,6 +128,7 @@ class user_Form_BootmenuEntries extends Zend_Form
$configfield = $this->createElement('select','configID');
$configfield->setLabel('Config:');
$configfield->addMultiOption($defaultconfigid, 'default');
+ $configfield->setAttrib('readOnly', $meta);
if(count($this->configlist)>0){
foreach($this->configlist as $config => $c){
@@ -131,6 +142,7 @@ class user_Form_BootmenuEntries extends Zend_Form
$orderfield = $this->createElement('select','order');
$orderfield ->setLabel('Position:');
+ $orderfield->setAttrib('readOnly', $meta);
for ($i = 0; $i <= $this->maxorder; $i++) {
$orderfield->addMultiOption($i, $i+1);
@@ -138,8 +150,8 @@ class user_Form_BootmenuEntries extends Zend_Form
$orderfield->setRegisterInArrayValidator(false);
$this->addElement($orderfield);
- if($this->action == "createbootmenuentry")
- $label = "Create Bootmenuentry";
+ if($this->action == "addbootmenuentry")
+ $label = "Add Bootmenuentry";
else
$label = "Edit Bootmenuentry";
diff --git a/application/modules/user/views/scripts/bootmenu/index.phtml b/application/modules/user/views/scripts/bootmenu/index.phtml
index 72051ab..5f150aa 100644
--- a/application/modules/user/views/scripts/bootmenu/index.phtml
+++ b/application/modules/user/views/scripts/bootmenu/index.phtml
@@ -74,11 +74,10 @@
<td class='action'>
<a href="<?php echo $this->url(
array(
- 'module' => 'dev',
+
'controller' => 'resource',
'action' => 'getbootmenuentry',
'bootmenuentryID' => $bootmenuentry->getID(),
- 'alpha' => $_SESSION['alphasessionID'],
'page' => $this->page
),
'default',
@@ -98,7 +97,6 @@
'controller' => 'bootmenu',
'action' => 'editbootmenuentry',
'bootmenuentryID' => $bootmenuentry->getID(),
- 'bootmenuID' => $bootmenu->getID(),
'maxorder' => count($this->bootmenuentrylist[$bootmenu->getID()]),
'oldorder' => $bootmenuentry->getOrder(),
'page' => $this->page