示例#1
0
        /// <summary>
        /// 是否拥有删除专题成员的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="group"></param>
        /// <param name="userId">被删除的用户Id</param>
        /// <returns>是否拥有删除专题成员的权限</returns>
        public static bool Topic_DeleteMember(this Authorizer authorizer, TopicEntity 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(TopicConfig.Instance().ApplicationId))
            {
                return(true);
            }
            TopicService groupService = new TopicService();

            //群管理员
            if (groupService.IsManager(group.TopicId, currentUser.UserId) && !groupService.IsManager(group.TopicId, userId))
            {
                return(true);
            }
            return(false);
        }
示例#2
0
        /// <summary>
        /// 是否具有设置群管理员的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public static bool Topic_SetManager(this Authorizer authorizer, TopicEntity 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(TopicConfig.Instance().ApplicationId))
            {
                return(true);
            }

            return(false);
        }
示例#3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="name">Searcher名称</param>
 /// <param name="indexPath">索引文件所在路径(支持"~/"及unc路径)</param>
 /// <param name="asQuickSearch">是否作为快捷搜索</param>
 /// <param name="displayOrder">显示顺序</param>
 public TopicSearcher(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(TopicConfig.Instance().ApplicationId);
 }
示例#4
0
        /// <summary>
        /// 是否具有浏览专题的权限
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public static bool Topic_View(this Authorizer authorizer, TopicEntity topic)
        {
            if (topic == null)
            {
                return(false);
            }

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

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

                if (authorizer.Topic_Manage(topic))
                {
                    return(true);
                }

                TopicService groupService = new TopicService();
                if (groupService.IsMember(topic.TopicId, UserContext.CurrentUser.UserId))
                {
                    return(true);
                }
            }

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

            return(false);
        }
示例#5
0
        /// <summary>
        /// 是否具有创建Topic的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="errorMessage">无权信息提示</param>
        /// <returns></returns>
        public static bool Topic_Create(this Authorizer authorizer, out string errorMessage)
        {
            errorMessage = string.Empty;
            IUser currentUser = UserContext.CurrentUser;

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

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

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

            foreach (var userId in userIds)
            {
                if (!IsMember(group.TopicId, userId))
                {
                    Invitation invitation = Invitation.New();
                    invitation.ApplicationId      = TopicConfig.Instance().ApplicationId;
                    invitation.InvitationTypeKey  = InvitationTypeKeys.Instance().InviteJoinTopic();
                    invitation.UserId             = userId;
                    invitation.SenderUserId       = sender.UserId;
                    invitation.Sender             = sender.DisplayName;
                    invitation.SenderUrl          = SiteUrls.Instance().SpaceHome(sender.UserId);
                    invitation.RelativeObjectId   = group.TopicId;
                    invitation.RelativeObjectName = group.TopicName;
                    invitation.RelativeObjectUrl  = SiteUrls.Instance().TopicHome(group.TopicKey);
                    invitation.Remark             = remark;
                    invitationService.Create(invitation);
                }
            }
        }
示例#7
0
 /// <summary>
 /// 专题的内容数
 /// </summary>
 /// <param name="ownerDataKeys"></param>
 /// <returns></returns>
 public static string TopicContentCount(this OwnerDataKeys ownerDataKeys)
 {
     return(TopicConfig.Instance().ApplicationKey + "TopicContentCount");
 }
示例#8
0
 /// <summary>
 /// 创建的专题数
 /// </summary>
 /// <param name="ownerDataKeys"></param>
 /// <returns></returns>
 public static string CreatedTopicCount(this OwnerDataKeys ownerDataKeys)
 {
     return(TopicConfig.Instance().ApplicationKey + "-ThreadCount");
 }