/// <summary> /// Creates condition for DB query (if filter set via web part). /// </summary> private String CreateCondition() { string where = String.Empty; //Is approved switch (IsApproved.ToLower()) { case "yes": where = SqlHelperClass.AddWhereCondition(where, "CommentApproved = 1"); break; case "no": where = SqlHelperClass.AddWhereCondition(where, "(CommentApproved = 0 OR CommentApproved IS NULL )"); break; } //Is spam switch (IsSpam.ToLower()) { case "yes": where = SqlHelperClass.AddWhereCondition(where, "CommentIsSpam = 1"); break; case "no": where = SqlHelperClass.AddWhereCondition(where, "(CommentIsSpam = 0 OR CommentIsSpam IS NULL )"); break; } return(where); }
/// <summary> /// Initializes the controls. /// </summary> private void SetupControls() { btnFilter.Text = GetString("general.show"); btnOk.Text = GetString("general.ok"); // Mass actions this.gridElem.GridOptions.ShowSelection = this.AllowMassActions; this.rowActions.Visible = this.AllowMassActions; lblSiteName.AssociatedControlClientID = siteSelector.DropDownSingleSelect.ClientID; lblBoardName.AssociatedControlClientID = boardSelector.DropDownSingleSelect.ClientID; gridElem.IsLiveSite = this.IsLiveSite; gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.ZeroRowsText = GetString("general.nodatafound"); this.btnOk.OnClientClick += "return MassConfirm('" + this.drpActions.ClientID + "'," + ScriptHelper.GetString(GetString("General.ConfirmGlobalDelete")) + ");"; ScriptHelper.RegisterDialogScript(this.Page); if (this.GroupID == 0) { this.GroupID = QueryHelper.GetInteger("groupid", 0); } ReloadFilter(); if (!RequestHelper.IsPostBack()) { // Preselect filter data PreselectFilter(";;" + this.GroupID + ";;;NO;;"); } if (this.GroupID > 0) { // Hide site selection this.plcSite.Visible = false; } if (this.BoardID > 0) { // Hide board selection this.plcBoard.Visible = false; // Hide site selection this.plcSite.Visible = false; if ((this.GroupID > 0) && this.IsLiveSite) { InitializeGroupNewMessage(); } } siteSelector.UniSelector.OnSelectionChanged += new EventHandler(UniSelector_OnSelectionChanged); // Reload message list script string board = (this.BoardID > 0 ? this.BoardID.ToString() : this.boardSelector.Value.ToString()); string group = this.GroupID.ToString(); string user = HTMLHelper.HTMLEncode(this.txtUserName.Text); string message = HTMLHelper.HTMLEncode(this.txtMessage.Text); string approved = this.drpApproved.SelectedItem.Value; string spam = this.drpSpam.SelectedItem.Value; bool changemaster = QueryHelper.GetBoolean("changemaster", false); // Set site selector siteSelector.DropDownSingleSelect.AutoPostBack = true; siteSelector.AllowAll = true; siteSelector.IsLiveSite = this.IsLiveSite; boardSelector.IsLiveSite = this.IsLiveSite; boardSelector.GroupID = this.GroupID; if (!ShowFilter) { SiteInfo si = SiteInfoProvider.GetSiteInfo(SiteName); if (si != null) { siteId = si.SiteID; } if (SiteName == TreeProvider.ALL_SITES) { siteId = -1; } } else { siteId = ValidationHelper.GetInteger(siteSelector.Value, 0); IsApproved = drpApproved.SelectedValue.ToLower(); IsSpam = drpSpam.SelectedValue.ToLower(); } if (siteId == 0) { siteId = CMSContext.CurrentSiteID; siteSelector.Value = siteId; } string cmdArg = siteId + ";" + board + ";" + group + ";" + user.Replace(";", "#sc#") + ";" + message.Replace(";", "#sc#") + ";" + approved + ";" + spam + ";" + changemaster; this.btnRefreshHdn.CommandArgument = cmdArg; this.mPostBackRefference = ControlsHelper.GetPostBackEventReference(this.btnRefreshHdn, null); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshBoardList", ScriptHelper.GetScript("function RefreshBoardList(){" + mPostBackRefference + "}")); this.siteSelector.OnlyRunningSites = this.IsLiveSite; string where = ""; // Sites dropdownlist if (siteId > 0) { where += "BoardSiteID = " + siteId + " AND"; } // Approved dropdownlist switch (IsApproved.ToLower()) { case "yes": where += " MessageApproved = 1 AND"; break; case "no": where += " MessageApproved = 0 AND"; break; } // Spam dropdownlist switch (IsSpam.ToLower()) { case "yes": where += " MessageIsSpam = 1 AND"; break; case "no": where += " MessageIsSpam = 0 AND"; break; } int selectedBoardId = 0; if (mBoardId > 0) { where += " MessageBoardID = " + mBoardId.ToString() + " AND"; selectedBoardId = mBoardId; } else { // Board dropdownlist selectedBoardId = ValidationHelper.GetInteger(boardSelector.Value, 0); if (selectedBoardId > 0) { where += " MessageBoardID = " + selectedBoardId + " AND"; } } if (txtUserName.Text.Trim() != "") { where += " MessageUserName LIKE '%" + txtUserName.Text.Trim().Replace("'", "''") + "%' AND"; } if (txtMessage.Text.Trim() != "") { where += " MessageText LIKE '%" + txtMessage.Text.Trim().Replace("'", "''") + "%' AND"; } bool isAuthorized = false; if (selectedBoardId > 0) { BoardInfo selectedBoard = BoardInfoProvider.GetBoardInfo(selectedBoardId); if (selectedBoard != null) { isAuthorized = BoardInfoProvider.IsUserAuthorizedToManageMessages(selectedBoard); } } // Show messages to boards only where user is moderator if (!isAuthorized && (!(CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.MessageBoards", "Modify") || CMSContext.CurrentUser.IsGroupAdministrator(this.mGroupId)))) { where += " BoardID IN (SELECT BoardID FROM Board_Moderator WHERE Board_Moderator.UserID = " + CMSContext.CurrentUser.UserID + " ) AND "; } if (this.mGroupId > 0) { where += " BoardGroupID =" + this.mGroupId; } else { where += "(BoardGroupID =0 OR BoardGroupID IS NULL)"; } gridElem.WhereCondition = where; if ((!RequestHelper.IsPostBack()) && (!string.IsNullOrEmpty(ItemsPerPage))) { gridElem.Pager.DefaultPageSize = ValidationHelper.GetInteger(ItemsPerPage, -1); } if (!String.IsNullOrEmpty(OrderBy)) { gridElem.OrderBy = OrderBy; } }