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; } }
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; } }
/// <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; } }
/// <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; } }
private static string GetContactListValues() { DataSet contactList = ContactListInfoProvider.GetContactList(MembershipContext.AuthenticatedUser.UserID, null, null, 0, "UserName,UserNickname,ContactListContactUserID"); if (!DataHelper.DataSourceIsEmpty(contactList)) { return(TextHelper.Join(";", DataHelper.GetStringValues(contactList.Tables[0], "ContactListContactUserID"))); } return(String.Empty); }
private static string GetContactListValues() { DataSet contactList = ContactListInfoProvider.GetContactList(CMSContext.CurrentUser.UserID, null, null, 0, "UserName,UserNickname,ContactListContactUserID"); if (!DataHelper.DataSourceIsEmpty(contactList)) { return(TextHelper.Join(";", SqlHelperClass.GetStringValues(contactList.Tables[0], "ContactListContactUserID"))); } return(String.Empty); }
/// <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); }
/// <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; } }
/// <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); }
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); }
protected DataSet gridContactList_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords) { return(ContactListInfoProvider.GetContactList(MembershipContext.AuthenticatedUser.UserID, completeWhere, currentOrder, currentTopN, "UserName, UserNickname, FullName, ContactListContactUserID", currentOffset, currentPageSize, ref totalRecords)); }
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"); }