hasIdentity()) {
$userIDsNamespace = Zend_Session::namespaceGet('userIDs');
if($userIDsNamespace['membershipID'] ==''){
$this->_redirect('/user/index');
}
$this->bootmenuMapper = new Application_Model_BootMenuMapper();
$this->bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper();
$this->membershipMapper = new Application_Model_MembershipMapper();
$this->membership = new Application_Model_Membership();
$this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership);
$this->db = Zend_Db_Table::getDefaultAdapter();
} else {
$this->_helper->redirector('login', 'auth');
}
$this->page = $this->_request->getParam('page');
}
public function indexAction()
{
$result = $this->_request->getParam('addresult');
if($result != ""){
$pbsNotifier = new Pbs_Notifier();
$this->view->notification = $pbsNotifier->notify('create',$result);
}
$result = $this->_request->getParam('deleteresult');
if($result != ""){
$pbsNotifier = new Pbs_Notifier();
$this->view->notification = $pbsNotifier->notify('delete',$result);
}
$result = $this->_request->getParam('modifyresult');
if($result != ""){
$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 Bootmenus sehen?
if(false)
$this->_redirect('/user/index');
$this->bootMenumapper = new Application_Model_BootMenuMapper();
$this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper();
$bootosMapper = new Application_Model_BootOsMapper();
$configMapper = new Application_Model_ConfigMapper();
if(true){
//TODO nur Bootmenus von Admins
$bootmenu = $this->bootmenuMapper->findBy(array('groupID' => $this->membership->getGroupID()));
foreach ($bootmenu as $bm){
$bootmenuID = $bm->getID();
$bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID));
foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry){
$bootmenuentry->setBootosID("[".$bootmenuentry->getBootosID()."] ".$bootosMapper->find($bootmenuentry->getBootosID())->getTitle());
$bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->gettitle());
}
}
}else{
$bootmenu = $this->bootmenuMapper->findBy(array('membershipID' => $this->membership->getID()));
$bootmenuID = $bootmenu[0]->getID();
$bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID));
foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry){
$bootmenuentry->setBootosID("[".$bootmenuentry->getBootosID()."] ".$bootosMapper->find($bootmenuentry->getBootosID())->getTitle());
$bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->gettitle());
}
}
// Pagination
$pagination = new Pbs_Pagination();
$pagination->setPerPage(2);
$pagination->setElement($bootmenu);
$pagination->setRequestPage($this->_request->getParam('page'));
$pagination->setPageUrl('/user/bootmenu/index'.((isset($this->view->search))?'/search/'.$this->view->search:''));
$bootmenu = $pagination->getElements();
$this->view->pagination = $pagination->pagination($pageurl);
$this->view->page = $pagination->getRequestPage();
$this->view->bootmenulist = $bootmenu;
$this->view->bootmenuentrylist = $bootmenuentries;
}
public function createbootmenuAction()
{
//TODO ACL Darf er BootMenus erstellen?
if(false)
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/forbidden');
if (!isset($_POST["createbootmenu"])){
$bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu', 'rights' => 'all','page' => $this->page));
} else {
$bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu', 'rights' => 'all','page' => $this->page),$_POST);
if ($bootmenuForm->isValid($_POST)) {
$bootmenu = new Application_Model_BootMenu($_POST);
$bootmenu->setMembershipID($this->membership->getID());
$bootmenu->setGroupID($this->membership->getGroupID());
$bootmenu->setCreated(time());
try{
$this->bootmenuMapper->save($bootmenu);
}catch(Zend_Exception $e){
echo "Caught exception: " . get_class($e) . "
";
echo "Message: " . $e->getMessage() . "
";
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/error');
}
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/ok');
}
}
$this->view->bootmenuForm = $bootmenuForm;
}
public function editbootmenuAction()
{
//TODO ACL Is he allowed to edit BootMenus?
if(false)
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
$bootmenuID = $this->_request->getParam('bootmenuID');
if (!is_numeric($bootmenuID))
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
$bootmenu = new Application_Model_BootMenu();
$this->bootmenuMapper->find($bootmenuID, $bootmenu);
if($this->membership->getGroupID() != $bootmenu->getGroupID())
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
if (!isset($_POST["editbootmenu"])){
$bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'rights' => 'all','page' => $this->page));
$bootmenuForm->populate($bootmenu->toArray());
}else{
$bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'rights' => 'all','page' => $this->page),$_POST);
if ($bootmenuForm->isValid($_POST)) {
$bootmenuold = $bootmenu;
$bootmenu = new Application_Model_BootMenu($_POST);
$bootmenu->setMembershipID($this->membership->getID());
$bootmenu->setGroupID($this->membership->getGroupID());
$bootmenu->setCreated(time());
$bootmenu->setID($bootmenuID);
//TODO ACL Is he allowed to edit this?
if(false)
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
try {
$this->bootmenuMapper->save($bootmenu);
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "
";
echo "Message: " . $e->getMessage() . "
";
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error');
}
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/ok');
}
}
$this->view->bootmenuForm = $bootmenuForm;
}
public function deletebootmenuAction()
{
//TODO ACL Is he allowed to delete Bootmenu?
if(false)
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden');
try{
$bootmenuID = $this->_request->getParam('bootmenuID');
if (!is_numeric($bootmenuID))
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden');
$bootmenu = new Application_Model_BootMenu();
$this->bootmenuMapper->find($bootmenuID, $bootmenu);
if($this->membership->getGroupID() != $bootmenu->getGroupID())
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden');
$this->bootmenuMapper->delete($bootmenu);
}catch(Zend_Exception $e){
echo "Caught exception: " . get_class($e) . "
";
echo "Message: " . $e->getMessage() . "
";
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/error');
}
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/ok');
}
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');
$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"])){
$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']);
$bootmenuentryForm->populate($_POST);
} else {
$bootmenuentryForm = new user_Form_BootmenuEntries(array(
'bootoslist'=>$bootoslist,
'maxorder'=> $maxorder,
'configlist'=>$configlist,
'page' => $this->page,
'action' => 'addbootmenuentry',
'rights' => 'meta'),$_POST);
if ($bootmenuentryForm->isValid($_POST)) {
$bootmenuentry = new Application_Model_BootMenuEntries($_POST);
$bootmenuentry->setBootmenuID($bootmenuID);
try {
if($bootmenuentry->getOrder() < $maxorder){
$bootmenuentry->setOrder($bootmenuentry->getOrder());
$this->bootmenuentryMapper->order($bootmenuentry);
}
//print_a($bootmenuentry);
$this->bootmenuentryMapper->save($bootmenuentry);
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "
";
echo "Message: " . $e->getMessage() . "
";
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/error');
}
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/ok');
}
}
$this->view->bootmenuentryForm = $bootmenuentryForm;
}
public function editbootmenuentryAction()
{
//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();
$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"])){
$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{
$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 ($bootmenuentryForm->isValid($_POST)) {
$bootmenuentryold= $bootmenuentry;
$bootmenuentry = new Application_Model_BootMenuEntries($_POST);
$bootmenuentry->setBootmenuID($bootmenu->getID());
$bootmenuentry->setID($bootmenuentryID);
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() < $oldorder)
$this->bootmenuentryMapper->orderbefore($bootmenuentry, $oldorder);
else
$this->bootmenuentryMapper->orderafter($bootmenuentry, $oldorder);
$this->bootmenuentryMapper->save($bootmenuentry);
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "
";
echo "Message: " . $e->getMessage() . "
";
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error');
}
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/ok');
}
}
$this->view->bootmenuentryForm = $bootmenuentryForm;
}
public function removebootmenuentryAction()
{
//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) . "
";
echo "Message: " . $e->getMessage() . "
";
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/error');
}
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/ok');
}
}