public MemberRequest updateMemberRequest(long userId, long memberRequestId, int status) throws Exception { MemberRequest memberRequest = memberRequestPersistence.findByPrimaryKey(memberRequestId); validate(memberRequest, userId); memberRequest.setModifiedDate(new Date()); memberRequest.setStatus(status); memberRequestPersistence.update(memberRequest, false); if (status == InviteMembersConstants.STATUS_ACCEPTED) { userLocalService.addGroupUsers( memberRequest.getGroupId(), new long[] {memberRequest.getReceiverUserId()}); if (memberRequest.getInvitedRoleId() > 0) { userGroupRoleLocalService.addUserGroupRoles( new long[] {memberRequest.getReceiverUserId()}, memberRequest.getGroupId(), memberRequest.getInvitedRoleId()); } if (memberRequest.getInvitedTeamId() > 0) { userLocalService.addTeamUsers( memberRequest.getInvitedTeamId(), new long[] {memberRequest.getReceiverUserId()}); } } return memberRequest; }
public MemberRequest updateMemberRequest(String key, long receiverUserId) throws PortalException, SystemException { MemberRequest memberRequest = memberRequestPersistence.findByKey(key); validate(memberRequest, 0); memberRequest.setModifiedDate(new Date()); memberRequest.setReceiverUserId(receiverUserId); memberRequestPersistence.update(memberRequest, false); return memberRequest; }
public MemberRequest addMemberRequest( long userId, long groupId, long receiverUserId, String receiverEmailAddress, long invitedRoleId, long invitedTeamId, ServiceContext serviceContext) throws PortalException, SystemException { // Member request User user = userLocalService.getUserById(userId); Date now = new Date(); long memberRequestId = counterLocalService.increment(); MemberRequest memberRequest = memberRequestPersistence.create(memberRequestId); memberRequest.setGroupId(groupId); memberRequest.setCompanyId(user.getCompanyId()); memberRequest.setUserId(userId); memberRequest.setUserName(user.getFullName()); memberRequest.setCreateDate(now); memberRequest.setModifiedDate(now); memberRequest.setKey(PortalUUIDUtil.generate()); memberRequest.setReceiverUserId(receiverUserId); memberRequest.setInvitedRoleId(invitedRoleId); memberRequest.setInvitedTeamId(invitedTeamId); memberRequest.setStatus(InviteMembersConstants.STATUS_PENDING); memberRequestPersistence.update(memberRequest, false); // Email try { sendEmail(receiverEmailAddress, memberRequest, serviceContext); } catch (Exception e) { throw new SystemException(e); } // Notifications sendNotificationEvent(memberRequest); return memberRequest; }