/// <summary>
    /// Reload data.
    /// </summary>
    public void ReloadData()
    {
        if (RelatedUserId > 0)
        {
            btnAddToIgnoreList.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Messsaging.AddToIgnoreListConfirmation")) + ");";

            btnAddToContactList.ToolTip       = GetString("Messsaging.AddToContactList");
            btnAddToIgnoreList.ToolTip        = GetString("Messsaging.AddToIgnoreList");
            imgAddToContactList.AlternateText = GetString("Messsaging.AddToContactList");
            imgAddToIgnoreList.AlternateText  = GetString("Messsaging.AddToIgnoreList");

            imgAddToContactList.ImageUrl = GetImageUrl("/CMSModules/CMS_Messaging/addtocontactlist.png");
            imgAddToIgnoreList.ImageUrl  = GetImageUrl("/CMSModules/CMS_Messaging/addtoignorelist.png");

            pnlButtons.Visible          = true;
            btnAddToContactList.Visible = true;
            btnAddToIgnoreList.Visible  = true;

            // Hide btnAddToContactList if sender is already in contact list
            if (ContactListInfoProvider.IsInContactList(CMSContext.CurrentUser.UserID, RelatedUserId))
            {
                btnAddToContactList.Visible = false;
            }
            // Hide btnAddToIgnoreList if sender is already in ignore list
            if (IgnoreListInfoProvider.IsInIgnoreList(CMSContext.CurrentUser.UserID, RelatedUserId))
            {
                btnAddToIgnoreList.Visible = false;
            }
        }
        else
        {
            pnlButtons.Visible = false;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public void ReloadData()
    {
        if (RelatedUserId > 0)
        {
            btnAddToIgnoreList.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Messsaging.AddToIgnoreListConfirmation")) + ");";

            btnAddToContactList.ToolTip = GetString("Messsaging.AddToContactList");
            btnAddToIgnoreList.ToolTip  = GetString("Messsaging.AddToIgnoreList");

            pnlButtons.Visible          = true;
            btnAddToContactList.Visible = true;
            btnAddToIgnoreList.Visible  = true;

            // Hide btnAddToContactList if sender is already in contact list
            if (ContactListInfoProvider.IsInContactList(MembershipContext.AuthenticatedUser.UserID, RelatedUserId))
            {
                btnAddToContactList.Visible = false;
            }
            // Hide btnAddToIgnoreList if sender is already in ignore list
            if (IgnoreListInfoProvider.IsInIgnoreList(MembershipContext.AuthenticatedUser.UserID, RelatedUserId))
            {
                btnAddToIgnoreList.Visible = false;
            }
        }
        else
        {
            pnlButtons.Visible = false;
        }
    }
Exemplo n.º 3
0
    private static string GetContactListValues()
    {
        DataSet ignoreList = IgnoreListInfoProvider.GetIgnoreList(MembershipContext.AuthenticatedUser.UserID, null, null, 0, "UserName,UserNickname,IgnoreListIgnoredUserID");

        if (!DataHelper.DataSourceIsEmpty(ignoreList))
        {
            return(TextHelper.Join(";", DataHelper.GetStringValues(ignoreList.Tables[0], "IgnoreListIgnoredUserID")));
        }

        return(String.Empty);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Removes the sample "cmseditor" user from the current user's ignore list. Called when the "Remove user from ignore list" button is pressed.
    /// Expects the AddUserToIgnoreList method to be run first.
    /// </summary>
    private bool RemoveUserFromIgnoreList()
    {
        // Gets "cmseditor" UserInfo object
        UserInfo user = UserInfoProvider.GetUserInfo("cmseditor");

        if (IgnoreListInfoProvider.IsInIgnoreList(CMSContext.CurrentUser.UserID, user.UserID))
        {
            // Removes "cmseditor" from the current user's ignore list
            IgnoreListInfoProvider.RemoveFromIgnoreList(CMSContext.CurrentUser.UserID, user.UserID);

            return(true);
        }

        return(false);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Adds the sample "cmseditor" user to the current user's ignore list. Called when the "Add user to ignore list" button is pressed.
    /// </summary>
    private bool AddUserToIgnoreList()
    {
        // Gets "cmseditor" UserInfo object
        UserInfo user = UserInfoProvider.GetUserInfo("cmseditor");

        if (!IgnoreListInfoProvider.IsInIgnoreList(CMSContext.CurrentUser.UserID, user.UserID))
        {
            // Adds "cmseditor" to the current user's ignore list
            IgnoreListInfoProvider.AddToIgnoreList(CMSContext.CurrentUser.UserID, user.UserID);

            return(true);
        }

        return(false);
    }
    protected void btnAddToIgnoreList_Click(object sender, EventArgs e)
    {
        try
        {
            // Current user ID
            int currentUserId = CMSContext.CurrentUser.UserID;

            // Add user to ignore list
            IgnoreListInfoProvider.AddToIgnoreList(currentUserId, RelatedUserId);

            InformationText = GetString("MessageUserButtons.IgnoreAdded");
        }
        catch (Exception ex)
        {
            ErrorText = ex.Message;
        }
    }
Exemplo n.º 7
0
    protected void PerformAction(string actionName, object actionArgument)
    {
        int currentid = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName)
        {
        case CONTACT_ACTION:
            // Add user to contact list
            ContactListInfoProvider.AddToContactList(MembershipContext.AuthenticatedUser.UserID, currentid);
            ShowConfirmation(GetString("messaging.search.addedsuccessfulytocontactlist"));
            break;

        case IGNORE_ACTION:
            // Add user to ignore list
            IgnoreListInfoProvider.AddToIgnoreList(MembershipContext.AuthenticatedUser.UserID, currentid);
            ShowConfirmation(GetString("messaging.search.addedsuccessfulytoignorelist"));
            break;
        }
    }
Exemplo n.º 8
0
    protected void PerformAction(string actionName, object actionArgument)
    {
        int currentid = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName)
        {
        case "contact":
            // Add user to contact list
            ContactListInfoProvider.AddToContactList(CMSContext.CurrentUser.UserID, currentid);
            ShowConfirmation(GetString("messaging.search.addedsuccessfulytocontactlist"));
            break;

        case "ignore":
            // Add user to ignore list
            IgnoreListInfoProvider.AddToIgnoreList(CMSContext.CurrentUser.UserID, currentid);
            ShowConfirmation(GetString("messaging.search.addedsuccessfulytoignorelist"));
            break;
        }
    }
Exemplo n.º 9
0
    /// <summary>
    /// Removes the sample "Andy" user from the current user's ignore list. Called when the "Remove user from ignore list" button is pressed.
    /// Expects the AddUserToIgnoreList method to be run first.
    /// </summary>
    private bool RemoveUserFromIgnoreList()
    {
        // Gets "Andy" UserInfo object
        UserInfo user = UserInfoProvider.GetUserInfo("MyNewIgnoredUser");

        if (IgnoreListInfoProvider.IsInIgnoreList(MembershipContext.AuthenticatedUser.UserID, user.UserID))
        {
            // Removes "Andy" from the current user's ignore list
            IgnoreListInfoProvider.RemoveFromIgnoreList(MembershipContext.AuthenticatedUser.UserID, user.UserID);

            user.Delete();

            return(true);
        }

        user.Delete();

        return(false);
    }
Exemplo n.º 10
0
    /// <summary>
    /// Adds the sample user to the current user's ignore list. Called when the "Add user to ignore list" button is pressed.
    /// </summary>
    private bool AddUserToIgnoreList()
    {
        // First create a new user which will be added to the ignore list
        UserInfo user = new UserInfo();

        user.UserName = "******";
        user.FullName = "My new ignored user";
        user.UserGUID = Guid.NewGuid();

        UserInfoProvider.SetUserInfo(user);

        if (!IgnoreListInfoProvider.IsInIgnoreList(MembershipContext.AuthenticatedUser.UserID, user.UserID))
        {
            // Adds "Andy" to the current user's ignore list
            IgnoreListInfoProvider.AddToIgnoreList(MembershipContext.AuthenticatedUser.UserID, user.UserID);

            return(true);
        }

        return(false);
    }
Exemplo n.º 11
0
    private void SaveUsers()
    {
        bool falseValues = false;

        // Remove old items
        string newValues = ValidationHelper.GetString(usUsers.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            // Add all new items to user
            foreach (string item in newItems)
            {
                int userId = ValidationHelper.GetInteger(item, 0);
                IgnoreListInfoProvider.RemoveFromIgnoreList(MembershipContext.AuthenticatedUser.UserID, userId);
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            // Add all new items to user
            foreach (string item in newItems)
            {
                int userId = ValidationHelper.GetInteger(item, 0);
                IgnoreListInfoProvider.AddToIgnoreList(MembershipContext.AuthenticatedUser.UserID, userId);
            }
        }

        if (falseValues)
        {
            currentValues = GetContactListValues();
            usUsers.Value = currentValues;
        }

        ShowChangesSaved();
    }
Exemplo n.º 12
0
    protected void btnSendMessage_Click(object sender, EventArgs e)
    {
        // This is because of ASP.NET default behaviour
        // The first empty line was trimmed after each postback
        if (BBEditor.Text.StartsWithCSafe("\n"))
        {
            BBEditor.Text = "\n" + BBEditor.Text;
        }
        // Flood protection
        if (!FloodProtectionHelper.CheckFlooding(CMSContext.CurrentSiteName, CMSContext.CurrentUser))
        {
            CurrentUserInfo currentUser = CMSContext.CurrentUser;

            // Check banned IP
            if (BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))
            {
                int recipientId = ucMessageUserSelector.Visible
                                      ? ucMessageUserSelector.SelectedUserID
                                      : ValidationHelper.GetInteger(hdnUserId.Value, 0);
                string message  = string.Empty;
                string nickName = HTMLHelper.HTMLEncode(txtFrom.Text.Trim());
                if (!ValidateBody(DiscussionMacroHelper.RemoveTags(ucBBEditor.Text)))
                {
                    message = GetString("SendMessage.EmptyBody");
                }


                // Check sender nick name if anonymous
                if (isAnonymousUser && (nickName == string.Empty))
                {
                    message = GetString("SendMesage.NoNickName");
                }

                UserInfo recipient = null;

                // Check recipient
                if (recipientId == 0)
                {
                    if (string.IsNullOrEmpty(ucMessageUserSelector.UserNameTextBox.Text.Trim()))
                    {
                        message = GetString("SendMesage.NoRecipient");
                    }
                    else
                    {
                        message = GetString("SendMesage.UserDoesntExists");
                    }
                }
                else
                {
                    recipient = UserInfoProvider.GetUserInfo(recipientId);

                    // Normal users can't send message to user from other site except for global admin
                    if (!recipient.IsInSite(CMSContext.CurrentSiteName) && !currentUser.IsGlobalAdministrator)
                    {
                        message = GetString("SendMesage.UserDoesntExists");
                    }

                    int defRecipientId = ValidationHelper.GetInteger(DefaultRecipient, 0);

                    // If default recipient selected and is same as message recipient, skip check on hidden users
                    if (recipient.UserID != defRecipientId)
                    {
                        //                  Manually disabled users              Hidden users if not replying to them                                       Not approved users
                        bool userAllowed = (recipient.UserIsDisabledManually || (recipient.UserIsHidden && (SendMessageMode != MessageActionEnum.Reply)) || recipient.UserSettings.UserWaitingForApproval);

                        // If live site mode hide not allowed users for all users except for global admins and public user for all users
                        if ((IsLiveSite && userAllowed && !currentUser.IsGlobalAdministrator) || (recipient.UserName.ToLowerCSafe() == "public"))
                        {
                            message = GetString("SendMesage.UserDoesntExists");
                        }
                    }
                }

                if (message == string.Empty)
                {
                    // Send message
                    try
                    {
                        // Check if current user is in recipient's ignore list
                        bool isIgnored = IgnoreListInfoProvider.IsInIgnoreList(recipientId, currentUser.UserID);


                        Message             = new MessageInfo();
                        Message.MessageBody = ucBBEditor.Text;
                        string subject = (txtSubject.Text.Trim() == string.Empty) ? GetString("Messaging.NoSubject") : txtSubject.Text.Trim();
                        Message.MessageSubject           = TextHelper.LimitLength(subject, 200);
                        Message.MessageRecipientUserID   = recipientId;
                        Message.MessageRecipientNickName = TextHelper.LimitLength(Functions.GetFormattedUserName(recipient.UserName, recipient.FullName, recipient.UserNickName, IsLiveSite), 200);
                        Message.MessageSent = DateTime.Now;

                        // Anonymous user
                        if (isAnonymousUser)
                        {
                            Message.MessageSenderNickName = TextHelper.LimitLength(nickName, 200);
                            Message.MessageSenderDeleted  = true;
                        }
                        else
                        {
                            Message.MessageSenderUserID   = currentUser.UserID;
                            Message.MessageSenderNickName = TextHelper.LimitLength(Functions.GetFormattedUserName(currentUser.UserName, currentUser.FullName, currentUser.UserNickName, IsLiveSite), 200);

                            // If the user is ignored, delete message automatically
                            if (isIgnored)
                            {
                                Message.MessageRecipientDeleted = true;
                            }
                        }

                        string error = string.Empty;

                        // Check bad words
                        if (!BadWordInfoProvider.CanUseBadWords(currentUser, CMSContext.CurrentSiteName))
                        {
                            // Prepare columns to check
                            Dictionary <string, int> columns = new Dictionary <string, int>();
                            columns.Add("MessageSubject", 200);
                            columns.Add("MessageBody", 0);
                            columns.Add("MessageSenderNickName", 200);
                            columns.Add("MessageRecipientNickName", 200);

                            // Perform bad word check
                            error = BadWordsHelper.CheckBadWords(Message, columns, currentUser.UserID, () => { return(ValidateBody(Message.MessageBody)); });
                        }

                        if (error != string.Empty)
                        {
                            ShowError(error);
                        }
                        else
                        {
                            // Check message subject, if empty set no subject text
                            if (Message.MessageSubject.Trim() == string.Empty)
                            {
                                Message.MessageSubject = GetString("Messaging.NoSubject");
                            }

                            // Whole text has been removed
                            if (!ValidateBody(Message.MessageBody))
                            {
                                ShowError(GetString("SendMessage.EmptyBodyBadWords"));
                            }
                            else
                            {
                                // Save the message
                                MessageInfoProvider.SetMessageInfo(Message);

                                // Send notification email, if not ignored
                                if (!isIgnored)
                                {
                                    MessageInfoProvider.SendNotificationEmail(Message, recipient, currentUser, CMSContext.CurrentSiteName);
                                }

                                ShowConfirmation(GetString("SendMesage.MessageSent"));
                                MessageId = 0;
                                ucMessageUserSelector.SelectedUserID = 0;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowError(ex.Message);
                        ErrorMessage = ex.Message;
                    }
                }
                // Error in the form
                else
                {
                    ShowError(message);
                    ErrorMessage = message;
                }
            }
            else
            {
                ShowError(GetString("General.BannedIP"));
            }
        }
        else
        {
            ShowError(GetString("General.FloodProtection"));
        }

        // External event
        if (SendButtonClick != null)
        {
            SendButtonClick(sender, e);
        }
    }
Exemplo n.º 13
0
    private void SaveUsers()
    {
        bool falseValues = false;

        // Remove old items
        string newValues = ValidationHelper.GetString(usUsers.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            // Add all new items to user
            foreach (string item in newItems)
            {
                int userId = ValidationHelper.GetInteger(item, 0);

                // Check permissions
                string result = string.Empty;
                if (result != String.Empty)
                {
                    lblError.Visible = true;
                    lblError.Text   += result;
                    falseValues      = true;
                    continue;
                }
                else
                {
                    IgnoreListInfoProvider.RemoveFromIgnoreList(CMSContext.CurrentUser.UserID, userId);
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            // Add all new items to user
            foreach (string item in newItems)
            {
                int userId = ValidationHelper.GetInteger(item, 0);

                // Check permissions
                string result = string.Empty;
                if (result != String.Empty)
                {
                    lblError.Visible = true;
                    lblError.Text   += result;
                    falseValues      = true;
                    continue;
                }
                else
                {
                    IgnoreListInfoProvider.AddToIgnoreList(CMSContext.CurrentUser.UserID, userId);
                }
            }
        }

        if (falseValues)
        {
            currentValues = GetContactListValues();
            usUsers.Value = currentValues;
        }

        lblInfo.Visible = true;
        lblInfo.Text    = GetString("General.ChangesSaved");
    }