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);
}
//ACL Darf er Bootmenus sehen?
if(!Pbs_Acl::checkRight('booai') && !Pbs_Acl::checkRight('booui'))
$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(Pbs_Acl::checkRight('booai')){
$bootmenu = $this->bootmenuMapper->findBy(array('groupID' => $this->membership->getGroupID()));
foreach ($bootmenu as $bm){
$bm->setCreated(date(Zend_Registry::get('dateformat'),$bm->getCreated()));
$bootmenuID = $bm->getID();
$bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID));
foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry){
if($bootmenuentry->getKcl())
$bootmenuentry->setKcl($bootosMapper->find($bootmenuentry->getBootosID())->getDefaultkcl());
else
$bootmenuentry->setKcl("deactivated (edit Bootmenuentry to activate)");
if($bootmenuentry->getKclappend() == null)
$bootmenuentry->setKclappend("none (edit Bootmenuentry to set KCL-Append)");
$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()));
$bootmenu[0]->setCreated(date(Zend_Registry::get('dateformat'),$bootmenu[0]->getCreated()));
$bootmenuID = $bootmenu[0]->getID();
$bootmenuentries[$bootmenuID] = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID));
foreach ($bootmenuentries[$bootmenuID] as $bootmenuentry){
if($bootmenuentry->getKcl())
$bootmenuentry->setKcl($bootosMapper->find($bootmenuentry->getBootosID())->getDefaultkcl());
else
$bootmenuentry->setKcl("deactivated (edit Bootmenuentry to activate)");
if($bootmenuentry->getKclappend() == null)
$bootmenuentry->setKclappend("none");
$bootmenuentry->setBootosID("[".$bootmenuentry->getBootosID()."] ".$bootosMapper->find($bootmenuentry->getBootosID())->getTitle());
$bootmenuentry->setConfigID("[".$bootmenuentry->getConfigID()."] ".$configMapper->find($bootmenuentry->getConfigID())->gettitle());
}
}
// Search
$search = $this->_request->getParam('search');
$mySearch = new Pbs_Search();
$mySearch->setSearchTerm($search);
$mySearch->setModule('bootmenu');
if($search != ''){
$this->view->search = $mySearch->getSearchTerm();
$bootmenu = $mySearch->search($bootmenu);
}
$this->view->searchform = $mySearch->searchForm();
// Pagination
$pagination = new Pbs_Pagination();
$pagination->setPerPage(5);
$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->page = $pagination->getRequestPage();
$this->view->bootmenulist = $bootmenu;
$this->view->bootmenuentrylist = $bootmenuentries;
}
public function searchAction(){
$this->_redirect('/user/bootmenu/index/search/'.($_GET['search']));
}
public function createbootmenuAction()
{
//ACL Darf er BootMenus erstellen?
if(!Pbs_Acl::checkRight('booc'))
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/forbidden');
if (!isset($_POST["createbootmenu"])){
$bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu','page' => $this->page));
} else {
$bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu','page' => $this->page),$_POST);
if ($bootmenuForm->isValid($_POST)) {
$bootmenu = new Application_Model_BootMenu($_POST);
$bootmenu->setCreated(time());
$bootmenu->setGroupID($this->membership->getGroupID());
$bootmenu->setDefaultbootmenu('0');
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()
{
//ACL Is he allowed to edit BootMenus?
if(!Pbs_Acl::checkRight('booe'))
$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','page' => $this->page));
$bootmenuForm->populate($bootmenu->toArray());
}else{
$bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu','page' => $this->page),$_POST);
if ($bootmenuForm->isValid($_POST)) {
$bootmenuold = $bootmenu;
$bootmenu = new Application_Model_BootMenu($_POST);
$bootmenu->setGroupID($this->membership->getGroupID());
$bootmenu->setCreated(time());
$bootmenu->setID($bootmenuID);
$bootmenu->setDefaultbootmenu($bootmenuold->getDefaultbootmenu());
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()
{
//ACL Is he allowed to delete Bootmenu?
if(!Pbs_Acl::checkRight('bood'))
$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 defaultbootmenuAction()
{
//ACL Is he allowed to set Bootmenu as Default?
if(!Pbs_Acl::checkRight('booe'))
$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.'/modifyresult/error');
$bootmenu = new Application_Model_BootMenu();
$this->bootmenuMapper->find($bootmenuID, $bootmenu);
if($bootmenu->getDefaultbootmenu() == false){
@list($defaultbootmenu) = $this->bootmenuMapper->findBy(array('defaultbootmenu' => '1'));
if($defaultbootmenu != null){
$defaultbootmenu->setDefaultbootmenu(false);
$this->bootmenuMapper->save($defaultbootmenu);
}
$bootmenu->setDefaultbootmenu(true);
$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');
}
public function addbootmenuentryAction()
{
//ACL Darf er BootMenuEntries erstellen?
if(!Pbs_Acl::checkRight('booae'))
$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();
$groupMapper = new Application_Model_GroupMapper();
$groupID = $this->membership->getGroupID();
$groupgroupsMapper = new Application_Model_GroupGroupsMapper();
$parents = array();
$bootoslist = array();
$parents = $groupgroupsMapper->getParentGroups($groupID);
foreach($parents as $k => $parent){
foreach($parent as $p){
$bootos = $bootosMapper->findBy(array("groupID" => $p));
foreach ($bootos as $b)
if($b->getPublic() - $k >= 0 ){
$grouptitle = $groupMapper->find($p)->getTitle();
$bootoslist[$b->getID()] = $b;
$bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle();
}
}
}
$configlist = array('Preset' => array(), 'Custom' => Array());
$configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID));
$configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID()));
if($this->membership->getGroupID() != $this->bootmenuMapper->find($bootmenuID)->getGroupID())
$this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden');
if (!isset($_POST["addbootmenuentry"])){
if(!isset($_POST['kcl']))
$_POST['kcl'] = true;
$bootmenuentryForm = new user_Form_BootmenuEntries(array(
'bootoslist'=> $bootoslist,
'bootosanzeige' => $bootosanzeige,
'maxorder'=> $maxorder,
'configlist'=> $configlist,
'page' => $this->page,
'action' => 'addbootmenuentry',
));
$bootmenuentryForm->populate(array('order' => $maxorder));
unset($_POST['defaultkcl']);
unset($_POST['configID']);
$bootmenuentryForm->populate($_POST);
} else {
$bootmenuentryForm = new user_Form_BootmenuEntries(array(
'bootoslist'=>$bootoslist,
'bootosanzeige' => $bootosanzeige,
'maxorder'=> $maxorder,
'configlist'=>$configlist,
'page' => $this->page,
'action' => 'addbootmenuentry',
),$_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()
{
//ACL Is he allowed to edit BootMenus?
if(!Pbs_Acl::checkRight('booee') && !Pbs_Acl::checkRight('booeem'))
$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();
$groupID = $this->membership->getGroupID();
$groupgroupsMapper = new Application_Model_GroupGroupsMapper();
$groupMapper = new Application_Model_GroupMapper();
$parents = array();
$bootoslist = array();
$parents = $groupgroupsMapper->getParentGroups($groupID);
foreach($parents as $k => $parent){
foreach($parent as $p){
$bootos = $bootosMapper->findBy(array("groupID" => $p));
foreach ($bootos as $b)
if($b->getPublic() - $k >= 0 ){
$grouptitle = $groupMapper->find($p)->getTitle();
$bootoslist[$b->getID()] = $b;
$bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle();
}
}
}
$configlist = array('Preset' => array(), 'Custom' => Array());
$configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID));
$configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID()));
$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"])){
if(!isset($_POST['kcl']))
$_POST['kcl'] = $bootmenuentry->getKcl();
$bootmenuentryForm = new user_Form_BootmenuEntries(array(
'bootoslist'=> $bootoslist,
'bootosanzeige' => $bootosanzeige,
'maxorder'=> $maxorder-1,
'configlist'=> $configlist,
'page' => $this->page,
'action' => 'editbootmenuentry',
));
if(!isset($_POST['configID'])){
$bootmenuentryForm->populate($bootmenuentry->toArray());
}
else{
unset($_POST['defaultkcl']);
unset($_POST['configID']);
$bootmenuentryForm->populate($_POST);
}
}else{
$bootmenuentryForm = new user_Form_BootmenuEntries(array(
'bootoslist'=> $bootoslist,
'bootosanzeige' => $bootosanzeige,
'maxorder'=> $maxorder-1,
'configlist'=> $configlist,
'page' => $this->page,
'action' => 'editbootmenuentry'),$_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()){
//ACL Is he allowed to edit this?
if(!Pbs_Acl::checkRight('booee'))
$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()
{
//ACL Is he allowed to delete Bootos?
if(!Pbs_Acl::checkRight('boode'))
$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');
}
}