/// <summary> /// Adds the sample "cmseditor" user to the current user's contact list. Called when the "Add user to contact list" button is pressed. /// </summary> private bool AddUserToContactList() { // Gets "cmseditor" UserInfo object UserInfo user = UserInfoProvider.GetUserInfo("cmseditor"); if (!ContactListInfoProvider.IsInContactList(CMSContext.CurrentUser.UserID, user.UserID)) { // Adds "cmseditor" to the current user's contact list ContactListInfoProvider.AddToContactList(CMSContext.CurrentUser.UserID, user.UserID); return(true); } return(false); }
protected void btnAddToContactList_Click(object sender, EventArgs e) { try { // Current user ID int currentUserId = CMSContext.CurrentUser.UserID; // Add user to contact list ContactListInfoProvider.AddToContactList(currentUserId, RelatedUserId); InformationText = GetString("MessageUserButtons.ContactAdded"); } catch (Exception ex) { ErrorText = ex.Message; } }
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; } }
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; } }
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(); }
/// <summary> /// Adds the sample user to the current user's contact list. Called when the "Add user to contact list" button is pressed. /// </summary> private bool AddUserToContactList() { // First create a new user which will be added to the contact list UserInfo user = new UserInfo(); user.UserName = "******"; user.FullName = "My new contact"; user.UserGUID = Guid.NewGuid(); UserInfoProvider.SetUserInfo(user); if (!ContactListInfoProvider.IsInContactList(MembershipContext.AuthenticatedUser.UserID, user.UserID)) { // Adds "Andy" to the current user's contact list ContactListInfoProvider.AddToContactList(MembershipContext.AuthenticatedUser.UserID, user.UserID); return(true); } return(false); }
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"); }