diff options
-rw-r--r-- | application/models/DbTable/RightCategory.php | 10 | ||||
-rw-r--r-- | application/models/Right.php | 60 | ||||
-rw-r--r-- | application/models/RightCategory.php | 94 | ||||
-rw-r--r-- | application/models/RightCategoryMapper.php | 103 | ||||
-rw-r--r-- | application/models/Role.php | 60 | ||||
-rw-r--r-- | application/models/RoleMapper.php | 6 | ||||
-rw-r--r-- | application/modules/dev/controllers/RoleController.php | 1 | ||||
-rw-r--r-- | application/modules/dev/forms/RoleAdd.php | 4 | ||||
-rw-r--r-- | application/modules/dev/forms/RoleEdit.php | 19 | ||||
-rw-r--r-- | application/modules/dev/views/scripts/role/show.phtml | 2 | ||||
-rw-r--r-- | application/modules/user/controllers/GroupController.php | 12 | ||||
-rw-r--r-- | application/modules/user/controllers/RoleController.php | 8 | ||||
-rw-r--r-- | application/modules/user/forms/RoleAdd.php | 4 | ||||
-rw-r--r-- | application/modules/user/forms/RoleEdit.php | 11 | ||||
-rw-r--r-- | application/modules/user/views/scripts/role/show.phtml | 2 | ||||
-rw-r--r-- | pbs-newdata.sql | 21 | ||||
-rw-r--r-- | pbs.sql | 18 |
17 files changed, 363 insertions, 72 deletions
diff --git a/application/models/DbTable/RightCategory.php b/application/models/DbTable/RightCategory.php new file mode 100644 index 0000000..65150ba --- /dev/null +++ b/application/models/DbTable/RightCategory.php @@ -0,0 +1,10 @@ +<?php + +class Application_Model_DbTable_RightCategory extends Zend_Db_Table_Abstract +{ + + protected $_name = 'pbs_rightcategory'; + + +} + diff --git a/application/models/Right.php b/application/models/Right.php index c0df29c..874453c 100644 --- a/application/models/Right.php +++ b/application/models/Right.php @@ -3,6 +3,7 @@ class Application_Model_Right { protected $_rightID; + protected $_rightcategoryID; protected $_title; protected $_description; @@ -53,6 +54,15 @@ class Application_Model_Right $this->_rightID = $_rightID; return $this; } + public function getRightcategoryID() + { + return $this->_rightcategoryID; + } + public function setRightcategoryID($_rightcategoryID) + { + $this->_rightID = $_rightcategoryID; + return $this; + } public function getTitle() { return $this->_title; @@ -71,39 +81,39 @@ class Application_Model_Right $this->_description = $_description; return $this; } - /** - * Returns current data as associative array using ReflectionClass - * - * @return array Returns associative array containing model data + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data * If "get"-method not available (our primary keys) the function getID() is called - */ - public function toArray() - { - $reflectionClass = new ReflectionClass($this); - $properties = $reflectionClass->getProperties(); - $result = array(); - foreach ($properties as $property) { - $key = $property->name; - if (substr($key, 0, 1) != '_' && $this->$key !== null) { - $method = 'get' . ucfirst($key); - if ($reflectionClass->hasMethod($method)) { - $result[$key] = $this->$method(); - } else { - $result[$key] = $this->$key; - } - } + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { $key = substr($key, 1); - $method = 'get' . ucfirst($key); + $method = 'get' . ucfirst($key); if ($reflectionClass->hasMethod($method)) { $result[$key] = $this->$method(); }else{ $result[$key] = $this->getID(); } - + } - } - return $result; - } + } + return $result; + } } diff --git a/application/models/RightCategory.php b/application/models/RightCategory.php new file mode 100644 index 0000000..42bcbb8 --- /dev/null +++ b/application/models/RightCategory.php @@ -0,0 +1,94 @@ +<?php + +class Application_Model_RightCategory +{ + protected $_rightcategoryID; + protected $_title; + + public function __construct(array $options = null) + { + if (is_array($options)) { + $this->setOptions($options); + } + } + + public function __set($name, $value) + { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid rightcategory property'); + } + $this->$method($value); + } + + public function __get($name) + { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid rightcategory property'); + } + return $this->$method(); + } + + public function setOptions(array $options) + { + $methods = get_class_methods($this); + foreach ($options as $key => $value) { + $method = 'set' . ucfirst($key); + if (in_array($method, $methods)) { + $this->$method($value); + } + } + return $this; + } + + public function getID() + { + return $this->_rightcategoryID; + } + public function setID($_rightcategoryID) + { + $this->_rightID = $_rightcategoryID; + return $this; + } + public function getTitle() + { + return $this->_title; + } + public function setTitle($_title) + { + $this->_title = $_title; + return $this; + } + + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } + +} + diff --git a/application/models/RightCategoryMapper.php b/application/models/RightCategoryMapper.php new file mode 100644 index 0000000..1a3d093 --- /dev/null +++ b/application/models/RightCategoryMapper.php @@ -0,0 +1,103 @@ +<?php + +class Application_Model_RightCategoryMapper +{ + + protected $_dbTable; + + public function findBy($criteria, $value) + { + try{ + $db = Zend_Db_Table::getDefaultAdapter(); + $select = $this->getDbTable()->select() + ->from($this->_dbTable) + ->where($criteria . ' = ?', $value); + $stmt = $select->query(); + $result = $stmt->fetchAll(); + return $result; + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + public function setDbTable($dbTable) + { + if (is_string($dbTable)) { + $dbTable = new $dbTable(); + } + + if (!$dbTable instanceof Zend_Db_Table_Abstract) { + throw new Exception('Invalid table data gateway provided'); + } + + $this->_dbTable = $dbTable; + + return $this; + } + + public function getDbTable() + { + if (null === $this->_dbTable) { + $this->setDbTable('Application_Model_DbTable_RightCategory'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_RightCategory $rightCategory) + { + + $data = array('rightcategoryID'=> $rightCategory->getID() ,'title'=> $rightCategory->getTitle() ); + + if (null === ($id = $rightCategory->getID()) ) { + unset($data['rightcategoryID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('rightcategoryID = ?' => $id)); + } + } + + public function delete(Application_Model_RightCategory $rightCategory) + { + if (null === ($id = $rightCategory->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('rightcategoryID = ?' => $id)); + } + } + + public function find($id) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $rightCategory = new Application_Model_RightCategory(); + $rightCategory->setID($row->rightcategoryID)->setTitle($row->title); + return $rightCategory; + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_RightCategory(); + + $entry->setID($row->rightcategoryID)->setTitle($row->title); + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_RightCategory $v1,Application_Model_RightCategory $v2){ + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1,$vv2); + } + +} + diff --git a/application/models/Role.php b/application/models/Role.php index 28f0af1..49ed377 100644 --- a/application/models/Role.php +++ b/application/models/Role.php @@ -6,6 +6,7 @@ class Application_Model_Role protected $_groupID; protected $_title; protected $_description; + protected $_inheritance; public function __construct(array $options = null) { @@ -81,39 +82,48 @@ class Application_Model_Role $this->_description = $_description; return $this; } - /** - * Returns current data as associative array using ReflectionClass - * - * @return array Returns associative array containing model data + public function getInheritance() + { + return $this->_inheritance; + } + public function setInheritance($_inheritance) + { + $this->_inheritance = $_inheritance; + return $this; + } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data * If "get"-method not available (our primary keys) the function getID() is called - */ - public function toArray() - { - $reflectionClass = new ReflectionClass($this); - $properties = $reflectionClass->getProperties(); - $result = array(); - foreach ($properties as $property) { - $key = $property->name; - if (substr($key, 0, 1) != '_' && $this->$key !== null) { - $method = 'get' . ucfirst($key); - if ($reflectionClass->hasMethod($method)) { - $result[$key] = $this->$method(); - } else { - $result[$key] = $this->$key; - } - } + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { $key = substr($key, 1); - $method = 'get' . ucfirst($key); + $method = 'get' . ucfirst($key); if ($reflectionClass->hasMethod($method)) { $result[$key] = $this->$method(); }else{ $result[$key] = $this->getID(); } - + } - } - return $result; - } + } + return $result; + } } diff --git a/application/models/RoleMapper.php b/application/models/RoleMapper.php index 561a7d4..4001e3e 100644 --- a/application/models/RoleMapper.php +++ b/application/models/RoleMapper.php @@ -47,7 +47,7 @@ class Application_Model_RoleMapper public function save(Application_Model_Role $role) { - $data = array('roleID'=> $role->getID() ,'groupID'=> $role->getGroupID() ,'title'=> $role->getTitle() ,'description'=> $role->getDescription() ); + $data = array('roleID'=> $role->getID() ,'groupID'=> $role->getGroupID() ,'title'=> $role->getTitle() ,'description'=> $role->getDescription(), 'inheritance' => $role->getInheritance() ); if (null === ($id = $role->getID()) ) { unset($data['roleID']); @@ -75,7 +75,7 @@ class Application_Model_RoleMapper $row = $result->current(); $role = new Application_Model_Role(); - $role->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description); + $role->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description)->setInheritance($row->inheritance); return $role; } @@ -86,7 +86,7 @@ class Application_Model_RoleMapper foreach ($resultSet as $row) { $entry = new Application_Model_Role(); - $entry->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description); + $entry->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description)->setInheritance($row->inheritance); $entries[] = $entry; } diff --git a/application/modules/dev/controllers/RoleController.php b/application/modules/dev/controllers/RoleController.php index 709d623..65989b6 100644 --- a/application/modules/dev/controllers/RoleController.php +++ b/application/modules/dev/controllers/RoleController.php @@ -75,6 +75,7 @@ class dev_RoleController extends Zend_Controller_Action $_POST['title'] = $role->getTitle(); $_POST['description'] = $role->getDescription(); $_POST['groupID'] = $role->getGroupID(); + $_POST['inheritance'] = $role->getInheritance(); $editForm = new dev_Form_RoleEdit(); } else { $editForm = new dev_Form_RoleEdit($_POST); diff --git a/application/modules/dev/forms/RoleAdd.php b/application/modules/dev/forms/RoleAdd.php index d773b17..7aae426 100644 --- a/application/modules/dev/forms/RoleAdd.php +++ b/application/modules/dev/forms/RoleAdd.php @@ -31,6 +31,10 @@ class dev_Form_RoleAdd extends Zend_Form 'label' => 'Description:', )); + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + $this->addElement('submit', 'add', array( 'required' => false, 'ignore' => true, diff --git a/application/modules/dev/forms/RoleEdit.php b/application/modules/dev/forms/RoleEdit.php index 2c79050..c0617b7 100644 --- a/application/modules/dev/forms/RoleEdit.php +++ b/application/modules/dev/forms/RoleEdit.php @@ -3,9 +3,9 @@ class dev_Form_RoleEdit extends Zend_Form { - public function init() - { - $this->setName("RoleEdit"); + public function init() + { + $this->setName("RoleEdit"); $this->setMethod('post'); $this->addElement('text', 'title', array( @@ -28,6 +28,17 @@ class dev_Form_RoleEdit extends Zend_Form 'value' => $_POST['description'], )); + if($_POST['inheritance'] == 1) { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + 'checked' => 'checked', + )); + } else { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + } + $this->addElement('hidden', 'groupID', array( 'value' => $_POST['groupID'], )); @@ -44,7 +55,7 @@ class dev_Form_RoleEdit extends Zend_Form 'label' => 'Cancel', 'onclick' => 'location.href="/dev/role/"', )); - } + } } diff --git a/application/modules/dev/views/scripts/role/show.phtml b/application/modules/dev/views/scripts/role/show.phtml index 93f2782..38e6023 100644 --- a/application/modules/dev/views/scripts/role/show.phtml +++ b/application/modules/dev/views/scripts/role/show.phtml @@ -13,10 +13,12 @@ if($this->roleID) { <tr> <th>Title</th> <th>Description</th> + <th>Inheritance</th> </tr> <tr class="entry"> <td><?php echo $this->role->getTitle(); ?></td> <td><?php echo $this->role->getDescription(); ?></td> + <td><?php if($this->role->getInheritance() == 1) echo "yes"; else echo "no"; ?></td> </tr> </table> <br /> diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php index 3180ebd..1ceb844 100644 --- a/application/modules/user/controllers/GroupController.php +++ b/application/modules/user/controllers/GroupController.php @@ -110,7 +110,15 @@ class User_GroupController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "<br/>"; return; } - $this->_helper->redirector('', 'group'); + if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show')) { + if(strpos($_SERVER['HTTP_REFERER'], '/groupID/')) { + $this->_redirect('/user/group/groupID/' . $groupID); + } else { + $this->_helper->redirector('show', 'group'); + } + } else { + $this->_helper->redirector('showall', 'group'); + } return; } } @@ -210,7 +218,7 @@ class User_GroupController extends Zend_Controller_Action } if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show')) { if(strpos($_SERVER['HTTP_REFERER'], '/groupID/')) { - $this->_redirect('/user/group/show/groupID/' . $groupID); + $this->_redirect('/user/group/showall'); } else { $this->_helper->redirector('changemembership', 'person'); } diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index b3795de..62d1550 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -76,10 +76,12 @@ class User_RoleController extends Zend_Controller_Action $_POST['title'] = $role->getTitle(); $_POST['description'] = $role->getDescription(); $_POST['groupID'] = $role->getGroupID(); + $_POST['inheritance'] = $role->getInheritance(); $editForm = new user_Form_RoleEdit(array('roleID' => $roleID)); } else { $editForm = new user_Form_RoleEdit(array('roleID' => $roleID), $_POST); if ($editForm->isValid($_POST)) { + $role = new Application_Model_Role($_POST); $role->setID($this->_request->getParam('roleID')); try { @@ -90,7 +92,11 @@ class User_RoleController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "<br/>"; return; } - $this->_helper->redirector('', 'role'); + if(strpos($_SERVER['HTTP_REFERER'], '/user/role/show/roleID')) { + $this->_redirect('/user/role/show/roleID/' . $roleID); + } else { + $this->_helper->redirector('', 'role'); + } return; } } diff --git a/application/modules/user/forms/RoleAdd.php b/application/modules/user/forms/RoleAdd.php index 3b5200b..a7e43a7 100644 --- a/application/modules/user/forms/RoleAdd.php +++ b/application/modules/user/forms/RoleAdd.php @@ -31,6 +31,10 @@ class user_Form_RoleAdd extends Zend_Form 'label' => 'Description:', )); + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + $this->addElement('submit', 'add', array( 'required' => false, 'ignore' => true, diff --git a/application/modules/user/forms/RoleEdit.php b/application/modules/user/forms/RoleEdit.php index 170a2f9..848dba3 100644 --- a/application/modules/user/forms/RoleEdit.php +++ b/application/modules/user/forms/RoleEdit.php @@ -33,6 +33,17 @@ class user_Form_RoleEdit extends Zend_Form 'value' => $_POST['description'], )); + if($_POST['inheritance'] == 1) { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + 'checked' => 'checked', + )); + } else { + $this->addElement('checkbox', 'inheritance', array( + 'label' => 'Inheritance:', + )); + } + $this->addElement('hidden', 'groupID', array( 'value' => $_POST['groupID'], )); diff --git a/application/modules/user/views/scripts/role/show.phtml b/application/modules/user/views/scripts/role/show.phtml index 9abab1a..8213e73 100644 --- a/application/modules/user/views/scripts/role/show.phtml +++ b/application/modules/user/views/scripts/role/show.phtml @@ -13,10 +13,12 @@ if($this->roleID) { <tr> <th>Title</th> <th>Description</th> + <th>Inheritance</th> </tr> <tr class="entry"> <td><?php echo $this->role->getTitle(); ?></td> <td><?php echo $this->role->getDescription(); ?></td> + <td><?php if($this->role->getInheritance() == 1) echo "yes"; else echo "no"; ?></td> </tr> </table> <br /> diff --git a/pbs-newdata.sql b/pbs-newdata.sql index 9a447ef..a85fdf2 100644 --- a/pbs-newdata.sql +++ b/pbs-newdata.sql @@ -36,16 +36,21 @@ INSERT INTO `pbs`.`pbs_groupgroups` (`parentID`, `groupID`) VALUES (3, 10); -- Adding role -INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`) VALUES (1, '1', 'Role 1-Group1', NULL); -INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`) VALUES (2, '1', 'Role 2-Group1', NULL); -INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`) VALUES (3, '2', 'Role 1-Group2', NULL); -INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`) VALUES (4, '2', 'Role 2-Group2', NULL); +INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`, `inheritance`) VALUES (1, '1', 'Role 1-Group1', NULL, 0); +INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`, `inheritance`) VALUES (2, '1', 'Role 2-Group1', NULL, 0); +INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`, `inheritance`) VALUES (3, '2', 'Role 1-Group2', NULL, 0); +INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`, `inheritance`) VALUES (4, '2', 'Role 2-Group2', NULL, 0); -- Adding right -INSERT INTO `pbs_right` (`rightID`, `title`, `description`) VALUES (1, 'Recht 1', NULL); -INSERT INTO `pbs_right` (`rightID`, `title`, `description`) VALUES (2, 'Recht 2', NULL); -INSERT INTO `pbs_right` (`rightID`, `title`, `description`) VALUES (3, 'Recht 3', NULL); -INSERT INTO `pbs_right` (`rightID`, `title`, `description`) VALUES (4, 'Recht 4', NULL); +INSERT INTO `pbs_rightcategory` (`rightcategoryID`, `title`) VALUES +(1, 'rightcategory 1'), +(2, 'rightcategory 2'), +(3, 'rightcategory 3'); + +INSERT INTO `pbs_right` (`rightID`, `rightcategoryID`, `title`, `description`) VALUES (1, 1, 'Recht 1', NULL); +INSERT INTO `pbs_right` (`rightID`, `rightcategoryID`, `title`, `description`) VALUES (2, 1, 'Recht 2', NULL); +INSERT INTO `pbs_right` (`rightID`, `rightcategoryID`, `title`, `description`) VALUES (3, 2, 'Recht 3', NULL); +INSERT INTO `pbs_right` (`rightID`, `rightcategoryID`, `title`, `description`) VALUES (4, 3, 'Recht 4', NULL); INSERT INTO `pbs_rightroles` (`roleID`, `rightID`) VALUES (1, 1), @@ -9,23 +9,33 @@ CREATE TABLE IF NOT EXISTS `pbs_group` ( PRIMARY KEY (`groupID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; +CREATE TABLE IF NOT EXISTS `pbs_rightcategory` ( + `rightcategoryID` int(11) NOT NULL AUTO_INCREMENT, + `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`rightcategoryID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `pbs_right` ( `rightID` int(11) NOT NULL AUTO_INCREMENT, + `rightcategoryID` int(11) NOT NULL, `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(140) COLLATE utf8_unicode_ci, - PRIMARY KEY (`rightID`) + `description` varchar(140) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`rightID`), + KEY `rightcategoryID` (`rightcategoryID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; +ALTER TABLE `pbs_right` + ADD CONSTRAINT `pbs_right_ibfk_1` FOREIGN KEY (`rightcategoryID`) REFERENCES `pbs_rightcategory` (`rightcategoryID`) ON DELETE CASCADE; CREATE TABLE IF NOT EXISTS `pbs_role` ( `roleID` int(11) NOT NULL AUTO_INCREMENT, `groupID` int(11) NOT NULL, `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `description` varchar(140) COLLATE utf8_unicode_ci, + `description` varchar(140) COLLATE utf8_unicode_ci DEFAULT NULL, + `inheritance` tinyint(1) NOT NULL, PRIMARY KEY (`roleID`), KEY `groupID` (`groupID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ; ALTER TABLE `pbs_role` ADD CONSTRAINT `pbs_role_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE; |