Beispiel #1
0
        public ActionResult CreateDiscussion(string board_id, string creator, string words, string heading, string delta_flags, string heading_delta_flags)
        {
            if (!Util.IsAjaxRequest(Request))
            {
                Util.ThrowBadRequestException("Not ajax post.");
            }

            object ret_obj = Warehouse.RateLimiter.Validate(CarryType.CreateDiscussion);

            if (ret_obj != null)
            {
                return(Json(ret_obj));
            }

            checkHeading(heading);

            checkLetterInput(creator, words, false);

            delta_flags         = delta_flags.Replace("\r\n", "\n");                    // 跟圖片一起上傳時(使用multipart/form-data),Chrome會帶\r\n做為換行。其它時候都是\n。IE無此問題。
            heading_delta_flags = heading_delta_flags.Replace("\r\n", "\n");

            checkEditFlags(delta_flags, false);
            checkEditFlags(heading_delta_flags, true);

            string discussion_id = DiscussionListStore.CreateDiscussion(board_id, creator, words, heading, delta_flags, Request.Files, heading_delta_flags);

            return(Json(new { discussion_id = discussion_id }));
        }
Beispiel #2
0
        public ActionResult DiscussionList(string level_1_id /*board_id or selection_id*/)
        {
            //Response.Cache.SetAllowResponseInBrowserHistory(true);
#if OLD
            object result = DiscussionListStore.GetDiscussionList(level_1_id);
            return(Json(result, JsonRequestBehavior.AllowGet));
#else
            return(new DiscussionListResult(level_1_id));
#endif
        }
Beispiel #3
0
        public ActionResult ControlLetter(string board_id, string discussion_id, string letter_id, string delta_flags, string reason)
        {
            if (!Util.IsAjaxRequest(Request))
            {
                Util.ThrowBadRequestException("Not ajax post.");
            }

            object ret_obj = Warehouse.RateLimiter.Validate(CarryType.ControlLetter);

            if (ret_obj != null)
            {
                return(Json(ret_obj));
            }

            checkControlFlags(delta_flags, letter_id == SandId.HEADING_LETTER_ID);
            if (reason.Length > 500 * HeartsConfiguration.LENGTH_CHECK_MARGIN /*counting into foreword*/)
            {
                Util.ThrowBadRequestException("理由長度過長。");
            }

            ControlHistory mh = DiscussionLoadStore.ControlLetter(board_id, discussion_id, letter_id, delta_flags);

            if (letter_id == SandId.HEADING_LETTER_ID)
            {
                delta_flags = SandFlags.Remove(delta_flags, SandFlags.MT_REPORT);
                DiscussionListStore.OperateFlags(board_id, discussion_id, new FlagMergeOperation(delta_flags));
            }
            if (mh.ReportCount != 0)
            {
                DiscussionListStore.OperateFlags(board_id, discussion_id, new FlagOperation
                {
                    type      = FlagOperation.Type.Add,
                    MetaTitle = SandFlags.MT_REPORT,
                    N         = mh.ReportCount
                });
            }

            int    id_num             = SandId.ExtractIdNumber(letter_id);
            string remark_delta_flags = SandFlags.Add(string.Empty, SandFlags.MT_REPLY_TO, id_num);
            string remark_letter_id   = DiscussionLoadStore.CreateLetter(board_id, discussion_id, null, reason, Subtype.d, remark_delta_flags, null);

            // while deleting/undeleting discussion, the remark_delta_flags is ,r0, and will be removed.

            return(Json(new { ok = true }));
        }
Beispiel #4
0
        public ActionResult EditLetter(string board_id, string discussion_id, string letter_id, string creator,
                                       string words, string delta_flags)
        {
            if (!Util.IsAjaxRequest(Request))
            {
                Util.ThrowBadRequestException("Not ajax post.");
            }

            object ret_obj = Warehouse.RateLimiter.Validate(CarryType.EditLetter);

            if (ret_obj != null)
            {
                return(Json(ret_obj));
            }

            checkLetterInput(creator, words, true);

            delta_flags = delta_flags.Replace("\r\n", "\n");

            if (letter_id == SandId.HEADING_LETTER_ID)
            {
                checkHeading(words);
                checkEditFlags(delta_flags, true);
            }
            else
            {
                checkEditFlags(delta_flags, false);
            }

            DiscussionLoadStore.EditLetter(board_id, discussion_id, letter_id, creator, words, delta_flags, Request.Files);

            if (letter_id == SandId.HEADING_LETTER_ID)
            {
                DiscussionListStore.EditHeading(board_id, discussion_id, words);
            }

            return(Json(new { letter_id = letter_id }));
        }