Beispiel #1
0
        /**************************************
        *  Validate开头的函数会抛出错误信息  *
        **************************************/

        /// <summary>
        /// 验证记录的内容合法性
        /// </summary>
        /// <param name="content">记录的内容</param>
        /// <returns></returns>
        private bool ValidateDoingContent(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                Context.ThrowError(new EmptyDoingContentError("content"));
                return(false);
            }

            if (StringUtil.GetByteCount(content) > Consts.Doing_Length)
            {
                Context.ThrowError(new InvalidDoingContentLengthError("content", content, Consts.Doing_Length));
                return(false);
            }

            ContentKeywordSettings keywords = AllSettings.Current.ContentKeywordSettings;

            string keyword = null;

            if (keywords.BannedKeywords.IsMatch(content, out keyword))
            {
                ThrowError(new DoingContentBannedKeywordsError("content", keyword));
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// 不更新 totalThreads
        /// </summary>
        /// <param name="threadcatalogs"></param>
        /// <returns></returns>
        public bool UpdateThreadCatalogs(ThreadCatalogCollection threadcatalogs)
        {
            if (threadcatalogs.Count == 0)
            {
                return(true);
            }

            foreach (ThreadCatalog threadCatalog in threadcatalogs)
            {
                if (string.IsNullOrEmpty(threadCatalog.ThreadCatalogName))
                {
                    ThrowError <EmptyThreadCatalogNameError>(new EmptyThreadCatalogNameError("threadCatalogName"));
                    return(false);
                }
                if (StringUtil.GetByteCount(threadCatalog.ThreadCatalogName) > Consts.Forum_ThreadCatalogNameLength)
                {
                    ThrowError <InvalidThreadCatalogNameLengthError>(new InvalidThreadCatalogNameLengthError("ThreadCatalogName", threadCatalog.ThreadCatalogName));
                    return(false);
                }
                if (StringUtil.GetByteCount(threadCatalog.LogoUrl) > Consts.Forum_ThreadCatalogLogoUrlLength)
                {
                    ThrowError <InvalidThreadCatalogLogoUrlLengthError>(new InvalidThreadCatalogLogoUrlLengthError("LogoUrl", threadCatalog.LogoUrl));
                    return(false);
                }
            }

            bool success = ForumDaoV5.Instance.UpdateThreadCatalogs(threadcatalogs);

            if (success)
            {
                ClearThreadCatalogsCache();
            }

            return(success);
        }
Beispiel #3
0
        public bool UpdateThreadCate(AuthUser operatorUser, int cateID, string cateName, bool enable, int sortOrder, IEnumerable <int> enableModelIDs)
        {
            if (AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_ThreadCate) == false)
            {
                ThrowError(new NoPermissionManageThreadCateError());
                return(false);
            }

            if (string.IsNullOrEmpty(cateName))
            {
                ThrowError(new EmptyThreadCateNameError("cateName"));
                return(false);
            }
            if (StringUtil.GetByteCount(cateName) > threadCateNameMaxLength)
            {
                ThrowError(new InvalidThreadCateNameLengthError("cateName", cateName, threadCateNameMaxLength));
                return(false);
            }
            int result = ThreadCateDao.Instance.UpdateThreadCate(cateID, cateName, enable, sortOrder);

            if (result > 0)
            {
                allThreadCates = null;
                EnableModels(operatorUser, cateID, enableModelIDs);
            }
            else
            {
                ThrowError(new ThreadCateNotExistsError(cateID));
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        private bool ValidateText(string text)
        {
            int maxLength = 100;

            if (string.IsNullOrEmpty(text))
            {
                ThrowError(new ImpressionTextEmptyError("text"));
                return(false);
            }

            if (StringUtil.GetByteCount(text) > maxLength)
            {
                ThrowError(new ImpressionTextLengthError("text", text, maxLength));
                return(false);
            }

            ContentKeywordSettings keywords = AllSettings.Current.ContentKeywordSettings;

            string keyword = null;

            if (keywords.BannedKeywords.IsMatch(text, out keyword))
            {
                ThrowError(new ImpressionTextBannedKeywordsError("text", keyword));
                return(false);
            }

            return(true);
        }
Beispiel #5
0
        public bool CreateThreadCateModelField(AuthUser operatorUser, int modelID, string fieldName, bool enable, int sortOrder, string fieldType
                                               , string fieldTypeSetting, bool search, bool advancedSearch, bool displayInList, bool mustFilled, string description)
        {
            if (AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_ThreadCate) == false)
            {
                ThrowError(new NoPermissionManageThreadCateError());
                return(false);
            }

            if (string.IsNullOrEmpty(fieldName))
            {
                ThrowError(new EmptyThreadCateModelFieldNameError("fieldName", 0));
                return(false);
            }

            if (StringUtil.GetByteCount(fieldName) > fieldNameMaxLength)
            {
                ThrowError(new InvalidThreadCateModelFieldNameLengthError("fieldName", 0, fieldName, fieldNameMaxLength));
                return(false);
            }

            int returnValue = ThreadCateDao.Instance.CreateThreadCateModelField(modelID, fieldName, enable, sortOrder, fieldType, fieldTypeSetting, search, advancedSearch, displayInList, mustFilled, description);

            if (returnValue == 0)
            {
                ThrowError(new ThreadCateModelNotExistsError(modelID));
                return(false);
            }
            else
            {
                allThreadCateModelFields = null;
            }

            return(true);
        }
Beispiel #6
0
        public bool CreateThreadCate(AuthUser operatorUser, string cateName, bool enable, int sortOrder)
        {
            if (AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_ThreadCate) == false)
            {
                ThrowError(new NoPermissionManageThreadCateError());
                return(false);
            }
            if (string.IsNullOrEmpty(cateName))
            {
                ThrowError(new EmptyThreadCateNameError("cateName"));
                return(false);
            }
            if (StringUtil.GetByteCount(cateName) > threadCateNameMaxLength)
            {
                ThrowError(new InvalidThreadCateNameLengthError("cateName", cateName, threadCateNameMaxLength));
                return(false);
            }
            bool success = ThreadCateDao.Instance.CreateThreadCate(cateName, enable, sortOrder);

            if (success)
            {
                allThreadCates = null;
                models         = null;
            }
            return(success);
        }
Beispiel #7
0
        public bool CreateModel(AuthUser operatorUser, int cateID, string modelName, bool enable, int sortOrder)
        {
            if (AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_ThreadCate) == false)
            {
                ThrowError(new NoPermissionManageThreadCateError());
                return(false);
            }
            if (string.IsNullOrEmpty(modelName))
            {
                ThrowError(new EmptyThreadCateModelNameError("modelName", 0));
                return(false);
            }
            if (StringUtil.GetByteCount(modelName) > modelNameMaxLength)
            {
                ThrowError(new InvalidThreadCateModelNameLengthError("modelName", 0, modelName, modelNameMaxLength));
                return(false);
            }

            int result = ThreadCateDao.Instance.CreateModel(cateID, modelName, enable, sortOrder);

            if (result > 0)
            {
                models = null;
                return(true);
            }
            else
            {
                ThrowError(new ThreadCateNotExistsError(cateID));
                return(false);
            }
        }
Beispiel #8
0
        private bool ValidateNotifyContent(string content)
        {
            if (StringUtil.GetByteCount(content) > 2000)
            {
                return(false);
            }

            return(true);
        }
Beispiel #9
0
        private bool ValidateNotifyParameters(string parameters)
        {
            if (StringUtil.GetByteCount(parameters) > 2000)
            {
                return(false);
            }

            return(true);
        }
Beispiel #10
0
        /// <summary>
        /// 检查IP是否合法
        /// </summary>
        /// <param name="IP"></param>
        /// <returns></returns>
        public static bool IsIPAddress(string IP)
        {
            if (string.IsNullOrEmpty(IP))
            {
                return(false);
            }

            if (StringUtil.GetByteCount(IP) > 50)
            {
                return(false);
            }

            return(Pool <IPRegex> .Instance.IsMatch(IP));
        }
Beispiel #11
0
        /// <summary>
        /// 检查Email是否正确
        ///
        /// 错误:
        /// EmptyEmailError
        /// EmailFormatError
        /// EmailForbiddenError
        /// </summary>
        /// <returns></returns>
        public static bool IsEmail(string email)
        {
            if (string.IsNullOrEmpty(email))
            {
                return(false);
            }

            if (StringUtil.GetByteCount(email) > 200)
            {
                return(false);
            }

            //检查格式是否正确
            return(Pool <EmailRegex> .Instance.IsMatch(email));
        }
Beispiel #12
0
		public bool CreateDenouncing(int operatorID, int targetID, int targetUserID, DenouncingType type, string content, string createIP)
        {
            if (targetID <= 0)
            {
                ThrowError(new InvalidParamError("targetID"));
                return false;
            }

            if (StringUtil.GetByteCount("content") > Consts.Report_Length)
            {
                Context.ThrowError(new InvalidReportLengthError("content", content, Consts.Report_Length));
                return false;
            }

			DenouncingDao.Instance.CreateDenouncing(operatorID, targetID, targetUserID, type, content, createIP);

            CacheUtil.Remove("Denouncing/Count");

            return true;
        }
Beispiel #13
0
        public bool UpdateModels(AuthUser operatorUser, IEnumerable <int> modelIDs, IEnumerable <int> sortOrders, IEnumerable <string> modelNames, IEnumerable <int> enableIDs)
        {
            if (AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_ThreadCate) == false)
            {
                ThrowError(new NoPermissionManageThreadCateError());
                return(false);
            }
            if (ValidateUtil.HasItems <int>(modelIDs) == false)
            {
                return(true);
            }

            int i = 0;

            foreach (string name in modelNames)
            {
                if (string.IsNullOrEmpty(name))
                {
                    ThrowError(new EmptyThreadCateModelNameError("modelName", i));
                }
                if (StringUtil.GetByteCount(name) > modelNameMaxLength)
                {
                    ThrowError(new InvalidThreadCateModelNameLengthError("modelName", i, name, modelNameMaxLength));
                }
                i++;
            }

            if (HasUnCatchedError)
            {
                return(false);
            }

            bool success = ThreadCateDao.Instance.UpdateModels(modelIDs, sortOrders, modelNames, enableIDs);

            if (success)
            {
                models = null;
            }

            return(success);
        }
Beispiel #14
0
        private bool ValidateForumParams(string codeName, string forumName, int?parentID, ForumType forumType, string password, string logoSrc, string themeID)
        {
            if (string.IsNullOrEmpty(codeName))
            {
                ThrowError <EmptyForumCodeNameError>(new EmptyForumCodeNameError("codeName"));
                return(false);
            }

            //System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"[\u4e00-\u9fa5]+");
            //if (reg.IsMatch(codeName))//不允许中文
            //{
            //    ThrowError<InvalidForumCodeNameError>(new InvalidForumCodeNameError("codeName", codeName));
            //    return false;
            //}

            //reg = new System.Text.RegularExpressions.Regex(@"[\\/\?\-#&]+");
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z-_\d]+$");
            if (reg.IsMatch(codeName) == false)
            {
                ThrowError <InvalidForumCodeNameError>(new InvalidForumCodeNameError("codeName", codeName));
                return(false);
            }

            if (StringUtil.GetByteCount(codeName) > Consts.Forum_CodeNameLength)
            {
                ThrowError <InvalidForumCodeNameLengthError>(new InvalidForumCodeNameLengthError("codeName", codeName));
                return(false);
            }
            if (string.IsNullOrEmpty(forumName))
            {
                ThrowError <EmptyForumNameError>(new EmptyForumNameError("forumName"));
                return(false);
            }
            if (StringUtil.GetByteCount(forumName) > Consts.Forum_NameLength)
            {
                ThrowError <InvalidForumNameLengthError>(new InvalidForumNameLengthError("forumName", forumName));
                return(false);
            }

            if (StringUtil.GetByteCount(logoSrc) > Consts.Forum_LogoSrcLength)
            {
                ThrowError <InvalidForumLogoSrcLengthError>(new InvalidForumLogoSrcLengthError("LogoSrc", logoSrc));
                return(false);
            }

            if (StringUtil.GetByteCount(password) > Consts.Forum_PasswordLength)
            {
                ThrowError <InvalidForumPasswordLengthError>(new InvalidForumPasswordLengthError("password", password));
                return(false);
            }
            if (themeID == null)
            {
                ThrowError <EmptyForumThemeIDError>(new EmptyForumThemeIDError("themeID"));
                return(false);
            }

            if (parentID != null)
            {
                if (forumType == ForumType.Catalog && parentID.Value != 0)
                {
                    ThrowError <InvalidForumCatalogParentIDError>(new InvalidForumCatalogParentIDError("parentID"));
                    return(false);
                }
                else if (forumType != ForumType.Catalog && parentID.Value == 0)
                {
                    ThrowError <InvalidForumParentIDError>(new InvalidForumParentIDError("parentID"));
                    return(false);
                }
            }

            return(true);
        }
Beispiel #15
0
        /// <summary>
        /// 评论编辑
        /// </summary>
        /// <param name="commentID"></param>
        /// <param name="content"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool ModifyComment(int operatorUserID, int commentID, string content, CommentType type, out string newContent)
        {
            newContent = content;

            if (commentID <= 0)
            {
                ThrowError(new InvalidParamError("commentID"));
                return(false);
            }

            Comment comment = GetCommentByID(commentID);

            if (comment == null)
            {
                ThrowError <InvalidParamError>(new InvalidParamError("commentID"));
                return(false);
            }

            if (ValidateCommentEditPermission(operatorUserID, comment) == false)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(content))
            {
                Context.ThrowError(new EmptyCommentError("content"));
                return(false);
            }
            if (StringUtil.GetByteCount(content) > Consts.Comment_Length)
            {
                Context.ThrowError(new InvalidCommentLengthError("content", content, Consts.Comment_Length));
                return(false);
            }

            bool   isApproved = true;
            string reverter, version;

            content = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords.Replace(content, out version, out reverter);

            string keyword = null;

            if (AllSettings.Current.ContentKeywordSettings.BannedKeywords.IsMatch(content, out keyword))
            {
                Context.ThrowError(new KeywordBannedError("content", keyword));
                return(false);
            }
            else if (AllSettings.Current.ContentKeywordSettings.ApprovedKeywords.IsMatch(content))
            {
                isApproved = false;
            }

            content = CommentUbbParser.ParseForSave(content);

            if (StringUtil.GetByteCount(content) > Consts.Comment_Length)
            {
                Context.ThrowError(new InvalidCommentLengthError("content", content, Consts.Comment_Length));
                return(false);
            }

            int targetID;

            CommentDao.Instance.UpdateComment(commentID, operatorUserID, isApproved, content, reverter, out targetID);

            if (type == CommentType.Doing)
            {
                CacheUtil.RemoveBySearch("Doing/List/All");
            }
            if (type == CommentType.Board)            //更新留言所在用户缓存的数据而不是留言的用户!
            {
                CacheUtil.RemoveBySearch(string.Format(cacheKey_List_Space, targetID, type));
            }

            newContent = content;

            if (isApproved == false)
            {
                ThrowError <UnapprovedCommentError>(new UnapprovedCommentError());
                return(false);
            }

            return(true);
        }
Beispiel #16
0
        /// <summary>
        /// 添加评论 并更新缓存
        /// </summary>
        /// <param name="userID">评论者ID</param>
        /// <param name="targetID">被评论的记录、日志、相册的ID</param>
        /// <param name="commentID">被评论的评论ID</param>
        /// <param name="type">评论类型 记录、日志、相册</param>
        /// <param name="content"></param>
        /// <param name="createIP"></param>
        /// <returns></returns>
        public bool AddComment(AuthUser operatorUser, int targetID, int commentID, CommentType type, string content, string createIP, bool isReply, int replyTargetUserID, out int newCommentId, out string newCommentContent)
        {
            Notify notify;

            newCommentId      = 0;
            newCommentContent = string.Empty;

            if (Permission.Can(operatorUser, SpacePermissionSet.Action.AddComment) == false)
            {
                ThrowError <NoPermissionAddCommentError>(new NoPermissionAddCommentError());
                return(false);
            }

            if (targetID < 0)
            {
                ThrowError(new InvalidParamError("targetID"));
                return(false);
            }

            if (commentID < 0)
            {
                ThrowError(new InvalidParamError("commentID"));
                return(false);
            }

            if (string.IsNullOrEmpty(content))
            {
                ThrowError(new EmptyCommentError("content"));
                return(false);
            }

            if (StringUtil.GetByteCount(content) > Consts.Comment_Length)
            {
                ThrowError(new InvalidCommentLengthError("content", content, Consts.Comment_Length));
                return(false);
            }



            int commentTargetUserID = GetCommentTargetUserID(targetID, type);

            if (FriendBO.Instance.MyInBlacklist(operatorUser.UserID, commentTargetUserID))
            {
                ThrowError(new PrivacyError());
                return(false);
            }

            bool isApproved = true;

            //string reverter, version;

            //content = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords.Replace(content, out version, out reverter);

            CommentPointType commentPointType = CommentPointType.AddApprovedComment;


            KeywordReplaceRegulation keywordReg = AllSettings.Current.ContentKeywordSettings.ReplaceKeywords;

            content = keywordReg.Replace(content);

            string keyword = null;

            if (AllSettings.Current.ContentKeywordSettings.BannedKeywords.IsMatch(content, out keyword))
            {
                Context.ThrowError(new KeywordBannedError("content", keyword));
                return(false);
            }


            if (AllSettings.Current.ContentKeywordSettings.ApprovedKeywords.IsMatch(content))
            {
                isApproved       = false;
                commentPointType = CommentPointType.AddNoApprovedComment;
            }

            if (StringUtil.GetByteCount(content) > Consts.Comment_Length)
            {
                Context.ThrowError(new InvalidCommentLengthError("content", content, Consts.Comment_Length));
                return(false);
            }

            int targetUserID = 0;

            int tempCommentID = 0;

            content           = CommentUbbParser.ParseForSave(content);
            newCommentContent = content;

            bool success = CommentPointAction.Instance.UpdateUserPoint(operatorUser.UserID, commentPointType, delegate(PointActionManager.TryUpdateUserPointState state)
            {
                if (state != PointActionManager.TryUpdateUserPointState.CheckSucceed)
                {
                    return(false);
                }
                else
                {
                    //添加评论并发送动态与通知
                    switch (type)
                    {
                    case CommentType.Board:
                        SimpleUser user = UserBO.Instance.GetSimpleUser(targetID);

                        if (user == null)
                        {
                            ThrowError(new UserNotExistsError("targetID", targetID));
                            return(false);
                        }

                        CommentDao.Instance.AddComment(operatorUser.UserID, targetID, type, isApproved, content, /* reverter, */ createIP, out targetUserID, out tempCommentID);
                        FeedBO.Instance.CreateLeveMessageFeed(operatorUser.UserID, targetID);

                        if (isReply && operatorUser.UserID != replyTargetUserID)
                        {
                            notify        = new BoardCommentNotify(operatorUser.UserID, tempCommentID, isReply, targetID);
                            notify.UserID = replyTargetUserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }
                        else if (targetID != operatorUser.UserID)
                        {
                            notify        = new BoardCommentNotify(operatorUser.UserID, tempCommentID, false, targetID);
                            notify.UserID = targetID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }

                        CacheUtil.RemoveBySearch(string.Format(cacheKey_List_Space, targetID, type));
                        break;

                    case CommentType.Blog:
                        BlogArticle article = BlogBO.Instance.GetBlogArticle(targetID);

                        if (article == null)
                        {
                            ThrowError(new NotExistsAlbumError(targetID));
                            return(false);
                        }

                        if (!article.EnableComment)
                        {
                            ThrowError(new PrivacyError());
                            return(false);
                        }
                        else
                        {
                            if (article.UserID != operatorUser.UserID)       //如果不是作者评论自己的 给作者加积分
                            {
                                CommentDao.Instance.AddComment(operatorUser.UserID, targetID, type, isApproved, content, /* reverter, */ createIP, out targetUserID, out tempCommentID);

                                success = BlogPointAction.Instance.UpdateUserPoint(article.UserID, BlogPointType.ArticleWasCommented);

                                if (success == false)
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                CommentDao.Instance.AddComment(operatorUser.UserID, targetID, type, isApproved, content, /* reverter, */ createIP, out targetUserID, out tempCommentID);
                            }
                        }

                        FeedBO.Instance.CreatBlogCommentFeed(operatorUser.UserID, article.UserID, targetID, article.Subject);

                        if (isReply && operatorUser.UserID != replyTargetUserID)
                        {
                            notify        = new BlogCommentNotify(operatorUser.UserID, article.Subject, targetID, tempCommentID, isReply, article.UserID);
                            notify.UserID = replyTargetUserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }
                        else if (article.UserID != operatorUser.UserID)
                        {
                            notify        = new BlogCommentNotify(operatorUser.UserID, article.Subject, targetID, tempCommentID, false, article.UserID);
                            notify.UserID = article.UserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }
                        break;

                    case CommentType.Doing:
                        Doing doing = DoingBO.Instance.GetDoing(targetID);

                        if (doing == null)
                        {
                            ThrowError(new NotExistsDoingError(targetID));
                            return(false);
                        }

                        CommentDao.Instance.AddComment(operatorUser.UserID, targetID, type, isApproved, content, /* reverter, */ createIP, out targetUserID, out tempCommentID);

                        if (isReply && operatorUser.UserID != replyTargetUserID)
                        {
                            notify        = new DoingPostNotify(operatorUser.UserID, doing.Content, doing.ID, tempCommentID, isReply, doing.UserID);
                            notify.UserID = replyTargetUserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }
                        else if (doing.UserID != operatorUser.UserID)
                        {
                            notify        = new DoingPostNotify(operatorUser.UserID, doing.Content, doing.ID, tempCommentID, false, doing.UserID);
                            notify.UserID = doing.UserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }
                        DoingBO.Instance.ClearCachedEveryoneData();
                        break;

                    case CommentType.Share:
                        Share share = ShareBO.Instance.GetUserShare(targetID);

                        if (share == null)
                        {
                            ThrowError(new NotExistsShareError(targetID));
                            return(false);
                        }

                        if (share.UserID != operatorUser.UserID)       //如果不是分享作者评论自己的分享 给分享作者加积分
                        {
                            CommentDao.Instance.AddComment(operatorUser.UserID, targetID, type, isApproved, content, /* reverter, */ createIP, out targetUserID, out tempCommentID);
                            success = SharePointAction.Instance.UpdateUserPoint(share.UserID, SharePointType.ShareWasCommeted);

                            if (!success)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            CommentDao.Instance.AddComment(operatorUser.UserID, targetID, type, isApproved, content, /* reverter, */ createIP, out targetUserID, out tempCommentID);
                        }

                        ShareBO.Instance.ClearCachedEveryoneData();

                        FeedBO.Instance.CreatShareCommentFeed(operatorUser.UserID, share.UserID, targetID, share.Type);

                        if (isReply && operatorUser.UserID != replyTargetUserID)
                        {
                            notify        = new SharePostNotify(operatorUser.UserID, targetID, tempCommentID, isReply, share.UserID);
                            notify.UserID = replyTargetUserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }
                        else if (share.UserID != operatorUser.UserID)
                        {
                            notify        = new SharePostNotify(operatorUser.UserID, targetID, tempCommentID, false, share.UserID);
                            notify.UserID = share.UserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }

                        break;

                    case CommentType.Photo:
                        Photo photo = AlbumBO.Instance.GetPhoto(targetID);

                        if (photo == null)
                        {
                            ThrowError(new NotExistsPhotoError(targetID));
                            return(false);
                        }

                        CommentDao.Instance.AddComment(operatorUser.UserID, targetID, type, isApproved, content, /* reverter, */ createIP, out targetUserID, out tempCommentID);
                        FeedBO.Instance.CreatPictureCommentFeed(operatorUser.UserID, targetUserID, targetID, photo.ThumbSrc, photo.Name, content);

                        if (isReply && operatorUser.UserID != replyTargetUserID)
                        {
                            notify        = new PhotoCommentNotify(operatorUser.UserID, targetID, photo.Name, tempCommentID, isReply, photo.UserID);
                            notify.UserID = replyTargetUserID;

                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }
                        else if (photo.UserID != operatorUser.UserID)
                        {
                            notify        = new PhotoCommentNotify(operatorUser.UserID, targetID, photo.Name, tempCommentID, false, photo.UserID);
                            notify.UserID = photo.UserID;
                            NotifyBO.Instance.AddNotify(operatorUser, notify);
                        }

                        break;
                    }
                    return(true);
                }
            });

            if (success == false)
            {
                return(false);
            }

            newCommentId = tempCommentID;

            //更新热度
            if (targetUserID != 0)
            {
                HotType hotType = HotType.Comment;

                if (type == CommentType.Board)
                {
                    hotType = HotType.Messag;
                }

                FriendBO.Instance.UpdateFriendHot(operatorUser.UserID, hotType, targetUserID);
            }

            if (isApproved == false)
            {
                Context.ThrowError(new UnapprovedCommentError());
                return(false);
            }

            return(true);
        }