private void AddRemovedFriendRelationshipEvent(string fromUsername, string toUsername, Relationship.eRelationshipStatus type) { Event newEvent = new Event(fromUsername); newEvent.Type = Event.eType.RemovedFriendRelationship; RemovedFriendRelationship removedFriendRelationship = new RemovedFriendRelationship(); removedFriendRelationship.Username = toUsername; removedFriendRelationship.Type = type; newEvent.DetailsXML = Misc.ToXml(removedFriendRelationship); newEvent.Save(); if (Config.Users.NewEventNotification) { string[] usernames = User.FetchMutuallyFriends(fromUsername); string text = String.Format("{0} {1} are no longer in relationship ({2})".Translate(), "<b>" + fromUsername + "</b>", toUsername, Relationship.GetRelationshipStatusString(type)); int imageID = 0; try { imageID = Photo.GetPrimary(fromUsername).Id; } catch (NotFoundException) { User user = null; try { user = User.Load(fromUsername); imageID = ImageHandler.GetPhotoIdByGender(user.Gender); } catch (NotFoundException) { return; } } string thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true); foreach (string friendUsername in usernames) { if (toUsername == friendUsername) continue; User.SendOnlineEventNotification(fromUsername, friendUsername, text, thumbnailUrl, UrlRewrite.CreateShowUserUrl(toUsername)); } } }
private void btnSaveChanges_Click(object sender, EventArgs e) { if (ValidateData()) { try { if (Config.Users.LocationPanelVisible) { if (LocationPicker1.Country.IsNotNullOrEmpty()) User.Country = LocationPicker1.Country; if (LocationPicker1.Region.IsNotNullOrEmpty()) User.State = LocationPicker1.Region; if (LocationPicker1.ZipCode.IsNotNullOrEmpty()) User.ZipCode = LocationPicker1.ZipCode; if (LocationPicker1.City.IsNotNullOrEmpty()) User.City = LocationPicker1.City; } User.Name = Config.Misc.EnableBadWordsFilterProfile ? Parsers.ProcessBadWords(txtName.Text) : txtName.Text; //User.Birthdate = datePicker1.SelectedDate; datePicker1.SelectedDate = BirthdayPicker1.SelectedDate; User.Birthdate = datePicker1.SelectedDate; if (!Config.Users.DisableGenderInformation) { if (Config.Users.CouplesSupport && User.Gender == User.eGender.Couple) { User.Birthdate2 = datePicker2.SelectedDate; } if (Config.Users.InterestedInFieldEnabled) { User.InterestedIn = (User.eGender)Convert.ToInt32(dropInterestedIn.SelectedValue); } } if (Config.Users.EnableRelationshipStatus) { if (ddRelationshipStatus.SelectedIndex > 0) // other than "Single" is selected { string toUsername = ddInRelationshipWith.SelectedValue.Length == 0 ? null : ddInRelationshipWith.SelectedValue; Relationship.eRelationshipStatus selectedStatus = (Relationship.eRelationshipStatus) Convert.ToInt32(ddRelationshipStatus.SelectedValue); Relationship relationship = Relationship.Fetch(CurrentUserSession.Username, null); if (relationship == null) { relationship = new Relationship(CurrentUserSession.Username, toUsername); relationship.Type = selectedStatus; } else if (relationship.ToUsername != toUsername) { if (relationship.Accepted && relationship.ToUsername != null) { AddRemovedFriendRelationshipEvent(relationship.FromUsername, relationship.ToUsername, relationship.Type); AddRemovedFriendRelationshipEvent(relationship.ToUsername, relationship.FromUsername, relationship.Type); } Relationship.Delete(relationship.FromUsername, relationship.ToUsername, null); Relationship.Delete(relationship.ToUsername, relationship.FromUsername, null); relationship = new Relationship(CurrentUserSession.Username, toUsername); relationship.Type = selectedStatus; } else if (relationship.Type != selectedStatus) { if (relationship.Accepted) relationship.PendingType = selectedStatus; else relationship.Type = selectedStatus; } if (toUsername == null) relationship.Accepted = true; relationship.Save(); } else { Relationship relationship = Relationship.Fetch(CurrentUserSession.Username, null); if (relationship != null && relationship.Accepted && relationship.ToUsername != null) { AddRemovedFriendRelationshipEvent(CurrentUserSession.Username, relationship.ToUsername, relationship.Type); AddRemovedFriendRelationshipEvent(relationship.ToUsername, CurrentUserSession.Username, relationship.Type); } Relationship.Delete(CurrentUserSession.Username, null, null); Relationship.Delete(null, CurrentUserSession.Username, null); } } User.Email = txtEmail.Text.Trim(); if (txtNewPassword.Text != "") { User.Password = txtNewPassword.Text; } User.ReceiveEmails = cbReceiveEmails.Checked; User.ProfileVisible = cbProfileVisible.Checked; int ageFrom; int ageTo; try { ageFrom = Convert.ToInt32(txtAgeFrom.Text); ageTo = Convert.ToInt32(txtAgeTo.Text); } catch { lblError.Text = Lang.Trans("Please enter valid age!"); lblError.Focus(); return; } if (ageFrom > ageTo) { lblError.Text = Lang.Trans("Please enter valid age!"); lblError.Focus(); return; } var incommingMessagesRestrictions = new IncomingMessagesRestrictions { AgeFrom = ageFrom, AgeTo = ageTo, MessagesFrom = ((IncomingMessagesRestrictions.eMessagesFrom) (Convert.ToInt32(ddMessagesFrom.SelectedValue))), PhotoRequired = cbPhotoRequired.Checked }; User.IncomingMessagesRestrictions = incommingMessagesRestrictions; #region set user options and privacy settings ulong options = ((PageBase) Page).CurrentUserSession.Options; options &= ~(ulong)eUserOptions.DisableBlogComments; options &= ~(ulong)eUserOptions.DisablePhotoRating; options &= ~(ulong)eUserOptions.DisableProfileComments; options &= ~(ulong)eUserOptions.DisablePhotoComments; options &= ~(ulong)eUserOptions.DisableProfileRating; options &= ~(ulong)eUserOptions.DisableProfileVoting; if (cbDisableBlogComments.Checked) options |= (ulong) eUserOptions.DisableBlogComments; if (cbDisablePhotoRating.Checked) options |= (ulong) eUserOptions.DisablePhotoRating; if (cbDisableProfileComments.Checked) options |= (ulong) eUserOptions.DisableProfileComments; if (cbDisablePhotoComments.Checked) options |= (ulong)eUserOptions.DisablePhotoComments; if (cbDisableProfileRating.Checked) options |= (ulong) eUserOptions.DisableProfileRating; if (cbDisableVoting.Checked) options |= (ulong)eUserOptions.DisableProfileVoting; User.Options = options; #endregion if (dropProfileSkin.SelectedIndex > 0) User.ProfileSkin = dropProfileSkin.SelectedIndex == 1 ? null : dropProfileSkin.SelectedValue; User.Update(); CurrentUserSession.Country = User.Country; CurrentUserSession.State = User.State; CurrentUserSession.City = User.City; CurrentUserSession.Longitude = User.Longitude; CurrentUserSession.Latitude = User.Latitude; CurrentUserSession.Options = options; CurrentUserSession.IncomingMessagesRestrictions = User.IncomingMessagesRestrictions; CurrentUserSession.ProfileSkin = User.ProfileSkin; lblError.CssClass = "message"; lblError.Text = Lang.Trans("Your account has been successfully updated!"); lblError.Focus(); if (SettingsSaved != null) { SettingsSaved(this, new EventArgs()); } } catch (Exception ex) { lblError.Text = ex.Message; lblError.Focus(); return; } } }