Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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");
    }