Example #1
0
    /// <summary>
    /// OnPreview handler.
    /// </summary>
    protected void forumEdit_OnPreview(object sender, EventArgs e)
    {
        // Preview title
        ltrTitle.Text = GetString("Forums_ForumNewPost_Header.Preview");
        // Display placeholder
        plcPreview.Visible = true;

        // Post properties
        ForumPostInfo fpi = sender as ForumPostInfo;

        if (fpi != null)
        {
            ltrAvatar.Text   = AvatarImage(fpi);
            ltrSubject.Text  = HTMLHelper.HTMLEncode(fpi.PostSubject);
            ltrText.Text     = ResolvePostText(fpi.PostText);
            ltrUserName.Text = HTMLHelper.HTMLEncode(fpi.PostUserName);
            ltrTime.Text     = CMSContext.ConvertDateTime(fpi.PostTime, this).ToString();

            BadgeInfo bi            = null;
            string    badgeName     = null;
            string    badgeImageUrl = null;

            bi = BadgeInfoProvider.GetBadgeInfo(CMSContext.CurrentUser.UserSettings.UserBadgeID);
            if (bi != null)
            {
                badgeName     = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName));
                badgeImageUrl = HTMLHelper.HTMLEncode(bi.BadgeImageURL);
            }

            ltrBadge.Text = GetNotEmpty(badgeName, "<div class=\"Badge\">" + badgeName + "</div>", "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>", ForumActionType.Badge) +
                            GetNotEmpty(badgeImageUrl, "<div class=\"BadgeImage\"><img alt=\"" + badgeName + "\" src=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge);
        }
    }
Example #2
0
    /// <summary>
    /// Deletes badge. Called when the "Delete badge" button is pressed.
    /// Expects the CreateBadge method to be run first.
    /// </summary>
    private bool DeleteBadge()
    {
        // Get the badge
        BadgeInfo deleteBadge = BadgeInfoProvider.GetBadgeInfo("MyNewBadge");

        // Delete the badge
        BadgeInfoProvider.DeleteBadgeInfo(deleteBadge);

        return(deleteBadge != null);
    }
Example #3
0
    /// <summary>
    /// OK button click event handler.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Validate entered values
        string error = new Validator().IsCodeName(txtName.Text.Trim(), GetString("general.invalidcodename"))
                       .NotEmpty(txtDisplayName.Text.Trim(), GetString("badge.errors.displayname")).Result;

        // Save new values
        if (DataHelper.IsEmpty(error))
        {
            // Check that code name is unique
            BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(txtName.Text.Trim());
            if ((bi == null) || ((bi != null) && (bi.BadgeID == badgeId)))
            {
                // Update existing record
                if (bi == null)
                {
                    bi = new BadgeInfo();
                }

                // Set properties
                bi.BadgeID          = badgeId;
                bi.BadgeName        = txtName.Text.Trim();
                bi.BadgeDisplayName = txtDisplayName.Text.Trim();
                bi.BadgeImageURL    = txtImageURL.Text.Trim();
                int topLimit = ValidationHelper.GetInteger(txtTopLimit.Text.Trim(), 0);
                if (topLimit >= 0)
                {
                    bi.BadgeTopLimit = topLimit;
                }
                else
                {
                    bi.BadgeTopLimit = 0;
                }
                bi.BadgeIsAutomatic = chkIsAutomatic.Checked;

                // Save BadgeInfo
                BadgeInfoProvider.SetBadgeInfo(bi);
                URLHelper.Redirect("~/CMSModules/Badges/Badges_Edit.aspx?saved=1&badgeid=" + bi.BadgeID);
            }
            else
            {
                lblError.ResourceString = "badge.errors.uniquecodename";
                lblError.Visible        = true;
            }
        }
        else
        {
            lblError.ResourceString = error;
            //badge.errors.values
            lblError.Visible = true;
        }
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CopyValues(forumEdit);

        if (IsAdHocForum)
        {
            plcHeader.Visible = false;
        }

        forumEdit.OnPreview            += forumEdit_OnPreview;
        forumEdit.OnModerationRequired += new EventHandler(forumEdit_OnModerationRequired);

        // Check whether subscription is for forum or post
        if (ForumContext.CurrentReplyThread == null)
        {
            ltrTitle.Text = GetString("Forums_ForumNewPost_Header.NewThread");

            if (ForumContext.CurrentPost != null && ForumContext.CurrentMode == ForumMode.Edit)
            {
                ltrTitle.Text = GetString("Forums_ForumNewPost_Header.EditPost");
            }
        }
        else
        {
            plcPreview.Visible = true;
            ltrTitle.Text      = GetString("Forums_ForumNewPost_Header.Reply");
            ltrAvatar.Text     = AvatarImage(ForumContext.CurrentReplyThread);
            ltrSubject.Text    = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostSubject);
            ltrText.Text       = ResolvePostText(ForumContext.CurrentReplyThread.PostText);
            ltrUserName.Text   = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostUserName);
            ltrTime.Text       = CMSContext.ConvertDateTime(ForumContext.CurrentReplyThread.PostTime, this).ToString();

            UserSettingsInfo usi           = UserSettingsInfoProvider.GetUserSettingsInfoByUser(ForumContext.CurrentReplyThread.PostUserID);
            BadgeInfo        bi            = null;
            string           badgeName     = null;
            string           badgeImageUrl = null;

            if (usi != null)
            {
                bi = BadgeInfoProvider.GetBadgeInfo(usi.UserBadgeID);
                if (bi != null)
                {
                    badgeName     = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName));
                    badgeImageUrl = HTMLHelper.HTMLEncode(bi.BadgeImageURL);
                }
            }

            ltrBadge.Text = GetNotEmpty(badgeName, "<div class=\"Badge\">" + badgeName + "</div>", "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>", ForumActionType.Badge) +
                            GetNotEmpty(badgeImageUrl, "<div class=\"BadgeImage\"><img alt=\"" + badgeName + "\" src=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge);
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (mValue > 0)
        {
            BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(mValue);
            if (bi != null)
            {
                lblBadgeText.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName));
                return;
            }
        }

        lblBadgeText.Visible = false;
    }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set the page title
        CurrentMaster.Title.TitleText     = GetString("badge.newbadge");
        CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_Badge/new.png");
        CurrentMaster.Title.HelpTopicName = "badge_edit";

        // Initialize breadcrumbs
        string[,] pageTitleTabs = new string[2, 3];
        pageTitleTabs[0, 0]     = GetString("badge.title");
        pageTitleTabs[0, 1]     = "~/CMSModules/Badges/Badges_List.aspx";
        pageTitleTabs[0, 2]     = "";
        pageTitleTabs[1, 1]     = "";
        pageTitleTabs[1, 2]     = "";
        pageTitleTabs[1, 0]     = GetString("badge.newbadge");

        // Initialize validators
        rfvName.ErrorMessage        = GetString("general.invalidcodename");
        rfvDisplayName.ErrorMessage = GetString("badge.errors.displayname");
        rvtxtTopLimit.ErrorMessage  = GetString("badge.errors.toplimit");

        // Get badge ID from query string
        badgeId = QueryHelper.GetInteger("badgeid", 0);
        if (badgeId > 0)
        {
            // Get BadgeInfo
            BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(badgeId);
            if (bi != null)
            {
                CurrentMaster.Title.TitleText  = GetString("badge.properties");
                pageTitleTabs[1, 0]            = HTMLHelper.HTMLEncode(bi.BadgeDisplayName);
                CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_Badge/object.png");

                // Load data
                if (!RequestHelper.IsPostBack())
                {
                    if ((QueryHelper.GetInteger("saved", 0) == 1) && !URLHelper.IsPostback())
                    {
                        ShowChangesSaved();
                    }
                    LoadData(bi);
                }
            }
        }

        CurrentMaster.Title.Breadcrumbs = pageTitleTabs;
    }
Example #7
0
    /// <summary>
    /// Gets and updates badge. Called when the "Get and update badge" button is pressed.
    /// Expects the CreateBadge method to be run first.
    /// </summary>
    private bool GetAndUpdateBadge()
    {
        // Get the badge
        BadgeInfo updateBadge = BadgeInfoProvider.GetBadgeInfo("MyNewBadge");

        if (updateBadge != null)
        {
            // Update the properties
            updateBadge.BadgeDisplayName = updateBadge.BadgeDisplayName.ToLowerCSafe();

            // Save the changes
            BadgeInfoProvider.SetBadgeInfo(updateBadge);

            return(true);
        }

        return(false);
    }
Example #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (mValue > 0)
        {
            BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(mValue);
            if (bi != null)
            {
                string displayName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName));
                imgBadge.ImageUrl      = ResolveUrl(HTMLHelper.HTMLEncode(bi.BadgeImageURL));
                imgBadge.AlternateText = displayName;
                imgBadge.Attributes.Add("title", displayName);
                // Add style information to the image - limit size
                imgBadge.Attributes.Add("style", "border-width:0px;");
                return;
            }
        }

        imgBadge.Visible = false;
    }
Example #9
0
    /// <summary>
    /// Adds badge to user. Called when the "Add badge to user" button is pressed.
    /// Expects the CreateBadge method to be run first.
    /// </summary>
    private bool AddBadgeToUser()
    {
        // Get user object
        UserInfo user = UserInfoProvider.GetUserInfo(MembershipContext.AuthenticatedUser.UserName);

        // Get badge object
        BadgeInfo myBadge = BadgeInfoProvider.GetBadgeInfo("MyNewBadge");

        if ((user != null) && (myBadge != null))
        {
            // Add badge to user settings
            user.UserSettings.UserBadgeID = myBadge.BadgeID;

            // Update user object in database
            UserInfoProvider.SetUserInfo(user);

            return(true);
        }

        return(false);
    }
Example #10
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData()
    {
        ForumPostInfo fpi = null;
        ForumInfo     fi  = null;


        #region "Load data"

        if (PostData != null)
        {
            fpi = new ForumPostInfo(PostData);
        }

        if (fpi == null)
        {
            fpi = PostInfo;
        }

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

        #endregion


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

        lnkUserName.Text = HTMLHelper.HTMLEncode(fpi.PostUserName);

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

        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;
        }

        ltlText.Text = "<div class=\"PostText\">" + dmh.ResolveMacros(fpi.PostText) + "</div>";

        userAvatar.Text = AvatarImage(fpi);

        if (DisplayBadgeInfo)
        {
            if (fpi.PostUserID > 0)
            {
                UserInfo ui = UserInfoProvider.GetUserInfo(fpi.PostUserID);
                if ((ui != null) && !ui.IsPublic())
                {
                    BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(ui.UserSettings.UserBadgeID);
                    if (bi != null)
                    {
                        ltlBadge.Text = "<div class=\"Badge\">" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "</div>";
                    }
                }
            }

            // Set public badge if no badge is set
            if (String.IsNullOrEmpty(ltlBadge.Text))
            {
                ltlBadge.Text = "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>";
            }
        }

        if (EnableSignature)
        {
            if (fpi.PostUserSignature.Trim() != "")
            {
                plcSignature.Visible = true;
                ltrSignature.Text    = HTMLHelper.HTMLEncode(fpi.PostUserSignature);
            }
        }

        if (!DisplayOnly)
        {
            string threadId = ForumPostInfoProvider.GetPostRootFromIDPath(ValidationHelper.GetString(GetData(PostData, "PostIdPath"), "")).ToString();

            // Reply
            if (IsAvailable(PostData, ForumActionType.Reply))
            {
                lnkReply.Visible     = true;
                lnkReply.Text        = GetString("Forums_WebInterface_ForumPost.replyLinkText");
                lnkReply.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Reply), "threadid", threadId);
            }
            else
            {
                lnkReply.Visible = false;
            }

            // Quote
            if (IsAvailable(PostData, ForumActionType.Quote))
            {
                lnkQuote.Visible     = true;
                lnkQuote.Text        = GetString("Forums_WebInterface_ForumPost.quoteLinkText");
                lnkQuote.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.Quote), "threadid", threadId);
            }
            else
            {
                lnkQuote.Visible = false;
            }

            // Display subscribe link
            if (IsAvailable(PostData, ForumActionType.SubscribeToPost))
            {
                lnkSubscribe.Visible     = true;
                lnkSubscribe.Text        = GetString("Forums_WebInterface_ForumPost.Subscribe");
                lnkSubscribe.NavigateUrl = URLHelper.UpdateParameterInUrl(GetURL(PostData, ForumActionType.SubscribeToPost), "threadid", threadId);
            }
            else
            {
                lnkSubscribe.Visible = false;
            }

            lnkUserName.CssClass = "PostUserLink";

            if (!String.IsNullOrEmpty(fpi.PostUserMail) && (fi.ForumDisplayEmails))
            {
                lnkUserName.NavigateUrl = "mailto:" + HTMLHelper.HTMLEncode(fpi.PostUserMail) + "?subject=" + HTMLHelper.HTMLEncode(fpi.PostSubject);
                lnkUserName.CssClass    = "PostUser";
            }
        }

        // Display action panel only if reply to link or subscription link are visible
        plcActions.Visible = ((lnkReply.Visible || lnkSubscribe.Visible || lnkQuote.Visible) & !DisplayOnly);

        if ((lnkReply.Visible) && (lnkQuote.Visible || lnkSubscribe.Visible))
        {
            lblActionSeparator.Visible = true;
        }

        if ((lnkQuote.Visible) && (lnkSubscribe.Visible))
        {
            lblActionSeparator2.Visible = true;
        }
    }
Example #11
0
    /// <summary>
    /// OnPrerender check whether.
    /// </summary>
    protected override void OnPreRender(EventArgs e)
    {
        postTreeElem.Selected = ValidationHelper.GetInteger(hdnSelected.Value, SelectedPost);
        if ((mSelectedPost == 0) && (RequestHelper.IsAJAXRequest()))
        {
            mSelectedPost = postTreeElem.Selected;
        }

        if (mSelectedPost > 0)
        {
            ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(mSelectedPost);
            if ((fpi != null) && (ForumContext.CurrentForum != null) && (fpi.PostForumID == ForumContext.CurrentForum.ForumID))
            {
                plcPostPreview.Visible = true;
                ltlPostSubject.Text    = HTMLHelper.HTMLEncode(fpi.PostSubject);
                ltlPostText.Text       = ResolvePostText(fpi.PostText);
                ltlSignature.Text      = GetSignatureArea(fpi, "<div class=\"SignatureArea\">", "</div>");
                ltlPostTime.Text       = TimeZoneHelper.ConvertToUserTimeZone(fpi.PostTime, false, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite).ToString();
                ltlPostUser.Text       = "<span class=\"PostUserName\">" + GetUserName(fpi) + "</span>";
                ltlAvatar.Text         = AvatarImage(fpi);
                mUnapproved            = !fpi.PostApproved ? " Unapproved" : "";

                if (ForumContext.CurrentForum.ForumEnableAdvancedImage)
                {
                    ltlPostText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS;
                }
                else
                {
                    ltlPostText.AllowedControls = "none";
                }

                attachmentDisplayer.ClearData();
                attachmentDisplayer.PostID = fpi.PostId;
                attachmentDisplayer.PostAttachmentCount = fpi.PostAttachmentCount;
                attachmentDisplayer.ReloadData();


                #region "Badge"

                if (DisplayBadgeInfo)
                {
                    if (fpi.PostUserID > 0)
                    {
                        UserInfo ui = UserInfoProvider.GetUserInfo(fpi.PostUserID);
                        if ((ui != null) && (!ui.IsPublic()))
                        {
                            BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(ui.UserSettings.UserBadgeID);
                            if (bi != null)
                            {
                                ltlBadge.Text = "<div class=\"Badge\">" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "</div>";
                                if (!String.IsNullOrEmpty(bi.BadgeImageURL))
                                {
                                    ltlBadge.Text += "<div class=\"BadgeImage\"><img alt=\"" + HTMLHelper.HTMLEncode(bi.BadgeDisplayName) + "\" src=\"" + HTMLHelper.HTMLEncode(GetImageUrl(bi.BadgeImageURL)) + "\" /></div>";
                                }
                            }
                        }
                    }

                    // Set public badge if no badge is set
                    if (String.IsNullOrEmpty(ltlBadge.Text))
                    {
                        ltlBadge.Text = "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>";
                    }
                }

                #endregion


                #region "Post actions"

                // Get the parent thread ID (for reply and quote)
                int threadId = ForumPostInfoProvider.GetPostRootFromIDPath(fpi.PostIDPath);

                ltlReply.Text     = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.replyLinkText"), "PostActionLink", ForumActionType.Reply, threadId);
                ltlQuote.Text     = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.quoteLinkText"), "PostActionLink", ForumActionType.Quote, threadId);
                ltlSubscribe.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.Subscribe"), "PostActionLink", ForumActionType.SubscribeToPost, threadId);

                ltlAnswer.Text    = GetLink(fpi, GetString("general.yes"), "ActionLink", ForumActionType.IsAnswer);
                ltlNotAnswer.Text = GetLink(fpi, GetString("general.no"), "ActionLink", ForumActionType.IsNotAnswer);

                if (ltlAnswer.Text != String.Empty)
                {
                    ltlWasHelpful.Text = GetString("Forums_WebInterface_ForumPost.Washelpful") + "&nbsp;";
                    ltlAnswer.Text    += "|";
                }

                ltlAddPostToFavorites.Text = GetLink(fpi, GetString("Forums_WebInterface_ForumPost.AddPostToFavorites"), "ActionLink", ForumActionType.AddPostToFavorites);

                ltlDelete.Text      = GetLink(fpi, GetString("general.delete"), "ActionLink", ForumActionType.Delete);
                ltlEdit.Text        = GetLink(fpi, GetString("general.edit"), "ActionLink", ForumActionType.Edit);
                ltlAttachments.Text = GetLink(fpi, GetString("general.attachments"), "ActionLink", ForumActionType.Attachment);

                #endregion


                // Hide separators
                if ((ltlReply.Text == "") || (ltlReply.Text != "" && ltlQuote.Text == ""))
                {
                    plcFirstSeparator.Visible = false;
                }

                if ((ltlSubscribe.Text == "") || (ltlSubscribe.Text != "" && ltlQuote.Text == ""))
                {
                    plcSecondSeparator.Visible = false;
                }

                if (ltlReply.Text != "" && ltlSubscribe.Text != "")
                {
                    plcFirstSeparator.Visible = true;
                }

                pnlManage.Visible = (EnableOnSiteManagement && (ForumContext.CurrentForum != null)) ? ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, CommunityGroupID) : false;
                if (pnlManage.Visible)
                {
                    ltlApprove.Text    = GetLink(fpi, GetString("general.approve"), "ActionLink", ForumActionType.Appprove);
                    ltlApproveAll.Text = GetLink(fpi, GetString("forums.approveall"), "ActionLink", ForumActionType.ApproveAll);
                    ltlReject.Text     = GetLink(fpi, GetString("general.reject"), "ActionLink", ForumActionType.Reject);
                    ltlRejectAll.Text  = GetLink(fpi, GetString("forums.rejectall"), "ActionLink", ForumActionType.RejectAll);
                    ltlSplit.Text      = GetLink(fpi, GetString("forums.splitthread"), "ActionLink", ForumActionType.SplitThread);
                    ltlMove.Text       = GetLink(fpi, GetString("forums.movethread"), "ActionLink", ForumActionType.MoveToTheOtherForum, threadId);
                }
            }
        }
        else
        {
            plcPostPreview.Visible = false;
        }

        if (ControlsHelper.IsInUpdatePanel(this))
        {
            ControlsHelper.GetUpdatePanel(this).Update();
        }

        base.OnPreRender(e);
    }