/// <summary> /// Initializes the controls on the page. /// </summary> private void SetupControl() { // Get current subscription ID mSubscriptionId = QueryHelper.GetInteger("subscriptionid", 0); mCurrentSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(mSubscriptionId); // Get current board and group ID boardId = QueryHelper.GetInteger("boardid", 0); groupId = QueryHelper.GetInteger("groupid", 0); BoardInfo boardObj = BoardInfoProvider.GetBoardInfo(boardId); if (boardObj != null) { // Check whether edited board belongs to group if ((boardObj.BoardGroupID == 0) || (groupId != boardObj.BoardGroupID)) { EditedObject = null; } } boardSubscription.IsLiveSite = false; boardSubscription.BoardID = boardId; boardSubscription.GroupID = groupId; boardSubscription.SubscriptionID = mSubscriptionId; boardSubscription.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(boardSubscription_OnCheckPermissions); boardSubscription.OnSaved += new EventHandler(boardSubscription_OnSaved); InitializeBreadcrumbs(); }
/// <summary> /// Initializes the controls on the page. /// </summary> private void SetupControl() { // Get current subscription ID mSubscriptionId = QueryHelper.GetInteger("subscriptionid", 0); mCurrentSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(mSubscriptionId); // Get current board and group ID boardId = QueryHelper.GetInteger("boardid", 0); groupId = QueryHelper.GetInteger("groupid", 0); BoardInfo boardObj = BoardInfoProvider.GetBoardInfo(boardId); if (boardObj != null) { // Check whether edited board belongs to group if ((boardObj.BoardGroupID == 0) || (groupId != boardObj.BoardGroupID)) { EditedObject = null; } } boardSubscription.IsLiveSite = false; boardSubscription.BoardID = boardId; boardSubscription.GroupID = groupId; boardSubscription.SubscriptionID = mSubscriptionId; boardSubscription.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(boardSubscription_OnCheckPermissions); boardSubscription.OnSaved += new EventHandler(boardSubscription_OnSaved); InitializeBreadcrumbs(); }
/// <summary> /// Deletes message board subscription. Called when the "Delete subscription" button is pressed. /// Expects the CreateMessageBoardSubscription method to be run first. /// </summary> private bool DeleteMessageBoardSubscription() { // Get the tree structure TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get root document TreeNode root = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", null, true); if (root != null) { // Get the message board BoardInfo board = BoardInfoProvider.GetBoardInfo("MyNewBoard", root.DocumentID); if (board != null) { // Get the message board subscription BoardSubscriptionInfo deleteSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(board.BoardID, MembershipContext.AuthenticatedUser.UserID); // Delete the message board subscription BoardSubscriptionInfoProvider.DeleteBoardSubscriptionInfo(deleteSubscription); return(deleteSubscription != null); } } return(false); }
/// <summary> /// Gets and updates message board subscription. Called when the "Get and update subscription" button is pressed. /// Expects the CreateMessageBoardSubscription method to be run first. /// </summary> private bool GetAndUpdateMessageBoardSubscription() { // Get the tree structure TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get root document TreeNode root = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", null, true); if (root != null) { // Get the message board BoardInfo board = BoardInfoProvider.GetBoardInfo("MyNewBoard", root.DocumentID); if (board != null) { // Get the message board subscription BoardSubscriptionInfo updateSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(board.BoardID, MembershipContext.AuthenticatedUser.UserID); if (updateSubscription != null) { // Update the properties updateSubscription.SubscriptionEmail = updateSubscription.SubscriptionEmail.ToLowerCSafe(); // Update the subscription BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(updateSubscription); return(true); } } } return(false); }
/// <summary> /// Initializes controls on the page. /// </summary> private void SetupControls() { if (UserID > 0) { boardSubscriptions.Visible = true; if (MembershipContext.AuthenticatedUser.UserID == UserID) { boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.userhasnosubscriptions"); } else { boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.NoDataUser"); } // Setup UniGrid control boardSubscriptions.IsLiveSite = IsLiveSite; boardSubscriptions.Pager.DefaultPageSize = 10; boardSubscriptions.OnAction += boardSubscriptions_OnAction; boardSubscriptions.OnExternalDataBound += boardSubscriptions_OnExternalDataBound; boardSubscriptions.OnDataReload += boardSubscriptions_OnDataReload; boardSubscriptions.ShowActionsMenu = true; BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); boardSubscriptions.AllColumns = SqlHelper.AddColumns(SqlHelper.JoinColumnList(bsi.ColumnNames), "BoardID, BoardDisplayName, BoardSiteID, NodeAliasPath, DocumentCulture"); mSiteName = SiteInfoProvider.GetSiteName(SiteID); } else { boardSubscriptions.Visible = false; } }
private void InitBreadCrumbs() { ucBreadcrumbs.Items.Clear(); ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = GetString("Group_General.Boards.Boards.BackToSubscriptions"), OnClientClick = ControlsHelper.GetPostBackEventReference(lnkBackHidden) + "; return false;" }); ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem()); // Initialize subscription breadcrumbs if (SubscriptionID > 0) { BoardSubscriptionInfo subscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(SubscriptionID); if (subscription != null) { ucBreadcrumbs.Items[1].Text = subscription.SubscriptionEmail; } } else { ucBreadcrumbs.Items[1].Text = GetString("Group_General.Boards.Boards.NewSubscription"); } }
/// <summary> /// Creates message board subscription. Called when the "Create subscription" button is pressed. /// Expects the CreateMessageBoard method to be run first. /// </summary> private bool CreateMessageBoardSubscription() { // Create new message board subscription object BoardSubscriptionInfo newSubscription = new BoardSubscriptionInfo(); // Get the tree structure TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get root document TreeNode root = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", null, true); if (root != null) { // Get the message board BoardInfo board = BoardInfoProvider.GetBoardInfo("MyNewBoard", root.DocumentID); if (board != null) { // Set the properties newSubscription.SubscriptionBoardID = board.BoardID; newSubscription.SubscriptionUserID = MembershipContext.AuthenticatedUser.UserID; newSubscription.SubscriptionEmail = "*****@*****.**"; newSubscription.SubscriptionLastModified = DateTime.Now; // Create the message board subscription BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(newSubscription); return(true); } } return(false); }
/// <summary> /// On action event handling. /// </summary> /// <param name="actionName">Name of the action.</param> /// <param name="actionArgument">Parameter for the action.</param> protected void boardSubscriptions_OnAction(string actionName, object actionArgument) { int boardSubscriptionId = ValidationHelper.GetInteger(actionArgument, 0); switch (actionName.ToLowerCSafe()) { case "delete": if (RaiseOnCheckPermissions(PERMISSION_MANAGE, this)) { if (StopProcessing) { return; } } try { BoardSubscriptionInfoProvider.DeleteBoardSubscriptionInfo(boardSubscriptionId); } catch (Exception ex) { ShowError(ex.Message); } break; case "approve": if (RaiseOnCheckPermissions(PERMISSION_MANAGE, this)) { if (StopProcessing) { return; } } // Approve BoardSubscriptionInfo object BoardSubscriptionInfo bsi = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(boardSubscriptionId); if ((bsi != null) && !bsi.SubscriptionApproved) { bsi.SubscriptionApproved = true; BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); // Send confirmation mail BoardInfo bi = BoardInfoProvider.GetBoardInfo(bsi.SubscriptionBoardID); if ((bi != null) && bi.BoardSendOptInConfirmation) { BoardSubscriptionInfoProvider.SendConfirmationEmail(bsi, true); } // Log activity if (MembershipContext.AuthenticatedUser.UserID == UserID) { Service <ICurrentContactMergeService> .Entry().UpdateCurrentContactEmail(bsi.SubscriptionEmail, MembershipContext.AuthenticatedUser); BoardSubscriptionInfoProvider.LogSubscriptionActivity(bsi, bi, PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, false); } } break; } }
/// <summary> /// Initializes controls on the page. /// </summary> private void SetupControls() { if (this.UserID > 0) { this.boardSubscriptions.Visible = true; if (CMSContext.CurrentUser.UserID == this.UserID) { this.boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.userhasnosubscriptions"); } else { this.boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.NoDataUser"); } // Setup UniGrid control this.boardSubscriptions.IsLiveSite = this.IsLiveSite; this.boardSubscriptions.Pager.DefaultPageSize = 10; this.boardSubscriptions.OnAction += new OnActionEventHandler(boardSubscriptions_OnAction); this.boardSubscriptions.OnExternalDataBound += new OnExternalDataBoundEventHandler(boardSubscriptions_OnExternalDataBound); boardSubscriptions.OnDataReload += new OnDataReloadEventHandler(boardSubscriptions_OnDataReload); boardSubscriptions.ShowActionsMenu = true; BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); boardSubscriptions.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(bsi.ColumnNames.ToArray()), "BoardID, BoardDisplayName, BoardSiteID, NodeAliasPath, DocumentCulture"); mSiteName = SiteInfoProvider.GetSiteName(SiteID); } else { this.boardSubscriptions.Visible = false; } }
/// <summary> /// Log activity (subscribing) /// </summary> /// <param name="bsi"></param> private void LogActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bsi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.MessageBoardSubscriptionEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary <string, object> contactData = new Dictionary <string, object>(); contactData.Add("ContactEmail", bsi.SubscriptionEmail); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, TitleData = bi.BoardName, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Log activity (subscribing). /// </summary> /// <param name="bsi">Board subscription info object</param> /// <param name="bi">Message board info</param> private void LogSubscribingActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bsi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.MessageBoardSubscriptionEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, TitleData = bi.BoardDisplayName, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
protected void btnOk_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.messageboards", CMSAdminControl.PERMISSION_MODIFY)) { return; } string errMsg = ValidateForm(); // If entered form was validated successfully if (string.IsNullOrEmpty(errMsg)) { BoardSubscriptionInfo bsi = null; // If existing subscription is edited if (this.SubscriptionID > 0) { bsi = this.CurrentSubscription; } else { bsi = new BoardSubscriptionInfo(); } // Get data according the selected type if (this.radAnonymousSubscription.Checked) { bsi.SubscriptionEmail = this.txtEmailAnonymous.Text; bsi.SubscriptionUserID = 0; } else { bsi.SubscriptionEmail = this.txtEmailRegistered.Text; bsi.SubscriptionUserID = ValidationHelper.GetInteger(this.userSelector.Value, 0); } bsi.SubscriptionBoardID = this.BoardID; // Save information on user BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); this.SubscriptionID = bsi.SubscriptionID; this.RaiseOnSaved(); // Display info on success if subscription is edited this.lblInfo.Text = GetString("general.changessaved"); this.lblInfo.Visible = true; } else { // Inform user on error this.lblError.Text = errMsg; this.lblError.Visible = true; this.lblInfo.Visible = false; } }
protected void btnOk_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.messageboards", PERMISSION_MODIFY)) { return; } string errMsg = ValidateForm(); // If entered form was validated successfully if (string.IsNullOrEmpty(errMsg)) { BoardSubscriptionInfo bsi = null; // If existing subscription is edited if (SubscriptionID > 0) { bsi = CurrentSubscription; } else { bsi = new BoardSubscriptionInfo(); } // Get data according the selected type if (radAnonymousSubscription.Checked) { bsi.SubscriptionEmail = txtEmailAnonymous.Text; bsi.SubscriptionUserID = 0; } else { bsi.SubscriptionEmail = txtEmailRegistered.Text; bsi.SubscriptionUserID = ValidationHelper.GetInteger(userSelector.Value, 0); } bsi.SubscriptionBoardID = BoardID; // Save information on user BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); if (chkSendConfirmationEmail.Checked) { BoardSubscriptionInfoProvider.SendConfirmationEmail(bsi, true); } SubscriptionID = bsi.SubscriptionID; RaiseOnSaved(); // Display info on success if subscription is edited ShowChangesSaved(); } else { // Inform user on error ShowError(errMsg); } }
protected void boardSubscriptions_OnAction(string actionName, object actionArgument) { BoardSubscriptionInfo bsi = null; // Get currently processed subscription ID int subscriptionId = ValidationHelper.GetInteger(actionArgument, 0); if (subscriptionId > 0) { switch (actionName.ToLowerCSafe()) { case "delete": if (!CheckPermissions("cms.messageboards", PERMISSION_MODIFY)) { return; } // Get subscription according current ID bsi = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(subscriptionId); if (bsi != null) { if (chkSendConfirmationEmail.Checked && bsi.SubscriptionApproved) { BoardSubscriptionInfoProvider.SendConfirmationEmail(bsi, false); } BoardSubscriptionInfoProvider.DeleteBoardSubscriptionInfo(bsi); } break; case "approve": if (!CheckPermissions("cms.messageboards", PERMISSION_MODIFY)) { return; } // Approve ForumSubscriptionInfo object bsi = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(subscriptionId); if ((bsi != null) && !bsi.SubscriptionApproved) { bsi.SubscriptionApproved = true; BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); if (chkSendConfirmationEmail.Checked) { BoardSubscriptionInfoProvider.SendConfirmationEmail(bsi, true); } } break; default: break; } RaiseOnAction(actionName, actionArgument); } }
private void InitBreadCrumbs() { // Initialize subscription breadcrumbs if (SubscriptionID > 0) { BoardSubscriptionInfo subscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(SubscriptionID); if (subscription != null) { lblEditSubscriptionBack.Text = breadCrumbsSeparator + HTMLHelper.HTMLEncode(subscription.SubscriptionEmail); } } else { lblEditSubscriptionBack.Text = breadCrumbsSeparator + GetString("Group_General.Boards.Boards.NewSubscription"); } }
/// <summary> /// Initializes the controls on the page. /// </summary> private void SetupControl() { // Get current subscription ID mSubscriptionId = QueryHelper.GetInteger("subscriptionid", 0); if (mSubscriptionId > 0) { mCurrentSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(mSubscriptionId); EditedObject = mCurrentSubscription; } // Get current board ID mBoardId = QueryHelper.GetInteger("boardid", 0); boardSubscription.IsLiveSite = false; boardSubscription.BoardID = mBoardId; boardSubscription.SubscriptionID = mSubscriptionId; boardSubscription.OnSaved += new EventHandler(boardSubscription_OnSaved); InitializeBreadcrumbs(); }
/// <summary> /// Initializes the controls on the page. /// </summary> private void SetupControl() { // Get current subscription ID mSubscriptionId = QueryHelper.GetInteger("subscriptionid", 0); if (mSubscriptionId > 0) { mCurrentSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(mSubscriptionId); EditedObject = mCurrentSubscription; } // Get current board ID mBoardId = QueryHelper.GetInteger("boardid", 0); boardSubscription.IsLiveSite = false; boardSubscription.BoardID = mBoardId; boardSubscription.SubscriptionID = mSubscriptionId; boardSubscription.OnSaved += boardSubscription_OnSaved; InitializeBreadcrumbs(); }
/// <summary> /// Gets and bulk updates message board subscriptions. Called when the "Get and bulk update subscriptions" button is pressed. /// Expects the CreateMessageBoardSubscription method to be run first. /// </summary> private bool GetAndBulkUpdateMessageBoardSubscriptions() { // Get the tree structure TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get the root document TreeNode root = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", null, true); if (root != null) { // Get the message board BoardInfo board = BoardInfoProvider.GetBoardInfo("MyNewBoard", root.DocumentID); if (board != null) { // Prepare the parameters string where = "SubscriptionBoardID = " + board.BoardID; // Get the data DataSet subscriptions = BoardSubscriptionInfoProvider.GetSubscriptions(where, null); if (!DataHelper.DataSourceIsEmpty(subscriptions)) { // Loop through the individual items foreach (DataRow subscriptionDr in subscriptions.Tables[0].Rows) { // Create object from DataRow BoardSubscriptionInfo modifySubscription = new BoardSubscriptionInfo(subscriptionDr); // Update the property modifySubscription.SubscriptionEmail = modifySubscription.SubscriptionEmail.ToUpper(); // Update the subscription BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(modifySubscription); } return(true); } } } return(false); }
/// <summary> /// OK click handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check banned ip if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { lblError.Visible = true; lblError.Text = GetString("General.BannedIP"); return; } // Check input fields string email = txtEmail.Text.Trim(); string result = new Validator().NotEmpty(email, rfvEmailRequired.ErrorMessage) .IsEmail(email, GetString("general.correctemailformat")).Result; // Try to subscribe new subscriber if (result == "") { // Try to create a new board BoardInfo boardInfo = null; if (this.BoardID == 0) { // Create new message board according to webpart properties boardInfo = new BoardInfo(this.BoardProperties); BoardInfoProvider.SetBoardInfo(boardInfo); // Update information on current message board this.BoardID = boardInfo.BoardID; // Set board-role relationship BoardRoleInfoProvider.SetBoardRoles(this.BoardID, this.BoardProperties.BoardRoles); // Set moderators BoardModeratorInfoProvider.SetBoardModerators(this.BoardID, this.BoardProperties.BoardModerators); } if (this.BoardID > 0) { // Check for duplicit e-mails DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("SubscriptionBoardID=" + this.BoardID + " AND SubscriptionEmail='" + SqlHelperClass.GetSafeQueryString(email, false) + "'", null); if (DataHelper.DataSourceIsEmpty(ds)) { BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); bsi.SubscriptionBoardID = this.BoardID; bsi.SubscriptionEmail = email; if ((CMSContext.CurrentUser != null) && !CMSContext.CurrentUser.IsPublic()) { bsi.SubscriptionUserID = CMSContext.CurrentUser.UserID; } BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); lblInfo.Visible = true; lblInfo.Text = GetString("board.subscription.beensubscribed"); // Clear form txtEmail.Text = ""; if (boardInfo == null) { boardInfo = BoardInfoProvider.GetBoardInfo(this.BoardID); } LogActivity(bsi, boardInfo); } else { result = GetString("board.subscription.emailexists"); } } } if (result != String.Empty) { lblError.Visible = true; lblError.Text = result; } }
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(SiteContext.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(SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { ShowError(GetString("General.FloodProtection")); return; } CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser; 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 = RequestContext.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 ((MessageID <= 0) && (!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; // Remember rating in cookie string docs = CookieHelper.GetValue(CookieName.RatedDocuments) ?? "|"; if (!docs.Contains("|" + DocumentContext.CurrentDocument.DocumentID + "|")) { docs += DocumentContext.CurrentDocument.DocumentID + "|"; // Actualize the cookie CookieHelper.SetValue(CookieName.RatedDocuments, docs, DateTime.Now.AddYears(1)); } } 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(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 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='" + SecurityHelper.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(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; } } } } if (!String.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); } }
/// <summary> /// Log activity (subscribing) /// </summary> private void LogActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { Activity activity = new ActivitySubscriptionMessageBoard(bi, bsi, CMSContext.CurrentDocument, CMSContext.ActivityEnvironmentVariables); activity.Log(); }
/// <summary> /// OK click handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check banned IP if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { ShowError(GetString("General.BannedIP")); return; } // Check input fields string email = txtEmail.Text.Trim(); string result = new Validator().NotEmpty(email, rfvEmailRequired.ErrorMessage) .IsEmail(email, GetString("general.correctemailformat")).Result; // Try to subscribe new subscriber if (result == "") { // Try to create a new board BoardInfo boardInfo = null; if (BoardID == 0) { // Create new message board according to webpart properties boardInfo = new BoardInfo(BoardProperties); BoardInfoProvider.SetBoardInfo(boardInfo); // Update information on current message board BoardID = boardInfo.BoardID; // Set board-role relationship BoardRoleInfoProvider.SetBoardRoles(BoardID, BoardProperties.BoardRoles); // Set moderators BoardModeratorInfoProvider.SetBoardModerators(BoardID, BoardProperties.BoardModerators); } if (BoardID > 0) { // Check for duplicit e-mails DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("(SubscriptionApproved <> 0) AND (SubscriptionBoardID=" + BoardID + ") AND (SubscriptionEmail='" + SqlHelperClass.GetSafeQueryString(email, false) + "')", null); if (DataHelper.DataSourceIsEmpty(ds)) { BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); bsi.SubscriptionBoardID = BoardID; bsi.SubscriptionEmail = email; if ((CMSContext.CurrentUser != null) && !CMSContext.CurrentUser.IsPublic()) { bsi.SubscriptionUserID = CMSContext.CurrentUser.UserID; } BoardSubscriptionInfoProvider.Subscribe(bsi, DateTime.Now, true, true); // Clear form txtEmail.Text = ""; if (boardInfo == null) { boardInfo = BoardInfoProvider.GetBoardInfo(BoardID); } // If subscribed, log activity if (bsi.SubscriptionApproved) { ShowConfirmation(GetString("board.subscription.beensubscribed")); LogActivity(bsi, boardInfo); } else { string confirmation = GetString("general.subscribed.doubleoptin"); int optInInterval = BoardInfoProvider.DoubleOptInInterval(CMSContext.CurrentSiteName); if (optInInterval > 0) { confirmation += "<br />" + string.Format(GetString("general.subscription_timeintervalwarning"), optInInterval); } ShowConfirmation(confirmation); } } else { result = GetString("board.subscription.emailexists"); } } } if (result != String.Empty) { ShowError(result); } }
/// <summary> /// Initializes controls on the page. /// </summary> private void SetupControls() { if (UserID > 0) { boardSubscriptions.Visible = true; if (MembershipContext.AuthenticatedUser.UserID == UserID) { boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.userhasnosubscriptions"); } else { boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.NoDataUser"); } // Setup UniGrid control boardSubscriptions.IsLiveSite = IsLiveSite; boardSubscriptions.Pager.DefaultPageSize = 10; boardSubscriptions.OnAction += boardSubscriptions_OnAction; boardSubscriptions.OnExternalDataBound += boardSubscriptions_OnExternalDataBound; boardSubscriptions.OnDataReload += boardSubscriptions_OnDataReload; boardSubscriptions.ShowActionsMenu = true; BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); boardSubscriptions.AllColumns = SqlHelper.AddColumns(SqlHelper.JoinColumnList(bsi.ColumnNames), "BoardID, BoardDisplayName, BoardSiteID, NodeAliasPath, DocumentCulture"); mSiteName = SiteInfoProvider.GetSiteName(SiteID); } else { boardSubscriptions.Visible = false; } }
/// <summary> /// Log activity (subscribing). /// </summary> /// <param name="bsi">Board subscription info object</param> /// <param name="bi">Message board info</param> private void LogSubscribingActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bsi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.MessageBoardSubscriptionEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, TitleData = bi.BoardDisplayName, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
protected void btnOk_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.messageboards", PERMISSION_MODIFY)) { return; } string errMsg = ValidateForm(); // If entered form was validated successfully if (string.IsNullOrEmpty(errMsg)) { BoardSubscriptionInfo bsi = null; // If existing subscription is edited if (SubscriptionID > 0) { bsi = CurrentSubscription; } else { bsi = new BoardSubscriptionInfo(); } // Get data according the selected type if (radAnonymousSubscription.Checked) { bsi.SubscriptionEmail = txtEmailAnonymous.Text; bsi.SubscriptionUserID = 0; } else { bsi.SubscriptionEmail = txtEmailRegistered.Text; bsi.SubscriptionUserID = ValidationHelper.GetInteger(userSelector.Value, 0); } bsi.SubscriptionBoardID = BoardID; // Save information on user BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); if (chkSendConfirmationEmail.Checked) { BoardSubscriptionInfoProvider.SendConfirmationEmail(bsi, true); } SubscriptionID = bsi.SubscriptionID; RaiseOnSaved(); // Display info on success if subscription is edited ShowChangesSaved(); } else { // Inform user on error ShowError(errMsg); } }
/// <summary> /// Log activity (subscribing) /// </summary> private void LogActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { Activity activity = new ActivitySubscriptionMessageBoard(bi, bsi, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables); activity.Log(); }
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> /// OK click handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check banned ip if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { lblError.Visible = true; lblError.Text = GetString("General.BannedIP"); return; } // Check input fields string email = txtEmail.Text.Trim(); string result = new Validator().NotEmpty(email, rfvEmailRequired.ErrorMessage) .IsEmail(email, GetString("general.correctemailformat")).Result; // Try to subscribe new subscriber if (result == "") { // Try to create a new board BoardInfo boardInfo = null; if (this.BoardID == 0) { // Create new message board according to webpart properties boardInfo = new BoardInfo(this.BoardProperties); BoardInfoProvider.SetBoardInfo(boardInfo); // Update information on current message board this.BoardID = boardInfo.BoardID; // Set board-role relationship BoardRoleInfoProvider.SetBoardRoles(this.BoardID, this.BoardProperties.BoardRoles); // Set moderators BoardModeratorInfoProvider.SetBoardModerators(this.BoardID, this.BoardProperties.BoardModerators); } if (this.BoardID > 0) { // Check for duplicit e-mails DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("SubscriptionBoardID=" + this.BoardID + " AND SubscriptionEmail='" + SqlHelperClass.GetSafeQueryString(email, false) + "'", null); if (DataHelper.DataSourceIsEmpty(ds)) { BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); bsi.SubscriptionBoardID = this.BoardID; bsi.SubscriptionEmail = email; if ((CMSContext.CurrentUser != null) && !CMSContext.CurrentUser.IsPublic()) { bsi.SubscriptionUserID = CMSContext.CurrentUser.UserID; } BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); lblInfo.Visible = true; lblInfo.Text = GetString("board.subscription.beensubscribed"); // Clear form txtEmail.Text = ""; if (boardInfo == null) { boardInfo = BoardInfoProvider.GetBoardInfo(this.BoardID); } LogActivity(bsi, boardInfo); } else { result = GetString("board.subscription.emailexists"); } } } if (result != String.Empty) { lblError.Visible = true; lblError.Text = result; } }
/// <summary> /// Log activity (subscribing) /// </summary> private void LogActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { var messageBoardActivityLogger = new MessageBoardActivityLogger(); messageBoardActivityLogger.LogMessageBoardSubscriptionActivity(bi, bsi, DocumentContext.CurrentDocument); }
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)) { lblError.Visible = true; lblError.Text = GetString("General.BannedIP"); return; } // Validate form string errorMessage = ValidateForm(); if (errorMessage == "") { // Check flooding when message being inserted through the LiveSite if (this.CheckFloodProtection && this.IsLiveSite && FloodProtectionHelper.CheckFlooding(CMSContext.CurrentSiteName, CMSContext.CurrentUser)) { lblError.Visible = true; lblError.Text = 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 adress messageInfo.MessageUserInfo.IPAddress = Request.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.ToLower().StartsWith("http://")) && (!url.ToLower().StartsWith("https://"))) { url = "http://" + url; } } else { url = ""; } messageInfo.MessageURL = url; messageInfo.MessageURL = messageInfo.MessageURL.ToLower().Replace("javascript", "_javascript"); messageInfo.MessageUserName = this.txtUserName.Text.Trim(); if (!currentUser.IsPublic()) { messageInfo.MessageUserID = currentUser.UserID; } messageInfo.MessageIsSpam = ValidationHelper.GetBoolean(this.chkSpam.Checked, false); if (this.BoardProperties.EnableContentRating && (ratingControl != null) && (ratingControl.GetCurrentRating() > 0)) { messageInfo.MessageRatingValue = ratingControl.CurrentRating; } 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(this.BoardProperties); BoardInfoProvider.SetBoardInfo(boardInfo); // Update information on current message board this.MessageBoardID = boardInfo.BoardID; // Set board-role relationship BoardRoleInfoProvider.SetBoardRoles(this.MessageBoardID, this.BoardProperties.BoardRoles); // Set moderators BoardModeratorInfoProvider.SetBoardModerators(this.MessageBoardID, this.BoardProperties.BoardModerators); } if (boardInfo != null) { // If the very new message is inserted if (this.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 (this.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); // Additionaly 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 duplicit e-mails DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("SubscriptionBoardID=" + this.MessageBoardID + " AND SubscriptionEmail='" + SqlHelperClass.GetSafeQueryString(email, false) + "'", null); if (DataHelper.DataSourceIsEmpty(ds)) { BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); bsi.SubscriptionBoardID = this.MessageBoardID; bsi.SubscriptionEmail = email; if (!currentUser.IsPublic()) { bsi.SubscriptionUserID = currentUser.UserID; } BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); ClearForm(); LogSubscribingActivity(bsi, boardInfo); } else { errorMessage = GetString("board.subscription.emailexists"); } } if (errorMessage == "") { try { // Save message info BoardMessageInfoProvider.SetBoardMessageInfo(messageInfo); LogCommentActivity(messageInfo, boardInfo); // If the board is moderated let the user know message is waiting for approval if (boardInfo.BoardModerated && (messageInfo.MessageApproved == false)) { this.lblInfo.Text = GetString("board.messageedit.waitingapproval"); this.lblInfo.Visible = true; } // Rise after message saved event if (OnAfterMessageSaved != null) { OnAfterMessageSaved(messageInfo); } // Clear form content ClearForm(); } catch (Exception ex) { errorMessage = ex.Message; } } } } if (errorMessage != "") { lblError.Text = errorMessage; lblError.Visible = true; } else { // Regenerate new captcha captchaElem.GenerateNew(); } }
/// <summary> /// Creates message board subscription. Called when the "Create subscription" button is pressed. /// Expects the CreateMessageBoard method to be run first. /// </summary> private bool CreateMessageBoardSubscription() { // Create new message board subscription object BoardSubscriptionInfo newSubscription = new BoardSubscriptionInfo(); // Get the tree structure TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Get root document TreeNode root = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", null, true); if (root != null) { // Get the message board BoardInfo board = BoardInfoProvider.GetBoardInfo("MyNewBoard", root.DocumentID); if (board != null) { // Set the properties newSubscription.SubscriptionBoardID = board.BoardID; newSubscription.SubscriptionUserID = CMSContext.CurrentUser.UserID; newSubscription.SubscriptionEmail = "*****@*****.**"; newSubscription.SubscriptionLastModified = DateTime.Now; // Create the message board subscription BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(newSubscription); return true; } } return false; }
/// <summary> /// Log activity (subscribing) /// </summary> /// <param name="bsi"></param> private void LogActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bsi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.MessageBoardSubscriptionEnabled(siteName) ) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary<string, object> contactData = new Dictionary<string, object>(); contactData.Add("ContactEmail", bsi.SubscriptionEmail); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, TitleData = bi.BoardName, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Gets and bulk updates message board subscriptions. Called when the "Get and bulk update subscriptions" button is pressed. /// Expects the CreateMessageBoardSubscription method to be run first. /// </summary> private bool GetAndBulkUpdateMessageBoardSubscriptions() { // Get the tree structure TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Get the root document TreeNode root = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", null, true); if (root != null) { // Get the message board BoardInfo board = BoardInfoProvider.GetBoardInfo("MyNewBoard", root.DocumentID); if (board != null) { // Prepare the parameters string where = "SubscriptionBoardID = " + board.BoardID; // Get the data DataSet subscriptions = BoardSubscriptionInfoProvider.GetSubscriptions(where, null); if (!DataHelper.DataSourceIsEmpty(subscriptions)) { // Loop through the individual items foreach (DataRow subscriptionDr in subscriptions.Tables[0].Rows) { // Create object from DataRow BoardSubscriptionInfo modifySubscription = new BoardSubscriptionInfo(subscriptionDr); // Update the property modifySubscription.SubscriptionEmail = modifySubscription.SubscriptionEmail.ToUpper(); // Update the subscription BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(modifySubscription); } return true; } } } return false; }
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 == "") { // 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 messageInfo; 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 = RequestContext.UserHostAddress; // User agent messageInfo.MessageUserInfo.Agent = Request.UserAgent; } // Setup message info messageInfo.MessageEmail = TextHelper.LimitLength(txtEmail.Text.Trim(), txtEmail.MaxLength); messageInfo.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; } } messageInfo.MessageURL = TextHelper.LimitLength(url, txtURL.MaxLength); messageInfo.MessageURL = messageInfo.MessageURL.ToLowerCSafe().Replace("javascript", "_javascript"); messageInfo.MessageUserName = TextHelper.LimitLength(txtUserName.Text.Trim(), txtUserName.MaxLength); if ((messageInfo.MessageID <= 0) && (!currentUser.IsPublic())) { messageInfo.MessageUserID = currentUser.UserID; if (!plcUserName.Visible) { messageInfo.MessageUserName = GetDefaultUserName(); } } 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.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 messageInfo.MessageInserted = DateTime.Now; 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(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(messageInfo, collumns, "MessageApproved", "MessageApprovedByUserID", messageInfo.MessageText, currentUser.UserID, () => ValidateMessage(messageInfo, validateUserName)); // Additionally check empty fields if (errorMessage == string.Empty) { if (!ValidateMessage(messageInfo, validateUserName)) { 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='" + 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")); 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(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) { ShowInformation(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.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); } }
public override void ReloadData() { ClearForm(); this.lblInfo.Visible = false; this.lblError.Visible = false; // Get current subscription ID if (this.SubscriptionID > 0) { // Get current subscription info this.CurrentSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(this.SubscriptionID); EditedObject = this.CurrentSubscription; // Load existing subscription data if (this.CurrentSubscription != null) { // If the subscription is related to the registered user if (this.CurrentSubscription.SubscriptionUserID > 0) { // Load data this.userSelector.Value = this.CurrentSubscription.SubscriptionUserID; this.txtEmailRegistered.Text = this.CurrentSubscription.SubscriptionEmail; this.radRegisteredSubscription.Checked = true; this.radAnonymousSubscription.Checked = false; ProcessDisabling(false); } else { // Load data this.txtEmailAnonymous.Text = this.CurrentSubscription.SubscriptionEmail; this.radAnonymousSubscription.Checked = true; this.radRegisteredSubscription.Checked = false; ProcessDisabling(true); } } } else { this.radAnonymousSubscription.Checked = true; this.radRegisteredSubscription.Checked = false; ProcessDisabling(true); } if (QueryHelper.GetBoolean("saved", false)) { // Display info on success if subscription is edited this.lblInfo.Text = GetString("general.changessaved"); this.lblInfo.Visible = true; } }
/// <summary> /// Log activity (subscribing). /// </summary> /// <param name="bsi">Board subscription info object</param> /// <param name="bi">Message board info</param> private void LogSubscribingActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { mMessageBoardActivityLogger.LogMessageBoardSubscriptionActivity(bi, bsi, DocumentContext.CurrentDocument); }
protected void btnOk_Click(object sender, EventArgs e) { if (!CheckPermissions("cms.messageboards", CMSAdminControl.PERMISSION_MODIFY)) { return; } string errMsg = ValidateForm(); // If entered form was validated successfully if (string.IsNullOrEmpty(errMsg)) { BoardSubscriptionInfo bsi = null; // If existing subscription is edited if (this.SubscriptionID > 0) { bsi = this.CurrentSubscription; } else { bsi = new BoardSubscriptionInfo(); } // Get data according the selected type if (this.radAnonymousSubscription.Checked) { bsi.SubscriptionEmail = this.txtEmailAnonymous.Text; bsi.SubscriptionUserID = 0; } else { bsi.SubscriptionEmail = this.txtEmailRegistered.Text; bsi.SubscriptionUserID = ValidationHelper.GetInteger(this.userSelector.Value, 0); } bsi.SubscriptionBoardID = this.BoardID; // Save information on user BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); this.SubscriptionID = bsi.SubscriptionID; this.RaiseOnSaved(); // Display info on success if subscription is edited this.lblInfo.Text = GetString("general.changessaved"); this.lblInfo.Visible = true; } else { // Inform user on error this.lblError.Text = errMsg; this.lblError.Visible = true; this.lblInfo.Visible = false; } }
/// <summary> /// OK click handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check banned IP if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { ShowError(GetString("General.BannedIP")); return; } // Check input fields string email = txtEmail.Text.Trim(); string result = new Validator().NotEmpty(email, rfvEmailRequired.ErrorMessage) .IsEmail(email, GetString("general.correctemailformat")).Result; // Try to subscribe new subscriber if (result == "") { // Try to create a new board BoardInfo boardInfo = null; if (BoardID == 0) { // Create new message board according to webpart properties boardInfo = new BoardInfo(BoardProperties); BoardInfoProvider.SetBoardInfo(boardInfo); // Update information on current message board BoardID = boardInfo.BoardID; // Set board-role relationship BoardRoleInfoProvider.SetBoardRoles(BoardID, BoardProperties.BoardRoles); // Set moderators BoardModeratorInfoProvider.SetBoardModerators(BoardID, BoardProperties.BoardModerators); } if (BoardID > 0) { // Check for duplicit e-mails DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("(SubscriptionApproved <> 0) AND (SubscriptionBoardID=" + BoardID + ") AND (SubscriptionEmail='" + SqlHelper.GetSafeQueryString(email, false) + "')", null); if (DataHelper.DataSourceIsEmpty(ds)) { BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); bsi.SubscriptionBoardID = BoardID; bsi.SubscriptionEmail = email; if ((MembershipContext.AuthenticatedUser != null) && !MembershipContext.AuthenticatedUser.IsPublic()) { bsi.SubscriptionUserID = MembershipContext.AuthenticatedUser.UserID; } BoardSubscriptionInfoProvider.Subscribe(bsi, DateTime.Now, true, true); // Clear form txtEmail.Text = ""; if (boardInfo == null) { boardInfo = BoardInfoProvider.GetBoardInfo(BoardID); } // If subscribed, log activity if (bsi.SubscriptionApproved) { ShowConfirmation(GetString("board.subscription.beensubscribed")); LogActivity(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 { result = GetString("board.subscription.emailexists"); } } } if (result != String.Empty) { ShowError(result); } }
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)) { lblError.Visible = true; lblError.Text = GetString("General.BannedIP"); return; } // Validate form string errorMessage = ValidateForm(); if (errorMessage == "") { // Check flooding when message being inserted through the LiveSite if (this.CheckFloodProtection && this.IsLiveSite && FloodProtectionHelper.CheckFlooding(CMSContext.CurrentSiteName, CMSContext.CurrentUser)) { lblError.Visible = true; lblError.Text = 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 adress messageInfo.MessageUserInfo.IPAddress = Request.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.ToLower().StartsWith("http://")) && (!url.ToLower().StartsWith("https://"))) { url = "http://" + url; } } else { url = ""; } messageInfo.MessageURL = url; messageInfo.MessageURL = messageInfo.MessageURL.ToLower().Replace("javascript", "_javascript"); messageInfo.MessageUserName = this.txtUserName.Text.Trim(); if (!currentUser.IsPublic()) { messageInfo.MessageUserID = currentUser.UserID; } messageInfo.MessageIsSpam = ValidationHelper.GetBoolean(this.chkSpam.Checked, false); if (this.BoardProperties.EnableContentRating && (ratingControl != null) && (ratingControl.GetCurrentRating() > 0)) { messageInfo.MessageRatingValue = ratingControl.CurrentRating; } 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(this.BoardProperties); BoardInfoProvider.SetBoardInfo(boardInfo); // Update information on current message board this.MessageBoardID = boardInfo.BoardID; // Set board-role relationship BoardRoleInfoProvider.SetBoardRoles(this.MessageBoardID, this.BoardProperties.BoardRoles); // Set moderators BoardModeratorInfoProvider.SetBoardModerators(this.MessageBoardID, this.BoardProperties.BoardModerators); } if (boardInfo != null) { // If the very new message is inserted if (this.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 (this.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); // Additionaly 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 duplicit e-mails DataSet ds = BoardSubscriptionInfoProvider.GetSubscriptions("SubscriptionBoardID=" + this.MessageBoardID + " AND SubscriptionEmail='" + SqlHelperClass.GetSafeQueryString(email, false) + "'", null); if (DataHelper.DataSourceIsEmpty(ds)) { BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); bsi.SubscriptionBoardID = this.MessageBoardID; bsi.SubscriptionEmail = email; if (!currentUser.IsPublic()) { bsi.SubscriptionUserID = currentUser.UserID; } BoardSubscriptionInfoProvider.SetBoardSubscriptionInfo(bsi); ClearForm(); LogSubscribingActivity(bsi, boardInfo); } else { errorMessage = GetString("board.subscription.emailexists"); } } if (errorMessage == "") { try { // Save message info BoardMessageInfoProvider.SetBoardMessageInfo(messageInfo); LogCommentActivity(messageInfo, boardInfo); // If the board is moderated let the user know message is waiting for approval if (boardInfo.BoardModerated && (messageInfo.MessageApproved == false)) { this.lblInfo.Text = GetString("board.messageedit.waitingapproval"); this.lblInfo.Visible = true; } // Rise after message saved event if (OnAfterMessageSaved != null) { OnAfterMessageSaved(messageInfo); } // Clear form content ClearForm(); } catch (Exception ex) { errorMessage = ex.Message; } } } } if (errorMessage != "") { lblError.Text = errorMessage; lblError.Visible = true; } else { // Regenerate new captcha captchaElem.GenerateNew(); } }
/// <summary> /// Initializes controls on the page. /// </summary> private void SetupControls() { if (this.UserID > 0) { this.boardSubscriptions.Visible = true; if (CMSContext.CurrentUser.UserID == this.UserID) { this.boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.userhasnosubscriptions"); } else { this.boardSubscriptions.ZeroRowsText = GetString("boardsubscripitons.NoDataUser"); } // Setup UniGrid control this.boardSubscriptions.IsLiveSite = this.IsLiveSite; this.boardSubscriptions.Pager.DefaultPageSize = 10; this.boardSubscriptions.OnAction += new OnActionEventHandler(boardSubscriptions_OnAction); this.boardSubscriptions.OnExternalDataBound += new OnExternalDataBoundEventHandler(boardSubscriptions_OnExternalDataBound); boardSubscriptions.OnDataReload += new OnDataReloadEventHandler(boardSubscriptions_OnDataReload); boardSubscriptions.ShowActionsMenu = true; BoardSubscriptionInfo bsi = new BoardSubscriptionInfo(); boardSubscriptions.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(bsi.ColumnNames.ToArray()), "BoardID, BoardDisplayName, BoardSiteID, NodeAliasPath, DocumentCulture"); mSiteName = SiteInfoProvider.GetSiteName(SiteID); } else { this.boardSubscriptions.Visible = false; } }
public override void ReloadData() { ClearForm(); // Get current subscription ID if (SubscriptionID > 0) { // Get current subscription info CurrentSubscription = BoardSubscriptionInfoProvider.GetBoardSubscriptionInfo(SubscriptionID); EditedObject = CurrentSubscription; // Load existing subscription data if (CurrentSubscription != null) { // If the subscription is related to the registered user if (CurrentSubscription.SubscriptionUserID > 0) { // Load data userSelector.Value = CurrentSubscription.SubscriptionUserID; txtEmailRegistered.Text = CurrentSubscription.SubscriptionEmail; radRegisteredSubscription.Checked = true; radAnonymousSubscription.Checked = false; ProcessDisabling(false); } else { // Load data txtEmailAnonymous.Text = CurrentSubscription.SubscriptionEmail; radAnonymousSubscription.Checked = true; radRegisteredSubscription.Checked = false; ProcessDisabling(true); } chkSendConfirmationEmail.Checked = pnlSendConfirmationEmail.Visible = false; } } else { radAnonymousSubscription.Checked = true; radRegisteredSubscription.Checked = false; ProcessDisabling(true); } if (QueryHelper.GetBoolean("saved", false)) { // Display info on success if subscription is edited ShowChangesSaved(); } }