/// <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;
        }
    }
Esempio n. 2
0
    /// <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);
    }
Esempio n. 3
0
    /// <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);
    }
    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 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 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);
        }
    }
Esempio n. 7
0
    /// <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);
    }
Esempio n. 8
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // Let the parent control now new message is being saved
        if (OnBeforeMessageSaved != null)
        {
            OnBeforeMessageSaved();
        }

        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            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();
        }
    }
Esempio n. 9
0
    /// <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;
        }
    }