protected void gridContactList_OnAction(string actionName, object actionArgument)
    {
        switch (actionName)
        {
        case "delete":
            int deletedUserId = ValidationHelper.GetInteger(actionArgument, 0);

            // If something is wrong return
            if (MembershipContext.AuthenticatedUser == null)
            {
                return;
            }

            try
            {
                // Deletes from contact list
                ContactListInfoProvider.RemoveFromContactList(MembershipContext.AuthenticatedUser.UserID, deletedUserId);
                ShowConfirmation(GetString("Messaging.ContactList.DeleteSuccessful"));
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
            break;
        }
    }
Пример #2
0
    protected void gridContactList_OnAction(string actionName, object actionArgument)
    {
        switch (actionName)
        {
        case "delete":
            int deletedUserId = ValidationHelper.GetInteger(actionArgument, 0);

            // If something is wrong return
            if (CMSContext.CurrentUser == null)
            {
                return;
            }

            try
            {
                // Deletes from contact list
                ContactListInfoProvider.RemoveFromContactList(CMSContext.CurrentUser.UserID, deletedUserId);
                pnlInfo.Visible = true;
                lblInfo.Text    = GetString("Messaging.ContactList.DeleteSuccessful");
            }
            catch (Exception ex)
            {
                pnlInfo.Visible = true;
                lblError.Text   = ex.Message;
            }
            break;
        }
    }
Пример #3
0
    /// <summary>
    /// Removes the sample "cmseditor" user from the current user's contact list. Called when the "Remove user from contact list" button is pressed.
    /// Expects the AddUserToContactList method to be run first.
    /// </summary>
    private bool RemoveUserFromContactList()
    {
        // Gets "cmseditor" UserInfo object
        UserInfo user = UserInfoProvider.GetUserInfo("cmseditor");

        if (ContactListInfoProvider.IsInContactList(CMSContext.CurrentUser.UserID, user.UserID))
        {
            // Removes "cmseditor" from the current user's contact list
            ContactListInfoProvider.RemoveFromContactList(CMSContext.CurrentUser.UserID, user.UserID);

            return(true);
        }

        return(false);
    }
Пример #4
0
    /// <summary>
    /// Removes the sample "Andy" user from the current user's contact list. Called when the "Remove user from contact list" button is pressed.
    /// Expects the AddUserToContactList method to be run first.
    /// </summary>
    private bool RemoveUserFromContactList()
    {
        // Gets "Andy" UserInfo object
        UserInfo user = UserInfoProvider.GetUserInfo("MyNewContact");

        if (ContactListInfoProvider.IsInContactList(MembershipContext.AuthenticatedUser.UserID, user.UserID))
        {
            // Removes "Andy" from the current user's contact list
            ContactListInfoProvider.RemoveFromContactList(MembershipContext.AuthenticatedUser.UserID, user.UserID);

            user.Delete();

            return(true);
        }

        user.Delete();

        return(false);
    }
Пример #5
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);
                ContactListInfoProvider.RemoveFromContactList(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);
                ContactListInfoProvider.AddToContactList(MembershipContext.AuthenticatedUser.UserID, userId);
            }
        }

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

        ShowChangesSaved();
    }
Пример #6
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
                {
                    ContactListInfoProvider.RemoveFromContactList(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
                {
                    ContactListInfoProvider.AddToContactList(CMSContext.CurrentUser.UserID, userId);
                }
            }
        }

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

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