'Checks if user is member of group_id or role
Extends Web2Py\'s requires_membership() to add new functionality:
- Custom Flash style
- Uses s3_has_role()'

def s3_has_membership(self, group_id=None, user_id=None, role=None):

    if self.override:
        return True
    group_id = (group_id or self.id_group(role))
    try:
        group_id = int(group_id)
    except:
        group_id = self.id_group(group_id)
    if self.s3_has_role(group_id):
        r = True
    else:
        r = False
    log = self.messages.has_membership_log
    if log:
        if ((not user_id) and self.user):
            user_id = self.user.id
        self.log_event(log, dict(user_id=user_id, group_id=group_id, check=r))
    return r
