private static function generateUserCacheData( $userId )
    {
        $user = eZUser::fetch( $userId );
        if ( !$user instanceof eZUser )
        {
            return null;
        }

        // user info (session: eZUserInfoCache)
        $data['info'][$userId] = array( 'contentobject_id'   => $user->attribute( 'contentobject_id' ),
                                        'login'              => $user->attribute( 'login' ),
                                        'email'              => $user->attribute( 'email' ),
                                        'is_enabled'         => $user->isEnabled( false ),
                                        'password_hash'      => $user->attribute( 'password_hash' ),
                                        'password_hash_type' => $user->attribute( 'password_hash_type' ) );

        // function groups relies on caching. The function generateUserCacheData relies on function groups.
        // To avoid an infinitive loop, the code is disabling caching in function generateUserCacheData.
        // At the end of this method flag is set to previous value again
        $previousCachingState = $user->setCachingEnabled( false );
        // user groups list (session: eZUserGroupsCache)
        $groups = $user->groups(); 
        $data['groups'] = $groups;

        // role list (session: eZRoleIDList)
        $groups[] = $userId;
        $data['roles'] = eZRole::fetchIDListByUser( $groups );

        // role limitation list (session: eZRoleLimitationValueList)
        $limitList = $user->limitList();
        foreach ( $limitList as $limit )
        {
            $data['role_limitations'][] = $limit['limit_value'];
        }

        // access array (session: AccessArray)
        $data['access_array'] = $user->generateAccessArray();

        // discount rules (session: eZUserDiscountRules<userId>)
        $data['discount_rules'] = eZUserDiscountRule::generateIDListByUserID( $userId );

        $user->setCachingEnabled( $previousCachingState );

        return $data;
    }