/// <summary>
    /// Occurs on rating event.
    /// </summary>
    protected void usrControl_RatingEvent(AbstractRatingControl sender)
    {
        // Check if control is enabled
        if (!(Enabled && HasPermissions() && !(CheckIfUserRated && TreeProvider.HasRated(DocumentContext.CurrentDocument))))
        {
            return;
        }

        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            pnlError.Visible = true;
            lblError.Text    = GetString("general.bannedip");
            return;
        }

        // Check null value
        if (!AllowZeroValue && usrControl.CurrentRating <= 0)
        {
            pnlError.Visible = true;
            lblError.Text    = ErrorMessage;
            return;
        }

        if (DocumentContext.CurrentDocument != null)
        {
            // Check whether user has already rated
            if (CheckIfUserRated && TreeProvider.HasRated(DocumentContext.CurrentDocument))
            {
                return;
            }

            // Update document rating, remember rating in cookie if required
            TreeProvider.AddRating(DocumentContext.CurrentDocument, usrControl.CurrentRating, CheckIfUserRated);

            // log activity
            LogActivity(usrControl.CurrentRating);

            // Get absolute rating value of the current rating
            double currRating = usrControl.MaxRating * usrControl.CurrentRating;
            // Reload rating control
            ReloadData(true);
            // Show message after rating if enabled or set
            if (!string.IsNullOrEmpty(MessageAfterRating))
            {
                pnlMessage.Visible = true;
                // Merge message text with rating values
                lblMessage.Text = String.Format(MessageAfterRating,
                                                Convert.ToInt32(currRating), usrControl.CurrentRating * usrControl.MaxRating, DocumentContext.CurrentDocument.DocumentRatings);
            }
            else
            {
                pnlMessage.Visible = false;
            }
        }
    }
    /// <summary>
    /// Initializes the controls.
    /// </summary>
    private void SetupControls()
    {
        lblRating.Text       = GetString("board.messageedit.rating");
        lblEmail.Text        = GetString("board.messageedit.email");
        lblMessage.Text      = GetString("board.messageedit.message");
        lblURL.Text          = GetString("board.messageedit.url");
        lblUserName.Text     = GetString("board.messageedit.username");
        lblAlreadyrated.Text = GetString("board.messageedit.alreadyrated");
        lblSubscribe.Text    = GetString("board.messageedit.subscribe");

        rfvMessage.ErrorMessage  = GetString("board.messageedit.rfvmessage");
        rfvUserName.ErrorMessage = GetString("board.messageedit.rfvusername");
        rfvEmail.ErrorMessage    = GetString("board.messageedit.rfvemail");

        btnOk.Text = GetString("board.messageedit.addmessage");

        txtUserName.ValidationGroup = ValidationGroup;
        rfvUserName.ValidationGroup = ValidationGroup;

        rfvEmail.ValidationGroup = ValidationGroup;

        txtMessage.ValidationGroup = ValidationGroup;
        rfvMessage.ValidationGroup = ValidationGroup;

        btnOk.ValidationGroup       = ValidationGroup;
        btnOkFooter.ValidationGroup = ValidationGroup;

        // Fields visibility
        plcUserName.Visible = BoardProperties.ShowNameField;
        plcEmail.Visible    = BoardProperties.ShowEmailField;
        plcUrl.Visible      = BoardProperties.ShowURLField;

        // Load message board
        if (BoardProperties != null)
        {
            if (!BoardProperties.BoardRequireEmails)
            {
                rfvEmail.Enabled = false;
            }

            if ((BoardProperties.BoardUseCaptcha) && (!AdvancedMode))
            {
                // Show captcha text and control
                pnlCaptcha.Visible = true;
            }
        }

        plcRating.Visible = false;

        // Show rating form only if user has not rated yet or rating check is disabled
        if (!AdvancedMode && BoardProperties.EnableContentRating && (!TreeProvider.HasRated(DocumentContext.CurrentDocument) || !BoardProperties.CheckIfUserRated))
        {
            if (DocumentContext.CurrentDocument != null)
            {
                plcRating.Visible = true;
                try
                {
                    // Insert rating control to page
                    ratingControl = (AbstractRatingControl)(Page.LoadUserControl(AbstractRatingControl.GetRatingControlUrl(BoardProperties.RatingType + ".ascx")));
                }
                catch (Exception ex)
                {
                    Controls.Add(new LiteralControl(ex.Message));
                    return;
                }

                // Init values
                ratingControl.ID                 = ID + "_RatingControl";
                ratingControl.MaxRating          = BoardProperties.MaxRatingValue;
                ratingControl.Visible            = true;
                ratingControl.Enabled            = true;
                ratingControl.RatingEvent       += ratingControl_RatingEvent;
                ratingControl.CurrentRating      = ValidationHelper.GetDouble(ViewState["ratingvalue"], 0);
                ratingControl.ExternalManagement = true;
                pnlRating.Controls.Clear();
                pnlRating.Controls.Add(ratingControl);
            }
        }

        if (AdvancedMode)
        {
            // Initialize advanced controls
            plcAdvanced.Visible        = true;
            lblApproved.Text           = GetString("board.messageedit.approved");
            lblSpam.Text               = GetString("board.messageedit.spam");
            lblInsertedCaption.Text    = GetString("board.messageedit.inserted");
            btnOk.ResourceString       = "general.saveandclose";
            btnOkFooter.ResourceString = "general.saveandclose";

            // Show or hide "Inserted" label
            bool showInserted = (MessageID > 0);
            lblInsertedCaption.Visible = showInserted;
            lblInserted.Visible        = showInserted;
            chkSubscribe.Visible       = false;
        }
        else
        {
            // If is not moderated then autocheck approve
            if (!BoardProperties.BoardModerated)
            {
                chkApproved.Checked = true;
            }
        }

        if (ModalMode)
        {
            plcFooter.Visible   = true;
            pnlOkButton.Visible = false;
        }
        else
        {
            plcFooter.Visible   = false;
            pnlOkButton.Visible = true;
        }

        // Show/hide subscription option
        plcChkSubscribe.Visible = BoardProperties.BoardEnableSubscriptions && BoardProperties.ShowEmailField;

        // For new message hide Is approved chkbox (auto approve)
        if (MessageID <= 0)
        {
            plcApproved.Visible = false;
        }

        // Hide message form if empty rating is not allowed and user has rated
        if (!BoardProperties.AllowEmptyRating && BoardProperties.CheckIfUserRated && TreeProvider.HasRated(DocumentContext.CurrentDocument))
        {
            pnlMessageEdit.Visible  = false;
            lblAlreadyrated.Visible = true;
        }
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Let the parent control now new message is being saved
        if (OnBeforeMessageSaved != null)
        {
            OnBeforeMessageSaved();
        }

        // Check if message board is opened
        if (!IsBoardOpen())
        {
            return;
        }

        // Check banned IP
        if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            ShowError(GetString("General.BannedIP"));
            return;
        }

        // Validate form
        string errorMessage = ValidateForm();

        if (errorMessage == String.Empty)
        {
            // Check flooding when message being inserted through the LiveSite
            if (CheckFloodProtection && IsLiveSite && FloodProtectionHelper.CheckFlooding(SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(GetString("General.FloodProtection"));
                return;
            }

            var currentUser = MembershipContext.AuthenticatedUser;

            BoardMessageInfo message;

            if (MessageID > 0)
            {
                // Get message info
                message        = BoardMessageInfoProvider.GetBoardMessageInfo(MessageID);
                MessageBoardID = message.MessageBoardID;
            }
            else
            {
                // Create new info
                message = new BoardMessageInfo();

                // User IP address
                message.MessageUserInfo.IPAddress = RequestContext.UserHostAddress;
                // User agent
                message.MessageUserInfo.Agent = Request.UserAgent;
            }

            // Setup message info
            message.MessageEmail = txtEmail.Text.Trim();
            message.MessageText  = txtMessage.Text.Trim();

            // Handle message URL
            string url = txtURL.Text.Trim();
            if (!String.IsNullOrEmpty(url))
            {
                string protocol = URLHelper.GetProtocol(url);
                if (String.IsNullOrEmpty(protocol))
                {
                    url = "http://" + url;
                }
            }

            message.MessageURL = TextHelper.LimitLength(url, txtURL.MaxLength);
            message.MessageURL = message.MessageURL.ToLowerCSafe().Replace("javascript", "_javascript");

            message.MessageUserName = TextHelper.LimitLength(txtUserName.Text.Trim(), txtUserName.MaxLength);
            if ((message.MessageID <= 0) && (!currentUser.IsPublic()))
            {
                message.MessageUserID = currentUser.UserID;
                if (!plcUserName.Visible)
                {
                    message.MessageUserName = GetDefaultUserName();
                }
            }

            message.MessageIsSpam = ValidationHelper.GetBoolean(chkSpam.Checked, false);

            if (BoardProperties.EnableContentRating && (ratingControl != null) &&
                (ratingControl.GetCurrentRating() > 0))
            {
                message.MessageRatingValue = ratingControl.CurrentRating;

                // Update document rating, remember rating in cookie
                TreeProvider.RememberRating(DocumentContext.CurrentDocument);
            }

            BoardInfo boardInfo;

            // If there is message board
            if (MessageBoardID > 0)
            {
                // Load message board
                boardInfo = Board;
            }
            else
            {
                // Create new message board according to webpart properties
                boardInfo = new BoardInfo(BoardProperties);
                BoardInfoProvider.SetBoardInfo(boardInfo);

                // Update information on current message board
                MessageBoardID = boardInfo.BoardID;

                // Set board-role relationship
                BoardRoleInfoProvider.SetBoardRoles(MessageBoardID, BoardProperties.BoardRoles);

                // Set moderators
                BoardModeratorInfoProvider.SetBoardModerators(MessageBoardID, BoardProperties.BoardModerators);
            }

            if (boardInfo != null)
            {
                if (BoardInfoProvider.IsUserAuthorizedToAddMessages(boardInfo))
                {
                    // If the very new message is inserted
                    if (MessageID == 0)
                    {
                        // If creating message set inserted to now and assign to board
                        message.MessageInserted = DateTime.Now;
                        message.MessageBoardID  = MessageBoardID;

                        // Handle auto approve action
                        bool isAuthorized = BoardInfoProvider.IsUserAuthorizedToManageMessages(boardInfo);
                        if (isAuthorized)
                        {
                            message.MessageApprovedByUserID = currentUser.UserID;
                            message.MessageApproved         = true;
                        }
                        else
                        {
                            // Is board moderated ?
                            message.MessageApprovedByUserID = 0;
                            message.MessageApproved         = !boardInfo.BoardModerated;
                        }
                    }
                    else
                    {
                        if (chkApproved.Checked)
                        {
                            // Set current user as approver
                            message.MessageApproved         = true;
                            message.MessageApprovedByUserID = currentUser.UserID;
                        }
                        else
                        {
                            message.MessageApproved         = false;
                            message.MessageApprovedByUserID = 0;
                        }
                    }

                    if (!AdvancedMode)
                    {
                        if (!BadWordInfoProvider.CanUseBadWords(MembershipContext.AuthenticatedUser, SiteContext.CurrentSiteName))
                        {
                            // Columns to check
                            Dictionary <string, int> collumns = new Dictionary <string, int>();
                            collumns.Add("MessageText", 0);
                            collumns.Add("MessageUserName", 250);

                            // Perform bad words check
                            bool validateUserName = plcUserName.Visible;
                            errorMessage = BadWordsHelper.CheckBadWords(message, collumns, "MessageApproved", "MessageApprovedByUserID",
                                                                        message.MessageText, currentUser.UserID, () => ValidateMessage(message, validateUserName));

                            // Additionally check empty fields
                            if (errorMessage == string.Empty)
                            {
                                if (!ValidateMessage(message, validateUserName))
                                {
                                    errorMessage = GetString("board.messageedit.emptybadword");
                                }
                            }
                        }
                    }

                    // Subscribe this user to message board
                    if (chkSubscribe.Checked)
                    {
                        string email = message.MessageEmail;

                        // Check for duplicate e-mails
                        DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("((SubscriptionApproved = 1) OR (SubscriptionApproved IS NULL)) AND SubscriptionBoardID=" + MessageBoardID +
                                                                                    " AND SubscriptionEmail='" + SqlHelper.GetSafeQueryString(email, false) + "'", null);
                        if (DataHelper.DataSourceIsEmpty(ds))
                        {
                            BoardSubscriptionInfo bsi = new BoardSubscriptionInfo();
                            bsi.SubscriptionBoardID = MessageBoardID;
                            bsi.SubscriptionEmail   = email;
                            if (!currentUser.IsPublic())
                            {
                                bsi.SubscriptionUserID = currentUser.UserID;
                            }
                            BoardSubscriptionInfoProvider.Subscribe(bsi, DateTime.Now, true, true);
                            ClearForm();

                            if (bsi.SubscriptionApproved)
                            {
                                ShowConfirmation(GetString("board.subscription.beensubscribed"));
                                Service.Resolve <ICurrentContactMergeService>().UpdateCurrentContactEmail(bsi.SubscriptionEmail, MembershipContext.AuthenticatedUser);
                                LogSubscribingActivity(bsi, boardInfo);
                            }
                            else
                            {
                                string confirmation  = GetString("general.subscribed.doubleoptin");
                                int    optInInterval = BoardInfoProvider.DoubleOptInInterval(SiteContext.CurrentSiteName);
                                if (optInInterval > 0)
                                {
                                    confirmation += "<br />" + String.Format(GetString("general.subscription_timeintervalwarning"), optInInterval);
                                }
                                ShowConfirmation(confirmation);
                            }
                        }
                        else
                        {
                            errorMessage = GetString("board.subscription.emailexists");
                        }
                    }

                    if (errorMessage == "")
                    {
                        try
                        {
                            // Save message info
                            BoardMessageInfoProvider.SetBoardMessageInfo(message);
                            Service.Resolve <ICurrentContactMergeService>().UpdateCurrentContactEmail(message.MessageEmail, MembershipContext.AuthenticatedUser);
                            LogCommentActivity(message, boardInfo);

                            if (BoardProperties.EnableContentRating && (ratingControl != null) && (ratingControl.GetCurrentRating() > 0))
                            {
                                LogRatingActivity(ratingControl.CurrentRating);
                            }

                            // If the message is not approved let the user know message is waiting for approval
                            if (message.MessageApproved == false)
                            {
                                ShowInformation(GetString("board.messageedit.waitingapproval"));
                            }

                            // Rise after message saved event
                            if (OnAfterMessageSaved != null)
                            {
                                OnAfterMessageSaved(message);
                            }

                            // Hide message form if user has rated and empty rating is not allowed
                            if (BoardProperties.CheckIfUserRated)
                            {
                                if (!BoardProperties.AllowEmptyRating && TreeProvider.HasRated(DocumentContext.CurrentDocument))
                                {
                                    pnlMessageEdit.Visible  = false;
                                    lblAlreadyrated.Visible = true;
                                }
                                else
                                {
                                    // Hide rating form if user has rated
                                    if (BoardProperties.EnableContentRating && (ratingControl != null) && ratingControl.GetCurrentRating() > 0)
                                    {
                                        plcRating.Visible = false;
                                    }
                                }
                            }

                            // Clear form content
                            ClearForm();
                        }
                        catch (Exception ex)
                        {
                            errorMessage = ex.Message;
                        }
                    }
                }
                else if (String.IsNullOrEmpty(errorMessage))
                {
                    errorMessage = ResHelper.GetString("general.actiondenied");
                }
            }
        }

        if (!String.IsNullOrEmpty(errorMessage))
        {
            ShowError(errorMessage);
        }
    }
    /// <summary>
    /// Reload all values.
    /// </summary>
    /// <param name="forceReload">Forces reload</param>
    public void ReloadData(bool forceReload)
    {
        if (StopProcessing || (loaded && !forceReload))
        {
            return;
        }

        // Check permissions
        if (HideToUnauthorizedUsers && !HasPermissions())
        {
            Visible = false;
            return;
        }

        if (DocumentContext.CurrentDocument != null)
        {
            try
            {
                // Insert rating control to page
                usrControl = (AbstractRatingControl)(Page.LoadUserControl(AbstractRatingControl.GetRatingControlUrl(RatingType + ".ascx")));
            }
            catch (Exception e)
            {
                Controls.Add(new LiteralControl(e.Message));
                return;
            }

            double rating = 0.0f;

            // Use current document rating if external value is not used
            if (mExternalValue < 0)
            {
                if (DocumentContext.CurrentDocument.DocumentRatings > 0)
                {
                    rating = DocumentContext.CurrentDocument.DocumentRatingValue / DocumentContext.CurrentDocument.DocumentRatings;
                }
            }
            else
            {
                rating = mExternalValue;
            }

            if ((rating < 0.0) || (rating > 1.0))
            {
                rating = 0.0;
            }

            usrControl.ID            = "RatingControl";
            usrControl.MaxRating     = MaxRatingValue;
            usrControl.CurrentRating = rating;
            usrControl.Visible       = true;
            usrControl.Enabled       = Enabled && HasPermissions() && !(CheckIfUserRated && TreeProvider.HasRated(DocumentContext.CurrentDocument));

            RefreshResultMessage();

            usrControl.RatingEvent += new AbstractRatingControl.OnRatingEventHandler(usrControl_RatingEvent);
            pnlRating.Controls.Clear();
            pnlRating.Controls.Add(usrControl);

            loaded = true;
        }
    }
예제 #5
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Let the parent control now new message is being saved
        if (OnBeforeMessageSaved != null)
        {
            OnBeforeMessageSaved();
        }

        // Check banned IP
        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            ShowError(GetString("General.BannedIP"));
            return;
        }

        // Validate form
        string errorMessage = ValidateForm();

        if (errorMessage == "")
        {
            // Check flooding when message being inserted through the LiveSite
            if (CheckFloodProtection && IsLiveSite && FloodProtectionHelper.CheckFlooding(CMSContext.CurrentSiteName, CMSContext.CurrentUser))
            {
                ShowError(GetString("General.FloodProtection"));
                return;
            }

            CurrentUserInfo currentUser = CMSContext.CurrentUser;

            BoardMessageInfo messageInfo = null;

            if (MessageID > 0)
            {
                // Get message info
                messageInfo    = BoardMessageInfoProvider.GetBoardMessageInfo(MessageID);
                MessageBoardID = messageInfo.MessageBoardID;
            }
            else
            {
                // Create new info
                messageInfo = new BoardMessageInfo();

                // User IP address
                messageInfo.MessageUserInfo.IPAddress = HTTPHelper.UserHostAddress;
                // User agent
                messageInfo.MessageUserInfo.Agent = Request.UserAgent;
            }

            // Setup message info
            messageInfo.MessageEmail = txtEmail.Text.Trim();
            messageInfo.MessageText  = txtMessage.Text.Trim();

            // Handle message URL
            string url = txtURL.Text.Trim();
            if ((url != "http://") && (url != "https://") && (url != ""))
            {
                if ((!url.ToLowerCSafe().StartsWithCSafe("http://")) && (!url.ToLowerCSafe().StartsWithCSafe("https://")))
                {
                    url = "http://" + url;
                }
            }
            else
            {
                url = "";
            }
            messageInfo.MessageURL = url;
            messageInfo.MessageURL = messageInfo.MessageURL.ToLowerCSafe().Replace("javascript", "_javascript");

            messageInfo.MessageUserName = txtUserName.Text.Trim();
            if (!currentUser.IsPublic())
            {
                messageInfo.MessageUserID = currentUser.UserID;
            }

            messageInfo.MessageIsSpam = ValidationHelper.GetBoolean(chkSpam.Checked, false);

            if (BoardProperties.EnableContentRating && (ratingControl != null) &&
                (ratingControl.GetCurrentRating() > 0))
            {
                messageInfo.MessageRatingValue = ratingControl.CurrentRating;

                // Update document rating, remember rating in cookie
                TreeProvider.AddRating(CMSContext.CurrentDocument, ratingControl.CurrentRating, true);
            }

            BoardInfo boardInfo = null;

            // If there is message board
            if (MessageBoardID > 0)
            {
                // Load message board
                boardInfo = Board;
            }
            else
            {
                // Create new message board according to webpart properties
                boardInfo = new BoardInfo(BoardProperties);
                BoardInfoProvider.SetBoardInfo(boardInfo);

                // Update information on current message board
                MessageBoardID = boardInfo.BoardID;

                // Set board-role relationship
                BoardRoleInfoProvider.SetBoardRoles(MessageBoardID, BoardProperties.BoardRoles);

                // Set moderators
                BoardModeratorInfoProvider.SetBoardModerators(MessageBoardID, BoardProperties.BoardModerators);
            }

            if (boardInfo != null)
            {
                // If the very new message is inserted
                if (MessageID == 0)
                {
                    // If creating message set inserted to now and assign to board
                    messageInfo.MessageInserted = currentUser.DateTimeNow;
                    messageInfo.MessageBoardID  = MessageBoardID;

                    // Handle auto approve action
                    bool isAuthorized = BoardInfoProvider.IsUserAuthorizedToManageMessages(boardInfo);
                    if (isAuthorized)
                    {
                        messageInfo.MessageApprovedByUserID = currentUser.UserID;
                        messageInfo.MessageApproved         = true;
                    }
                    else
                    {
                        // Is board moderated ?
                        messageInfo.MessageApprovedByUserID = 0;
                        messageInfo.MessageApproved         = !boardInfo.BoardModerated;
                    }
                }
                else
                {
                    if (chkApproved.Checked)
                    {
                        // Set current user as approver
                        messageInfo.MessageApproved         = true;
                        messageInfo.MessageApprovedByUserID = currentUser.UserID;
                    }
                    else
                    {
                        messageInfo.MessageApproved         = false;
                        messageInfo.MessageApprovedByUserID = 0;
                    }
                }

                if (!AdvancedMode)
                {
                    if (!BadWordInfoProvider.CanUseBadWords(CMSContext.CurrentUser, CMSContext.CurrentSiteName))
                    {
                        // Columns to check
                        Dictionary <string, int> collumns = new Dictionary <string, int>();
                        collumns.Add("MessageText", 0);
                        collumns.Add("MessageUserName", 250);

                        // Perform bad words check
                        errorMessage = BadWordsHelper.CheckBadWords(messageInfo, collumns, "MessageApproved", "MessageApprovedByUserID",
                                                                    messageInfo.MessageText, currentUser.UserID, () => { return(ValidateMessage(messageInfo)); });

                        // Additionally check empty fields
                        if (errorMessage == string.Empty)
                        {
                            if (!ValidateMessage(messageInfo))
                            {
                                errorMessage = GetString("board.messageedit.emptybadword");
                            }
                        }
                    }
                }

                // Subscribe this user to message board
                if (chkSubscribe.Checked)
                {
                    string email = messageInfo.MessageEmail;

                    // Check for duplicate e-mails
                    DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("((SubscriptionApproved = 1) OR (SubscriptionApproved IS NULL)) AND SubscriptionBoardID=" + MessageBoardID +
                                                                                " AND SubscriptionEmail='" + SqlHelperClass.GetSafeQueryString(email, false) + "'", null);
                    if (DataHelper.DataSourceIsEmpty(ds))
                    {
                        BoardSubscriptionInfo bsi = new BoardSubscriptionInfo();
                        bsi.SubscriptionBoardID = MessageBoardID;
                        bsi.SubscriptionEmail   = email;
                        if (!currentUser.IsPublic())
                        {
                            bsi.SubscriptionUserID = currentUser.UserID;
                        }
                        BoardSubscriptionInfoProvider.Subscribe(bsi, DateTime.Now, true, true);
                        ClearForm();

                        if (bsi.SubscriptionApproved)
                        {
                            LogSubscribingActivity(bsi, boardInfo);
                        }
                    }
                    else
                    {
                        errorMessage = GetString("board.subscription.emailexists");
                    }
                }

                if (errorMessage == "")
                {
                    try
                    {
                        // Save message info
                        BoardMessageInfoProvider.SetBoardMessageInfo(messageInfo);

                        LogCommentActivity(messageInfo, boardInfo);

                        if (BoardProperties.EnableContentRating && (ratingControl != null) && (ratingControl.GetCurrentRating() > 0))
                        {
                            LogRatingActivity(ratingControl.CurrentRating);
                        }

                        // If the message is not approved let the user know message is waiting for approval
                        if (messageInfo.MessageApproved == false)
                        {
                            ShowError(GetString("board.messageedit.waitingapproval"));
                        }

                        // Rise after message saved event
                        if (OnAfterMessageSaved != null)
                        {
                            OnAfterMessageSaved(messageInfo);
                        }

                        // Hide message form if user has rated and empty rating is not allowed
                        if (!BoardProperties.AllowEmptyRating && TreeProvider.HasRated(CMSContext.CurrentDocument))
                        {
                            pnlMessageEdit.Visible  = false;
                            lblAlreadyrated.Visible = true;
                        }
                        else
                        {
                            // Hide rating form if user has rated
                            if (BoardProperties.EnableContentRating && (ratingControl != null) && ratingControl.GetCurrentRating() > 0)
                            {
                                plcRating.Visible = false;
                            }
                        }

                        // Clear form content
                        ClearForm();
                    }
                    catch (Exception ex)
                    {
                        errorMessage = ex.Message;
                    }
                }
            }
        }


        if (!String.IsNullOrEmpty(errorMessage))
        {
            ShowError(errorMessage);
        }
        else
        {
            // Regenerate new captcha
            captchaElem.GenerateNew();
        }
    }