cvs: pear /LiveUser/Perm Simple.php /LiveUser/Perm/Storage SQL.php
| From: | Lukas Smith | Date: | Sun, 12 Dec 2004 21:25:56 +0000 |
| Subject: | cvs: pear /LiveUser/Perm Simple.php /LiveUser/Perm/Storage SQL.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-27260@lists.php.net to get a copy of this message | ||
lsmith Sun Dec 12 16:25:56 2004 EDT
Modified files:
/pear/LiveUser/Perm Simple.php
/pear/LiveUser/Perm/Storage SQL.php
Log:
- added new default for config arrays inside static methods so we can fetch them from the admin
classes)
http://cvs.php.net/diff.php/pear/LiveUser/Perm/Simple.php?r1=1.5&r2=1.6&ty=u Index: pear/LiveUser/Perm/Simple.php diff -u pear/LiveUser/Perm/Simple.php:1.5 pear/LiveUser/Perm/Simple.php:1.6 --- pear/LiveUser/Perm/Simple.php:1.5 Mon Dec 6 13:39:16 2004 +++ pear/LiveUser/Perm/Simple.php Sun Dec 12 16:25:52 2004 @@ -30,7 +30,7 @@ * * @author Markus Wolff <wolff@21st.de> * @author Bjoern Kraus <krausbn@php.net> - * @version $Id: Simple.php,v 1.5 2004/12/06 18:39:16 lsmith Exp $ + * @version $Id: Simple.php,v 1.6 2004/12/12 21:25:52 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -78,6 +78,8 @@ */ var $_stack = null; + var $alias = array(); + /** * Class constructor. Feel free to override in backend subclasses. */ @@ -92,6 +94,35 @@ } } } + $this->alias = LiveUser::arrayMergeClobber(LiveUser_Perm_Simple::getAliasDefaults(), $this->alias); + } + + function getAliasDefaults() + { + return array( + 'perm_user_id' => null, + 'auth_user_id' => null, + 'auth_container_name' => null, + 'perm_type' => null, + 'right_id' => null, + 'right_level' => null, + 'area_id' => null, + 'application_id' => null, + 'right_define_name' => null, + 'area_define_name' => null, + 'application_define_name' => null, + 'section_id' => null, + 'section_type' => null, + 'name' => null, + 'description' => null, + 'group_id' => null, + 'group_type' => null, + 'group_define_name' => null, + 'is_active' => null, + 'owner_user_id' => null, + 'owner_group_id' => null, + 'implied_right_id' => null, + ); } /** http://cvs.php.net/diff.php/pear/LiveUser/Perm/Storage/SQL.php?r1=1.2&r2=1.3&ty=u Index: pear/LiveUser/Perm/Storage/SQL.php diff -u pear/LiveUser/Perm/Storage/SQL.php:1.2 pear/LiveUser/Perm/Storage/SQL.php:1.3 --- pear/LiveUser/Perm/Storage/SQL.php:1.2 Sat Nov 13 22:29:08 2004 +++ pear/LiveUser/Perm/Storage/SQL.php Sun Dec 12 16:25:56 2004 @@ -43,7 +43,7 @@ * * @author Lukas Smith <smith@backendmedia.com> * @author Bjoern Kraus <krausbn@php.net> - * @version $Id: SQL.php,v 1.2 2004/11/14 03:29:08 dufuz Exp $ + * @version $Id: SQL.php,v 1.3 2004/12/12 21:25:56 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -92,14 +92,28 @@ 'group_define_name' => array('type' => 'text', 'name' => 'group_define_name') ), 'optional' => array( - 'group_type' => array('type' => 'integer', 'name' => 'group_type'), - 'is_active' => array('type' => 'boolean', 'name' => 'is_active'), + 'group_type' => array('type' => 'integer', 'name' => 'group_type'), + 'is_active' => array('type' => 'boolean', 'name' => 'is_active'), 'owner_user_id' => array('type' => 'integer', 'name' => 'owner_user_id'), 'owner_group_id' => array('type' => 'integer', 'name' => 'owner_group_id') ) ); /** + * + * @access public + * @var array + */ + var $tables = array(); + + /** + * + * @access public + * @var array + */ + var $fields = array(); + + /** * Constructor * * @access protected @@ -109,6 +123,196 @@ function LiveUser_Perm_Storage_MDB2(&$confArray, &$storageConf) { $this->LiveUser_Perm_Storage($confArray, $storageConf); + + $this->tables = LiveUser::arrayMergeClobber(LiveUser_Perm_Simple::getTableDefaults(), $this->tables); + $this->fields = LiveUser::arrayMergeClobber(LiveUser_Perm_Simple::getFieldDefaults(), $this->fields); + } + + function getTableDefaults() + { + return array( + 'perm_users' => array( + 'fields' => array( + 'perm_user_id' => 'seq', + 'auth_user_id' => true, + 'auth_container_name' => true, + 'perm_type' => false, + ), + 'joins' => array( + 'userrights' => 'perm_user_id', + 'groupusers' => 'perm_user_id', + ), + 'id' => 'perm_user_id', + ), + 'userrights' => array( + 'fields' => array( + 'perm_user_id' => true, + 'right_id' => true, + 'right_level' => false, + ), + 'joins' => array( + 'perm_users' => 'perm_user_id', + 'rights' => 'right_id', + ), + ), + 'rights' => array( + 'fields' => array( + 'right_id' => 'seq', + 'area_id' => false, + 'right_define_name' => false, + ), + 'joins' => array( + 'areas' => 'area_id', + 'userrights' => 'right_id', + 'grouprights' => 'right_id', + 'rights_implied' => array( + 'right_id' => 'right_id', + 'right_id' => 'implied_right_id', + ), + 'translations' => array( + 'right_id' => 'section_id', + LIVEUSER_SECTION_RIGHT => 'section_type', + ), + ), + 'id' => 'right_id', + ), + 'rights_implied' => array( + 'fields' => array( + 'right_id' => true, + 'implied_right_id' => true, + ), + 'joins' => array( + 'rights' => array( + 'right_id' => 'right_id', + 'implied_right_id' => 'right_id', + ), + ), + ), + 'translations' => array( + 'fields' => array( + 'section_id' => true, + 'section_type' => true, + 'name' => false, + 'description' => false, + ), + 'joins' => array( + 'rights' => array( + 'section_id' => 'right_id', + 'section_type' => LIVEUSER_SECTION_RIGHT, + ), + 'areas' => array( + 'section_id' => 'area_id', + 'section_type' => LIVEUSER_SECTION_AREA, + ), + 'applications' => array( + 'section_id' => 'application_id', + 'section_type' => LIVEUSER_SECTION_APPLICATION, + ), + 'groups' => array( + 'section_id' => 'group_id', + 'section_type' => LIVEUSER_SECTION_GROUP, + ), + ), + ), + 'areas' => array( + 'fields' => array( + 'area_id' => 'seq', + 'application_id' => false, + 'area_define_name' => false, + ), + 'joins' => array( + 'rights' => 'area_id', + 'applications' => 'application_id', + 'translations' => array( + 'area_id' => 'section_id', + LIVEUSER_SECTION_AREA => 'section_type', + ), + ), + 'id' => 'area_id', + ), + 'applications' => array( + 'fields' => array( + 'application_id' => 'seq', + 'application_define_name' => false, + ), + 'joins' => array( + 'areas' => 'application_id', + 'translations' => array( + 'application_id' => 'section_id', + LIVEUSER_SECTION_APPLICATION => 'section_type', + ), + ), + 'id' => 'application_id', + ), + 'groups' => array( + 'fields' => array( + 'group_id' => 'seq', + 'group_type' => false, + 'group_define_name' => false, + 'is_active' => false, + 'owner_user_id' => false, + 'owner_group_id' => false, + ), + 'joins' => array( + 'groupusers' => 'group_id', + 'grouprights' => 'group_id', + 'translations' => array( + 'group_id' => 'section_id', + LIVEUSER_SECTION_GROUP => 'section_type', + ), + ), + 'id' => 'group_id', + ), + 'groupusers' => array( + 'fields' => array( + 'perm_user_id' => true, + 'group_id' => true, + ), + 'joins' => array( + 'groups' => 'group_id', + 'perm_users' => 'perm_user_id', + ), + ), + 'grouprights' => array( + 'fields' => array( + 'group_id' => true, + 'right_id' => true, + 'right_level' => false, + ), + 'joins' => array( + 'rights' => 'right_id', + 'groups' => 'group_id', + ), + ), + ); + } + + function getFieldDefaults() + { + return array( + 'perm_user_id' => 'integer', + 'auth_user_id' => 'integer', + 'auth_container_name' => 'text', + 'perm_type' => 'integer', + 'right_id' => 'integer', + 'right_level' => 'integer', + 'area_id' => 'integer', + 'application_id' => 'integer', + 'right_define_name' => 'text', + 'area_define_name' => 'text', + 'application_define_name' => 'text', + 'section_id' => 'integer', + 'section_type' => 'integer', + 'name' => 'text', + 'description' => 'text', + 'group_id' => 'integer', + 'group_type' => 'integer', + 'group_define_name' => 'text', + 'is_active' => 'boolean', + 'owner_user_id' => 'integer', + 'owner_group_id' => 'integer', + 'implied_right_id' => 'integer', + ); } /**
http://cvs.php.net/diff.php/pear/LiveUser/Perm/Simple.php?r1=1.5&r2=1.6&ty=u Index: pear/LiveUser/Perm/Simple.php diff -u pear/LiveUser/Perm/Simple.php:1.5 pear/LiveUser/Perm/Simple.php:1.6 --- pear/LiveUser/Perm/Simple.php:1.5 Mon Dec 6 13:39:16 2004 +++ pear/LiveUser/Perm/Simple.php Sun Dec 12 16:25:52 2004 @@ -30,7 +30,7 @@ * * @author Markus Wolff <wolff@21st.de> * @author Bjoern Kraus <krausbn@php.net> - * @version $Id: Simple.php,v 1.5 2004/12/06 18:39:16 lsmith Exp $ + * @version $Id: Simple.php,v 1.6 2004/12/12 21:25:52 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -78,6 +78,8 @@ */ var $_stack = null; + var $alias = array(); + /** * Class constructor. Feel free to override in backend subclasses. */ @@ -92,6 +94,35 @@ } } } + $this->alias = LiveUser::arrayMergeClobber(LiveUser_Perm_Simple::getAliasDefaults(), $this->alias); + } + + function getAliasDefaults() + { + return array( + 'perm_user_id' => null, + 'auth_user_id' => null, + 'auth_container_name' => null, + 'perm_type' => null, + 'right_id' => null, + 'right_level' => null, + 'area_id' => null, + 'application_id' => null, + 'right_define_name' => null, + 'area_define_name' => null, + 'application_define_name' => null, + 'section_id' => null, + 'section_type' => null, + 'name' => null, + 'description' => null, + 'group_id' => null, + 'group_type' => null, + 'group_define_name' => null, + 'is_active' => null, + 'owner_user_id' => null, + 'owner_group_id' => null, + 'implied_right_id' => null, + ); } /** http://cvs.php.net/diff.php/pear/LiveUser/Perm/Storage/SQL.php?r1=1.2&r2=1.3&ty=u Index: pear/LiveUser/Perm/Storage/SQL.php diff -u pear/LiveUser/Perm/Storage/SQL.php:1.2 pear/LiveUser/Perm/Storage/SQL.php:1.3 --- pear/LiveUser/Perm/Storage/SQL.php:1.2 Sat Nov 13 22:29:08 2004 +++ pear/LiveUser/Perm/Storage/SQL.php Sun Dec 12 16:25:56 2004 @@ -43,7 +43,7 @@ * * @author Lukas Smith <smith@backendmedia.com> * @author Bjoern Kraus <krausbn@php.net> - * @version $Id: SQL.php,v 1.2 2004/11/14 03:29:08 dufuz Exp $ + * @version $Id: SQL.php,v 1.3 2004/12/12 21:25:56 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -92,14 +92,28 @@ 'group_define_name' => array('type' => 'text', 'name' => 'group_define_name') ), 'optional' => array( - 'group_type' => array('type' => 'integer', 'name' => 'group_type'), - 'is_active' => array('type' => 'boolean', 'name' => 'is_active'), + 'group_type' => array('type' => 'integer', 'name' => 'group_type'), + 'is_active' => array('type' => 'boolean', 'name' => 'is_active'), 'owner_user_id' => array('type' => 'integer', 'name' => 'owner_user_id'), 'owner_group_id' => array('type' => 'integer', 'name' => 'owner_group_id') ) ); /** + * + * @access public + * @var array + */ + var $tables = array(); + + /** + * + * @access public + * @var array + */ + var $fields = array(); + + /** * Constructor * * @access protected @@ -109,6 +123,196 @@ function LiveUser_Perm_Storage_MDB2(&$confArray, &$storageConf) { $this->LiveUser_Perm_Storage($confArray, $storageConf); + + $this->tables = LiveUser::arrayMergeClobber(LiveUser_Perm_Simple::getTableDefaults(), $this->tables); + $this->fields = LiveUser::arrayMergeClobber(LiveUser_Perm_Simple::getFieldDefaults(), $this->fields); + } + + function getTableDefaults() + { + return array( + 'perm_users' => array( + 'fields' => array( + 'perm_user_id' => 'seq', + 'auth_user_id' => true, + 'auth_container_name' => true, + 'perm_type' => false, + ), + 'joins' => array( + 'userrights' => 'perm_user_id', + 'groupusers' => 'perm_user_id', + ), + 'id' => 'perm_user_id', + ), + 'userrights' => array( + 'fields' => array( + 'perm_user_id' => true, + 'right_id' => true, + 'right_level' => false, + ), + 'joins' => array( + 'perm_users' => 'perm_user_id', + 'rights' => 'right_id', + ), + ), + 'rights' => array( + 'fields' => array( + 'right_id' => 'seq', + 'area_id' => false, + 'right_define_name' => false, + ), + 'joins' => array( + 'areas' => 'area_id', + 'userrights' => 'right_id', + 'grouprights' => 'right_id', + 'rights_implied' => array( + 'right_id' => 'right_id', + 'right_id' => 'implied_right_id', + ), + 'translations' => array( + 'right_id' => 'section_id', + LIVEUSER_SECTION_RIGHT => 'section_type', + ), + ), + 'id' => 'right_id', + ), + 'rights_implied' => array( + 'fields' => array( + 'right_id' => true, + 'implied_right_id' => true, + ), + 'joins' => array( + 'rights' => array( + 'right_id' => 'right_id', + 'implied_right_id' => 'right_id', + ), + ), + ), + 'translations' => array( + 'fields' => array( + 'section_id' => true, + 'section_type' => true, + 'name' => false, + 'description' => false, + ), + 'joins' => array( + 'rights' => array( + 'section_id' => 'right_id', + 'section_type' => LIVEUSER_SECTION_RIGHT, + ), + 'areas' => array( + 'section_id' => 'area_id', + 'section_type' => LIVEUSER_SECTION_AREA, + ), + 'applications' => array( + 'section_id' => 'application_id', + 'section_type' => LIVEUSER_SECTION_APPLICATION, + ), + 'groups' => array( + 'section_id' => 'group_id', + 'section_type' => LIVEUSER_SECTION_GROUP, + ), + ), + ), + 'areas' => array( + 'fields' => array( + 'area_id' => 'seq', + 'application_id' => false, + 'area_define_name' => false, + ), + 'joins' => array( + 'rights' => 'area_id', + 'applications' => 'application_id', + 'translations' => array( + 'area_id' => 'section_id', + LIVEUSER_SECTION_AREA => 'section_type', + ), + ), + 'id' => 'area_id', + ), + 'applications' => array( + 'fields' => array( + 'application_id' => 'seq', + 'application_define_name' => false, + ), + 'joins' => array( + 'areas' => 'application_id', + 'translations' => array( + 'application_id' => 'section_id', + LIVEUSER_SECTION_APPLICATION => 'section_type', + ), + ), + 'id' => 'application_id', + ), + 'groups' => array( + 'fields' => array( + 'group_id' => 'seq', + 'group_type' => false, + 'group_define_name' => false, + 'is_active' => false, + 'owner_user_id' => false, + 'owner_group_id' => false, + ), + 'joins' => array( + 'groupusers' => 'group_id', + 'grouprights' => 'group_id', + 'translations' => array( + 'group_id' => 'section_id', + LIVEUSER_SECTION_GROUP => 'section_type', + ), + ), + 'id' => 'group_id', + ), + 'groupusers' => array( + 'fields' => array( + 'perm_user_id' => true, + 'group_id' => true, + ), + 'joins' => array( + 'groups' => 'group_id', + 'perm_users' => 'perm_user_id', + ), + ), + 'grouprights' => array( + 'fields' => array( + 'group_id' => true, + 'right_id' => true, + 'right_level' => false, + ), + 'joins' => array( + 'rights' => 'right_id', + 'groups' => 'group_id', + ), + ), + ); + } + + function getFieldDefaults() + { + return array( + 'perm_user_id' => 'integer', + 'auth_user_id' => 'integer', + 'auth_container_name' => 'text', + 'perm_type' => 'integer', + 'right_id' => 'integer', + 'right_level' => 'integer', + 'area_id' => 'integer', + 'application_id' => 'integer', + 'right_define_name' => 'text', + 'area_define_name' => 'text', + 'application_define_name' => 'text', + 'section_id' => 'integer', + 'section_type' => 'integer', + 'name' => 'text', + 'description' => 'text', + 'group_id' => 'integer', + 'group_type' => 'integer', + 'group_define_name' => 'text', + 'is_active' => 'boolean', + 'owner_user_id' => 'integer', + 'owner_group_id' => 'integer', + 'implied_right_id' => 'integer', + ); } /**