示例#1
0
 public void Handle(DiscussionStarted @event)
 {
     _userId       = @event.UserId;
     _forumId      = @event.ForumId;
     _discussionId = @event.DiscussionId;
     _author       = @event.Author;
     _subject      = @event.Subject;
     _closed       = false;
 }
    public ForumCreatedEvent(ForumId id, string title, string description)
    {
      Condition.Requires(id, "id").IsNotNull();
      Condition.Requires(title, "title").IsNotNullOrEmpty();
      Condition.Requires(description, "description").IsNotNull();

      Id = id;
      Title = title;
      Description = description;
    }
示例#3
0
        public ForumUpdatedEvent(ForumId id, string title, string description)
        {
            Condition.Requires(id, "id").IsNotNull();
            Condition.Requires(title, "title").IsNotNullOrEmpty();
            Condition.Requires(description, "description").IsNotNull();

            Id          = id;
            Title       = title;
            Description = description;
        }
示例#4
0
 public DiscussionStarted(
     string userId,
     ForumId forumId,
     DiscussionId discussionId,
     Author author,
     string subject) :
     base(null, discussionId.Id, nameof(Discussion), 1)
 {
     UserId       = userId;
     ForumId      = forumId;
     DiscussionId = discussionId;
     Author       = author;
     Subject      = subject;
 }
        protected override void Render(HtmlTextWriter writer)
        {
            Controls.TopicBrowser tb = new Controls.TopicBrowser();

            tb.PortalId = PortalId;
            tb.ModuleId = ForumModuleId;
            tb.TabId    = ForumTabId;
            if (tb.TabId <= 0)
            {
                tb.TabId = int.Parse(Request.QueryString["TabID"]);
            }
            tb.ForumGroupId = ForumGroupId;
            tb.ForumId      = ForumId;

            if (ForumId > 0)
            {
                if (Permissions.HasAccess(ForumInfo.Security.View, ForumUser.UserRoles))
                {
                    tb.ForumIds = ForumId.ToString();
                }
                else
                {
                    writer.Write(string.Empty);
                    return;
                }
            }
            else
            {
                tb.ForumIds = UserForumsList;
            }
            if (Request.QueryString["atg"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["atg"]))
            {
                tb.TagId = int.Parse(Request.QueryString["atg"]);
            }
            if (Request.QueryString["act"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["act"]))
            {
                tb.CategoryId = int.Parse(Request.QueryString["act"]);
            }
            tb.ForumUser      = ForumUser;
            tb.PageIndex      = PageId;
            tb.PageSize       = MainSettings.PageSize;
            tb.Template       = ItemTemplate.Text;
            tb.HeaderTemplate = HeaderTemplate.Text;
            tb.FooterTemplate = FooterTemplate.Text;
            tb.ImagePath      = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + MainSettings.Theme);
            tb.TopicId        = TopicId;
            tb.TimeZoneOffset = TimeZoneOffset;
            writer.Write(tb.Render());
        }
示例#6
0
        public Discussion(
            string userId,
            ForumId forumId,
            DiscussionId discussionId,
            Author author,
            string subject)
        {
            Assert.NotNullOrEmpty(userId, nameof(userId));
            Assert.NotNull(forumId, nameof(forumId));
            Assert.NotNull(discussionId, nameof(discussionId));
            Assert.NotNull(author, nameof(author));
            Assert.NotNullOrEmpty(subject, nameof(subject));

            Apply(new DiscussionStarted(userId, forumId, discussionId, author, subject));
        }
示例#7
0
        public async Task SendPostAsync(string content, bool enableTrack, bool enableEmoji, bool enableSignature, CancellationToken token = default)
        {
            if (content.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(content));
            }
            Client.Current.CheckLogOn();
            await Client.Current.HttpClient.PostAsync(Client.ForumsUri, getContent()).AsTask(token);

            return;

            IEnumerable <KeyValuePair <string, string> > getContent()
            {
                yield return(new KeyValuePair <string, string>("act", "Post"));

                yield return(new KeyValuePair <string, string>("CODE", "03"));

                yield return(new KeyValuePair <string, string>("f", ForumId.ToString()));

                yield return(new KeyValuePair <string, string>("t", Id.ToString()));

                yield return(new KeyValuePair <string, string>("st", "0"));

                yield return(new KeyValuePair <string, string>("auth_key", Md5));

                yield return(new KeyValuePair <string, string>("fast_reply_used", "1"));

                yield return(new KeyValuePair <string, string>("Post", content));

                if (enableTrack)
                {
                    yield return(new KeyValuePair <string, string>("enabletrack", "1"));
                }
                if (enableEmoji)
                {
                    yield return(new KeyValuePair <string, string>("enableemo", "yes"));
                }
                if (enableSignature)
                {
                    yield return(new KeyValuePair <string, string>("enablesig", "yes"));
                }
                yield return(new KeyValuePair <string, string>("submit", "Add Reply"));
            }
        }
示例#8
0
 => await WithModerator(ForumId, async() =>
 {
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentPage == -1)
            {
                CurrentPage = 0;
            }

            if (ForumId != null)
            {
                _currentForum = Forums.GetForum(ForumId.Value);
                if (_currentForum == null)
                {
                    throw new ArgumentException("Invalid Forum ID");
                }
                if (_currentForum.Type == 1)
                {
                    Response.Redirect(_currentForum.Url, true);
                }

                fLogin.forum = _currentForum;
                if (!IsPostBack)
                {
                    if (IsAuthenticated)
                    {
                        //do we have access to this forum
                        if (!Forums.IsUserInForumRole(Member.Username, ForumId.Value))
                        {
                            if (Session[session] == null || Session[session].ToString() != ForumId.ToString())
                            {
                                if (_currentForum.Password != null &&
                                    !String.IsNullOrEmpty(_currentForum.Password.Trim()))
                                {
                                    if (Session[session] == null || Session[session].ToString() == "")
                                    {
                                        var mp         = (ModalPopupExtender)fLogin.FindControl("popup");
                                        var masterPage = this.Page.Master;
                                        if (masterPage != null)
                                        {
                                            var cph = (ContentPlaceHolder)masterPage.FindControl("CPM");

                                            cph.Visible = false;
                                        }
                                        mp.Show();
                                    }
                                    else
                                    {
                                        if (Session[session].ToString() != ForumId.ToString())
                                        {
                                            throw new SecurityException("You are not authorised to view this forum");
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Session[session] = ForumId.ToString();
                        }
                    }
                }
                _currentForum.Roles = Forums.GetForumRoles(_currentForum.Id).ToList();
                if (!IsAuthenticated && (_currentForum.Roles.Count > 0 && !_currentForum.Roles.Contains("All")))
                {
                    //if (Session[session] == null || Session[session].ToString() != ForumId.ToString())
                    throw new SecurityException("You must be logged in to view this forum");
                }
                Session["IsAdminOrModerator"] = IsAdministrator || IsForumModerator;

                populate = PopulateData;

                //phPager.Controls.Add(_topicPager);

                Page.Title       = string.Format(webResources.ttlForumPage, _currentForum.Subject, Config.ForumTitle);
                lblHotTopic.Text = string.Format(webResources.lblHotTopics, Config.HotTopicNum);
                string pagedescription = _currentForum.Description.CleanForumCodeTags();
                metadescription.Text = String.Format("<meta name=\"description\" content=\"{0}\">", pagedescription);
            }
            else
            {
                //Response.Redirect("error.aspx?msg=errInvalidForumId", true);
                throw new HttpException(404, "Forum not found");
            }
            InitializeStickyCollapse();


            if (Request.Params["whichpage"] != null)
            {
                try
                {
                    //_topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1;
                    _topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1;
                }
                catch (Exception)
                {
                    //Response.Redirect("error.aspx?msg=errInvalidPageNumber",true);
                    throw new HttpException(404, "forum page not found");
                }
            }

            if (!IsPostBack)
            {
                //create CacheKeyDependency if it does not exists
                if (Cache[TopicODS.CacheKeyDependency] == null || (int)Cache[TopicODS.CacheKeyDependency] != ForumId)
                {
                    object obj = ForumId;
                    Cache[TopicODS.CacheKeyDependency] = obj;
                }
                BindData();
            }
            if (Page.IsPostBack)
            {
                string postbackbtn = Request.Form["__EVENTTARGET"];
                string argument    = Request.Form["__EVENTARGUMENT"];
                int    id;
                switch (postbackbtn)
                {
                case "LockTopic":
                    id = Convert.ToInt32(argument);
                    LockTopic(id);
                    break;

                case "UnLockTopic":
                    id = Convert.ToInt32(argument);
                    UnLockTopic(id);
                    break;

                case "DeleteTopic":
                    id = Convert.ToInt32(argument);
                    DeleteTopic(id);
                    break;

                case "StickTopic":
                    id = Convert.ToInt32(argument);
                    StickTopic(id);
                    break;

                case "UnStickTopic":
                    id = Convert.ToInt32(argument);
                    UnStickTopic(id);
                    break;
                }
            }
        }
示例#10
0
        private void SetupPageControls()
        {
            cbxSig.Checked  = Member.UseSignature;
            cbxLock.Checked = _topicLocked;
            if (_thisTopic != null)
            {
                cbxSticky.Checked = _thisTopic.IsSticky;
            }

            switch (_action)
            {
            case "topic":
                SubjectDiv.Visible = true;
                ForumDiv.Visible   = (IsAdministrator || (_inModeratedList && !Config.RestrictModeratorMove));

                ForumDropDown.SelectedValue = ForumId.ToString();
                cbxSticky.Visible           = _inModeratedList;
                cbxLock.Visible             = _inModeratedList;
                if (ForumId.HasValue)
                {
                    if (_forum.Type == 3 && String.IsNullOrEmpty(Message.Text))
                    {
                        var    file    = new StreamReader(Server.MapPath(Config.CultureSpecificDataDirectory + "bugtemplate.txt"));
                        string content = file.ReadToEnd();
                        Message.Text = content;
                        file.Close();
                        file.Dispose();
                    }
                }
                break;

            case "reply":
                SubjectDiv.Visible = false;
                cbxSticky.Visible  = false;
                cbxLock.Visible    = _inModeratedList;
                ForumDiv.Visible   = false;
                break;

            case "quote":
                SubjectDiv.Visible = false;
                cbxSticky.Visible  = false;
                ForumDiv.Visible   = false;
                cbxLock.Visible    = _inModeratedList;
                Message.Text       = GetQuotedMessage();
                break;

            case "edit":
                switch (_type)
                {
                case "topics":
                    cbxSticky.Visible = _inModeratedList;
                    cbxLock.Visible   = _inModeratedList;
                    SetupForEditMessage();
                    break;

                case "reply":
                    cbxSticky.Visible = false;
                    cbxLock.Visible   = _inModeratedList;
                    SetupForEditMessage();
                    break;

                case "forum":
                    if (Request.UrlReferrer != null)
                    {
                        Response.Redirect(Request.UrlReferrer.AbsoluteUri);
                    }
                    break;
                }

                break;

            default:
                if (Request.UrlReferrer != null)
                {
                    Response.Redirect(Request.UrlReferrer.AbsoluteUri);
                }
                break;
            }
        }
 => await WithValidForum(ForumId, ForumId == 0, async (thisForum) =>