コード例 #1
0
def user_participation_coach_of_group(userInfo, groupInfo):
    assert IGSUserInfo.providedBy(userInfo), '%s is not a IGSUserInfo' % \
        userInfo
    assert IGSGroupInfo.providedBy(groupInfo)
    ptnCoachId = groupInfo.get_property('ptn_coach_id', '')
    retval = (user_member_of_group(userInfo, groupInfo)
              and (userInfo.id == ptnCoachId))
    assert type(retval) == bool
    return retval
コード例 #2
0
    def update(self):
        self.__updated = True
        self.siteInfo = createObject('groupserver.SiteInfo',
          self.context)
        self.groupsInfo = createObject('groupserver.GroupsInfo',
          self.context)
        self.userInfo = IGSUserInfo(self.context)

        rws = [w for w in self.widgets if w.required]
        rwIds = ['\'#%s\'' % w.name.replace('.', '\\\\.') for w in rws]
        self.requiredWidgetsArray = '%s' % ', '.join(rwIds);
コード例 #3
0
def user_invited_member_of_group(userInfo, groupInfo, siteInfo):
    assert IGSUserInfo.providedBy(userInfo), \
        '%s is not a IGSUserInfo' % userInfo
    assert IGSGroupInfo.providedBy(groupInfo), \
        '%s is not an IGSGroupInfo' % groupInfo
    context = groupInfo.groupObj
    invited_group_members = \
        InvitedGroupMembers(context, siteInfo).members
    retval = userInfo.id in [m.id for m in invited_group_members]
    assert type(retval) == bool
    return retval
コード例 #4
0
def user_blocked_member_of_group(userInfo, groupInfo):
    assert IGSUserInfo.providedBy(userInfo), \
        '%s is not an IGSUserInfo' % userInfo
    assert IGSGroupInfo.providedBy(groupInfo), \
        '%s is not an IGSGroupInfo' % groupInfo
    context = groupInfo.groupObj
    mlistInfo = createObject('groupserver.MailingListInfo', context)
    retval = (user_member_of_group(userInfo, groupInfo) and
              (userInfo.id in [m.id for m in mlistInfo.blocked_members]))
    assert type(retval) == bool
    return retval
コード例 #5
0
def user_posting_member_of_group(userInfo, groupInfo):
    assert IGSUserInfo.providedBy(userInfo), \
        '%s is not an IGSUserInfo' % userInfo
    assert IGSGroupInfo.providedBy(groupInfo), \
        '%s is not an IGSGroupInfo' % groupInfo
    context = groupInfo.groupObj
    mlistInfo = IGSMailingListInfo(context)
    retval = (user_member_of_group(userInfo, groupInfo) and
              (userInfo.id in [m.id for m in mlistInfo.posting_members]))
    assert type(retval) == bool
    return retval
コード例 #6
0
def user_unverified_member_of_group(userInfo, groupInfo):
    assert IGSUserInfo.providedBy(userInfo), \
        '%s is not a IGSUserInfo' % userInfo
    assert IGSGroupInfo.providedBy(groupInfo), \
        '%s is not an IGSGroupInfo' % groupInfo
    context = groupInfo.groupObj
    unverified_group_members = \
        get_unverified_group_users(context, groupInfo.id)
    retval = (user_member_of_group(userInfo, groupInfo) and
              (userInfo.id in [m.getId() for m in unverified_group_members]))
    assert type(retval) == bool
    return retval
コード例 #7
0
    def __init__(self, context):
        self.context = context
        # the context we are passed might already be a userinfo
        if IGSUserInfo.providedBy(context):
            self.userInfo = context
        else:
            self.userInfo = createObject('groupserver.LoggedInUser', context)

        emailUser = EmailUser(self.userInfo.user, self.userInfo)
        defaultAddresses = emailUser.get_delivery_addresses()
        self.defaultAddress = ''
        if defaultAddresses:
            self.defaultAddress = defaultAddresses[0]
コード例 #8
0
def user_unverified_member_of_group(userInfo, groupInfo):
    assert IGSUserInfo.providedBy(userInfo), \
        '%s is not a IGSUserInfo' % userInfo
    assert IGSGroupInfo.providedBy(groupInfo), \
        '%s is not an IGSGroupInfo' % groupInfo
    context = groupInfo.groupObj
    unverified_group_members = \
        get_unverified_group_users(context, groupInfo.id)
    retval = (user_member_of_group(userInfo, groupInfo) and
              (userInfo.id in [m.getId()
                               for m in unverified_group_members]))
    assert type(retval) == bool
    return retval
コード例 #9
0
    def __init__(self, context):
        self.context = context
        # the context we are passed might already be a userinfo
        if IGSUserInfo.providedBy(context):
            self.userInfo = context
        else:
            self.userInfo = createObject('groupserver.LoggedInUser',
                                         context)

        emailUser = EmailUser(self.userInfo.user, self.userInfo)
        defaultAddresses = emailUser.get_delivery_addresses()
        self.defaultAddress = ''
        if defaultAddresses:
            self.defaultAddress = defaultAddresses[0]
コード例 #10
0
    def __call__(self, context, verificationId):
        queries = VerificationQuery()

        s = queries.verificationId_status(verificationId)
        if s == queries.NOT_FOUND:
            raise VerificationIdNotFoundError(verificationId)

        userId = queries.get_userId_from_verificationId(verificationId)
        aclUsers = context.site_root().acl_users
        user = aclUsers.getUser(userId)
        assert user, 'No user for userId %s' % userId

        userInfo = IGSUserInfo(user)
        return VerifyEmailUser(userInfo)
コード例 #11
0
    def __init__(self, group, userInfo):
        assert IGSGroupFolder.providedBy(group),\
          u'%s is not a group folder' % group
        assert IGSUserInfo.providedBy(userInfo),\
          u'%s is not a user-info' % userInfo

        self.site_root = group.site_root()
        self.userInfo = userInfo
        self.groupInfo = IGSGroupInfo(group)

        self.__status = None
        self.__statusNum = 0
        self.__canPost = None
        self.__profileInterfaces = None
コード例 #12
0
    def __init__(self, group, userInfo):
        assert IGSGroupFolder.providedBy(group),\
          u'%s is not a group folder' % group
        assert IGSUserInfo.providedBy(userInfo),\
          u'%s is not a user-info' % userInfo

        self.site_root = group.site_root()
        self.userInfo = userInfo
        self.groupInfo = IGSGroupInfo(group)

        self.__status = None
        self.__statusNum = 0
        self.__canPost = None
        self.__profileInterfaces = None
コード例 #13
0
def create_user_from_email(context, email):
    if not context:
        m = 'Context is "{0}"'.format(context)
        raise ValueError(m)
    if type(email) not in (str, unicode):
        m = 'Email is a "{0}", not a string'.format(type(email))
        raise TypeError(m)
    if not email:
        m = 'The email address is "{0}"'.format(email)
        raise ValueError(m)
    if '@' not in email:
        m = 'No "@" in the email "{0}"'.format(email)
        raise ValueError(m)

    m = 'utils.create_user_from_email: Creating a new user for the '\
      'address <%s>' % email
    log.info(m)

    userNum = long(new_md5(asctime() + email).hexdigest(), 16)
    userId = str(convert_int2b62(userNum))

    # Ensure that the user ID is unique. There is also a race
    #   condition, and the loop is non-deterministic.
    acl_users = __get_acl_users_for_context(context)
    while (acl_users.getUserById(userId)):
        userNum = long(new_md5(asctime() + email).hexdigest(), 16)
        userId = str(convert_int2b62(userNum))

    displayName = email.split('@')[0]

    user = acl_users.simple_register_user(email, userId, displayName)
    userInfo = IGSUserInfo(user)
    emailUser = EmailUser(context, userInfo)
    emailUser.set_delivery(email)

    # --=mpj17=-- Ensure that the user's profile is owned by the user, and
    #   *only* the user.
    p = '/'.join(acl_users.getPhysicalPath()).encode('ascii', 'ignore')
    assign_ownership(user, user.getId(), recursive=0, acl_user_path=p)
    user.manage_delLocalRoles(
        [uid for uid in user.users_with_local_role('Owner') if uid != userId])

    m = 'utils.create_user_from_email: Created a new user {name} ({id})'
    msg = m.format(name=user.getProperty('fn', ''), id=user.getId())
    log.info(msg)

    assert user
    assert isinstance(user, CustomUser)
    return user
コード例 #14
0
    def __init__(self, siteInfo, user):
        if not siteInfo:
            m = 'No siteInfo'
            raise ValueError(m)
        self.siteInfo = siteInfo

        if not user:
            m = 'No userInfo'
            raise ValueError(m)
        if IGSUserInfo.providedBy(user):
            self.userInfo = user
        else:
            self.userInfo = IGSUserInfo(user)

        self.queries = AuditQuery()
        self.factory = AuditEventFactory()
コード例 #15
0
    def create_user(self):
        email = self.user_data['email']
        user = create_user_from_email(self.context, email)
        first_name = self.user_data['first_name']
        last_name = self.user_data['last_name']
        fn = '%s %s' % (first_name, last_name)
        user.manage_changeProperties(fn=fn, givenName=first_name,
                                        familyName=last_name)

        userInfo = IGSUserInfo(user)
        login(self.context, user)
        vid = 'AssumedTrue%s' % email.replace('@', 'at')
        eu = EmailVerificationUser(self.context, userInfo, email)
        eu.add_verification_id(vid)
        eu.verify_email(vid)

        return user
コード例 #16
0
    def __init__(self, siteInfo, user):
        """Create an login auditor.

        DESCRIPTION
            The constructor for an auditor is passed all the data
            that will be the same for the events that are created
            during one use of the auditor by a Zope 3 page-view.

        ARGUMENTS
            "userInfo"
            "siteInfo"

        SIDE EFFECTS
        """
        self.user = user
        self.userInfo = IGSUserInfo(user)
        self.siteInfo = siteInfo

        self.queries = AuditQuery()

        self.factory = LoginAuditEventFactory()
コード例 #17
0
    def __init__(self, userInfo, membersInfo):
        assert IGSUserInfo.providedBy(userInfo), \
          u'%s is not a GSUserInfo' % userInfo
        assert IGSGroupMembersInfo.providedBy(membersInfo), \
          u'%s is not a GSGroupMembersInfo' % membersInfo

        self.userInfo = userInfo
        self.membersInfo = membersInfo
        self.groupInfo = membersInfo.groupInfo
        self.siteInfo = membersInfo.siteInfo
        self.groupIsModerated = membersInfo.mlistInfo.is_moderated
        self.postingIsSpecial = (self.groupInfo.group_type == 'announcement')
        self.numPostingMembers = len(membersInfo.postingMembers)

        self.__status_label = self.__isNormalMember = None
        self.__isSiteAdmin = self.__isGroupAdmin = None
        self.__isPtnCoach = self.__isPostingMember = None
        self.__isModerator = self.__isModerated = None
        self.__isBlocked = self.__isInvited = None
        self.__isMember = self.__isFullMember = None
        self.__isConfused = self.__isOddlyConfigured = None
        self.__isUnverified = None
コード例 #18
0
    def __init__(self, userInfo, membersInfo):
        assert IGSUserInfo.providedBy(userInfo), \
          u'%s is not a GSUserInfo' % userInfo
        assert IGSGroupMembersInfo.providedBy(membersInfo), \
          u'%s is not a GSGroupMembersInfo' % membersInfo

        self.userInfo = userInfo
        self.membersInfo = membersInfo
        self.groupInfo = membersInfo.groupInfo
        self.siteInfo = membersInfo.siteInfo
        self.groupIsModerated = membersInfo.mlistInfo.is_moderated
        self.postingIsSpecial = (self.groupInfo.group_type == 'announcement')
        self.numPostingMembers = len(membersInfo.postingMembers)

        self.__status_label = self.__isNormalMember = None
        self.__isSiteAdmin = self.__isGroupAdmin = None
        self.__isPtnCoach = self.__isPostingMember = None
        self.__isModerator = self.__isModerated = None
        self.__isBlocked = self.__isInvited = None
        self.__isMember = self.__isFullMember = None
        self.__isConfused = self.__isOddlyConfigured = None
        self.__isUnverified = None
コード例 #19
0
    def __call__(self, context, verificationId):
        queries = VerificationQuery()

        s = queries.verificationId_status(verificationId)
        if s == queries.NOT_FOUND:
            raise VerificationIdNotFoundError(verificationId)

        userId = queries.get_userId_from_verificationId(verificationId)
        aclUsers = context.site_root().acl_users
        user = aclUsers.getUser(userId)
        if not user:
            m = 'No user for the verification ID "{0}"'
            msg = m.format(verificationId)
            raise NoUserForVerificationId(msg)
        userInfo = IGSUserInfo(user)
        emailUser = EmailUser(context, userInfo)

        email = queries.get_email_from_verificationId(verificationId)
        assert email in emailUser.get_addresses(), \
            'Address %s does not belong to %s (%s)' %\
            (email, userInfo.name, userInfo.id)

        return EmailVerificationUser(context, userInfo, email)
コード例 #20
0
 def userInfo(self):
     try:
         retval = IGSUserInfo(self.user)
     except TypeError:
         retval = GSAnonymousUserInfo()
     return retval
コード例 #21
0
 def __init__(self, context, user, email):
     userInfo = IGSUserInfo(user)
     EmailVerificationUser.__init__(self, context, userInfo, email)
コード例 #22
0
 def __init__(self, user):
     userInfo = IGSUserInfo(user)
     EmailUser.__init__(self, user, userInfo)
コード例 #23
0
 def __init__(self, user):
     userInfo = IGSUserInfo(user)
     self.context = user
     self.emailUser = EmailUser(userInfo.user, userInfo)
     self._addresses = None
コード例 #24
0
    def update(self):
        self.__updated = True

        self.currentSite = createObject('groupserver.SiteInfo', self.context)
        self.userInfo = IGSUserInfo(self.context)
        self.siteMemberships = SiteMembership(self.context)
コード例 #25
0
 def __init__(self, context, request):
     PageForm.__init__(self, context, request)
     self.siteInfo = createObject('groupserver.SiteInfo', context)
     self.userInfo = IGSUserInfo(context)
コード例 #26
0
 def userInfo(self):
     retval = IGSUserInfo(self.context)
     assert retval
     return retval
コード例 #27
0
def userInfo_to_user(u):
    if IGSUserInfo.providedBy(u):
        user = u.user
    else:
        user = u
    return user
コード例 #28
0
 def emailUser(self):
     userInfo = IGSUserInfo(self.user)
     retval = EmailUser(self.user, userInfo)
     return retval
コード例 #29
0
 def userInfo(self):
     retval = IGSUserInfo(self.ctx)
     assert retval
     return retval
コード例 #30
0
 def userInfo(self):
     retval = IGSUserInfo(self.user)
     return retval
コード例 #31
0
 def userInfo(self):
     retval = IGSUserInfo(self.context)
     return retval
コード例 #32
0
def user_to_userInfo(u):
    if ICustomUser.providedBy(u):
        user = IGSUserInfo(u)
    else:
        user = u
    return user
コード例 #33
0
 def userInfo(self):
     retval = IGSUserInfo(self.user)
     assert retval
     assert not (retval.anonymous)
     return retval
コード例 #34
0
def userInfo_to_user(u):
    if IGSUserInfo.providedBy(u):
        user = u.user
    else:
        user = u
    return user
コード例 #35
0
 def notify(self):
     userInfo = IGSUserInfo(self.context)
     sender = MessageSender(self.context, userInfo)
     text = self.textTemplate()
     html = self.htmlTemplate()
     sender.send_message('What is going on in your groups', text, html)
コード例 #36
0
 def __call__(self, context, email):
     aclUsers = context.site_root().acl_users
     user = aclUsers.get_userByEmail(email)
     assert user, 'No user for email address %s' % email
     userInfo = IGSUserInfo(user)
     return EmailVerificationUser(context, userInfo, email)