diff options
author | michael pereira | 2011-04-08 03:21:00 +0200 |
---|---|---|
committer | michael pereira | 2011-04-08 03:21:00 +0200 |
commit | 906ef8eff141f91bf1628d844db357ca0e29abf6 (patch) | |
tree | 120f879d217758145db760261d451543c4230486 | |
parent | acl merge (diff) | |
download | pbs2-906ef8eff141f91bf1628d844db357ca0e29abf6.tar.gz pbs2-906ef8eff141f91bf1628d844db357ca0e29abf6.tar.xz pbs2-906ef8eff141f91bf1628d844db357ca0e29abf6.zip |
defaultbootmenu fertig
-rw-r--r-- | application/models/BootMenu.php | 10 | ||||
-rw-r--r-- | application/models/BootMenuMapper.php | 8 | ||||
-rw-r--r-- | application/modules/user/controllers/BootmenuController.php | 39 | ||||
-rw-r--r-- | application/modules/user/views/scripts/bootmenu/index.phtml | 22 | ||||
-rw-r--r-- | pbs-newdata.sql | 12 | ||||
-rw-r--r-- | pbs.sql | 1 | ||||
-rw-r--r-- | public/media/img/default.png | bin | 0 -> 307 bytes | |||
-rw-r--r-- | public/media/img/default_grey.png | bin | 0 -> 2786 bytes |
8 files changed, 80 insertions, 12 deletions
diff --git a/application/models/BootMenu.php b/application/models/BootMenu.php index da4e4d1..c25dad7 100644 --- a/application/models/BootMenu.php +++ b/application/models/BootMenu.php @@ -7,6 +7,7 @@ class Application_Model_BootMenu protected $_groupID; protected $_title; protected $_created; + protected $_defaultbootmenu; public function __construct(array $options = null) { @@ -90,6 +91,15 @@ class Application_Model_BootMenu $this->_created = $_created; return $this; } + public function getDefaultbootmenu() + { + return $this->_defaultbootmenu; + } + public function setDefaultbootmenu($_defaultbootmenu) + { + $this->_defaultbootmenu = $_defaultbootmenu; + return $this; + } /** * Returns current data as associative array using ReflectionClass * diff --git a/application/models/BootMenuMapper.php b/application/models/BootMenuMapper.php index 1043897..1730181 100644 --- a/application/models/BootMenuMapper.php +++ b/application/models/BootMenuMapper.php @@ -74,7 +74,7 @@ class Application_Model_BootMenuMapper public function save(Application_Model_BootMenu $botmenu) { - $data = array('bootmenuID'=> $botmenu->getID() ,'membershipID'=> $botmenu->getMembershipID(), 'groupID'=> $botmenu->getGroupID() ,'title'=> $botmenu->getTitle() ,'created'=> $botmenu->getCreated() ); + $data = array('bootmenuID'=> $botmenu->getID() ,'membershipID'=> $botmenu->getMembershipID(), 'groupID'=> $botmenu->getGroupID() ,'title'=> $botmenu->getTitle() ,'created'=> $botmenu->getCreated(), 'defaultbootmenu' => $botmenu->getDefaultbootmenu()); if (null === ($id = $botmenu->getID()) ) { unset($data['bootmenuID']); @@ -103,10 +103,10 @@ class Application_Model_BootMenuMapper if($botmenu == null){ $botmenu = new Application_Model_BootMenu(); - $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created); + $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created)->setDefaultbootmenu($row->defaultbootmenu); return $botmenu; }else{ - $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created); + $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created)->setDefaultbootmenu($row->defaultbootmenu); } @@ -119,7 +119,7 @@ class Application_Model_BootMenuMapper foreach ($resultSet as $row) { $entry = new Application_Model_BootMenu(); - $entry->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created); + $entry->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created)->setDefault($row->default); $entries[] = $entry; } diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php index 466ecb8..a79a770 100644 --- a/application/modules/user/controllers/BootmenuController.php +++ b/application/modules/user/controllers/BootmenuController.php @@ -102,7 +102,7 @@ class user_BootmenuController extends Zend_Controller_Action // Pagination $pagination = new Pbs_Pagination(); - $pagination->setPerPage(2); + $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:'')); @@ -138,6 +138,7 @@ class user_BootmenuController extends Zend_Controller_Action $bootmenu = new Application_Model_BootMenu($_POST); $bootmenu->setCreated(time()); $bootmenu->setGroupID($this->membership->getGroupID()); + $bootmenu->setDefaultbootmenu('0'); try{ $this->bootmenuMapper->save($bootmenu); @@ -186,6 +187,7 @@ class user_BootmenuController extends Zend_Controller_Action $bootmenu->setGroupID($this->membership->getGroupID()); $bootmenu->setCreated(time()); $bootmenu->setID($bootmenuID); + $bootmenu->setDefaultbootmenu($bootmenuold->getDefaultbootmenu()); try { $this->bootmenuMapper->save($bootmenu); @@ -232,6 +234,41 @@ class user_BootmenuController extends Zend_Controller_Action $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) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error'); + } + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/ok'); + + } + public function addbootmenuentryAction() { diff --git a/application/modules/user/views/scripts/bootmenu/index.phtml b/application/modules/user/views/scripts/bootmenu/index.phtml index 74d0666..2e04618 100644 --- a/application/modules/user/views/scripts/bootmenu/index.phtml +++ b/application/modules/user/views/scripts/bootmenu/index.phtml @@ -16,10 +16,30 @@ <?php if(count($this->bootmenulist)==0) echo "There are no BootMenus to display." ?> <?php foreach ($this->bootmenulist as $bootmenu): ?> - <div class='element'> + <?php + $class=''; + if($bootmenu->getDefaultbootmenu() == true) + $class= 'highlight'; + ?> + <div class='element<?php echo " $class";?>'> <div class='number'><?php echo $this->escape($bootmenu->getID()); ?></div> <div class='content'> <div class='actions'> + <a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'bootmenu', + 'action' => 'defaultbootmenu', + 'bootmenuID' => $bootmenu->getID(), + 'page' => $this->page + ), + 'default', + true, false) ?>"> + <?php if($bootmenu->getDefaultbootmenu() == true): ?> + <img src='/media/img/default.png' alt='Checked as default'/></a> + <?php else: ?> + <img src='/media/img/default_grey.png' alt='Not checked as default' /></a> + <?php endif; ?> <a href="<?php echo $this->url( array( 'module' => 'user', diff --git a/pbs-newdata.sql b/pbs-newdata.sql index d57a837..0954204 100644 --- a/pbs-newdata.sql +++ b/pbs-newdata.sql @@ -112,12 +112,12 @@ INSERT INTO `pbs_pool` (`poolID`, `groupID`, `title`, `description`, `location`) (4, 1, 'Pool 4', 'Description 4', '2 OG'); -- Adding Bootmenus -INSERT INTO `pbs_bootmenu` (`bootmenuID`, `membershipID`, `groupID`, `title`, `created`) VALUES -(1, NULL, 1, 'Bootmenu 1', '1299694422'), -(2, NULL, 1, 'Bootmenu 2', '1299694433'), -(3, NULL, 1, 'Bootmenu 3', '1299694441'), -(4, NULL, 1, 'Bootmenu 4', '1299694454'), -(5, NULL, 1, 'Bootmenu 5', '1299694461'); +INSERT INTO `pbs_bootmenu` (`bootmenuID`, `membershipID`, `groupID`, `title`, `created`,`defaultbootmenu`) VALUES +(1, NULL, 1, 'Bootmenu 1', '1299694422', '0'), +(2, NULL, 1, 'Bootmenu 2', '1299694433', '0'), +(3, NULL, 1, 'Bootmenu 3', '1299694441', '0'), +(4, NULL, 1, 'Bootmenu 4', '1299694454', '1'), +(5, NULL, 1, 'Bootmenu 5', '1299694461', '0'); -- Adding BootOs to BootMenus INSERT INTO `pbs_bootmenuentries` (`bootmenuentriesID`, `bootosID`, `bootmenuID`, `title`, `kcl`, `kclappend`, `configID`, `order`) VALUES @@ -161,6 +161,7 @@ CREATE TABLE IF NOT EXISTS `pbs_bootmenu` ( `groupID` int(11), `title` varchar(30) NOT NULL, `created` varchar(14) NOT NULL, + `defaultbootmenu` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`bootmenuID`), KEY `groupID` (`groupID`), KEY `membershipID` (`membershipID`) diff --git a/public/media/img/default.png b/public/media/img/default.png Binary files differnew file mode 100644 index 0000000..feff985 --- /dev/null +++ b/public/media/img/default.png diff --git a/public/media/img/default_grey.png b/public/media/img/default_grey.png Binary files differnew file mode 100644 index 0000000..ade8fde --- /dev/null +++ b/public/media/img/default_grey.png |