Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currentForumPost = "";

        // get forumPost id from querystring
        postId = QueryHelper.GetInteger("postid", 0);
        ForumPostInfo forumPostObj = ForumPostInfoProvider.GetForumPostInfo(postId);

        if (forumPostObj != null)
        {
            currentForumPost = HTMLHelper.HTMLEncode(forumPostObj.PostSubject);
        }

        CurrentMaster.PanelContent.CssClass = String.Empty;

        string listingPost = QueryHelper.GetString("listingpost", null);

        if (!String.IsNullOrEmpty(listingPost))
        {
            listingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(listingPost);
        }

        this.postEdit.EditPostID          = postId;
        this.postEdit.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(postEdit_OnCheckPermissions);
        this.postEdit.OnSaved            += new EventHandler(postEdit_OnSaved);
        this.postEdit.IsLiveSite          = false;

        this.InitializeMasterPage(currentForumPost);
    }
    /// <summary>
    /// Returns link the the forum.
    /// </summary>
    /// <param name="favoritePostId">Pots id</param>
    /// <param name="favoriteForumId">Forum id</param>
    protected string GetFavoriteLink(object favoritePostId, object favoriteForumId, object postForumID, object postIDPath)
    {
        int    postId      = ValidationHelper.GetInteger(favoritePostId, 0);
        int    forumId     = ValidationHelper.GetInteger(favoriteForumId, 0);
        int    postForumId = ValidationHelper.GetInteger(postForumID, forumId);
        string postIdPath  = ValidationHelper.GetString(postIDPath, "");

        string link = "#";

        // Post favorite
        if (postId > 0)
        {
            ForumInfo forumInfo = ForumInfoProvider.GetForumInfo(postForumId);
            if (forumInfo != null)
            {
                // If forum URL is not set, try to use base forum url
                string forumUrl = (ForumUrl == String.Empty) ? forumInfo.ForumBaseUrl : ForumUrl;
                int    threadId = ForumPostInfoProvider.GetPostRootFromIDPath(postIdPath);

                if (String.IsNullOrEmpty(forumUrl))
                {
                    forumUrl = RequestContext.CurrentURL;
                }

                link = URLHelper.UpdateParameterInUrl(ResolveUrl(forumUrl), "forumid", postForumId.ToString());
                link = URLHelper.UpdateParameterInUrl(link, "threadid", threadId.ToString());
                link = URLHelper.RemoveParameterFromUrl(link, "thread");
                link = URLHelper.RemoveParameterFromUrl(link, "mode");
                link = URLHelper.RemoveParameterFromUrl(link, "postid");
                link = URLHelper.RemoveParameterFromUrl(link, "replyto");
                link = URLHelper.RemoveParameterFromUrl(link, "subscribeto");
            }
        }

        // Forum favorite
        else if (forumId > 0)
        {
            ForumInfo forumInfo = ForumInfoProvider.GetForumInfo(forumId);
            if (forumInfo != null)
            {
                // If forum URL is not set, try to use base forum url
                string forumUrl = (ForumUrl == String.Empty) ? forumInfo.ForumBaseUrl : ForumUrl;

                if (String.IsNullOrEmpty(forumUrl))
                {
                    forumUrl = RequestContext.CurrentURL;
                }

                link = URLHelper.UpdateParameterInUrl(ResolveUrl(forumUrl), "forumid", forumId.ToString());
                link = URLHelper.RemoveParameterFromUrl(link, "threadid");
                link = URLHelper.RemoveParameterFromUrl(link, "thread");
                link = URLHelper.RemoveParameterFromUrl(link, "mode");
                link = URLHelper.RemoveParameterFromUrl(link, "postid");
                link = URLHelper.RemoveParameterFromUrl(link, "replyto");
                link = URLHelper.RemoveParameterFromUrl(link, "subscribeto");
            }
        }

        return(HTMLHelper.EncodeLinkReference(link));
    }
    /// <summary>
    /// Initializes Master Page.
    /// </summary>
    protected void InitializeMasterPage()
    {
        string        currentForumPost = "";
        ForumPostInfo forumPostObj     = ForumPostInfoProvider.GetForumPostInfo(postId);

        if (forumPostObj != null)
        {
            currentForumPost = HTMLHelper.HTMLEncode(forumPostObj.PostSubject);
        }

        Title = "Forum Post edit";

        // Initialize breadcrumbs
        PageBreadcrumbs.Items.Add(new BreadcrumbItem
        {
            Text        = GetString("ForumPost_Edit.ItemListLink"),
            RedirectUrl = ResolveUrl("~/CMSModules/Forums/Tools/Posts/ForumPost_View.aspx?postid=" + postId + listingParameter),
        });
        PageBreadcrumbs.Items.Add(new BreadcrumbItem
        {
            Text = currentForumPost,
        });

        PageTitle.TitleText = GetString("ForumPost_Edit.HeaderCaption");
        // Ensure correct breadcrumbs suffix
        UIHelper.SetBreadcrumbsSuffix(GetString("objecttype.forums_forumpost"));
    }
    /// <summary>
    /// Creates forum post. Called when the "Create post" button is pressed.
    /// </summary>
    private bool CreateForumPost()
    {
        // Get the forum
        ForumInfo forum = ForumInfoProvider.GetForumInfo("MyNewForum", CMSContext.CurrentSiteID);

        if (forum != null)
        {
            // Create new forum post object
            ForumPostInfo newPost = new ForumPostInfo();

            // Set the properties
            newPost.PostUserID   = CMSContext.CurrentUser.UserID;
            newPost.PostUserMail = CMSContext.CurrentUser.Email;
            newPost.PostUserName = CMSContext.CurrentUser.UserName;
            newPost.PostForumID  = forum.ForumID;
            newPost.PostTime     = DateTime.Now;
            newPost.PostApproved = true;
            newPost.PostText     = "This is my new post";
            newPost.PostSubject  = "My new post";

            // Save the forum post
            ForumPostInfoProvider.SetForumPostInfo(newPost);

            return(true);
        }

        return(false);
    }
Example #5
0
    /// <summary>
    /// Returns link to selected post.
    /// </summary>
    /// <param name="postIdPath">Post id path</param>
    /// <param name="forumId">Forum id</param>
    public static string GetPostURL(object postIdPath, object forumId)
    {
        string pIdPath = ValidationHelper.GetString(postIdPath, string.Empty);
        int    fId     = ValidationHelper.GetInteger(forumId, 0);

        return(ForumPostInfoProvider.GetPostURL(pIdPath, fId, true));
    }
Example #6
0
    /// <summary>
    /// Reloads the data of the forum control.
    /// </summary>
    public override void ReloadData()
    {
        base.ReloadData();

        this.UniPager1.Enabled  = this.EnableThreadPaging;
        this.UniPager1.PageSize = this.ThreadPageSize;

        // Hide selected area if forum is AdHoc
        if (this.IsAdHocForum)
        {
            plcHeader.Visible = false;
            if (ForumContext.CurrentForum.ForumID == 0)
            {
                plcContent.Visible = false;
            }
        }

        // Get thread and subscribe link url
        bool newThread       = base.IsAvailable(null, ForumActionType.NewThread);
        bool newSubscription = base.IsAvailable(null, ForumActionType.SubscribeToForum);
        bool newFavorites    = base.IsAvailable(null, ForumActionType.AddForumToFavorites);
        bool newBreadCrumbs  = (ForumBreadcrumbs1.GenerateBreadcrumbs() != "");

        // Hide separators according to the link visibility
        // Each separator is hidden if the item preceeding the separator is invisible or
        // no item is behind the separator.
        if (!newThread || (!newSubscription && !newFavorites && !newBreadCrumbs))
        {
            plcActionSeparator.Visible = false;
        }
        if (!newSubscription || (!newFavorites && !newBreadCrumbs))
        {
            plcAddToFavoritesSeparator.Visible = false;
        }
        if (!newFavorites || !newBreadCrumbs)
        {
            plcBreadcrumbsSeparator.Visible = false;
        }

        if ((ForumContext.CurrentForum != null) && (ForumContext.CurrentForum.ForumID > 0))
        {
            string orderBy = "PostStickOrder Desc, PostThreadLastPostTime DESC";
            if (ForumContext.UserIsModerator(this.ForumID, this.CommunityGroupID))
            {
                orderBy = "PostStickOrder Desc, PostThreadLastPostTimeAbsolute DESC";
            }

            // Retrieve data just for the current page
            int currentOffset = EnablePostsPaging ? ThreadPageSize * (UniPager1.CurrentPage - 1) : 0;
            int maxRecords    = EnablePostsPaging ? ThreadPageSize : 0;
            int totalRecords  = 0;

            listForums.DataSource = ForumPostInfoProvider.SelectForumPosts(this.ForumID, "/%", null, orderBy, 0, !ForumContext.UserIsModerator(this.ForumID, this.CommunityGroupID), -1, null, currentOffset, maxRecords, ref totalRecords);

            // Set the total number of records to the pager
            UniPager1.PagedControl.PagerForceNumberOfResults = totalRecords;

            listForums.DataBind();
        }
    }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currentForumPost = "";

        string[] post = QueryHelper.GetString("postid", "").Split(';');
        postId = ValidationHelper.GetInteger(post[0], 0);
        ForumContext.CheckSite(0, 0, postId);

        if (post.Length >= 2)
        {
            forumId = ValidationHelper.GetInteger(post[1], 0);
            this.postListing.ForumId = forumId;
        }

        // Show current post
        postInfo = ForumPostInfoProvider.GetForumPostInfo(postId);
        if (postInfo != null)
        {
            currentForumPost          = HTMLHelper.HTMLEncode(postInfo.PostSubject);
            this.postListing.PostInfo = postInfo;
        }
        // If not post, show current forum
        else if (forumId > 0)
        {
            ForumInfo fi = ForumInfoProvider.GetForumInfo(forumId);
            if (fi != null)
            {
                currentForumPost = fi.ForumDisplayName;
            }
        }

        this.postListing.IsLiveSite = false;

        this.InitializeMasterPage(currentForumPost);
    }
Example #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currentForumPost = "";

        postId = QueryHelper.GetInteger("postid", 0);
        ForumContext.CheckSite(0, 0, postId);
        CurrentMaster.PanelContent.CssClass = String.Empty;

        ForumPostInfo forumPostObj = ForumPostInfoProvider.GetForumPostInfo(postId);

        if (forumPostObj != null)
        {
            currentForumPost = HTMLHelper.HTMLEncode(forumPostObj.PostSubject);
        }

        string listingPost = QueryHelper.GetString("listingpost", null);

        if (!String.IsNullOrEmpty(listingPost))
        {
            listingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(listingPost);
        }

        postEdit.EditPostID = postId;

        postEdit.OnSaved   += new EventHandler(postEdit_OnSaved);
        postEdit.IsLiveSite = false;
        InitializeMasterPage(currentForumPost);
    }
    /// <summary>
    /// Gets and bulk updates forum posts. Called when the "Get and bulk update posts" button is pressed.
    /// Expects the CreateForumPost method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateForumPosts()
    {
        // Prepare the parameters
        string where = "PostSubject LIKE N'My new post%'";
        string orderBy = "";
        string columns = "";
        int    topN    = 10;

        // Get the data
        DataSet posts = ForumPostInfoProvider.GetForumPosts(where, orderBy, topN, columns);

        if (!DataHelper.DataSourceIsEmpty(posts))
        {
            // Loop through the individual items
            foreach (DataRow postDr in posts.Tables[0].Rows)
            {
                // Create object from DataRow
                ForumPostInfo modifyPost = new ForumPostInfo(postDr);

                // Update the properties
                modifyPost.PostSubject = modifyPost.PostSubject.ToUpper();

                // Save the changes
                ForumPostInfoProvider.SetForumPostInfo(modifyPost);
            }

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Gets and updates forum post. Called when the "Get and update post" button is pressed.
    /// Expects the CreateForumPost method to be run first.
    /// </summary>
    private bool GetAndUpdateForumPost()
    {
        // Prepare the parameters
        string where = "PostSubject LIKE N'My new post%'";
        string orderBy = "";
        string columns = "";
        int    topN    = 10;

        // Get the data
        DataSet posts = ForumPostInfoProvider.GetForumPosts(where, orderBy, topN, columns);

        if (!DataHelper.DataSourceIsEmpty(posts))
        {
            ForumPostInfo updatePost = new ForumPostInfo(posts.Tables[0].Rows[0]);

            // Update the properties
            updatePost.PostSubject = updatePost.PostSubject.ToLower();

            // Save the changes
            ForumPostInfoProvider.SetForumPostInfo(updatePost);

            return(true);
        }

        return(false);
    }
Example #11
0
    /// <summary>
    /// Loads the data.
    /// </summary>
    private void LoadData()
    {
        // Get the forum post
        ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(PostID, 0));
        ForumInfo     fi  = null;

        if (fpi != null)
        {
            fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID);
        }
        else
        {
            return;
        }

        if (fi.ForumEnableAdvancedImage)
        {
            ltrText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS;
        }
        else
        {
            ltrText.AllowedControls = "none";
        }

        // Display converted datetime for live site
        lblDate.Text = CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString();

        lblUser.Text    = HTMLHelper.HTMLEncode(fpi.PostUserName);
        lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject);

        DiscussionMacroHelper dmh = new DiscussionMacroHelper();

        dmh.EnableBold          = fi.ForumEnableFontBold;
        dmh.EnableItalics       = fi.ForumEnableFontItalics;
        dmh.EnableStrikeThrough = fi.ForumEnableFontStrike;
        dmh.EnableUnderline     = fi.ForumEnableFontUnderline;
        dmh.EnableCode          = fi.ForumEnableCodeSnippet;
        dmh.EnableColor         = fi.ForumEnableFontColor;
        dmh.EnableImage         = fi.ForumEnableImage || fi.ForumEnableAdvancedImage;
        dmh.EnableQuote         = fi.ForumEnableQuote;
        dmh.EnableURL           = fi.ForumEnableURL || fi.ForumEnableAdvancedURL;
        dmh.MaxImageSideSize    = fi.ForumImageMaxSideSize;
        dmh.QuotePostText       = GetString("DiscussionMacroResolver.QuotePostText");

        if (fi.ForumHTMLEditor)
        {
            dmh.EncodeText = false;
            dmh.ConvertLineBreaksToHTML = false;
        }
        else
        {
            dmh.EncodeText = true;
            dmh.ConvertLineBreaksToHTML = true;
        }

        // Resolve the macros and display the post text
        ltrText.Text = dmh.ResolveMacros(fpi.PostText);
    }
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);


        #region "Security"

        postEdit.OnCheckPermissions += new CheckPermissionsEventHandler(postEdit_OnCheckPermissions);
        postNew.OnCheckPermissions  += new CheckPermissionsEventHandler(postNew_OnCheckPermissions);

        #endregion


        postNew.OnInsertPost   += new EventHandler(postNew_OnInsertPost);
        postNew.OnPreview      += new EventHandler(postNew_OnPreview);
        postEdit.OnPreview     += new EventHandler(postEdit_OnPreview);
        postEdit.OnCancelClick += new EventHandler(postEdit_OnCancelClick);
        postEdit.OnSaved       += new EventHandler(postEdit_OnSaved);

        // Set forum
        treeElem.ForumID = mForumId;
        postNew.ForumID  = mForumId;
        postEdit.ForumID = mForumId;

        // Get post ID
        postId = ValidationHelper.GetInteger(hdnPost.Value, 0);
        if (postId > 0)
        {
            postEdit.EditPostID = postId;
            post = ForumPostInfoProvider.GetForumPostInfo(postId);
        }

        // Unigrid settings
        UniGrid.Visible              = false;
        UniGrid.Query                = "";
        UniGrid.OnAction            += new OnActionEventHandler(UniGrid_OnAction);
        UniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound);

        // Initialize page elements
        titleViewElem.TitleText  = GetString("ForumPost_View.PostTitleText");
        titleViewElem.TitleImage = GetImageUrl("Objects/Forums_ForumPost/object.png");
        titleEditElem.TitleText  = GetString("ForumPost_Edit.HeaderCaption");
        titleEditElem.TitleImage = GetImageUrl("Objects/Forums_ForumPost/object.png");
        lnkEditBack.Text         = GetString("general.view");
        lnkEditBack.Click       += new EventHandler(lnkEditBack_Click);

        if (post != null)
        {
            lblEditBack.Text = breadCrumbsSeparator + HTMLHelper.HTMLEncode(post.PostSubject);
            InitializeMenu();
        }

        // Add handlers
        treeElem.OnGetPostIconUrl += new CMSModules_Forums_Controls_PostTree.GetIconEventHandler(treeElem_OnGetPostIconUrl);

        actionsElem.ActionPerformed += new CommandEventHandler(actionsElem_ActionPerformed);
    }
Example #13
0
    /// <summary>
    /// On populate create child nodes.
    /// </summary>
    protected void treeElem_TreeNodePopulate(object sender, TreeNodeEventArgs e)
    {
        e.Node.ChildNodes.Clear();
        e.Node.PopulateOnDemand = false;

        int postId = ValidationHelper.GetInteger(e.Node.Value, 0);

        // Set the ForumID if not set already
        if (ForumContext.ForumID == 0)
        {
            ForumPostInfo postInfo = ForumPostInfoProvider.GetForumPostInfo(postId);
            if (postInfo != null)
            {
                ForumContext.ForumID = postInfo.PostForumID;
                ForumID = postInfo.PostForumID;
            }
        }

        // Get child nodes
        SiteMapNodeCollection childNodes = MapProvider.GetChildNodes(postId, RegularLoad);

        int index = 0;

        foreach (ForumPostTreeNode childNode in childNodes)
        {
            int childNodeId = (int)((DataRow)childNode.ItemData)["PostID"];
            if (childNodeId != postId)
            {
                TreeNode newNode          = CreateNode(childNode, index);
                bool?    originalExpanded = newNode.Expanded;

                // Force node to expand and load child posts
                if (DetailModeIE)
                {
                    newNode.PopulateOnDemand = true;
                    newNode.Expanded         = true;
                }

                e.Node.ChildNodes.Add(newNode);

                // Restore original expanded state
                if (DetailModeIE)
                {
                    newNode.Expanded = originalExpanded;
                }

                index++;
            }

            // Ensure there is only one 'click here for more' item
            if (UseMaxPostNodes && (MaxPostNodes > 0) && (index > MaxPostNodes))
            {
                break;
            }
        }
    }
Example #14
0
    protected void postEdit_OnSaved(object sender, EventArgs e)
    {
        ForumPostInfo forumPostObj = ForumPostInfoProvider.GetForumPostInfo(postId);

        if (forumPostObj != null)
        {
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + forumPostObj.PostId + "&forumid=" + forumPostObj.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + forumPostObj.PostId + listingParameter + "';");
        }
    }
Example #15
0
    private void EnsureEditedObject()
    {
        if (NewForumPostIsBeingCreated)
        {
            // New post is being created => we cannot retrieve it via provider
            return;
        }

        EditedObject = ForumPostInfoProvider.GetForumPostInfo(PostID);
    }
Example #16
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);


        #region "Security"

        postEdit.OnCheckPermissions += postEdit_OnCheckPermissions;
        postNew.OnCheckPermissions  += postNew_OnCheckPermissions;

        #endregion


        postNew.OnInsertPost   += postNew_OnInsertPost;
        postNew.OnPreview      += postNew_OnPreview;
        postEdit.OnPreview     += postEdit_OnPreview;
        postEdit.OnCancelClick += postEdit_OnCancelClick;
        postEdit.OnSaved       += postEdit_OnSaved;

        // Set forum
        treeElem.ForumID = mForumId;
        postNew.ForumID  = mForumId;
        postEdit.ForumID = mForumId;

        // Get post ID
        postId = ValidationHelper.GetInteger(hdnPost.Value, 0);
        if (postId > 0)
        {
            postEdit.EditPostID = postId;
            post = ForumPostInfoProvider.GetForumPostInfo(postId);
        }

        // Unigrid settings
        UniGrid.Visible              = false;
        UniGrid.Query                = "";
        UniGrid.OnAction            += UniGrid_OnAction;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;

        // Initialize page elements
        titleViewElem.TitleText = GetString("ForumPost_View.PostTitleText");
        titleEditElem.TitleText = GetString("ForumPost_Edit.HeaderCaption");

        lnkBackHidden.Click += lnkBackHidden_Click;

        if (post != null)
        {
            InitializeBreadcrumbs(post.PostSubject);
            InitializeMenu();
        }

        // Add handlers
        treeElem.OnGetStatusIcons += treeElem_OnGetPostIconUrl;

        actionsElem.ActionPerformed += actionsElem_ActionPerformed;
    }
Example #17
0
    DataSet postSubscription_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        string where = "PostId IN (SELECT SubscriptionPostID FROM Forums_ForumSubscription WHERE (SubscriptionUserID = " + UserID + ") AND (ISNULL(SubscriptionApproved, 1) = 1)) AND (PostApproved = 1)";
        if (!String.IsNullOrEmpty(completeWhere))
        {
            where += " AND (" + completeWhere + ")";
        }

        DataSet ds = ForumPostInfoProvider.GetForumPosts(where, "PostSubject", 0, "PostID, PostForumID, PostSubject");

        totalRecords = DataHelper.GetItemsCount(ds);
        return(ds);
    }
Example #18
0
    protected void postNew_OnInsertPost(object sender, EventArgs e)
    {
        // Set properties
        postId                = postNew.EditPostID;
        treeElem.Selected     = postId;
        postEdit.EditPostID   = postId;
        postView.PostID       = postId;
        postNew.ReplyToPostID = 0;

        // Save post to database
        post          = ForumPostInfoProvider.GetForumPostInfo(postId);
        hdnPost.Value = postId.ToString();
        DisplayControl("view");
    }
    /// <summary>
    /// Handles the Click event of the btnDelete control.
    /// </summary>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        // Check permissions
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        // Delete the post
        ForumPostInfoProvider.DeleteForumPostInfo(ValidationHelper.GetInteger(PostID, 0));

        // Reload the parent window
        RefreshParentWindow();
    }
Example #20
0
    /// <summary>
    /// Stick thread event handler.
    /// </summary>
    protected void btnSplitThread_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        if (PostInfo != null)
        {
            ForumPostInfoProvider.SplitThread(PostInfo);

            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + PostInfo.PostId + "&forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + PostID + mListingParameter + "';");
        }
    }
Example #21
0
    /// <summary>
    /// Lock thread event handler.
    /// </summary>
    protected void btnLockThread_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", CMSAdminControl.PERMISSION_MODIFY))
        {
            return;
        }

        if (this.PostInfo != null)
        {
            this.PostInfo.PostIsLocked = !this.PostInfo.PostIsLocked;
            ForumPostInfoProvider.SetForumPostInfo(this.PostInfo);

            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + this.PostInfo.PostId + "&forumid=" + this.PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + this.PostID + listingParameter + "';");
        }
    }
Example #22
0
    /// <summary>
    /// Topic move action handler.
    /// </summary>
    protected void btnMove_Click(object sender, EventArgs e)
    {
        int forumId = ValidationHelper.GetInteger(this.drpMoveToForum.SelectedValue, 0);

        if (forumId > 0)
        {
            ForumPostInfo fpi = ForumContext.CurrentThread;
            if ((fpi == null) && (this.CurrentThread > 0))
            {
                fpi = ForumPostInfoProvider.GetForumPostInfo(this.CurrentThread);
            }

            if (fpi != null)
            {
                // Move the thread
                ForumPostInfoProvider.MoveThread(fpi, forumId);

                this.plcMoveInner.Visible = false;

                // Generate back button
                this.ltlMoveBack.Text = GetLink(null, GetString("general.back"), "ActionLink", ForumActionType.Thread);

                string    targetForumName = this.drpMoveToForum.SelectedItem.Text.TrimStart(' ');
                ForumInfo fi = ForumInfoProvider.GetForumInfo(forumId);
                if (fi != null)
                {
                    targetForumName = HTMLHelper.HTMLEncode(fi.ForumDisplayName);
                }

                // Display info
                this.lblMoveInfo.Text    = String.Format(GetString("forum.thread.topicmoved"), targetForumName);
                this.lblMoveInfo.Visible = true;

                this.SetValue("TopicMoved", true);

                if (TopicMoved != null)
                {
                    TopicMoved(this, null);
                }
            }
        }
        else
        {
            this.lblMoveError.Text    = GetString("forum.thread.movetopic.selectforum");
            this.lblMoveError.Visible = true;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get object display name
        ForumInfo     fi   = ForumInfoProvider.GetForumInfo((subscriptionApproval.SubscriptionObject != null) ? subscriptionApproval.SubscriptionObject.SubscriptionForumID : 0);
        ForumPostInfo fpi  = ForumPostInfoProvider.GetForumPostInfo((subscriptionApproval.SubscriptionObject != null) ? subscriptionApproval.SubscriptionObject.SubscriptionPostID : 0);
        string        name = (fpi != null) ? TextHelper.LimitLength(fpi.PostSubject, 50) : (fi != null) ? fi.ForumDisplayName : null;

        // Set text to display according to subscription object
        string objectText = "forum.subscriptionconfirmation";

        if (fpi != null)
        {
            objectText = "forumpost.subscriptionconfirmation";
        }

        PageTitle title = PageTitle;

        title.TitleText = HTMLHelper.HTMLEncode(string.Format(GetString(objectText), (name != null) ? ScriptHelper.GetString(name) : null));
    }
    protected void CheckGroupPermissions(string permissionType, CMSAdminControl sender)
    {
        int groupId = 0;

        if (postView.PostID == 0)
        {
            groupId = GetGroupIdFromForum(postView.ForumID);
        }
        else
        {
            var post = ForumPostInfoProvider.GetForumPostInfo(postView.PostID);
            if (post != null)
            {
                groupId = GetGroupIdFromForum(post.PostForumID);
            }
        }

        CheckGroupPermissions(groupId, CMSAdminControl.PERMISSION_MANAGE);
    }
    protected void postView_OnCheckPermissions(string permissionType, CMSAdminControl sender)
    {
        int           groupId = 0;
        ForumPostInfo fpi     = ForumPostInfoProvider.GetForumPostInfo(postView.PostID);

        if (fpi != null)
        {
            ForumInfo fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID);
            if (fi != null)
            {
                ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID);
                if (fgi != null)
                {
                    groupId = fgi.GroupGroupID;
                }
            }
        }

        CheckPermissions(groupId, CMSAdminControl.PERMISSION_MANAGE);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get object display name
        ForumInfo     fi   = ForumInfoProvider.GetForumInfo((unsubscription.SubscriptionObject != null) ? unsubscription.SubscriptionObject.SubscriptionForumID : 0);
        ForumPostInfo fpi  = ForumPostInfoProvider.GetForumPostInfo((unsubscription.SubscriptionObject != null) ? unsubscription.SubscriptionObject.SubscriptionPostID : 0);
        string        name = (fpi != null) ? TextHelper.LimitLength(fpi.PostSubject, 50) : (fi != null) ? fi.ForumDisplayName : null;

        // Set text to display according to subscription object
        string objectText = "forum.unsubscription";

        if (fpi != null)
        {
            objectText = "forumpost.unsubscription";
        }

        PageTitle title = CurrentMaster.Title;

        title.TitleImage = GetImageUrl("Design/Controls/Subscriptions/unsubscription.png");
        title.TitleText  = HTMLHelper.HTMLEncode(string.Format(GetString(objectText), (name != null) ? ScriptHelper.GetString(name) : null));
    }
    /// <summary>
    /// Handles the Click event of the btnApprove control.
    /// </summary>
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        // Check permissions
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        // Approve the post
        ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(PostID, 0));

        if (fpi != null)
        {
            fpi.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
            fpi.PostApproved         = true;
            ForumPostInfoProvider.SetForumPostInfo(fpi);
        }

        // Reload the parent window
        RefreshParentWindow();
    }
    /// <summary>
    /// Approve, reject or delete post.
    /// </summary>
    protected void gridApprove_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        case "deletepost":
            ForumPostInfoProvider.DeleteForumPostInfo(ValidationHelper.GetInteger(actionArgument, 0));
            break;

        case "approve":
            ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(actionArgument, 0));
            if (fpi != null)
            {
                fpi.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                fpi.PostApproved         = true;
                ForumPostInfoProvider.SetForumPostInfo(fpi);
            }
            break;
        }

        RaiseOnAction(actionName, actionArgument);
    }
Example #29
0
    /// <summary>
    /// This function is executed by callback initiated by 'Delete' button in menu.
    /// </summary>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        ForumPostInfoProvider.DeleteForumPostInfo(PostID);

        if (PostInfo.PostParentID == 0)
        {
            //reload post edit frames with actual data
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?forumid=" + PostInfo.PostForumID + mListingParameter + "';");
        }
        else
        {
            //reload post edit frames with actual data
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + PostInfo.PostParentID + "&forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + PostInfo.PostParentID + mListingParameter + "';");
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get postId, groupId
        postId  = QueryHelper.GetInteger("postid", 0);
        groupId = 0;
        ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(postId);

        if (fpi != null)
        {
            ForumInfo fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID);
            if (fi != null)
            {
                ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID);
                if (fgi != null)
                {
                    groupId = fgi.GroupGroupID;
                }
            }
        }

        // Check permissions
        CheckGroupPermissions(groupId, "Read");

        if (groupId > 0)
        {
            // Set the post ID
            PostApprove.PostID       = postId;
            PostApproveFooter.PostID = postId;

            // Set methods which check the permissions
            PostApprove.OnCheckPermissions       += new CMSAdminControl.CheckPermissionsEventHandler(PostApprove_OnCheckPermissions);
            PostApproveFooter.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(PostApprove_OnCheckPermissions);

            // Page title
            this.CurrentMaster.Title.TitleText  = GetString("forums_forumnewpost_header.preview");
            this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Forums_ForumPost/object.png");
        }
    }