コード例 #1
0
        public static void CheckControlRight(string board_id, string discussion_id, string letter_id, ref string delta_flags,
                                             DynamicTableEntity entity)
        {
            Subtype subtype = LetterConverter.GetSubtype(entity);

            if (subtype == Subtype.d)
            {
                Util.ThrowUnauthorizedException("不能修改的類型。");
            }

            bool auto_unreport = false;

            if (SandFlags.Check(delta_flags, SandFlags.MT_PERMANENT_DELETE, 1))
            {
                GroupStore.CheckPermanentDeleteRight(board_id, discussion_id, letter_id, entity);
                auto_unreport = true;
            }

            int delete_num = SandFlags.GetNumber(delta_flags, SandFlags.MT_DELETED);

            if (delete_num == 1 || delete_num == -1)
            {
                //bool is_undelete = SandFlags.Check(delta_flags, SandFlags.DELETED_FLAG_CHAR, -1);

                int user_level = GroupStore.CheckDeleteRight(board_id, discussion_id, letter_id, entity, delete_num == -1);

                //delta_flags = SandFlags.DELETED_FLAG_CHAR + (delete_num * user_level).ToString();
                //delta_flags = SandFlags.MultiplyNumber(delta_flags, SandFlags.DELETED_FLAG_CHAR, user_level);
                delta_flags = SandFlags.Operate(delta_flags, new FlagOperation
                {
                    type      = FlagOperation.Type.Multiply,
                    MetaTitle = SandFlags.MT_DELETED,
                    N         = user_level
                });

                string current_flags = entity.GetFlags();
                SandFlags.CheckLevel(current_flags, SandFlags.MT_DELETED, delta_flags);

                auto_unreport = true;
            }
            if (SandFlags.Check(delta_flags, SandFlags.MT_REPORT, 0))
            {
                GroupStore.CheckUnreportRight(board_id);
            }
            else if (SandFlags.Check(delta_flags, SandFlags.MT_REPORT, 1))
            {
            }
            else
            {
                if (auto_unreport)
                {
                    delta_flags = SandFlags.Add(delta_flags, SandFlags.MT_REPORT, 0);
                }
            }
        }
コード例 #2
0
        public static void CheckEditRight(string board_id, string discussion_id, DynamicTableEntity entity)
        {
            Subtype subtype = LetterConverter.GetSubtype(entity);

            if (subtype == Subtype.d)
            {
                Util.ThrowUnauthorizedException("不能編輯的類型。");
            }

            if (!CreatorConverter.IsCurrentUserCreator(entity) &&
                !DiscussionLoadStore.IsCurrentUserDiscussionCreator(board_id, discussion_id) &&
                !IsBoardOwner(board_id))
            {
                Util.ThrowUnauthorizedException("沒有編輯權限。只有副板主以上、串主、或原作者可以編輯。");
            }
        }
コード例 #3
0
        public void AddLetter(DynamicTableEntity entity)
        {
            Subtype subtype = LetterConverter.GetSubtype(entity);

            if (subtype == Subtype.h)
            {
                this.viewType = entity.GetViewType();
            }

            string json = LetterConverter.LetterToJson(entity, this.BoardId, this.DiscussionId, this.viewType);

            if (subtype == Subtype.h)
            {
                if (this.headingJson == null)
                {
                    this.headingJson = json;
                }
            }
            else if (entity.RowKey == SandId.FIRST_SUBJECT_LETTER_ID)
            {
                if (this.subjectJson == null)
                {
                    this.subjectJson = json;
                }
            }
            else if (subtype == Subtype.s || subtype == Subtype.r)
            {
                this.replyQueue.Enqueue(json);

                if (this.replyQueue.Count > REPLY_COUNT)
                {
                    string dummy;
                    this.replyQueue.TryDequeue(out dummy);
                }
            }
            // subtype d is ignored. when there are lots of subtype d, replies will be pushed out of queue.
        }
コード例 #4
0
        private void addLetter(TextWriter writer, DynamicTableEntity entity)
        {
            LetterConverter.WriteForCrawler(writer, entity, false, null);

            Subtype subtype = LetterConverter.GetSubtype(entity);

            switch (subtype)
            {
            case Subtype.h:
                if (this.Heading == null)
                {
                    this.Heading = /*RemoveForeMeta*/ (LetterConverter.GetAbstract(entity));
                }
                break;

            case Subtype.s:
                // when subject is split to multiple segments, subtype s will be met multiple times.
                if (this.Description == null)
                {
                    this.Description = extractOgImage(LetterConverter.GetWholeWords(entity, false));
                }
                break;
            }
        }