예제 #1
0
    /// <summary>
    /// Deletes message. Called when the "Delete message" button is pressed.
    /// Expects the CreateMessage method to be run first.
    /// </summary>
    private bool DeleteMessage()
    {
        // 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)
            {
                // Get the data
                DataSet messages = BoardMessageInfoProvider.GetMessages(board.BoardID);
                if (!DataHelper.DataSourceIsEmpty(messages))
                {
                    // Get the message
                    BoardMessageInfo deleteMessage = new BoardMessageInfo(messages.Tables[0].Rows[0]);

                    // Delete the message
                    BoardMessageInfoProvider.DeleteBoardMessageInfo(deleteMessage);

                    return(deleteMessage != null);
                }
            }
        }

        return(false);
    }
예제 #2
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        BoardMessageInfo message = BoardMessageInfoProvider.GetBoardMessageInfo(Convert.ToInt32(actionArgument));
        BoardInfo        bi      = BoardInfoProvider.GetBoardInfo(message.MessageBoardID);

        string[] argument = null;

        switch (actionName)
        {
        case "delete":
        case "approve":
            // Check whether user is board moderator first
            if (!BoardInfoProvider.IsUserAuthorizedToManageMessages(bi))
            {
                // Then check modify to messageboards
                if (!CheckPermissions("cms.messageboards", CMSAdminControl.PERMISSION_MODIFY))
                {
                    return;
                }
            }
            break;
        }

        switch (actionName)
        {
        case "delete":
            if (message != null)
            {
                BoardMessageInfoProvider.DeleteBoardMessageInfo(message);
            }
            break;

        case "approve":
            if (message != null)
            {
                if (message.MessageApproved)
                {
                    // Reject message
                    message.MessageApproved         = false;
                    message.MessageApprovedByUserID = 0;
                }
                else
                {
                    // Approve message
                    message.MessageApproved         = true;
                    message.MessageApprovedByUserID = CMSContext.CurrentUser.UserID;
                }
                BoardMessageInfoProvider.SetBoardMessageInfo(message);
            }
            break;

        default:
            break;
        }

        this.RaiseOnAction(actionName, ((argument == null) ? actionArgument : argument));
    }
예제 #3
0
    private void boardMsgActions_OnMessageAction(string actionName, object argument)
    {
        // Get current board message ID
        int boardMessageId       = ValidationHelper.GetInteger(argument, 0);
        BoardMessageInfo message = BoardMessageInfoProvider.GetBoardMessageInfo(boardMessageId);

        // Handle not existing message
        if (message == null)
        {
            return;
        }

        if ((bi != null) && BoardInfoProvider.IsUserAuthorizedToManageMessages(bi))
        {
            switch (actionName.ToLowerCSafe())
            {
            case "delete":
                // Delete message
                BoardMessageInfoProvider.DeleteBoardMessageInfo(message);

                rptBoardMessages.ClearCache();
                ReloadData();
                break;

            case "approve":
                // Approve board message
                if (MembershipContext.AuthenticatedUser != null)
                {
                    message.MessageApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                    message.MessageApproved         = true;
                    BoardMessageInfoProvider.SetBoardMessageInfo(message);
                }

                rptBoardMessages.ClearCache();
                ReloadData();
                break;

            case "reject":
                // Reject board message
                if (MembershipContext.AuthenticatedUser != null)
                {
                    message.MessageApprovedByUserID = 0;
                    message.MessageApproved         = false;
                    BoardMessageInfoProvider.SetBoardMessageInfo(message);
                }

                rptBoardMessages.ClearCache();
                ReloadData();
                break;
            }
        }
    }
    protected void btnOk_Clicked(object sender, EventArgs e)
    {
        // Check permissions
        if (!CheckPermissions("cms.messageboards", PERMISSION_MODIFY))
        {
            return;
        }

        if (drpActions.SelectedValue != "SELECT")
        {
            var list = gridElem.SelectedItems;
            if (list.Count > 0)
            {
                foreach (string messageId in list)
                {
                    BoardMessageInfo message = BoardMessageInfoProvider.GetBoardMessageInfo(Convert.ToInt32(messageId));
                    switch (drpActions.SelectedValue)
                    {
                    case "DELETE":
                        // Delete board
                        BoardMessageInfoProvider.DeleteBoardMessageInfo(message);
                        break;

                    case "APPROVE":
                        if (!message.MessageApproved)
                        {
                            message.MessageApproved         = true;
                            message.MessageApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                            BoardMessageInfoProvider.SetBoardMessageInfo(message);
                        }
                        break;

                    case "REJECT":
                        // Reject message
                        if (message.MessageApproved)
                        {
                            message.MessageApproved         = false;
                            message.MessageApprovedByUserID = 0;
                            BoardMessageInfoProvider.SetBoardMessageInfo(message);
                        }
                        break;

                    case "SPAM":
                        if (!message.MessageIsSpam)
                        {
                            message.MessageIsSpam = true;
                            BoardMessageInfoProvider.SetBoardMessageInfo(message);
                        }
                        break;

                    case "NOSPAM":
                        if (message.MessageIsSpam)
                        {
                            message.MessageIsSpam = false;
                            BoardMessageInfoProvider.SetBoardMessageInfo(message);
                        }
                        break;
                    }
                }
            }
            else
            {
                ltlScript.Text += ScriptHelper.GetAlertScript(GetString("general.noitems"));
            }
        }

        gridElem.ResetSelection();

        ReloadData();
    }