function _listGroupIDsForUserExpand($oUser) { $iUserId = KTUtil::getId($oUser); global $default; $oCache = KTCache::getSingleton(); $group = "groupidsforuser"; if (PEAR::isError($oUser)) { var_dump($oUser); } list($bCached, $mCached) = $oCache->get($group, $oUser->getId()); if ($bCached) { if (KTLOG_CACHE) { $default->log->debug(sprintf("Using group cache for _listGroupIDsForUserExpand %d", $iUserId)); } return $mCached; } // Get all subgroups $aSubGroups = GroupUtil::_listSubGroups(); $aGroupArray = array(); if (!empty($aSubGroups)) { $aGroupArray = GroupUtil::_invertGroupArray($aSubGroups); } //$aGroupArray = GroupUtil::_invertGroupArray(GroupUtil::buildGroupArray()); //$aDirectGroups = GroupUtil::listGroupsForUser($oUser); $sQuery = "SELECT group_id FROM {$default->users_groups_table} WHERE user_id = ?"; $aParams = array($iUserId); $aGroupIDs = DBUtil::getResultArrayKey(array($sQuery, $aParams), "group_id"); if (!empty($aGroupArray)) { foreach ($aGroupIDs as $iGroupID) { $aExtraIDs = KTUtil::arrayGet($aGroupArray, $iGroupID); if (is_array($aExtraIDs)) { $aGroupIDs = kt_array_merge($aGroupIDs, $aExtraIDs); } } } $aGroupIDs = array_unique($aGroupIDs); sort($aGroupIDs); $oCache->set($group, $oUser->getId(), $aGroupIDs); return $aGroupIDs; }