/// <summary>
    /// Initializes the controls.
    /// </summary>
    private void SetupControls()
    {
        btnFilter.Text = GetString("general.search");
        btnOk.Text     = GetString("general.ok");

        // Mass actions
        gridElem.GridOptions.ShowSelection = AllowMassActions;
        plcActions.Visible = AllowMassActions;

        lblSiteName.AssociatedControlClientID  = siteSelector.DropDownSingleSelect.ClientID;
        lblBoardName.AssociatedControlClientID = boardSelector.DropDownSingleSelect.ClientID;

        gridElem.IsLiveSite           = IsLiveSite;
        gridElem.OnAction            += gridElem_OnAction;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;
        gridElem.OnBeforeDataReload  += gridElem_OnBeforeDataReload;
        gridElem.ZeroRowsText         = GetString("general.nodatafound");

        btnOk.OnClientClick += "return MassConfirm('" + drpActions.ClientID + "'," + ScriptHelper.GetString(GetString("General.ConfirmGlobalDelete")) + ");";

        ScriptHelper.RegisterDialogScript(Page);

        if (GroupID == 0)
        {
            GroupID = QueryHelper.GetInteger("groupid", 0);
        }

        ReloadFilter();

        if (!RequestHelper.IsPostBack())
        {
            var defaultApproved = "NO";

            if (SelectedBoardID > 0)
            {
                // Check if board is moderated
                var boardInfo = BoardInfoProvider.GetBoardInfo(SelectedBoardID);
                if ((boardInfo != null) && (!boardInfo.BoardModerated))
                {
                    defaultApproved = "";
                }
            }

            // Preselect filter data
            PreselectFilter(String.Format(";;{0};;;{1};;", GroupID, defaultApproved));
        }

        if (GroupID > 0)
        {
            // Hide site selection
            plcSite.Visible = false;
        }

        if (BoardID > 0)
        {
            // Hide board selection
            plcBoard.Visible = false;

            // Hide site selection
            plcSite.Visible = false;

            if ((GroupID > 0) && IsLiveSite)
            {
                InitializeGroupNewMessage();
            }
        }

        siteSelector.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged;

        // Reload message list script
        string board        = (BoardID > 0 ? BoardID.ToString() : boardSelector.Value.ToString());
        string group        = GroupID.ToString();
        string user         = HTMLHelper.HTMLEncode(txtUserName.Text);
        string message      = HTMLHelper.HTMLEncode(txtMessage.Text);
        string approved     = drpApproved.SelectedItem.Value;
        string spam         = drpSpam.SelectedItem.Value;
        bool   changemaster = QueryHelper.GetBoolean("changemaster", false);

        // Set site selector
        siteSelector.DropDownSingleSelect.AutoPostBack = true;
        siteSelector.AllowAll   = true;
        siteSelector.IsLiveSite = IsLiveSite;

        boardSelector.IsLiveSite = IsLiveSite;
        boardSelector.GroupID    = GroupID;

        if (!ShowFilter)
        {
            SiteInfo si = SiteInfoProvider.GetSiteInfo(SiteName);
            if (si != null)
            {
                siteId = si.SiteID;
            }
            if (SiteName == TreeProvider.ALL_SITES)
            {
                siteId = -1;
            }
        }
        else
        {
            // Collect values from filter controls
            siteId     = SelectedSiteID;
            IsApproved = drpApproved.SelectedValue.ToLowerCSafe();
            IsSpam     = drpSpam.SelectedValue.ToLowerCSafe();
        }


        if (siteId == 0)
        {
            siteId             = SiteContext.CurrentSiteID;
            siteSelector.Value = siteId;
        }

        SelectedSiteID = siteId;

        string cmdArg = siteId + ";" + board + ";" + group + ";" + user.Replace(";", "#sc#") + ";" +
                        message.Replace(";", "#sc#") + ";" + approved + ";" + spam + ";" + changemaster;

        btnRefreshHdn.CommandArgument = cmdArg;
        mPostBackRefference           = ControlsHelper.GetPostBackEventReference(btnRefreshHdn, null);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshBoardList", ScriptHelper.GetScript("function RefreshBoardList(){" +
                                                                                                                mPostBackRefference + "}"));

        siteSelector.OnlyRunningSites = IsLiveSite;

        gridElem.WhereCondition = GetWhereCondition();

        if ((!RequestHelper.IsPostBack()) && (!string.IsNullOrEmpty(ItemsPerPage)))
        {
            gridElem.Pager.DefaultPageSize = ValidationHelper.GetInteger(ItemsPerPage, -1);
        }

        if (!String.IsNullOrEmpty(OrderBy))
        {
            gridElem.OrderBy = OrderBy;
        }
    }
    /// <summary>
    /// Creates where condition reflecting filter settings.
    /// </summary>
    private string GetFilterWhereCondition()
    {
        string where = String.Empty;

        // Sites dropdown list
        if (SelectedSiteID > 0)
        {
            where = SqlHelper.AddWhereCondition(where, "BoardSiteID = " + SelectedSiteID);
        }

        // Approved dropdown list
        switch (IsApproved.ToLowerCSafe())
        {
        case "yes":
            where = SqlHelper.AddWhereCondition(where, "MessageApproved = 1");
            break;

        case "no":
            where = SqlHelper.AddWhereCondition(where, "MessageApproved = 0");
            break;
        }

        // Spam dropdown list
        switch (IsSpam.ToLowerCSafe())
        {
        case "yes":
            where = SqlHelper.AddWhereCondition(where, "MessageIsSpam = 1");
            break;

        case "no":
            where = SqlHelper.AddWhereCondition(where, "MessageIsSpam = 0");
            break;
        }

        if (BoardID > 0)
        {
            where = SqlHelper.AddWhereCondition(where, "MessageBoardID = " + BoardID.ToString());
        }
        else
        {
            // Board dropdown list
            if (SelectedBoardID > 0)
            {
                where = SqlHelper.AddWhereCondition(where, "MessageBoardID = " + SelectedBoardID);
            }
            else if (GroupID > 0)
            {
                where = SqlHelper.AddWhereCondition(where, "BoardGroupID =" + GroupID);
            }
            else
            {
                where = SqlHelper.AddWhereCondition(where, "BoardGroupID IS NULL");
            }
        }

        if (txtUserName.Text.Trim() != "")
        {
            where = SqlHelper.AddWhereCondition(where, "MessageUserName LIKE '%" + txtUserName.Text.Trim().Replace("'", "''") + "%'");
        }

        if (txtMessage.Text.Trim() != "")
        {
            where = SqlHelper.AddWhereCondition(where, "MessageText LIKE '%" + txtMessage.Text.Trim().Replace("'", "''") + "%'");
        }

        return(where);
    }
Exemple #3
0
        public override string ToString()
        {
            var str = FirmwareVersion.ToString();

            return(BoardID.ToString() + " - Firmware Version: " + str.Substring(0, 4) + "-" + str.Substring(4, 2) + "-" + str.Substring(6, 2) + "-" + str.Substring(8, 2));
        }