Exemple #1
0
        /// <summary>
        /// 是否具有浏览群组的权限
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static bool Group_View(this Authorizer authorizer, GroupEntity group)
        {
            if (group == null)
            {
                return(false);
            }

            if (group.AuditStatus == AuditStatus.Success)
            {
                if (group.IsPublic)
                {
                    return(true);
                }

                if (UserContext.CurrentUser == null)
                {
                    return(false);
                }

                if (authorizer.Group_Manage(group))
                {
                    return(true);
                }

                GroupService groupService = new GroupService();
                if (groupService.IsMember(group.GroupId, UserContext.CurrentUser.UserId))
                {
                    return(true);
                }
            }

            if (authorizer.IsAdministrator(GroupConfig.Instance().ApplicationId))
            {
                return(true);
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// 是否具有邀请好友加入群组的权限
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static bool Group_Invite(this Authorizer authorizer, GroupEntity group)
        {
            if (group == null)
            {
                return(false);
            }
            if (UserContext.CurrentUser == null)
            {
                return(false);
            }

            GroupService groupService = new GroupService();

            if (authorizer.Group_Manage(group))
            {
                return(true);
            }
            if (group.EnableMemberInvite && groupService.IsMember(group.GroupId, UserContext.CurrentUser.UserId))
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void GroupMemberApplyNoticeModule_After(GroupMemberApply sender, CommonEventArgs eventArgs)
        {
            GroupService groupService = new GroupService();
            GroupEntity entity = groupService.Get(sender.GroupId);
            if (entity == null)
                return;

            User senderUser = DIContainer.Resolve<IUserService>().GetFullUser(sender.UserId);
            if (senderUser == null)
                return;
            InvitationService invitationService = new InvitationService();
            Invitation invitation;
            NoticeService noticeService = DIContainer.Resolve<NoticeService>();
            Notice notice;
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                if (sender.ApplyStatus == GroupMemberApplyStatus.Pending)
                {
                    List<long> toUserIds = new List<long>();
                    toUserIds.Add(entity.UserId);
                    toUserIds.AddRange(entity.GroupManagers.Select(n => n.UserId));
                    foreach (var toUserId in toUserIds)
                    {
                        //申请加入群组的请求
                        if (!groupService.IsMember(sender.GroupId, sender.UserId))
                        {
                            invitation = Invitation.New();
                            invitation.ApplicationId = GroupConfig.Instance().ApplicationId;
                            invitation.InvitationTypeKey = InvitationTypeKeys.Instance().ApplyJoinGroup();
                            invitation.UserId = toUserId;
                            invitation.SenderUserId = sender.UserId;
                            invitation.Sender = senderUser.DisplayName;
                            invitation.SenderUrl = SiteUrls.Instance().SpaceHome(sender.UserId);
                            invitation.RelativeObjectId = sender.GroupId;
                            invitation.RelativeObjectName = entity.GroupName;
                            invitation.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey));
                            invitation.Remark = sender.ApplyReason;
                            invitationService.Create(invitation);
                        }
                    }
                }
            }

            string noticeTemplateName = string.Empty;
            if (eventArgs.EventOperationType == EventOperationType.Instance().Approved())
            {
                if (sender.ApplyStatus == GroupMemberApplyStatus.Approved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyApproved();
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                if (sender.ApplyStatus == GroupMemberApplyStatus.Disapproved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyDisapproved();
                }
            }

            if (string.IsNullOrEmpty(noticeTemplateName))
                return;

            notice = Notice.New();

            notice.UserId = sender.UserId;
            notice.ApplicationId = GroupConfig.Instance().ApplicationId;
            notice.TypeId = NoticeTypeIds.Instance().Hint();
            //notice.LeadingActorUserId = UserContext.CurrentUser.UserId;
            //notice.LeadingActor = UserContext.CurrentUser.DisplayName;
            //notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(UserContext.CurrentUser.UserId));
            notice.RelativeObjectId = sender.GroupId;
            notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64);
            notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey));
            notice.TemplateName = noticeTemplateName;
            noticeService.Create(notice);
        }
Exemple #4
0
        /// <summary>
        /// 是否具有浏览群组的权限
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static bool Group_View(this Authorizer authorizer, GroupEntity group)
        {
            if (group == null)
                return false;

            if (group.AuditStatus == AuditStatus.Success)
            {
                if (group.IsPublic)
                    return true;

                if (UserContext.CurrentUser == null)
                    return false;

                if (authorizer.Group_Manage(group))
                    return true;

                GroupService groupService = new GroupService();
                if (groupService.IsMember(group.GroupId, UserContext.CurrentUser.UserId))
                    return true;
            }

            if (authorizer.IsAdministrator(GroupConfig.Instance().ApplicationId))
                return true;

            return false;
        }
Exemple #5
0
        /// <summary>
        /// 是否具有邀请好友加入群组的权限
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static bool Group_Invite(this Authorizer authorizer, GroupEntity group)
        {
            if (group == null)
                return false;
            if (UserContext.CurrentUser == null)
                return false;

            GroupService groupService = new GroupService();
            if (authorizer.Group_Manage(group))
                return true;
            if (group.EnableMemberInvite && groupService.IsMember(group.GroupId, UserContext.CurrentUser.UserId))
                return true;

            return false;
        }