Example #1
0
        /// <summary>
        /// 是否具有设置群管理员的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public static bool Group_SetManager(this Authorizer authorizer, GroupEntity group)
        {
            if (group == null)
            {
                return(false);
            }

            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }

            //群主
            if (group.UserId == currentUser.UserId)
            {
                return(true);
            }

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

            return(false);
        }
Example #2
0
        /// <summary>
        /// 是否拥有删除群组成员的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="group"></param>
        /// <param name="userId">被删除的用户Id</param>
        /// <returns>是否拥有删除群组成员的权限</returns>
        public static bool Group_DeleteMember(this Authorizer authorizer, GroupEntity group, long userId)
        {
            if (group == null)
            {
                return(false);
            }

            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }

            //群主
            if (group.UserId == currentUser.UserId)
            {
                return(true);
            }

            if (authorizer.IsAdministrator(GroupConfig.Instance().ApplicationId))
            {
                return(true);
            }
            GroupService groupService = new GroupService();

            //群管理员
            if (groupService.IsManager(group.GroupId, currentUser.UserId) && !groupService.IsManager(group.GroupId, userId))
            {
                return(true);
            }
            return(false);
        }
Example #3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="name">Searcher名称</param>
 /// <param name="indexPath">索引文件所在路径(支持"~/"及unc路径)</param>
 /// <param name="asQuickSearch">是否作为快捷搜索</param>
 /// <param name="displayOrder">显示顺序</param>
 public GroupSearcher(string name, string indexPath, bool asQuickSearch, int displayOrder)
 {
     this.Name           = name;
     this.IndexPath      = Tunynet.Utilities.WebUtility.GetPhysicalFilePath(indexPath);
     this.AsQuickSearch  = asQuickSearch;
     this.DisplayOrder   = displayOrder;
     searchEngine        = SearcherFactory.GetSearchEngine(indexPath);
     publiclyAuditStatus = auditService.GetPubliclyAuditStatus(GroupConfig.Instance().ApplicationId);
 }
Example #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);
        }
Example #5
0
        /// <summary>
        /// 是否具有创建Group的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="errorMessage">无权信息提示</param>
        /// <returns></returns>
        public static bool Group_Create(this Authorizer authorizer, out string errorMessage)
        {
            errorMessage = string.Empty;
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                errorMessage = "您需要先登录,才能创建群组";
                return(false);
            }

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

            if (currentUser.Rank < GroupConfig.Instance().MinUserRankOfCreateGroup)
            {
                errorMessage = string.Format("只有等级达到{0}级,才能创建群组,您现在的等级是{1}", GroupConfig.Instance().MinUserRankOfCreateGroup, currentUser.Rank);
                return(false);
            }
            return(true);
        }
Example #6
0
        /// <summary>
        /// 发送加入群组邀请
        /// </summary>
        /// <param name="group"><see cref="GroupEntity"/></param>
        /// <param name="sender">发送人</param>
        /// <param name="userIds">邀请接收人</param>
        /// <param name="remark">附言</param>
        public void SendInvitations(GroupEntity group, IUser sender, string remark, IEnumerable <long> userIds)
        {
            //调用InvitationService的发送请求的方法
            InvitationService invitationService = new InvitationService();

            foreach (var userId in userIds)
            {
                if (!IsMember(group.GroupId, userId))
                {
                    Invitation invitation = Invitation.New();
                    invitation.ApplicationId      = GroupConfig.Instance().ApplicationId;
                    invitation.InvitationTypeKey  = InvitationTypeKeys.Instance().InviteJoinGroup();
                    invitation.UserId             = userId;
                    invitation.SenderUserId       = sender.UserId;
                    invitation.Sender             = sender.DisplayName;
                    invitation.SenderUrl          = SiteUrls.Instance().SpaceHome(sender.UserId);
                    invitation.RelativeObjectId   = group.GroupId;
                    invitation.RelativeObjectName = group.GroupName;
                    invitation.RelativeObjectUrl  = SiteUrls.Instance().GroupHome(group.GroupKey);
                    invitation.Remark             = remark;
                    invitationService.Create(invitation);
                }
            }
        }
Example #7
0
 /// <summary>
 /// 群组的内容数
 /// </summary>
 /// <param name="ownerDataKeys"></param>
 /// <returns></returns>
 public static string GroupContentCount(this OwnerDataKeys ownerDataKeys)
 {
     return(GroupConfig.Instance().ApplicationKey + "GroupContentCount");
 }
Example #8
0
 /// <summary>
 /// 创建的群组数
 /// </summary>
 /// <param name="ownerDataKeys"></param>
 /// <returns></returns>
 public static string CreatedGroupCount(this OwnerDataKeys ownerDataKeys)
 {
     return(GroupConfig.Instance().ApplicationKey + "-ThreadCount");
 }