Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SetBrowserClass();
        bodyElem.Attributes["class"] = mBodyClass;

        // Prepare dataset
        DataSet ds = new DataSet();

        ds.Tables.Add();
        ds.Tables[0].Columns.Add("UserControlDisplayName");
        ds.Tables[0].Columns.Add("UserControlCodeName");

        // Get file names of rating controls
        string[] fileList = Directory.GetFiles(Server.MapPath(AbstractRatingControl.GetRatingControlUrl("")), "*.ascx");
        string   fileName = null;

        foreach (string file in fileList)
        {
            fileName = Path.GetFileNameWithoutExtension(file);
            // Initialize dataset
            ds.Tables[0].Rows.Add(GetString("contentrating." + fileName), fileName);
        }

        // Initialize grid
        gridForms.Columns[0].HeaderText = "<strong>" + GetString("SelectRatingDialog.FormName") + "</strong>";
        gridForms.DataSource            = ds;
        gridForms.DataBind();
    }
    /// <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;
            }
        }
    }
Exemplo n.º 3
0
    protected override void CreateChildControls()
    {
        base.CreateChildControls();
        string oldSelectedValue = drpRatingsControls.SelectedValue;

        string[] fileList     = Directory.GetFiles(Server.MapPath(AbstractRatingControl.GetRatingControlUrl("")), "*.ascx");
        string   fileNameOnly = null;

        drpRatingsControls.Items.Clear();
        foreach (string fileName in fileList)
        {
            fileNameOnly = Path.GetFileNameWithoutExtension(fileName);
            drpRatingsControls.Items.Add(new ListItem(fileNameOnly, fileNameOnly));
        }

        if (drpRatingsControls.Items.FindByValue(oldSelectedValue) != null)
        {
            drpRatingsControls.SelectedValue = oldSelectedValue;
        }
    }
    /// <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 ratingControl_RatingEvent(AbstractRatingControl sender)
 {
     ViewState["ratingvalue"] = sender.CurrentRating;
 }
    /// <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");
        revEmailValid.ErrorMessage = GetString("board.messageedit.revemail");
        rfvEmail.ErrorMessage = GetString("board.messageedit.rfvemail");

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

        // Ensure unique validation group name in case of multiple controls in one page
        string valGroup = UniqueID;

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

        txtEmail.ValidationGroup = valGroup;
        rfvEmail.ValidationGroup = valGroup;
        revEmailValid.ValidationGroup = valGroup;
        revEmailValid.ValidationExpression = @"^([\w0-9_\-\+]+(\.[\w0-9_\-\+]+)*@[\w0-9_-]+(\.[\w0-9_-]+)+)*$";

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

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

        // 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 ratingControl_RatingEvent(AbstractRatingControl sender)
 {
     ViewState["ratingvalue"] = sender.CurrentRating;
 }
Exemplo n.º 8
0
    private void rptBoardMessages_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.DataItem != null)
        {
            if (e.Item.Controls.Count > 0)
            {
                // Load 'MessageActions.ascx' control
                BoardMessageActions boardMsgActions = (BoardMessageActions)e.Item.Controls[0].FindControl("messageActions");

                Control pnlRating = e.Item.Controls[0].FindControl("pnlRating");

                if ((boardMsgActions != null) || (pnlRating != null))
                {
                    DataRow drvRow = ((DataRowView)e.Item.DataItem).Row;

                    // Create new comment info object
                    BoardMessageInfo bmi = new BoardMessageInfo(drvRow);

                    if (boardMsgActions != null)
                    {
                        // Initialize control
                        boardMsgActions.MessageID      = bmi.MessageID;
                        boardMsgActions.MessageBoardID = MessageBoardID;

                        // Register for OnAction event
                        boardMsgActions.OnMessageAction += boardMsgActions_OnMessageAction;

                        // Handle buttons displaying
                        boardMsgActions.ShowApprove = ((BoardProperties.ShowApproveButton) && (!bmi.MessageApproved) && userVerified);
                        boardMsgActions.ShowReject  = ((BoardProperties.ShowRejectButton) && (bmi.MessageApproved) && userVerified);
                        boardMsgActions.ShowDelete  = ((BoardProperties.ShowDeleteButton) && userVerified);
                        boardMsgActions.ShowEdit    = ((BoardProperties.ShowEditButton) && userVerified);
                    }

                    // Init content rating control if enabled and rating is greater than zero
                    if (pnlRating != null)
                    {
                        if ((bmi.MessageRatingValue > 0) && (BoardProperties.EnableContentRating))
                        {
                            pnlRating.Visible = true;
                            if (DocumentContext.CurrentDocument != null)
                            {
                                AbstractRatingControl usrControl;
                                try
                                {
                                    // Insert rating control to page
                                    usrControl = (AbstractRatingControl)(Page.LoadUserControl(AbstractRatingControl.GetRatingControlUrl(BoardProperties.RatingType + ".ascx")));
                                }
                                catch (Exception ex)
                                {
                                    Controls.Add(new LiteralControl(ex.Message));
                                    return;
                                }

                                // Init values
                                usrControl.ID            = "messageRating";
                                usrControl.MaxRating     = BoardProperties.MaxRatingValue;
                                usrControl.CurrentRating = bmi.MessageRatingValue;
                                usrControl.Visible       = true;
                                usrControl.Enabled       = false;

                                pnlRating.Controls.Clear();
                                pnlRating.Controls.Add(usrControl);
                            }
                        }
                        else
                        {
                            pnlRating.Visible = false;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 9
0
    /// <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");

        chkSubscribe.Text = GetString("board.messageedit.subscribe");

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

        // Ensure unique validation group name in case of multiple controls in one page
        string valGroup = UniqueID;

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

        txtEmail.ValidationGroup           = valGroup;
        rfvEmail.ValidationGroup           = valGroup;
        revEmailValid.ValidationGroup      = valGroup;
        revEmailValid.ValidationExpression = @"^([\w0-9_\-\+]+(\.[\w0-9_\-\+]+)*@[\w0-9_-]+(\.[\w0-9_-]+)+)*$";

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

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

        if (CMSContext.ViewMode == ViewModeEnum.LiveSite)
        {
            lblMessage.CssClass = "";
        }

        // 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;
        if (!AdvancedMode && this.BoardProperties.EnableContentRating)
        {
            if (CMSContext.CurrentDocument != null)
            {
                plcRating.Visible = true;
                try
                {
                    // Insert rating control to page
                    ratingControl = (AbstractRatingControl)(Page.LoadControl(AbstractRatingControl.GetRatingControlUrl(BoardProperties.RatingType + ".ascx")));
                }
                catch (Exception ex)
                {
                    Controls.Add(new LiteralControl(ex.Message));
                    return;
                }

                // Init values
                ratingControl.ID                 = this.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.ok";
            btnOkFooter.ResourceString = "general.ok";

            // 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 (!this.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 = this.BoardProperties.BoardEnableSubscriptions;

        // For new message hide Is approved chkbox (auto approve)
        if (this.MessageID <= 0)
        {
            this.plcApproved.Visible = false;
        }
    }
Exemplo n.º 10
0
    /// <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");

        chkSubscribe.Text = GetString("board.messageedit.subscribe");

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

        // Ensure unique validation group name in case of multiple controls in one page
        string valGroup = UniqueID;

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

        txtEmail.ValidationGroup = valGroup;
        rfvEmail.ValidationGroup = valGroup;
        revEmailValid.ValidationGroup = valGroup;
        revEmailValid.ValidationExpression = @"^([\w0-9_\-\+]+(\.[\w0-9_\-\+]+)*@[\w0-9_-]+(\.[\w0-9_-]+)+)*$";

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

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

        if (CMSContext.ViewMode == ViewModeEnum.LiveSite)
        {
            lblMessage.CssClass = "";
        }

        // 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;
        if (!AdvancedMode && this.BoardProperties.EnableContentRating)
        {
            if (CMSContext.CurrentDocument != null)
            {
                plcRating.Visible = true;
                try
                {
                    // Insert rating control to page
                    ratingControl = (AbstractRatingControl)(Page.LoadControl(AbstractRatingControl.GetRatingControlUrl(BoardProperties.RatingType + ".ascx")));
                }
                catch (Exception ex)
                {
                    Controls.Add(new LiteralControl(ex.Message));
                    return;
                }

                // Init values
                ratingControl.ID = this.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.ok";
            btnOkFooter.ResourceString = "general.ok";

            // 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 (!this.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 = this.BoardProperties.BoardEnableSubscriptions;

        // For new message hide Is approved chkbox (auto approve)
        if (this.MessageID <= 0)
        {
            this.plcApproved.Visible = false;
        }
    }
    /// <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;
        }
    }
Exemplo n.º 12
0
    /// <summary>
    /// Occures on rating event.
    /// </summary>
    protected void usrControl_RatingEvent(AbstractRatingControl sender)
    {
        // Check if control is enabled
        if (!(this.Enabled && HasPermissions() && !(this.CheckIfUserRated && TreeProvider.HasRated(CMSContext.CurrentDocument))))
        {
            return;
        }

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

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

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

            // Update document rating, remember rating in cookie if required
            TreeProvider.AddRating(CMSContext.CurrentDocument, usrControl.CurrentRating, this.CheckIfUserRated);
            // Get absolute rating value of the current rating
            double currRating = usrControl.MaxRating * usrControl.CurrentRating;
            // Reload rating control
            ReloadData();
            // Show message after rating if enabled or set
            if (!string.IsNullOrEmpty(this.MessageAfterRating))
            {
                pnlMessage.Visible = true;
                // Merge message text with rating values
                lblMessage.Text = String.Format(this.MessageAfterRating,
                    Convert.ToInt32(currRating), usrControl.CurrentRating * usrControl.MaxRating, CMSContext.CurrentDocument.DocumentRatings);
            }
            else
            {
                pnlMessage.Visible = false;
            }

            // log activity
            LogActivity(usrControl.CurrentRating);
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// Reload all values.
    /// </summary>
    public void ReloadData()
    {
        if (this.StopProcessing)
        {
            return;
        }

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

        if (CMSContext.CurrentDocument != null)
        {
            try
            {
                // Insert rating control to page
                usrControl = (AbstractRatingControl)(this.Page.LoadControl(AbstractRatingControl.GetRatingControlUrl(this.RatingType + ".ascx")));
            }
            catch (Exception e)
            {
                this.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 (CMSContext.CurrentDocument.DocumentRatings > 0)
                {
                    rating = CMSContext.CurrentDocument.DocumentRatingValue / CMSContext.CurrentDocument.DocumentRatings;
                }
            }
            else
            {
                rating = mExternalValue;
            }

            // Check allowed interval 0.0-1.0
            if ((rating < 0.0) || (rating > 1.0))
            {
                rating = 0.0;
            }

            // Init values
            usrControl.ID = "RatingControl";
            usrControl.MaxRating = this.MaxRatingValue;
            usrControl.CurrentRating = rating;
            usrControl.Visible = true;
            usrControl.Enabled = this.Enabled && HasPermissions() && !(this.CheckIfUserRated && TreeProvider.HasRated(CMSContext.CurrentDocument));

            RefreshResultMessage();

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