cvs: pear /Perm_LiveUser/Admin/Perm Common.php DB_Common.php MDB_Common.php /Perm_LiveUser/Admin/Perm/Container DB_Complex.php DB_Medium.php
MDB_Complex.php MDB_Medium.php MDB_Simple.php
| From: | Arnaud Limbourg | Date: | Thu, 04 Dec 2003 16:16:59 +0000 |
| Subject: | cvs: pear /Perm_LiveUser/Admin/Perm Common.php DB_Common.php MDB_Common.php /Perm_LiveUser/Admin/Perm/Container DB_Complex.php DB_Medium.php MDB_Complex.php MDB_Medium.php MDB_Simple.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-14613@lists.php.net to get a copy of this message | ||
arnaud Thu Dec 4 11:16:59 2003 EDT
Modified files:
/pear/Perm_LiveUser/Admin/Perm Common.php DB_Common.php
MDB_Common.php
/pear/Perm_LiveUser/Admin/Perm/Container DB_Complex.php
DB_Medium.php
MDB_Complex.php
MDB_Medium.php
MDB_Simple.php
Log:
* rework of the admin classes. They now extend each other from complex to simple
* rename getAllUsers to getUsers
Index: pear/Perm_LiveUser/Admin/Perm/Common.php diff -u pear/Perm_LiveUser/Admin/Perm/Common.php:1.10 pear/Perm_LiveUser/Admin/Perm/Common.php:1.11 --- pear/Perm_LiveUser/Admin/Perm/Common.php:1.10 Fri Sep 26 10:30:44 2003 +++ pear/Perm_LiveUser/Admin/Perm/Common.php Thu Dec 4 11:16:58 2003 @@ -49,12 +49,24 @@ * * @author Markus Wolff <wolff@21st.de> * @author Bjoern Kraus <krausbn@php.net> - * @version $Id: Common.php,v 1.10 2003/09/26 14:30:44 lsmith Exp $ + * @version $Id: Common.php,v 1.11 2003/12/04 16:16:58 arnaud Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_Common { /** + * Indicates if backend module initialized correctly. If yes, + * TRUE, if not false. Backend module won't initialize if the + * init value (usually an object or resource handle that + * identifies the backend to be used) is not of the required + * type. + * + * @var boolean + * @access private + */ + var $init_ok = false; + + /** * Class constructor. Feel free to override in backend subclasses. * * @access protected Index: pear/Perm_LiveUser/Admin/Perm/DB_Common.php diff -u pear/Perm_LiveUser/Admin/Perm/DB_Common.php:1.33 pear/Perm_LiveUser/Admin/Perm/DB_Common.php:1.34 --- pear/Perm_LiveUser/Admin/Perm/DB_Common.php:1.33 Thu Dec 4 04:20:20 2003 +++ pear/Perm_LiveUser/Admin/Perm/DB_Common.php Thu Dec 4 11:16:58 2003 @@ -33,7 +33,7 @@ * DB based containers used to maintain * the permission database. * - * @version $Id: DB_Common.php,v 1.33 2003/12/04 09:20:20 arnaud Exp $ + * @version $Id: DB_Common.php,v 1.34 2003/12/04 16:16:58 arnaud Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_DB_Common extends LiveUser_Admin_Perm_Common @@ -65,18 +65,6 @@ var $prefix = 'liveuser_'; /** - * Indicates if backend module initialized correctly. If yes, - * TRUE, if not false. Backend module won't initialize if the - * init value (usually an object or resource handle that - * identifies the backend to be used) is not of the required - * type. - * - * @var boolean - * @access private - */ - var $init_ok = false; - - /** * @var string * @access private */ @@ -86,12 +74,11 @@ * Constructor * * @access protected - * @param mixed Array or PEAR::DB object. - * @param array not used for now + * @param array full liveuser configuration array * @return void * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_DB_Common(&$connectOptions, $conf = array()) + function &LiveUser_Admin_Perm_DB_Common(&$connectOptions) { if (is_array($connectOptions)) { foreach ($connectOptions as $key => $value) { Index: pear/Perm_LiveUser/Admin/Perm/MDB_Common.php diff -u pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.18 pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.19 --- pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.18 Thu Dec 4 03:57:58 2003 +++ pear/Perm_LiveUser/Admin/Perm/MDB_Common.php Thu Dec 4 11:16:58 2003 @@ -33,7 +33,7 @@ * MDB based containers used to maintain * the permission database. * - * @version $Id: MDB_Common.php,v 1.18 2003/12/04 08:57:58 arnaud Exp $ + * @version $Id: MDB_Common.php,v 1.19 2003/12/04 16:16:58 arnaud Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_MDB_Common extends LiveUser_Admin_Perm_Common @@ -54,17 +54,6 @@ * @var string */ var $_language = ''; - /** - * Indicates if backend module initialized correctly. If yes, - * TRUE, if not false. Backend module won't initialize if the - * init value (usually an object or resource handle that - * identifies the backend to be used) is not of the required - * type. - * - * @var boolean - * @access private - */ - var $init_ok = false; /** * @var string @@ -79,12 +68,11 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB(&$connectOptions) { if (is_array($connectOptions)) { foreach ($connectOptions as $key => $value) { Index: pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php:1.26 pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php:1.27 --- pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php:1.26 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php Thu Dec 4 11:16:59 2003 @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/DB_Common.php'; +require_once 'LiveUser/Admin/Perm/Container/DB_Medium.php'; /** * This is a PEAR::DB admin class for the LiveUser package. @@ -45,10 +45,10 @@ * @author Christian Dickmann <dickmann@php.net> * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> - * @version $Id: DB_Complex.php,v 1.26 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: DB_Complex.php,v 1.27 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_DB_Complex extends LiveUser_Admin_Perm_DB_Common +class LiveUser_Admin_Perm_Container_DB_Complex extends LiveUser_Admin_Perm_Container_DB_Medium { /** * Constructor @@ -57,12 +57,10 @@ * @param mixed Array or PEAR::DB object. * @param array configuration array not used atm * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_DB_Complex(&$connectOptions, $conf = array()) + function &LiveUser_Admin_Perm_Container_DB_Complex(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_DB($connectOptions, $conf); - $this->container_type = 'DB_Complex'; + $this->LiveUser_Admin_Perm_Container_DB_Medium($connectOptions); } /** @@ -283,58 +281,6 @@ } /** - * Activate group - * - * @access public - * @param integer id of group - * @return mixed boolean or DB Error object or false - */ - function activateGroup($group_id) - { - if (!is_numeric($group_id)) { - return false; - } - - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "Y" - WHERE - group_id = ' . (int)$group_id; - - $result = $this->dbc->query($query); - - if (DB::isError($result)) { - return $result; - }; - - return true; - } - - /** - * Deactivate group - * - * @access public - * @param integer id of group - * @return mixed boolean or DB Error object - */ - function deactivateGroup($group_id) - { - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "N" - WHERE - group_id = ' . (int)$group_id; - $result = $this->dbc->query($query); - if (DB::isError($result)) { - return $result; - }; - - return true; - } - - /** * Imply right * * @access public @@ -435,93 +381,6 @@ return true; } - // XXX - // function *Scope - - /** - * Grand right to group - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or DB Error object - */ - function grantGroupRight($group_id, $right_id, $right_level) - { - $query = 'INSERT INTO - ' . $this->prefix . 'grouprights - (group_id, right_id, right_level) - VALUES - ( - ' . (int)$group_id . ', - ' . (int)$right_id . ', - ' . (int)$right_level . ' - )'; - - $result = $this->dbc->query($query); - - if (DB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Revoke right from group - * - * @access public - * @param integer id of group - * @param integer id of right - * @return mixed boolean or DB Error object - */ - function revokeGroupRight($group_id, $right_id) - { - $query = 'DELETE FROM - ' . $this->prefix . 'grouprights - WHERE - group_id = ' . (int)$group_id . ' AND - right_id = ' . (int)$right_id; - $result = $this->dbc->query($query); - if (DB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Update right level of groupRight - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or DB Error object - */ - function updateGroupRight($group_id, $right_id, $right_level) - { - $query = 'UPDATE - ' . $this->prefix . 'grouprights - SET - right_level = ' . (int)$right_level . ' - WHERE - group_id = ' . (int)$group_id . ' AND - right_id = ' . (int)$right_id; - - $result = $this->dbc->query($query); - - if (DB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - /** * Add User to Group * Index: pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php:1.21 pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php:1.22 --- pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php:1.21 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php Thu Dec 4 11:16:59 2003 @@ -17,8 +17,8 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA /** - * DB_Medium permission administration class - * + * Container for medium-complexity rights managements. + * * @package LiveUser * @category authentication */ @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/DB_Common.php'; +require_once 'LiveUser/Admin/Perm/Container/DB_Simple.php'; /** * This is a PEAR::DB admin class for the LiveUser package. @@ -46,23 +46,21 @@ * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: DB_Medium.php,v 1.21 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: DB_Medium.php,v 1.22 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_DB_Medium extends LiveUser_Admin_Perm_DB_Common +class LiveUser_Admin_Perm_Container_DB_Medium extends LiveUser_Admin_Perm_Container_DB_Simple { /** * Constructor * * @access protected - * @param mixed Array or PEAR::DB object. + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_DB_Medium(&$connectOptions, $conf = array()) + function &LiveUser_Admin_Perm_Container_DB_Medium(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_DB($connectOptions, $conf); - $this->container_type = 'DB_Medium'; + $this->LiveUser_Admin_Perm_Container_DB_Simple($connectOptions); } /** @@ -274,9 +272,10 @@ * @access public * @param integer id of group * @param integer id of right + * @param integer right level * @return mixed boolean or DB Error object */ - function grantGroupRight($group_id, $right_id) + function grantGroupRight($group_id, $right_id, $right_level = 1) { $query = 'INSERT INTO ' . $this->prefix . 'grouprights @@ -285,7 +284,7 @@ ( ' . (int)$group_id . ', ' . (int)$right_id . ', - 1 + ' . (int)$right_level . ' )'; $result = $this->dbc->query($query); @@ -325,6 +324,35 @@ } /** + * Update right level of groupRight + * + * @access public + * @param integer id of group + * @param integer id of right + * @param integer right level + * @return mixed boolean or DB Error object + */ + function updateGroupRight($group_id, $right_id, $right_level) + { + $query = 'UPDATE + ' . $this->prefix . 'grouprights + SET + right_level = ' . (int)$right_level . ' + WHERE + group_id = ' . (int)$group_id . ' AND + right_id = ' . (int)$right_id; + + $result = $this->dbc->query($query); + + if (DB::isError($result)) { + return $result; + }; + + // Job done ... + return true; + } + + /** * Add User to Group * * @access public @@ -401,13 +429,13 @@ translations.name as name, translations.comment as comment, groups.is_active as is_active - FROM'; + FROM '; if (isset($options['where_user_id'])) { - $query .= ' ' . $this->prefix . 'groupusers groupusers,'; + $query .= $this->prefix . 'groupusers groupusers,'; } - $query .= ' ' . $this->prefix . 'groups groups, + $query .= $this->prefix . 'groups groups, ' . $this->prefix . 'translations translations WHERE'; @@ -462,4 +490,4 @@ return $_groups; } } -?> +?> \ No newline at end of file Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.15 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.16 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.15 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php Thu Dec 4 11:16:59 2003 @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/MDB_Common.php'; +require_once 'LiveUser/Admin/Perm/MDB_Complex.php'; /** * This is a PEAR::MDB admin class for the LiveUser package. @@ -45,10 +45,10 @@ * @author Christian Dickmann <dickmann@php.net> * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> - * @version $Id: MDB_Complex.php,v 1.15 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: MDB_Complex.php,v 1.16 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_MDB_Complex extends LiveUser_Admin_Perm_MDB_Common +class LiveUser_Admin_Perm_Container_MDB_Complex extends LiveUser_Admin_Perm_Container_MDB_Medium { /** * Constructor @@ -57,14 +57,12 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB_Complex(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB_Complex(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_MDB($connectOptions, $conf); + $this->LiveUser_Admin_Perm_Container_MDB_Medium($connectOptions); $this->container_type = 'MDB_Complex'; } @@ -284,59 +282,6 @@ return true; } - - /** - * Activate group - * - * @access public - * @param integer id of group - * @return mixed boolean or MDB Error object or false - */ - function activateGroup($group_id) - { - if (!is_numeric($group_id)) { - return false; - } - - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "'.$this->dbc->getValue('boolean', true).'" - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id); - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - return true; - } - - /** - * Deactivate group - * - * @access public - * @param integer id of group - * @return mixed boolean or MDB Error object - */ - function deactivateGroup($group_id) - { - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "N" - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id); - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - return true; - } - /** * Imply right * @@ -438,173 +383,6 @@ return true; } - // XXX - // function *Scope - - /** - * Update right level of userRight - * - * @access public - * @param string id of user - * @param integer id of right - * @param integer right level - * @return mixed boolean or MDB Error object - */ - function updateUserRight($authId, $right_id, $right_level) - { - $query = 'UPDATE - ' . $this->prefix . 'userrights - SET - right_level = ' . $this->dbc->getValue('integer', $right_level) . ' - WHERE - perm_user_id = ' . $this->_getPermUserId($authId) . ' AND - right_id = ' . $this->dbc->getValue('integer', $right_id); - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Grand right to group - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or MDB Error object - */ - function grantGroupRight($group_id, $right_id, $right_level) - { - $query = 'INSERT INTO - ' . $this->prefix . 'grouprights - (group_id, right_id, right_level) - VALUES - ( - ' . $this->dbc->getValue('integer', $group_id) . ', - ' . $this->dbc->getValue('integer', $right_id) . ', - ' . $this->dbc->getValue('integer', $right_level) . ' - )'; - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Revoke right from group - * - * @access public - * @param integer id of group - * @param integer id of right - * @return mixed boolean or MDB Error object - */ - function revokeGroupRight($group_id, $right_id) - { - $query = 'DELETE FROM - ' . $this->prefix . 'grouprights - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND - right_id = ' . $this->dbc->getValue('integer', $right_id); - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Update right level of groupRight - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or MDB Error object - */ - function updateGroupRight($group_id, $right_id, $right_level) - { - $query = 'UPDATE - ' . $this->prefix . 'grouprights - SET - right_level = ' . $this->dbc->getValue('integer', $right_level) . ' - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND - right_id = ' . $this->dbc->getValue('integer', $right_id); - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Add User to Group - * - * @access public - * @param string id of user - * @param integer id of group - * @return mixed boolean or MDB Error object - */ - function addUserToGroup($authId, $group_id) - { - $query = 'INSERT INTO - ' . $this->prefix . 'groupusers - (group_id, perm_user_id) - VALUES - ( - ' . $this->dbc->getValue('integer', $group_id) . ', - ' . $this->_getPermUserId($authId) . ' - )'; - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Remove User from Group - * - * @access public - * @param string id of user - * @param integer id of group - * @return mixed boolean or MDB Error object - */ - function removeUserFromGroup($authId, $group_id) - { - $query = 'DELETE FROM - ' . $this->prefix . 'groupusers - WHERE - perm_user_id = ' . $this->_getPermUserId($authId) . ' AND - group_id = ' . $this->dbc->getValue('integer', $group_id); - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - /** * Get list of all groups * @@ -737,4 +515,4 @@ return $result; } } -?> +?> \ No newline at end of file Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.13 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.14 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.13 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php Thu Dec 4 11:16:59 2003 @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/MDB_Common.php'; +require_once 'LiveUser/Admin/Perm/Container/MDB_Simple.php'; /** * This is a PEAR::MDB admin class for the LiveUser package. @@ -46,10 +46,10 @@ * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: MDB_Medium.php,v 1.13 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: MDB_Medium.php,v 1.14 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_MDB_Medium extends LiveUser_Admin_Perm_MDB_Common +class LiveUser_Admin_Perm_Container_MDB_Medium extends LiveUser_Admin_Perm_Container_MDB_Simple { /** * Constructor @@ -58,14 +58,12 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB_Medium(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB_Medium(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_MDB($connectOptions, $conf); + $this->LiveUser_Admin_Perm_Container_MDB_Simple($connectOptions); $this->container_type = 'MDB_Medium'; } @@ -264,7 +262,9 @@ is_active = "N" WHERE group_id = ' . $this->dbc->getValue('integer', $group_id); + $result = $this->dbc->query($query); + if (MDB::isError($result)) { return $result; }; @@ -278,9 +278,10 @@ * @access public * @param integer id of group * @param integer id of right + * @param integer right level * @return mixed boolean or MDB Error object */ - function grantGroupRight($group_id, $right_id) + function grantGroupRight($group_id, $right_id, $right_level = 1) { $query = 'INSERT INTO ' . $this->prefix . 'grouprights @@ -289,7 +290,7 @@ ( ' . $this->dbc->getValue('integer', $group_id) . ', ' . $this->dbc->getValue('integer', $right_id) . ', - 1 + ' . $this->dbc->getValue('integer', $right_level) . ' )'; $result = $this->dbc->query($query); @@ -317,6 +318,33 @@ WHERE group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND right_id = ' . $this->dbc->getValue('integer', $right_id); + $result = $this->dbc->query($query); + if (MDB::isError($result)) { + return $result; + }; + + // Job done ... + return true; + } + + /** + * Update right level of groupRight + * + * @access public + * @param integer id of group + * @param integer id of right + * @param integer right level + * @return mixed boolean or MDB Error object + */ + function updateGroupRight($group_id, $right_id, $right_level) + { + $query = 'UPDATE + ' . $this->prefix . 'grouprights + SET + right_level = ' . $this->dbc->getValue('integer', $right_level) . ' + WHERE + group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND + right_id = ' . $this->dbc->getValue('integer', $right_id); $result = $this->dbc->query($query); @@ -383,6 +411,38 @@ return true; } + // XXX + // function *Scope + + /** + * Update right level of userRight + * + * @access public + * @param string id of user + * @param integer id of right + * @param integer right level + * @return mixed boolean or MDB Error object + */ + function updateUserRight($authId, $right_id, $right_level) + { + $query = 'UPDATE + ' . $this->prefix . 'userrights + SET + right_level = ' . $this->dbc->getValue('integer', $right_level) . ' + WHERE + perm_user_id = ' . $this->_getPermUserId($authId) . ' AND + right_id = ' . $this->dbc->getValue('integer', $right_id); + + $result = $this->dbc->query($query); + + if (MDB::isError($result)) { + return $result; + }; + + // Job done ... + return true; + } + /** * Get list of all groups * @@ -467,4 +527,4 @@ return $_groups; } } -?> +?> \ No newline at end of file Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php:1.10 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php:1.11 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php:1.10 Wed Nov 26 05:59:01 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php Thu Dec 4 11:16:59 2003 @@ -48,7 +48,7 @@ * This class is only experimental. API may change. Use it at your own risk. * * @author Björn Kraus <krausbn@php.net> - * @version $Id: MDB_Simple.php,v 1.10 2003/11/26 10:59:01 lsmith Exp $ + * @version $Id: MDB_Simple.php,v 1.11 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser * @category authentication */ @@ -61,15 +61,13 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB_Simple(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB_Simple(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_MDB($connectOptions, $conf); + $this->LiveUser_Admin_Perm_Container_MDB($connectOptions); $this->container_type = 'MDB_Simple'; } } -?> +?> \ No newline at end of file
Index: pear/Perm_LiveUser/Admin/Perm/Common.php diff -u pear/Perm_LiveUser/Admin/Perm/Common.php:1.10 pear/Perm_LiveUser/Admin/Perm/Common.php:1.11 --- pear/Perm_LiveUser/Admin/Perm/Common.php:1.10 Fri Sep 26 10:30:44 2003 +++ pear/Perm_LiveUser/Admin/Perm/Common.php Thu Dec 4 11:16:58 2003 @@ -49,12 +49,24 @@ * * @author Markus Wolff <wolff@21st.de> * @author Bjoern Kraus <krausbn@php.net> - * @version $Id: Common.php,v 1.10 2003/09/26 14:30:44 lsmith Exp $ + * @version $Id: Common.php,v 1.11 2003/12/04 16:16:58 arnaud Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_Common { /** + * Indicates if backend module initialized correctly. If yes, + * TRUE, if not false. Backend module won't initialize if the + * init value (usually an object or resource handle that + * identifies the backend to be used) is not of the required + * type. + * + * @var boolean + * @access private + */ + var $init_ok = false; + + /** * Class constructor. Feel free to override in backend subclasses. * * @access protected Index: pear/Perm_LiveUser/Admin/Perm/DB_Common.php diff -u pear/Perm_LiveUser/Admin/Perm/DB_Common.php:1.33 pear/Perm_LiveUser/Admin/Perm/DB_Common.php:1.34 --- pear/Perm_LiveUser/Admin/Perm/DB_Common.php:1.33 Thu Dec 4 04:20:20 2003 +++ pear/Perm_LiveUser/Admin/Perm/DB_Common.php Thu Dec 4 11:16:58 2003 @@ -33,7 +33,7 @@ * DB based containers used to maintain * the permission database. * - * @version $Id: DB_Common.php,v 1.33 2003/12/04 09:20:20 arnaud Exp $ + * @version $Id: DB_Common.php,v 1.34 2003/12/04 16:16:58 arnaud Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_DB_Common extends LiveUser_Admin_Perm_Common @@ -65,18 +65,6 @@ var $prefix = 'liveuser_'; /** - * Indicates if backend module initialized correctly. If yes, - * TRUE, if not false. Backend module won't initialize if the - * init value (usually an object or resource handle that - * identifies the backend to be used) is not of the required - * type. - * - * @var boolean - * @access private - */ - var $init_ok = false; - - /** * @var string * @access private */ @@ -86,12 +74,11 @@ * Constructor * * @access protected - * @param mixed Array or PEAR::DB object. - * @param array not used for now + * @param array full liveuser configuration array * @return void * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_DB_Common(&$connectOptions, $conf = array()) + function &LiveUser_Admin_Perm_DB_Common(&$connectOptions) { if (is_array($connectOptions)) { foreach ($connectOptions as $key => $value) { Index: pear/Perm_LiveUser/Admin/Perm/MDB_Common.php diff -u pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.18 pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.19 --- pear/Perm_LiveUser/Admin/Perm/MDB_Common.php:1.18 Thu Dec 4 03:57:58 2003 +++ pear/Perm_LiveUser/Admin/Perm/MDB_Common.php Thu Dec 4 11:16:58 2003 @@ -33,7 +33,7 @@ * MDB based containers used to maintain * the permission database. * - * @version $Id: MDB_Common.php,v 1.18 2003/12/04 08:57:58 arnaud Exp $ + * @version $Id: MDB_Common.php,v 1.19 2003/12/04 16:16:58 arnaud Exp $ * @package LiveUser */ class LiveUser_Admin_Perm_MDB_Common extends LiveUser_Admin_Perm_Common @@ -54,17 +54,6 @@ * @var string */ var $_language = ''; - /** - * Indicates if backend module initialized correctly. If yes, - * TRUE, if not false. Backend module won't initialize if the - * init value (usually an object or resource handle that - * identifies the backend to be used) is not of the required - * type. - * - * @var boolean - * @access private - */ - var $init_ok = false; /** * @var string @@ -79,12 +68,11 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB(&$connectOptions) { if (is_array($connectOptions)) { foreach ($connectOptions as $key => $value) { Index: pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php:1.26 pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php:1.27 --- pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php:1.26 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/DB_Complex.php Thu Dec 4 11:16:59 2003 @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/DB_Common.php'; +require_once 'LiveUser/Admin/Perm/Container/DB_Medium.php'; /** * This is a PEAR::DB admin class for the LiveUser package. @@ -45,10 +45,10 @@ * @author Christian Dickmann <dickmann@php.net> * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> - * @version $Id: DB_Complex.php,v 1.26 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: DB_Complex.php,v 1.27 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_DB_Complex extends LiveUser_Admin_Perm_DB_Common +class LiveUser_Admin_Perm_Container_DB_Complex extends LiveUser_Admin_Perm_Container_DB_Medium { /** * Constructor @@ -57,12 +57,10 @@ * @param mixed Array or PEAR::DB object. * @param array configuration array not used atm * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_DB_Complex(&$connectOptions, $conf = array()) + function &LiveUser_Admin_Perm_Container_DB_Complex(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_DB($connectOptions, $conf); - $this->container_type = 'DB_Complex'; + $this->LiveUser_Admin_Perm_Container_DB_Medium($connectOptions); } /** @@ -283,58 +281,6 @@ } /** - * Activate group - * - * @access public - * @param integer id of group - * @return mixed boolean or DB Error object or false - */ - function activateGroup($group_id) - { - if (!is_numeric($group_id)) { - return false; - } - - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "Y" - WHERE - group_id = ' . (int)$group_id; - - $result = $this->dbc->query($query); - - if (DB::isError($result)) { - return $result; - }; - - return true; - } - - /** - * Deactivate group - * - * @access public - * @param integer id of group - * @return mixed boolean or DB Error object - */ - function deactivateGroup($group_id) - { - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "N" - WHERE - group_id = ' . (int)$group_id; - $result = $this->dbc->query($query); - if (DB::isError($result)) { - return $result; - }; - - return true; - } - - /** * Imply right * * @access public @@ -435,93 +381,6 @@ return true; } - // XXX - // function *Scope - - /** - * Grand right to group - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or DB Error object - */ - function grantGroupRight($group_id, $right_id, $right_level) - { - $query = 'INSERT INTO - ' . $this->prefix . 'grouprights - (group_id, right_id, right_level) - VALUES - ( - ' . (int)$group_id . ', - ' . (int)$right_id . ', - ' . (int)$right_level . ' - )'; - - $result = $this->dbc->query($query); - - if (DB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Revoke right from group - * - * @access public - * @param integer id of group - * @param integer id of right - * @return mixed boolean or DB Error object - */ - function revokeGroupRight($group_id, $right_id) - { - $query = 'DELETE FROM - ' . $this->prefix . 'grouprights - WHERE - group_id = ' . (int)$group_id . ' AND - right_id = ' . (int)$right_id; - $result = $this->dbc->query($query); - if (DB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Update right level of groupRight - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or DB Error object - */ - function updateGroupRight($group_id, $right_id, $right_level) - { - $query = 'UPDATE - ' . $this->prefix . 'grouprights - SET - right_level = ' . (int)$right_level . ' - WHERE - group_id = ' . (int)$group_id . ' AND - right_id = ' . (int)$right_id; - - $result = $this->dbc->query($query); - - if (DB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - /** * Add User to Group * Index: pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php:1.21 pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php:1.22 --- pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php:1.21 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/DB_Medium.php Thu Dec 4 11:16:59 2003 @@ -17,8 +17,8 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA /** - * DB_Medium permission administration class - * + * Container for medium-complexity rights managements. + * * @package LiveUser * @category authentication */ @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/DB_Common.php'; +require_once 'LiveUser/Admin/Perm/Container/DB_Simple.php'; /** * This is a PEAR::DB admin class for the LiveUser package. @@ -46,23 +46,21 @@ * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: DB_Medium.php,v 1.21 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: DB_Medium.php,v 1.22 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_DB_Medium extends LiveUser_Admin_Perm_DB_Common +class LiveUser_Admin_Perm_Container_DB_Medium extends LiveUser_Admin_Perm_Container_DB_Simple { /** * Constructor * * @access protected - * @param mixed Array or PEAR::DB object. + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_DB_Medium(&$connectOptions, $conf = array()) + function &LiveUser_Admin_Perm_Container_DB_Medium(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_DB($connectOptions, $conf); - $this->container_type = 'DB_Medium'; + $this->LiveUser_Admin_Perm_Container_DB_Simple($connectOptions); } /** @@ -274,9 +272,10 @@ * @access public * @param integer id of group * @param integer id of right + * @param integer right level * @return mixed boolean or DB Error object */ - function grantGroupRight($group_id, $right_id) + function grantGroupRight($group_id, $right_id, $right_level = 1) { $query = 'INSERT INTO ' . $this->prefix . 'grouprights @@ -285,7 +284,7 @@ ( ' . (int)$group_id . ', ' . (int)$right_id . ', - 1 + ' . (int)$right_level . ' )'; $result = $this->dbc->query($query); @@ -325,6 +324,35 @@ } /** + * Update right level of groupRight + * + * @access public + * @param integer id of group + * @param integer id of right + * @param integer right level + * @return mixed boolean or DB Error object + */ + function updateGroupRight($group_id, $right_id, $right_level) + { + $query = 'UPDATE + ' . $this->prefix . 'grouprights + SET + right_level = ' . (int)$right_level . ' + WHERE + group_id = ' . (int)$group_id . ' AND + right_id = ' . (int)$right_id; + + $result = $this->dbc->query($query); + + if (DB::isError($result)) { + return $result; + }; + + // Job done ... + return true; + } + + /** * Add User to Group * * @access public @@ -401,13 +429,13 @@ translations.name as name, translations.comment as comment, groups.is_active as is_active - FROM'; + FROM '; if (isset($options['where_user_id'])) { - $query .= ' ' . $this->prefix . 'groupusers groupusers,'; + $query .= $this->prefix . 'groupusers groupusers,'; } - $query .= ' ' . $this->prefix . 'groups groups, + $query .= $this->prefix . 'groups groups, ' . $this->prefix . 'translations translations WHERE'; @@ -462,4 +490,4 @@ return $_groups; } } -?> +?> \ No newline at end of file Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.15 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.16 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php:1.15 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Complex.php Thu Dec 4 11:16:59 2003 @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/MDB_Common.php'; +require_once 'LiveUser/Admin/Perm/MDB_Complex.php'; /** * This is a PEAR::MDB admin class for the LiveUser package. @@ -45,10 +45,10 @@ * @author Christian Dickmann <dickmann@php.net> * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> - * @version $Id: MDB_Complex.php,v 1.15 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: MDB_Complex.php,v 1.16 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_MDB_Complex extends LiveUser_Admin_Perm_MDB_Common +class LiveUser_Admin_Perm_Container_MDB_Complex extends LiveUser_Admin_Perm_Container_MDB_Medium { /** * Constructor @@ -57,14 +57,12 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB_Complex(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB_Complex(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_MDB($connectOptions, $conf); + $this->LiveUser_Admin_Perm_Container_MDB_Medium($connectOptions); $this->container_type = 'MDB_Complex'; } @@ -284,59 +282,6 @@ return true; } - - /** - * Activate group - * - * @access public - * @param integer id of group - * @return mixed boolean or MDB Error object or false - */ - function activateGroup($group_id) - { - if (!is_numeric($group_id)) { - return false; - } - - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "'.$this->dbc->getValue('boolean', true).'" - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id); - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - return true; - } - - /** - * Deactivate group - * - * @access public - * @param integer id of group - * @return mixed boolean or MDB Error object - */ - function deactivateGroup($group_id) - { - $query = 'UPDATE - ' . $this->prefix . 'groups - SET - is_active = "N" - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id); - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - return true; - } - /** * Imply right * @@ -438,173 +383,6 @@ return true; } - // XXX - // function *Scope - - /** - * Update right level of userRight - * - * @access public - * @param string id of user - * @param integer id of right - * @param integer right level - * @return mixed boolean or MDB Error object - */ - function updateUserRight($authId, $right_id, $right_level) - { - $query = 'UPDATE - ' . $this->prefix . 'userrights - SET - right_level = ' . $this->dbc->getValue('integer', $right_level) . ' - WHERE - perm_user_id = ' . $this->_getPermUserId($authId) . ' AND - right_id = ' . $this->dbc->getValue('integer', $right_id); - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Grand right to group - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or MDB Error object - */ - function grantGroupRight($group_id, $right_id, $right_level) - { - $query = 'INSERT INTO - ' . $this->prefix . 'grouprights - (group_id, right_id, right_level) - VALUES - ( - ' . $this->dbc->getValue('integer', $group_id) . ', - ' . $this->dbc->getValue('integer', $right_id) . ', - ' . $this->dbc->getValue('integer', $right_level) . ' - )'; - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Revoke right from group - * - * @access public - * @param integer id of group - * @param integer id of right - * @return mixed boolean or MDB Error object - */ - function revokeGroupRight($group_id, $right_id) - { - $query = 'DELETE FROM - ' . $this->prefix . 'grouprights - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND - right_id = ' . $this->dbc->getValue('integer', $right_id); - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Update right level of groupRight - * - * @access public - * @param integer id of group - * @param integer id of right - * @param integer right level - * @return mixed boolean or MDB Error object - */ - function updateGroupRight($group_id, $right_id, $right_level) - { - $query = 'UPDATE - ' . $this->prefix . 'grouprights - SET - right_level = ' . $this->dbc->getValue('integer', $right_level) . ' - WHERE - group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND - right_id = ' . $this->dbc->getValue('integer', $right_id); - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Add User to Group - * - * @access public - * @param string id of user - * @param integer id of group - * @return mixed boolean or MDB Error object - */ - function addUserToGroup($authId, $group_id) - { - $query = 'INSERT INTO - ' . $this->prefix . 'groupusers - (group_id, perm_user_id) - VALUES - ( - ' . $this->dbc->getValue('integer', $group_id) . ', - ' . $this->_getPermUserId($authId) . ' - )'; - $result = $this->dbc->query($query); - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - - /** - * Remove User from Group - * - * @access public - * @param string id of user - * @param integer id of group - * @return mixed boolean or MDB Error object - */ - function removeUserFromGroup($authId, $group_id) - { - $query = 'DELETE FROM - ' . $this->prefix . 'groupusers - WHERE - perm_user_id = ' . $this->_getPermUserId($authId) . ' AND - group_id = ' . $this->dbc->getValue('integer', $group_id); - - $result = $this->dbc->query($query); - - if (MDB::isError($result)) { - return $result; - }; - - // Job done ... - return true; - } - /** * Get list of all groups * @@ -737,4 +515,4 @@ return $result; } } -?> +?> \ No newline at end of file Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.13 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.14 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php:1.13 Thu Dec 4 03:57:59 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Medium.php Thu Dec 4 11:16:59 2003 @@ -26,7 +26,7 @@ /** * Require the parent class definition */ -require_once 'LiveUser/Admin/Perm/MDB_Common.php'; +require_once 'LiveUser/Admin/Perm/Container/MDB_Simple.php'; /** * This is a PEAR::MDB admin class for the LiveUser package. @@ -46,10 +46,10 @@ * @author Markus Wolff <wolff@21st.de> * @author Matt Scifo <mscifo@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: MDB_Medium.php,v 1.13 2003/12/04 08:57:59 arnaud Exp $ + * @version $Id: MDB_Medium.php,v 1.14 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser */ -class LiveUser_Admin_Perm_Container_MDB_Medium extends LiveUser_Admin_Perm_MDB_Common +class LiveUser_Admin_Perm_Container_MDB_Medium extends LiveUser_Admin_Perm_Container_MDB_Simple { /** * Constructor @@ -58,14 +58,12 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB_Medium(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB_Medium(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_MDB($connectOptions, $conf); + $this->LiveUser_Admin_Perm_Container_MDB_Simple($connectOptions); $this->container_type = 'MDB_Medium'; } @@ -264,7 +262,9 @@ is_active = "N" WHERE group_id = ' . $this->dbc->getValue('integer', $group_id); + $result = $this->dbc->query($query); + if (MDB::isError($result)) { return $result; }; @@ -278,9 +278,10 @@ * @access public * @param integer id of group * @param integer id of right + * @param integer right level * @return mixed boolean or MDB Error object */ - function grantGroupRight($group_id, $right_id) + function grantGroupRight($group_id, $right_id, $right_level = 1) { $query = 'INSERT INTO ' . $this->prefix . 'grouprights @@ -289,7 +290,7 @@ ( ' . $this->dbc->getValue('integer', $group_id) . ', ' . $this->dbc->getValue('integer', $right_id) . ', - 1 + ' . $this->dbc->getValue('integer', $right_level) . ' )'; $result = $this->dbc->query($query); @@ -317,6 +318,33 @@ WHERE group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND right_id = ' . $this->dbc->getValue('integer', $right_id); + $result = $this->dbc->query($query); + if (MDB::isError($result)) { + return $result; + }; + + // Job done ... + return true; + } + + /** + * Update right level of groupRight + * + * @access public + * @param integer id of group + * @param integer id of right + * @param integer right level + * @return mixed boolean or MDB Error object + */ + function updateGroupRight($group_id, $right_id, $right_level) + { + $query = 'UPDATE + ' . $this->prefix . 'grouprights + SET + right_level = ' . $this->dbc->getValue('integer', $right_level) . ' + WHERE + group_id = ' . $this->dbc->getValue('integer', $group_id) . ' AND + right_id = ' . $this->dbc->getValue('integer', $right_id); $result = $this->dbc->query($query); @@ -383,6 +411,38 @@ return true; } + // XXX + // function *Scope + + /** + * Update right level of userRight + * + * @access public + * @param string id of user + * @param integer id of right + * @param integer right level + * @return mixed boolean or MDB Error object + */ + function updateUserRight($authId, $right_id, $right_level) + { + $query = 'UPDATE + ' . $this->prefix . 'userrights + SET + right_level = ' . $this->dbc->getValue('integer', $right_level) . ' + WHERE + perm_user_id = ' . $this->_getPermUserId($authId) . ' AND + right_id = ' . $this->dbc->getValue('integer', $right_id); + + $result = $this->dbc->query($query); + + if (MDB::isError($result)) { + return $result; + }; + + // Job done ... + return true; + } + /** * Get list of all groups * @@ -467,4 +527,4 @@ return $_groups; } } -?> +?> \ No newline at end of file Index: pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php diff -u pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php:1.10 pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php:1.11 --- pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php:1.10 Wed Nov 26 05:59:01 2003 +++ pear/Perm_LiveUser/Admin/Perm/Container/MDB_Simple.php Thu Dec 4 11:16:59 2003 @@ -48,7 +48,7 @@ * This class is only experimental. API may change. Use it at your own risk. * * @author Björn Kraus <krausbn@php.net> - * @version $Id: MDB_Simple.php,v 1.10 2003/11/26 10:59:01 lsmith Exp $ + * @version $Id: MDB_Simple.php,v 1.11 2003/12/04 16:16:59 arnaud Exp $ * @package LiveUser * @category authentication */ @@ -61,15 +61,13 @@ * when instantiating LiveUser::factory() * * @access protected - * @param mixed Array or PEAR::MDB object. - * @param array configuration array + * @param array full liveuser conf array * @return void - * @see LiveUser::factory() */ - function &LiveUser_Admin_Perm_Container_MDB_Simple(&$connectOptions, $conf) + function &LiveUser_Admin_Perm_Container_MDB_Simple(&$connectOptions) { - $this->LiveUser_Admin_Perm_Container_MDB($connectOptions, $conf); + $this->LiveUser_Admin_Perm_Container_MDB($connectOptions); $this->container_type = 'MDB_Simple'; } } -?> +?> \ No newline at end of file