diff options
| author | Tyler Bello <tylerbello@users.sourceforge.net> | 2009-11-16 20:32:48 +0000 |
|---|---|---|
| committer | Tyler Bello <tylerbello@users.sourceforge.net> | 2009-11-16 20:32:48 +0000 |
| commit | 3e1de1b815d826ef6f006da5fd10ada521a46b77 (patch) | |
| tree | 5d6e2b859319a8bee69fe5e6ca166671dc702ba1 | |
| parent | 4e05a306c4ee7c152d5af055b8c695a1980e999f (diff) | |
| download | users-3e1de1b815d826ef6f006da5fd10ada521a46b77.tar.gz users-3e1de1b815d826ef6f006da5fd10ada521a46b77.tar.bz2 users-3e1de1b815d826ef6f006da5fd10ada521a46b77.zip | |
move getGroups from BitPermUser to BitUser, function unrelated to permissions AND to resolve an apparent PHP function resolution issue
| -rw-r--r-- | BitPermUser.php | 38 | ||||
| -rw-r--r-- | BitUser.php | 39 |
2 files changed, 36 insertions, 41 deletions
diff --git a/BitPermUser.php b/BitPermUser.php index 5357f74..c0f65f5 100644 --- a/BitPermUser.php +++ b/BitPermUser.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_users/BitPermUser.php,v 1.83 2009/10/29 18:01:49 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_users/BitPermUser.php,v 1.84 2009/11/16 20:32:48 tylerbello Exp $ * * Lib for user administration, groups and permissions * This lib uses pear so the constructor requieres @@ -11,7 +11,7 @@ * All Rights Reserved. See below for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details * - * $Id: BitPermUser.php,v 1.83 2009/10/29 18:01:49 spiderr Exp $ + * $Id: BitPermUser.php,v 1.84 2009/11/16 20:32:48 tylerbello Exp $ * @package users */ @@ -24,7 +24,7 @@ require_once( USERS_PKG_PATH.'/BitUser.php' ); * Class that holds all information for a given user * * @author spider <spider@steelsun.com> - * @version $Revision: 1.83 $ + * @version $Revision: 1.84 $ * @package users * @subpackage BitPermUser */ @@ -370,38 +370,6 @@ class BitPermUser extends BitUser { } /** - * getGroups - * - * @param array $pUserId - * @param array $pForceRefresh - * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure - */ - function getGroups( $pUserId=NULL, $pForceRefresh = FALSE ) { - $pUserId = !empty( $pUserId ) ? $pUserId : $this->mUserId; - if( !isset( $this->cUserGroups[$pUserId] ) || $pForceRefresh ) { - $query = " - SELECT ug.`group_id`, ug.`group_name`, ug.`user_id` as group_owner_user_id - FROM `".BIT_DB_PREFIX."users_groups_map` ugm INNER JOIN `".BIT_DB_PREFIX."users_groups` ug ON (ug.`group_id`=ugm.`group_id`) - WHERE ugm.`user_id`=? OR ugm.`group_id`=".ANONYMOUS_GROUP_ID; - $ret = $this->mDb->getAssoc( $query, array(( int )$pUserId )); - if( $ret ) { - foreach( array_keys( $ret ) as $groupId ) { - $res = array(); - foreach( $res as $key=>$val) { - $ret[$key] = array( 'group_name' => $val ); - } - } - } - // cache it - $this->cUserGroups[$pUserId] = $ret; - return $ret; - } else { - return $this->cUserGroups[$pUserId]; - } - } - - /** * getDefaultGroup get the default group of a given user * * @param array $pGroupId pass in a Group ID to make conditional function diff --git a/BitUser.php b/BitUser.php index d163f25..4dfc966 100644 --- a/BitUser.php +++ b/BitUser.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_users/BitUser.php,v 1.239 2009/11/11 17:42:13 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_users/BitUser.php,v 1.240 2009/11/16 20:32:48 tylerbello Exp $ * * Lib for user administration, groups and permissions * This lib uses pear so the constructor requieres @@ -12,7 +12,7 @@ * All Rights Reserved. See below for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details * - * $Id: BitUser.php,v 1.239 2009/11/11 17:42:13 spiderr Exp $ + * $Id: BitUser.php,v 1.240 2009/11/16 20:32:48 tylerbello Exp $ * @package users */ @@ -42,7 +42,7 @@ define( "ACCOUNT_DISABLED", -6 ); * Class that holds all information for a given user * * @author spider <spider@steelsun.com> - * @version $Revision: 1.239 $ + * @version $Revision: 1.240 $ * @package users * @subpackage BitUser */ @@ -2298,9 +2298,36 @@ class BitUser extends LibertyMime { return $ret; } - // PURE VIRTUAL FUNCTIONS - function getGroups () { - print "CALL TO PURE VIRTUAL FUNCTIONS"; bt(); die; + /** + * getGroups + * + * @param array $pUserId + * @param array $pForceRefresh + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function getGroups( $pUserId=NULL, $pForceRefresh = FALSE ) { + $pUserId = !empty( $pUserId ) ? $pUserId : $this->mUserId; + if( !isset( $this->cUserGroups[$pUserId] ) || $pForceRefresh ) { + $query = " + SELECT ug.`group_id`, ug.`group_name`, ug.`user_id` as group_owner_user_id + FROM `".BIT_DB_PREFIX."users_groups_map` ugm INNER JOIN `".BIT_DB_PREFIX."users_groups` ug ON (ug.`group_id`=ugm.`group_id`) + WHERE ugm.`user_id`=? OR ugm.`group_id`=".ANONYMOUS_GROUP_ID; + $ret = $this->mDb->getAssoc( $query, array(( int )$pUserId )); + if( $ret ) { + foreach( array_keys( $ret ) as $groupId ) { + $res = array(); + foreach( $res as $key=>$val) { + $ret[$key] = array( 'group_name' => $val ); + } + } + } + // cache it + $this->cUserGroups[$pUserId] = $ret; + return $ret; + } else { + return $this->cUserGroups[$pUserId]; + } } /** |
