Exemplo n.º 1
0
		public void Page_Init(object o, System.EventArgs e)
		{
			MusicType mtRoot = new MusicType(1);
			Tree.Controls.Add(MusicNode(mtRoot, 0));
		}
Exemplo n.º 2
0
		static void AddParents(List<Q> qList, MusicType mt)
		{
			if (mt.HasParent)
			{
				qList.Add(new Q(EventMusicType.Columns.MusicTypeK, mt.Parent.K));
				AddParents(qList, mt.Parent);
			}
		}
Exemplo n.º 3
0
		void UpdateAncestors(MusicType mt)
		{
			this.MusicTypeK = mt.K;
		}
Exemplo n.º 4
0
		Control MusicNode(MusicType mt, int level)
		{
			Control c = new Control();
			HtmlGenericControl ItemDiv = new HtmlGenericControl("div");
			ItemDiv.Style["margin-left"] = ((int)(level * 30)).ToString() + "px";
			ItemDiv.ID = "Item" + mt.K.ToString();

			CheckBox ItemCb = new CheckBox();
			ItemCb.ID = "ItemCb" + mt.K.ToString();
			ItemCb.Text = mt.Name;
			if (mt.Children.Count > 0)
			{
				ItemCb.Text += " ...";
				ItemCb.Attributes["onclick"] = "showHide('" + this.ClientID + "'," + mt.K.ToString() + ");";

			}

			ItemDiv.Controls.Add(ItemCb);
			if (mt.Children.Count > 0)
			{
				Label LabCb = new Label();
				LabCb.ID = "LabCb" + mt.K.ToString();
				LabCb.Text = " <b>un-tick <i>" + mt.GenericName.ToLower() + "</i> to show more music types</b>";
				ItemDiv.Controls.Add(LabCb);
			}
			c.Controls.Add(ItemDiv);
			if (mt.Children.Count > 0)
			{
				HtmlGenericControl ChildrenDiv = new HtmlGenericControl("div");
				ChildrenDiv.ID = "Children" + mt.K.ToString();

				foreach (MusicType mtChild in mt.Children)
				{
					ChildrenDiv.Controls.Add(MusicNode(mtChild, level + 1));
				}
				c.Controls.Add(ChildrenDiv);
			}
			return c;
		}
Exemplo n.º 5
0
		public void PrefsUpdateClick(object o, System.EventArgs e)
		{
			Page.Validate();
			bool sendVerifyEmail = false;
			if (Page.IsValid)
			{
				#region Handle change of email address
				if (Usr.Current.Email != Email.Text)
				{
					//Check for duplicate email addresses in the database
					Query q = new Query();
					q.QueryCondition = new Q(Usr.Columns.Email, Email.Text);
					q.ReturnCountOnly = true;
					UsrSet ds = new UsrSet(q);

					if (ds.Count == 0)
					{
						//No duplicate - update email address
						Usr.Current.AdminNote += "\nThis user changed their email address from " + Usr.Current.Email + " to " + Email.Text + " on " + DateTime.Now.ToString();
						Usr.Current.Email = Email.Text;
						Usr.Current.EmailDateTime = DateTime.Now;
						if (HttpContext.Current != null)
							Usr.Current.EmailIp = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);
						Usr.Current.IsEmailVerified = false;
						Usr.Current.IsEmailBroken = false;
						sendVerifyEmail = true;
					}
					else
					{
						//Duplicate - display error
						EmailDuplicateValidator.IsValid = false;
					}
				}
				#endregion
				#region Handle phone number entry
				System.Text.RegularExpressions.Regex rNumbers = new System.Text.RegularExpressions.Regex("[^0123456789]");
				string mobileNumber = rNumbers.Replace(MobileNumber.Text.Trim(), "");
				string dialingCode = rNumbers.Replace(DialingCodeDropDown.SelectedValue, "");
				string dialingCodeOther = rNumbers.Replace(DialingCodeOther.Text.Trim(), "");
				string fullMobile = "";
				if (mobileNumber.StartsWith("0"))
				{
					mobileNumber = mobileNumber.Substring(1);
				}
				if (dialingCode.Equals("0"))
				{
					dialingCode = dialingCodeOther;
				}
				if (mobileNumber.Length > 0)
				{
					fullMobile = dialingCode + mobileNumber;
				}
				if (MobileNumber.Text != mobileNumber)
					MobileNumber.Text = mobileNumber;
				if (DialingCodeDropDown.SelectedValue.Equals("0") && DialingCodeOther.Text != dialingCode)
					DialingCodeOther.Text = dialingCode;
				#endregion

				//Database will only update if all validators are valid
				if (Page.IsValid)
				{
					Usr.Current.FirstName = Cambro.Web.Helpers.StripHtml(FirstName.Text).Trim();
					Usr.Current.LastName = Cambro.Web.Helpers.StripHtml(LastName.Text).Trim();
					string nick = Usr.GetCompliantNickName(NickName.Text);
					Usr.Current.NickName = nick;
					Usr.Current.IsSkeleton = false;

					if (!Usr.Current.Mobile.Equals(fullMobile))
						Usr.Current.AdminNote += "\n\nUsr has changed mobile number from " + Usr.Current.Mobile + " to: " + fullMobile + " on " + DateTime.Now.ToString() + ".\n";

					Usr.Current.Mobile = fullMobile;
					Usr.Current.MobileCountryCode = dialingCode;
					Usr.Current.MobileNumber = mobileNumber;
					Usr.Current.IsMale = SexMale.Checked;
					Usr.Current.IsFemale = SexFemale.Checked;
					Usr.Current.DateOfBirth = new DateTime(int.Parse(DateOfBirthYear.Text), int.Parse(DateOfBirthMonth.Text), int.Parse(DateOfBirthDay.Text));
					Usr.Current.SendSpottedEmails = SendSpottedEmails.Checked;
					Usr.Current.SendSpottedTexts = SendSpottedTexts.Checked;
					Usr.Current.SendFlyers = SendFlyers.Checked;
					Usr.Current.SendInvites = SendInvites.Checked;
					Usr.Current.LegalTermsUser2 = true;
					Usr.Current.IsDj = IsDjYes.Checked;

					#region Update hometown and add UsrPlaceVisit record for this place
					Place p = new Place(int.Parse(HomeTownDropDownList.SelectedValue));
					if (Usr.Current.HomePlaceK != p.K)
					{
						Usr.Current.HomePlaceK = p.K;

						try
						{
							UsrPlaceVisit upv = new UsrPlaceVisit(Usr.Current.K, p.K);
						}
						catch
						{
							UsrPlaceVisit upv = new UsrPlaceVisit();
							upv.UsrK = Usr.Current.K;
							upv.PlaceK = p.K;
							upv.Update();
						}
					}
					Usr.Current.UpdatePlacesVisitCount(false);
					#endregion

					#region Update favourite music and add UsrMusicTypeFavourite record for this musictype
					MusicType mt = new MusicType(int.Parse(FavouriteMusicDropDownList.SelectedValue));
					if (Usr.Current.FavouriteMusicTypeK != mt.K)
					{
						Usr.Current.FavouriteMusicTypeK = mt.K;

						Prefs.Current["MusicPref"] = mt.K;

						try
						{
							UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite(Usr.Current.K, mt.K);
						}
						catch
						{
							UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite();
							newMtf.UsrK = Usr.Current.K;
							newMtf.MusicTypeK = mt.K;
							newMtf.Update();
						}
					}
					Usr.Current.UpdateMusicTypesFavouriteCount(false);
					#endregion

					if (!Usr.Current.IsSkeletonFromSignup && Password2.Text.Length > 0)
					{
						//Remove all saved cards...
						Usr.Current.DeleteAllSavedCards();
						Usr.Current.SetPassword(Password2.Text.Trim(), false);
					}

					Usr.Current.Update();

					if (Usr.Current.GroupsWhoHavePendingInvitationsForMe.Count > 0)
					{
						foreach (GridViewRow gvr in uiAddedByGroupsGridView.Rows)
						{
							if (((CheckBox)gvr.FindControl("uiCheckBox")).Checked)
							{
								int groupK = (int)uiAddedByGroupsGridView.DataKeys[gvr.RowIndex].Value;
								try
								{
									Group g = new Group(groupK);
									GroupUsr gu = g.GetGroupUsr(Usr.Current);
									if (Bobs.Group.AllowJoinRequest(Usr.Current, g, gu))
										g.Join(Usr.Current, gu);
								}
								catch { }
							}
						}
					}
					if (Usr.Current.UsrsWhoHavePendingBuddyRequestsForMe.Count > 0)
					{
						foreach (GridViewRow gvr in uiAddedByUsrsGridView.Rows)
						{
							if (((CheckBox)gvr.FindControl("uiCheckBox")).Checked)
							{
								int buddyUsrK = (int)uiAddedByUsrsGridView.DataKeys[gvr.RowIndex].Value;
								try
								{
									Usr.Current.AddBuddy(new Usr(buddyUsrK), Usr.AddBuddySource.WelcomePage, Buddy.BuddyFindingMethod.Nickname, null);
								}
								catch (Exception ex) { SpottedException.TryToSaveExceptionAndChildExceptions(ex, HttpContext.Current, Usr.Current, Visit.Current, "", "Welcome page", "", 0, null); }
							}
						}
					}

					#region Send email verify email, if needed
					if (sendVerifyEmail)
					{
						Mailer mail = new Mailer();
						mail.SendEvenIfUnverifiedOrBroken = true;
						mail.Subject = "You changed your DontStayIn email address...";
						mail.Body = @"<h1>You changed your email address...</h1><p>Please click the following link to verify your email address and allow posting to our discussion boards:</p>
<p align=""center"" style=""padding:8px 0px 9px 0px;""><a href=""[LOGIN]"" style=""font-size:14px;font-weight:bold;"">Click here to verify your email</a></p>";
						mail.To = Usr.Current.Email;
						mail.UsrRecipient = Usr.Current;
						mail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						mail.Send();
					}
					#endregion

					Log.Increment(Log.Items.WelcomeSignUp);

					if (Usr.Current.AddedByGroupK > 0)
					{
						if (Request.QueryString["Url"] != null && Request.QueryString["Url"].Length > 0)
							Response.Redirect(Request.QueryString["Url"]);
						else
							Response.Redirect(Usr.Current.AddedByGroup.Url());
					}
					else
					{
						if (Request.QueryString["Url"] != null && Request.QueryString["Url"].Length > 0)
							Response.Redirect("/popup/mixmag?url=" + HttpUtility.UrlEncode(Request.QueryString["Url"]));
						else
							Response.Redirect("/popup/mixmag");
					}
				}
			}
		}
Exemplo n.º 6
0
		void Save(bool RedirectToPic)
		{
			if (IsEdit)
			{
				string newName = Cambro.Web.Helpers.Strip(NameTextBox.Text);
				bool changedName = !CurrentGroup.Name.Equals(newName);
				CurrentGroup.Name = newName;

				CurrentGroup.Description = Cambro.Web.Helpers.Strip(DescriptionTextBox.Text);
				CurrentGroup.PostingRules = Cambro.Web.Helpers.Strip(RulesTextBox.Text);
				CurrentGroup.LongDescriptionHtml = IntroHtml.GetHtml();

				bool newPrivateChat;
				if (GroupPagePrivate.Checked)
				{
					CurrentGroup.PrivateGroupPage = true;
					CurrentGroup.PrivateMemberList = true;
					newPrivateChat = true;
				}
				else
				{
					CurrentGroup.PrivateGroupPage = false;
					CurrentGroup.PrivateMemberList = MembersListPrivate.Checked;
					newPrivateChat = ChatForumPrivate.Checked;
				}
				bool changedPrivateChat = newPrivateChat != CurrentGroup.PrivateChat;
				CurrentGroup.PrivateChat = newPrivateChat;

				if (MembershipMember.Checked)
					CurrentGroup.Restriction = Group.RestrictionEnum.Member;
				else if (MembershipModerator.Checked)
					CurrentGroup.Restriction = Group.RestrictionEnum.Moderator;
				else
					CurrentGroup.Restriction = Group.RestrictionEnum.None;

				int newTheme;
				if (ThemesRadioButtonList.SelectedValue.Equals("18"))
					newTheme = 0;
				else
				{
					Theme t = new Theme(int.Parse(ThemesRadioButtonList.SelectedValue));
					newTheme = t.K;
				}
				bool changedTheme = newTheme != CurrentGroup.ThemeK;
				CurrentGroup.ThemeK = newTheme;


				int newCountry;
				int oldCountry = CurrentGroup.CountryK;
				if (LocationTypeCountry.Checked || LocationTypePlace.Checked)
				{
					Country c = new Country(int.Parse(LocationCountryDropDown.SelectedValue));
					if (!c.Enabled)
						throw new Exception("invalid country!");
					newCountry = c.K;
				}
				else
				{
					newCountry = 0;
				}
				bool changedCountry = CurrentGroup.CountryK != newCountry;
				CurrentGroup.CountryK = newCountry;

				int newPlace;
				int oldPlace = CurrentGroup.PlaceK;
				if (LocationTypePlace.Checked)
				{
					Place p = new Place(int.Parse(LocationPlaceDropDown.SelectedValue));
					if (!p.Enabled || p.CountryK != CurrentGroup.CountryK)
						throw new Exception("invalid place!");
					newPlace = p.K;
				}
				else
				{
					newPlace = 0;
				}
				bool changedPlace = CurrentGroup.PlaceK != newPlace;
				CurrentGroup.PlaceK = newPlace;

				int newMusicType;
				if (CurrentGroup.ThemeK == 1 || CurrentGroup.ThemeK == 2)
				{
					if (!MusicTypesRadioButtonList.SelectedValue.Equals("0"))
					{
						MusicType mt = new MusicType(int.Parse(MusicTypesRadioButtonList.SelectedValue));
						if (!(mt.ParentK == 0 || mt.ParentK == 1))
							throw new Exception("Invalid music type");
						newMusicType = mt.K;
					}
					else
					{
						newMusicType = 0;
					}
				}
				else
				{
					newMusicType = 0;
				}
				bool changedMusic = CurrentGroup.MusicTypeK != newMusicType;
				CurrentGroup.MusicTypeK = newMusicType;

				if (changedName)
					CurrentGroup.CreateUniqueUrlName(false);

				Transaction transaction = null;//new Transaction();
				try
				{
					if (changedPrivateChat)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.PrivateGroup, CurrentGroup.PrivateChat));
						update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K);
						update.Run(transaction);
					}

					if (changedTheme)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.ThemeK, CurrentGroup.ThemeK));
						update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K);
						update.Run(transaction);
					}

					if (changedCountry)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.CountryK, CurrentGroup.CountryK));
						update.Where = new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Group), new Q(Thread.Columns.ParentObjectK, CurrentGroup.K));
						update.Run(transaction);
					}

					if (changedPlace)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.PlaceK, CurrentGroup.PlaceK));
						update.Where = new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Group), new Q(Thread.Columns.ParentObjectK, CurrentGroup.K));
						update.Run(transaction);

						if (oldPlace > 0)
						{
							Place oldP = new Place(oldPlace);
							oldP.UpdateTotalComments(null);
						}
						if (newPlace > 0)
						{
							Place newP = new Place(newPlace);
							newP.UpdateTotalComments(null);
						}
					}

					if (changedMusic)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.MusicTypeK, CurrentGroup.MusicTypeK));
						update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K);
						update.Run(transaction);
					}

					if (changedName)
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Group, CurrentGroup.K, true);
						job.ExecuteAsynchronously();
					}
					CurrentGroup.Update(transaction);

					//transaction.Commit();
				}
				catch (Exception ex)
				{
					//transaction.Rollback();
					throw ex;
				}
				finally
				{
					//transaction.Close();
				}
				if (RedirectToPic)
				{
					if (ContainerPage.Url["promoterk"].IsInt)
						Response.Redirect(CurrentGroup.UrlApp("edit", "pic", "", "promoterk", ContainerPage.Url["promoterk"]));
					else
						Response.Redirect(CurrentGroup.UrlApp("edit", "pic", ""));
				}
				else
				{
					RedirectSaved();
				}


			}
			else
			{
				GroupSet gsDup = new GroupSet(new Query(new Q(Group.Columns.DuplicateGuid, (Guid)ContainerPage.ViewStatePublic["GroupDuplicateGuid"])));
				if (gsDup.Count != 0)
				{
					Response.Redirect(gsDup[0].UrlApp("edit", "pic", ""));
				}
				else
				{
					Group g = new Group();
					g.Name = Cambro.Web.Helpers.Strip(NameTextBox.Text);
					g.Description = Cambro.Web.Helpers.Strip(DescriptionTextBox.Text);

					g.LongDescriptionHtml = IntroHtml.GetHtml();
					
					g.PostingRules = Cambro.Web.Helpers.Strip(RulesTextBox.Text, true, true, false, true);
					g.DateTimeCreated = DateTime.Now;
					g.PrivateGroupPage = GroupPagePrivate.Checked;
					if (GroupPagePrivate.Checked)
					{
						g.PrivateMemberList = true;
						g.PrivateChat = true;
					}
					else
					{
						g.PrivateMemberList = MembersListPrivate.Checked;
						g.PrivateChat = ChatForumPrivate.Checked;
					}

					if (MembershipMember.Checked)
						g.Restriction = Group.RestrictionEnum.Member;
					else if (MembershipModerator.Checked)
						g.Restriction = Group.RestrictionEnum.Moderator;
					else
						g.Restriction = Group.RestrictionEnum.None;

					if (ThemesRadioButtonList.SelectedValue.Equals("18"))
						g.ThemeK = 0;
					else
					{
						Theme t = new Theme(int.Parse(ThemesRadioButtonList.SelectedValue));
						g.ThemeK = t.K;
					}

					if (LocationTypeCountry.Checked || LocationTypePlace.Checked)
					{
						Country c = new Country(int.Parse(LocationCountryDropDown.SelectedValue));
						if (!c.Enabled)
							throw new Exception("invalid country!");
						g.CountryK = c.K;
					}
					if (LocationTypePlace.Checked)
					{
						Place p = new Place(int.Parse(LocationPlaceDropDown.SelectedValue));
						if (!p.Enabled || p.CountryK != g.CountryK)
							throw new Exception("invalid place!");
						g.PlaceK = p.K;
					}

					if (g.ThemeK == 1 || g.ThemeK == 2)
					{
						if (!MusicTypesRadioButtonList.SelectedValue.Equals("0"))
						{
							MusicType mt = new MusicType(int.Parse(MusicTypesRadioButtonList.SelectedValue));
							if (!(mt.ParentK == 0 || mt.ParentK == 1))
								throw new Exception("Invalid music type");
							g.MusicTypeK = mt.K;
						}
					}

					g.CreateUniqueUrlName(false);

					g.DuplicateGuid = (Guid)ContainerPage.ViewStatePublic["GroupDuplicateGuid"];
					g.EmailOnAllThreads = false;

					g.Update();

					g.ChangeUsr(false, Usr.Current.K, true, true, true, true, Bobs.GroupUsr.StatusEnum.Member, DateTime.Now, true);

					Response.Redirect(g.UrlApp("edit", "pic", ""));
				}
			}
		}
Exemplo n.º 7
0
		public static Event AddEvent(
			string name, 
			int venueK, 
			StartTimes? startTime, 
			DateTime date, 
			string shortDetails, 
			string safeLongDetails, 
			Guid? duplicateGuid, 
			int? capacity, 
			Usr usr, 
			int[] musicTypeKs, 
			int[] brandKs,
			bool spotterRequest,
			string spotterRequestName,
			string spotterRequestNumber)
		{
			Event ev = new Event();

			Venue venue = new Venue(venueK);
			Transaction t = null;//new Transaction();
			try
			{
				ev.AddedDateTime = DateTime.Now;
				ev.VenueK = venue.K;
				ev.Name = Cambro.Web.Helpers.StripHtml(name).Trim();
				ev.StartTime = startTime ?? StartTimes.Evening;;
				ev.DateTime = date;
				ev.ShortDetailsHtml = Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.StripHtml(shortDetails ?? ""), 500);

				ev.LongDetailsHtml = safeLongDetails;

				ev.DuplicateGuid = duplicateGuid ?? Guid.NewGuid();

				ev.Capacity = capacity ?? venue.Capacity;

				ev.AdminNote += "Event added by owner " + DateTime.Now.ToString();

				ev.OwnerUsrK = Usr.Current.K;

				ev.SpotterRequest = spotterRequest;
				ev.SpotterRequestName = spotterRequestName;
				ev.SpotterRequestNumber = spotterRequestNumber;

				if (!usr.IsSuper)
				{
					ev.IsNew = true;
					ev.ModeratorUsrK = Usr.GetEventModeratorUsrK();
				}
				ev.InitUrlFragment();
				ev.Update(t);

				foreach (int musicTypeK in musicTypeKs ?? new int[]{})
				{
					MusicType mt = new MusicType(musicTypeK);
					EventMusicType emt = new EventMusicType();
					emt.EventK = ev.K;
					emt.MusicTypeK = mt.K;
					emt.Update(t);
				}
				foreach (int brandK in brandKs ?? new int[] { })
				{
					EventBrand eb = new EventBrand();
					eb.BrandK = brandK;
					eb.EventK = ev.K;
					eb.Update(t);
				}

				ev.UpdateMusicTypesString(t);

				ev.Venue.UpdateTotalEvents(t);
				ev.Owner.UpdateEventCount(t);

				//t.Commit();
				

			}
			catch (Exception ex)
			{
				//t.Rollback();
				ev.DeleteAll(null);
				throw ex;
			}
			finally
			{
				//t.Close();
			}

			Mailer sm = new Mailer();
			sm.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
			sm.UsrRecipient = Usr.Current;
			sm.To = Usr.Current.Email;
			sm.Subject = "You've added an event!";
			sm.Body += "<p>You've added an event to the DontStayIn events database.</p>";
			sm.Body += "<p>Click the link below to view the event:</p>";
			sm.Body += "<p><a href=\"[LOGIN(" + ev.Url() + ")]\">" + HttpUtility.HtmlEncode(ev.FriendlyName) + "</a></p>";
			sm.Body += "<h2>Make changes</h2>";
			sm.Body += "<p>You can make changes or corrections to the event details by clicking the link below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/event-" + ev.K.ToString() + "/edit)]\">Edit your event</a></p>";
			sm.Body += "<h2>How about a banner advert?</h2>";
			sm.Body += "<p>You can add a banner advert to your event by using the link below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/pages/bannerpreview/eventk-" + ev.K.ToString() + ")]\">Add a banner</a></p>";
			sm.Body += "<h2>Add photos or a review</h2>";
			sm.Body += "<p>After the event you can upload photos or add a review with the links below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/pages/galleries/add/eventk-" + ev.K.ToString() + ")]\">Add photos</a> or <a href=\"[LOGIN(" + ev.UrlApp("review") + ")]\">add a review</a></p>";
			sm.Body += "<h2>Are you the event promoter?</h2>";
			sm.Body += "<p>If you organise this event, you can sign up for a FREE promoter account by using the link below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/pages/promoters/edit)]\">Apply for a promoter account</a></p>";
			sm.RedirectUrl = ev.Url();
			sm.Send();
			return ev;

		}
Exemplo n.º 8
0
		static void AddMusicTypeChildren(MusicType mt, ref List<int> musicTypes)
		{
			if (mt.Children.Count > 0)
			{
				foreach (MusicType mtChild in mt.Children)
				{
					if (!musicTypes.Contains(mtChild.K))
					{
						musicTypes.Add(mtChild.K);
					}
					if (mtChild.ParentK == 1)
					{
						AddMusicTypeChildren(mtChild, ref musicTypes);
					}
				}
			}
		}
Exemplo n.º 9
0
		void SaveEvent()
		{
			bool duplicate = false;
			//Save the event
			if (IsNew)
			{
				//Duplicate?
				EventSet esDup = new EventSet(new Query(new Q(Event.Columns.DuplicateGuid, (Guid)ContainerPage.ViewStatePublic["EventDuplicateGuid"])));
				if (esDup.Count == 0)
				{
					Event ev = Event.AddEvent(
						Cambro.Web.Helpers.StripHtml(EventName.Text).Trim(),
						CurrentVenue.K,
						StartTime,
						PanelDateCal.SelectedDate,
						Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.StripHtml(EventShortDetailsHtml.Text), 500),
						EventLongDetailsHtml.GetHtml(),
						(Guid)ContainerPage.ViewStatePublic["EventDuplicateGuid"],
						EventCapacity.Text.Trim().Length > 0 ? int.Parse(EventCapacity.Text.Trim()) : null as int?,
						Usr.Current, 
						MusicTypesUc.SelectedMusicTypes.ToArray(), 
						null,
						SpotterRequestYes.Checked,
						SpotterRequestYes.Checked ? Cambro.Web.Helpers.StripHtml(SpotterRequestName.Text).Truncate(100) : "",
						SpotterRequestYes.Checked ? Cambro.Web.Helpers.StripHtml(SpotterRequestNumber.Text).Truncate(100) : ""
					);
					ViewState["InsertedEventK"] = ev.K;
				}
				else
				{
					ViewState["InsertedEventK"] = esDup[0].K;
					duplicate = true;
				}
			}
			else if (IsEdit)
			{

				if (!Usr.Current.CanEdit(CurrentEvent))
					throw new Exception("You may not edit this event!");

				bool changedDate = false;
				bool changedVenue = false;
				CurrentEvent.Name = Cambro.Web.Helpers.StripHtml(EventName.Text).Trim();
				CurrentEvent.StartTime = StartTime;
				if (CanEditDateVenue)
				{
					if (CurrentEvent.DateTime != PanelDateCal.SelectedDate)
					{
						CurrentEvent.DateTime = PanelDateCal.SelectedDate;
						changedDate = true;
					}
				}
				CurrentEvent.ShortDetailsHtml = Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.StripHtml(EventShortDetailsHtml.Text), 500);

				CurrentEvent.LongDetailsHtml = EventLongDetailsHtml.GetHtml();

				CurrentEvent.SpotterRequest = SpotterRequestYes.Checked;
				if (SpotterRequestYes.Checked)
				{
					CurrentEvent.SpotterRequestName = Cambro.Web.Helpers.StripHtml(SpotterRequestName.Text).Truncate(100);
					CurrentEvent.SpotterRequestNumber = Cambro.Web.Helpers.StripHtml(SpotterRequestNumber.Text).Truncate(100);
				}
				else
				{
					CurrentEvent.SpotterRequestName = "";
					CurrentEvent.SpotterRequestNumber = "";
				}

				if (EventCapacity.Text.Length > 0)
					CurrentEvent.Capacity = int.Parse(EventCapacity.Text);

				if (CurrentEvent.AdminNote.Length > 0)
					CurrentEvent.AdminNote += "\n";
				CurrentEvent.AdminNote += "Event modified by " + Usr.Current.NickName + " (K=" + Usr.Current.K.ToString() + ") " + DateTime.Now.ToString();

				if (Usr.Current.IsSuper)
				{
					CurrentEvent.IsNew = false;
					CurrentEvent.IsEdited = false;
				}
				else
				{
					CurrentEvent.IsEdited = true;
					CurrentEvent.ModeratorUsrK = Usr.GetEventModeratorUsrK();
				}

				CurrentEvent.Update();

				if (CanEditDateVenue)
				{
					Venue v = this.PanelDetailsVenuePicker.Venue;
					if (v!= null && CurrentEvent.VenueK != v.K)
					{
						changedVenue = true;
						CurrentEvent.ChangeVenue(v.K, false);
					}
				}

				if (changedDate || changedVenue)
				{
					CurrentEvent.UpdateUrlFragment(false);
					Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Event, CurrentEvent.K, true);
					job.ExecuteAsynchronously();
				}

				foreach (int ob in MusicTypesUc.SelectedMusicTypes)
				{
					MusicType mt = new MusicType(ob);
					try
					{
						EventMusicType emt = new EventMusicType(CurrentEvent.K, mt.K);
					}
					catch
					{
						EventMusicType emt = new EventMusicType();
						emt.EventK = CurrentEvent.K;
						emt.MusicTypeK = mt.K;
						emt.Update();
					}
				}
				CurrentEvent.MusicTypes = null;
				foreach (EventMusicType emt in CurrentEvent.EventMusicTypes)
				{
					if (!MusicTypesUc.SelectedMusicTypes.Contains(emt.MusicTypeK))
					{
						emt.Delete();
						emt.Update();
					}
				}

				CurrentEvent.UpdateMusicTypesString(null);
			}
			if (IsNew || IsEdit)
			{
				if (!duplicate)
				{
					//Update brands...
					ArrayList selectedBrands = new ArrayList();
					ArrayList eventBrands = new ArrayList();
					ArrayList allBrandKs = new ArrayList();
					ArrayList allBrands = new ArrayList();

					foreach (var kvp in uiBrandsMultiSelector.Selections)
					{
						try
						{
							Brand b = new Brand(int.Parse(kvp.Value));
							selectedBrands.Add(b.K);
							if (!allBrandKs.Contains(b.K))
							{
								allBrandKs.Add(b.K);
								allBrands.Add(b);
							}
						}
						catch
						{ }
					}
					foreach (Brand b in CurrentEvent.Brands)
					{
						eventBrands.Add(b.K);
						if (!selectedBrands.Contains(b.K))
							CurrentEvent.AssignBrand(b.K, false, null);
					}
					foreach (int i in selectedBrands)
					{
						if (!eventBrands.Contains(i))
							CurrentEvent.AssignBrand(i, true, null);

					}
					foreach (Brand b in allBrands)
					{
						b.UpdateTotalComments(null);
					}


				}
			}

		}
Exemplo n.º 10
0
		public static EventSet GetEventSetFromEventBoxKey(string key)
		{
			EventPageStub data = EventPageDetails.GetStubFromKey(key);

			Query q = new Query();

			Q dateQ = new Q(true);
			Q ticketsQ = new Q(true);
			if (data.tabType == TabType.Tickets)
			{
				q.OrderBy = new OrderBy(@"
1.0 * (LOG(2) / LOG((DATEDIFF(wk, GETDATE(), [Event].[DateTime]) * 0.25) + 2)) +
1.0 * (1 - (LOG((1.0 / (([TicketHeat] / 10.0) + 1)) + 1) / LOG(2))) +
1.0 * (1 - (LOG((1.0 / (([Event].[UsrAttendCount] / 30.0) + 1)) + 1) / LOG(2))) --+ 
--1.0 * (1 - (LOG((1.0 / (([Event].[TotalComments] / 100.0) + 1)) + 1) / LOG(2)))
DESC, [Event].[K]", Event.Columns.DateTime, Event.Columns.UsrAttendCount, Event.Columns.TotalComments);

				dateQ = Event.FutureEventsQueryCondition;
				ticketsQ = new Q(Event.Columns.IsTicketsAvailable, true);

			}
			else if (data.tabType == TabType.Future)
			{
				q.OrderBy = new OrderBy(@"
1.0 * (LOG(2) / LOG((DATEDIFF(wk, GETDATE(), [Event].[DateTime]) * 0.25) + 2)) +
1.0 * (1 - (LOG((1.0 / (([Event].[UsrAttendCount] / 30.0) + 1)) + 1) / LOG(2))) --+ 
--1.0 * (1 - (LOG((1.0 / (([Event].[TotalComments] / 100.0) + 1)) + 1) / LOG(2)))
DESC, [Event].[K]", Event.Columns.DateTime, Event.Columns.UsrAttendCount, Event.Columns.TotalComments);

				dateQ = Event.FutureEventsQueryCondition;

			}
			else
			{
				q.OrderBy = new OrderBy(@"
1.0 * (LOG(2) / LOG(0 - (DATEDIFF(wk, GETDATE(), [Event].[DateTime]) * 0.25) + 2)) +
1.0 * (1 - (LOG((1.0 / (([Event].[UsrAttendCount] / 30.0) + 1)) + 1) / LOG(2))) --+ 
--0.5 * (1 - (LOG((1.0 / (([Event].[TotalComments] / 100.0) + 1)) + 1) / LOG(2))) +
--0.5 * (1 - (LOG((1.0 / (([Event].[LivePhotos] / 75.0) + 1)) + 1) / LOG(2))) + 
DESC, [Event].[K]", Event.Columns.DateTime, Event.Columns.UsrAttendCount, Event.Columns.TotalComments, Event.Columns.LivePhotos);

				//q.OrderBy = Event.PastEventOrder;

				dateQ = new And(Event.PreviousEventsQueryCondition, new Q(Event.Columns.DateTime, QueryOperator.GreaterThan, DateTime.Today.AddDays(-60)));
			}

			//supported object types: None, Brand, Country, Place
			Q parentObjectQ;
			TableElement parentObjectTableElement;
			if (data.parentObjectType == Model.Entities.ObjectType.None)
			{
				parentObjectTableElement = new TableElement(TablesEnum.Event);
				parentObjectQ = new Q(true);
			}
			else if (data.parentObjectType == Model.Entities.ObjectType.Country)
			{
				parentObjectTableElement = Event.PlaceAllJoin;
				parentObjectQ = new Q(Place.Columns.CountryK, data.parentObjectK);
			}
			else if (data.parentObjectType == Model.Entities.ObjectType.Place)
			{
				parentObjectTableElement = Event.VenueAllJoin;
				parentObjectQ = new Q(Venue.Columns.PlaceK, data.parentObjectK);
			}
			else if (data.parentObjectType == Model.Entities.ObjectType.Brand)
			{
				parentObjectTableElement = Event.EventBrandJoin;
				parentObjectQ = new Q(EventBrand.Columns.BrandK, data.parentObjectK);
			}
			else
				throw new Exception("Unsupported object type");

			q.TableElement = parentObjectTableElement;

			Q musicTypeQ = new Q(true);
			if (data.musicTypeK > 1)
			{
				List<int> al = new List<int>();
				MusicType mt = new MusicType(data.musicTypeK);
				al.Add(mt.K);
				if (mt.ParentK == 1)
				{
					foreach (MusicType mtChild in mt.Children)
					{
						al.Add(mtChild.K);
					}
				}
				musicTypeQ = new InListQ(EventMusicType.Columns.MusicTypeK, al);

				q.TableElement = new Join(
					parentObjectTableElement,
					new TableElement(TablesEnum.EventMusicType),
					QueryJoinType.Left,
					Event.Columns.K,
					EventMusicType.Columns.EventK);
				q.Distinct = true;
				q.DistinctColumn = Event.Columns.K;

			}

			q.QueryCondition = new And(
				dateQ,
				parentObjectQ,
				musicTypeQ,
				ticketsQ);

			q.CacheDuration = TimeSpan.FromDays(1);

			q.Paging.RecordsPerPage = 8;
			q.Paging.RequestedPageIndex = data.pageIndex;

			EventSet es = new EventSet(q);
			return es;
		}
Exemplo n.º 11
0
		static void updateFromDetailsData(Usr u, Hashtable detailsPanelData)
		{

			Place p = new Place((int)detailsPanelData["PlaceK"]);
			u.HomePlaceK = p.K;
			u.AddressCountryK = p.CountryK;

			MusicType mt = new MusicType((int)detailsPanelData["MusicTypeK"]);
			u.FavouriteMusicTypeK = mt.K;

			#region update UsrMusicTypeFavourite table
			try
			{
				UsrMusicTypeFavourite umf = new UsrMusicTypeFavourite();
				umf.UsrK = u.K;
				umf.MusicTypeK = mt.K;
				umf.Update();

				u.UpdateMusicTypesFavouriteCount(false);
			}
			catch { }
			#endregion

			#region update UsrPlaceVisit table
			try
			{
				UsrPlaceVisit upv = new UsrPlaceVisit();
				upv.UsrK = u.K;
				upv.PlaceK = p.K;
				upv.Update();

				u.UpdatePlacesVisitCount(false);
			}
			catch { }
			#endregion

			#region Facebook
			u.FacebookStory = (bool)detailsPanelData["Facebook"];
			u.FacebookStory1 = (bool)detailsPanelData["Facebook"];

			u.FacebookEventAdd = (bool)detailsPanelData["Facebook"];
			u.FacebookEventAttend = (bool)detailsPanelData["Facebook"];

			u.FacebookStoryAttendEvent = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryBuyTicket = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryEventReview = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryFavourite = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryJoinGroup = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryLaugh = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryNewBuddy = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryNewTopic = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryPhotoFeatured = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryPostNews = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryPublishArticle = (bool)detailsPanelData["Facebook"];
			u.FacebookStorySpotted = (bool)detailsPanelData["Facebook"];
			u.FacebookStoryUploadPhoto = (bool)detailsPanelData["Facebook"];

			#endregion

			#region WeeklyEmail
			u.SendSpottedEmails = (bool)detailsPanelData["WeeklyEmail"];
			#endregion

			#region PartyInvites
			u.SendSpottedTexts = (bool)detailsPanelData["PartyInvites"];
			u.SendFlyers = (bool)detailsPanelData["PartyInvites"];
			u.SendInvites = (bool)detailsPanelData["PartyInvites"];
			#endregion

			u.AgreeTerms = true;
			u.LegalTermsUser2 = true;
			u.IsSkeleton = false;
			u.Update();

			#region update Prefs

			if (mt.K != 1)
				Prefs.Current["MusicPref"] = mt.K;

			if (p.CountryK != 224)
				Prefs.Current["HomeCountryK"] = p.CountryK;

			if (mt.K != 1 || p.CountryK != 224)
				Prefs.Current.Update();

			#endregion
		}
Exemplo n.º 12
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			ContainerPage.SetPageTitle("Weekly email options");
			Usr.KickUserIfNotLoggedIn("You must be logged in to use this page.");

			MusicLabel.Text = "";
			GenericMusicLabel.Text = "";
			PlacesLabel.Text = "";

			#region Build SelectedMusicTypes, GenericMusicTypes and SelectedPlaces
			SortedList SelectedMusicTypes = new SortedList();
			SortedList GenericMusicTypes = new SortedList();
			SortedList SelectedPlaces = new SortedList();
			ArrayList musicTypesK = new ArrayList();

			if (Usr.Current.MusicTypesFavouriteCount > 0)
			{
				foreach (MusicType mt in Usr.Current.MusicTypesFavourite)
				{
					if (!musicTypesK.Contains(mt.K))
					{
						musicTypesK.Add(mt.K);
						SelectedMusicTypes.Add(mt.Order, mt);
						if (mt.ParentK > 1 && !musicTypesK.Contains(mt.ParentK))
						{
							musicTypesK.Add(mt.ParentK);
							GenericMusicTypes.Add(mt.Parent.Order, mt.Parent);
						}
					}
				}
			}
			else
			{
				if (Usr.Current.FavouriteMusicTypeK != 0)
				{
					musicTypesK.Add(Usr.Current.FavouriteMusicTypeK);
					SelectedMusicTypes.Add(Usr.Current.FavouriteMusicType.Order, Usr.Current.FavouriteMusicType);
				}
			}
			if (!musicTypesK.Contains(1))
			{
				musicTypesK.Add(1);
				MusicType mtAllMusic = new MusicType(1);
				GenericMusicTypes.Add(mtAllMusic.Order, mtAllMusic);
			}


			ArrayList placesK = new ArrayList();
			if (Usr.Current.HomePlaceK > 0)
			{
				placesK.Add(Usr.Current.HomePlaceK);
				SelectedPlaces.Add(Usr.Current.Home.Name, Usr.Current.Home);
			}
			PlaceSet ps = Usr.Current.PlacesVisit(null, 0);
			foreach (Place p in ps)
			{
				if (!placesK.Contains(p.K))
				{
					placesK.Add(p.K);
					SelectedPlaces.Add(p.Name, p);
				}
			}
			#endregion

			bool first = true;
			if (SelectedMusicTypes.Count == 0)
				MusicLabel.Text = "[none selected]";
			else
			{
				foreach (MusicType mt in SelectedMusicTypes.Values)
				{
					MusicLabel.Text += (first ? "" : ", ") + mt.Name;
					first = false;
				}
			}

			first = true;
			if (GenericMusicTypes.Count == 0)
				GenericMusicP.Visible = false;
			else
			{
				foreach (MusicType mt in GenericMusicTypes.Values)
				{
					GenericMusicLabel.Text += (first ? "" : ", ") + mt.Name;
					first = false;
				}
			}

			first = true;
			if (SelectedPlaces.Count == 0)
				PlacesLabel.Text = "[none selected]";
			else
			{
				foreach (Place p in SelectedPlaces.Values)
				{
					PlacesLabel.Text += (first ? "" : ", ") + p.NamePlainRegion;
					first = false;
				}
			}


			if (!Page.IsPostBack)
			{
				EmailCheck.Checked = Usr.Current.SendSpottedEmails;

				MusicGeneric.Checked = Usr.Current.UpdateSendGenericMusic;

				OptionsPanel.Visible = Usr.Current.SendSpottedEmails;
			}
		}
Exemplo n.º 13
0
		public bool SaveMusicTargetting(IList<int> musicTypeKs)
		{
			this.musicTypesChosen = null;
			this.musicTypesAll = null;

			Delete delete = new Delete(TablesEnum.BannerMusicType, new Q(BannerMusicType.Columns.BannerK, this.K));
			delete.Run();

			if (musicTypeKs.Count == 0 || musicTypeKs.Contains(1))
			{
				return false;
			}

			List<int> done = new List<int>(musicTypeKs.Count);
			foreach (int mtK in musicTypeKs)
			{
				MusicType mt = new MusicType(mtK);
				if (!done.Contains(mt.K))
				{
					BannerMusicType newBmt = new BannerMusicType()
					{
						BannerK = this.K,
						MusicTypeK = mt.K,
						Chosen = true
					};
					newBmt.Update();
					done.Add(mt.K);
				}
				if (mt.ParentK > 1 && !done.Contains(mt.ParentK))
				{
					BannerMusicType newParentBmt = new BannerMusicType()
					{
						BannerK = this.K,
						MusicTypeK = mt.ParentK,
						Chosen = false
					};
					newParentBmt.Update();
					done.Add(mt.ParentK);
				}
				if (mt.ParentK == 1)
				{
					foreach (MusicType child in mt.Children)
					{
						if (!done.Contains(child.K))
						{
							BannerMusicType newChildBmt = new BannerMusicType()
							{
								BannerK = this.K,
								MusicTypeK = child.K,
								Chosen = false
							};
							newChildBmt.Update();
							done.Add(child.K);
						}
					}
				}
			}
			return true;
		}
Exemplo n.º 14
0
		static void AddChildren(List<Q> qList, MusicType mt)
		{
			if (mt.Children.Count > 0)
			{
				foreach (MusicType mtChild in mt.Children)
				{
					qList.Add(new Q(EventMusicType.Columns.MusicTypeK, mtChild.K));
					AddChildren(qList, mtChild);
				}
			}
		}
Exemplo n.º 15
0
		static void AddMusicTypeQChildren(ArrayList musicTypesQ, MusicType mt, ref ArrayList musicTypesK)
		{
			if (mt.Children.Count > 0)
			{
				foreach (MusicType mtChild in mt.Children)
				{
					if (!musicTypesK.Contains(mtChild.K))
					{
						musicTypesQ.Add(new Q(Usr.Columns.FavouriteMusicTypeK, mtChild.K));
						musicTypesQ.Add(new Q(UsrMusicTypeFavourite.Columns.MusicTypeK, mtChild.K));
						musicTypesK.Add(mtChild.K);
					}
				}
			}
		}
Exemplo n.º 16
0
		public void Init(Usr u)
		{
			AllMusicTypes = null;
			SelectedMusicTypes = null;
			GenericMusicTypes = null;
			SelectedPlaces = null;
			MusicQ = null;
			PlaceQ = null;
			#region Populate MusicQ and MusicTypes
			if (u.FavouriteMusicTypeK == 0 && u.MusicTypesFavouriteCount == 0)
			{
				MusicQ = new Q(true);
			}
			else
			{
				List<int> musicTypesK = new List<int>();

				#region Add MusicTypes
				if (u.MusicTypesFavouriteCount > 0)
				{
					foreach (MusicType mt in u.MusicTypesFavourite)
					{
						if (!musicTypesK.Contains(mt.K))
						{
							musicTypesK.Add(mt.K);
							AllMusicTypes.Add(mt.Order, mt);
							SelectedMusicTypes.Add(mt.Order, mt);
							AddMusicTypeChildren(mt, ref musicTypesK);
							#region Add the parent
							if (u.UpdateSendGenericMusic && mt.ParentK > 1 && !musicTypesK.Contains(mt.ParentK))
							{
								musicTypesK.Add(mt.ParentK);
								AllMusicTypes.Add(mt.Parent.Order, mt.Parent);
								GenericMusicTypes.Add(mt.Parent.Order, mt.Parent);
							}
							#endregion
						}
					}
				}
				else
				{
					if (u.FavouriteMusicTypeK != 0)
					{
						musicTypesK.Add(u.FavouriteMusicTypeK);
						AllMusicTypes.Add(u.FavouriteMusicType.Order, u.FavouriteMusicType);
						SelectedMusicTypes.Add(u.FavouriteMusicType.Order, u.FavouriteMusicType);
						AddMusicTypeChildren(u.FavouriteMusicType, ref musicTypesK);
					}
				}
				if (u.UpdateSendGenericMusic && !musicTypesK.Contains(1))
				{
					musicTypesK.Add(1);
					MusicType mtAllMusic = new MusicType(1);
					AllMusicTypes.Add(mtAllMusic.Order, mtAllMusic);
					GenericMusicTypes.Add(mtAllMusic.Order, mtAllMusic);
				}
				#endregion
				musicTypesK.Sort();
				MusicQ = new Or(musicTypesK.ConvertAll<Q>(mtk => new Q(EventMusicType.Columns.MusicTypeK, mtk)).ToArray());
			}
			#endregion
			#region Populate PlaceQ and SelectedPlaces
			List<int> placesK = new List<int>();
			if (u.HomePlaceK > 0)
			{
				placesK.Add(u.HomePlaceK);
				SelectedPlaces.Add(u.Home.Name, u.Home);
			}

			foreach (Place p in u.PlacesVisit(null, 0))
			{
				if (!placesK.Contains(p.K))
				{
					placesK.Add(p.K);
					SelectedPlaces.Add(p.Name, p);
				}
			}

			if (placesK.Count > 0)
			{
				placesK.Sort();
				PlaceQ = new Or(placesK.ConvertAll<Q>(pk => new Q(Venue.Columns.PlaceK, pk)).ToArray());
			}
			else
			{
				PlaceQ = new Q(false);
			}
			#endregion
		}
Exemplo n.º 17
0
		public Dictionary<string, int> ResolveUsrsFromMultiBuddyChooserValues(IEnumerable<string> values, int restrictionGroupK, int threadK, Q restrictionGroupQ)
		{
			Dictionary<string, int> hash = new Dictionary<string, int>();

			foreach (var item in values)
			{
				if (item.StartsWith("{'email'"))
				{
					var esv = javaScriptSerializer.Deserialize<EmailSuggestionValue>(item);
					hash[esv.email] = CreateUsrFromEmail(esv.email, true);
					
				}else if (item.StartsWith("{'emails'"))
				{
					var esv = javaScriptSerializer.Deserialize<EmailsSuggestionValue>(item);
					string[] emails = GlobalObject.unescape(esv.emails).Split(' ');
					foreach (var email in emails)
					{
						hash[email] = CreateUsrFromEmail(email, esv.buddies);
					}
				}
				else if (item.StartsWith("{'MusicTypeK'"))
				{
					var musicTypeAndPlaceK = javaScriptSerializer.Deserialize<MusicTypeKAndPlaceK>(item);
					Query q = new Query();
					Join j = new Join(
						Usr.BuddyUsrJoin,
						new TableElement(TablesEnum.UsrMusicTypeFavourite),
						QueryJoinType.Left,
						Usr.Columns.K,
						UsrMusicTypeFavourite.Columns.UsrK);
					q.TableElement = new Join(
						j,
						new TableElement(TablesEnum.UsrPlaceVisit),
						QueryJoinType.Left,
						Usr.Columns.K,
						UsrPlaceVisit.Columns.UsrK);

					if (threadK > 0)
					{
						q.TableElement = new Join(
							q.TableElement,
							new TableElement(TablesEnum.ThreadUsr),
							QueryJoinType.Left,
							new And(
								new Q(Usr.Columns.K, ThreadUsr.Columns.UsrK, true),
								new Q(ThreadUsr.Columns.ThreadK, threadK)
							)
						);

					}
					else if (restrictionGroupK > 0)
					{
						q.TableElement = new Join(
							q.TableElement,
							new TableElement(TablesEnum.GroupUsr),
							QueryJoinType.Left,
							new And(
								new Q(Usr.Columns.K, GroupUsr.Columns.UsrK, true),
								new Q(GroupUsr.Columns.GroupK, restrictionGroupK)
							)
						);
					}

					Q placeQ = new Q(true);
					if (musicTypeAndPlaceK.PlaceK > 0)
					{
						placeQ = new Or(
							new Q(Usr.Columns.HomePlaceK, musicTypeAndPlaceK.PlaceK),
							new Q(UsrPlaceVisit.Columns.PlaceK, musicTypeAndPlaceK.PlaceK));
					}
					Q musicQ = new Q(true);
					if (musicTypeAndPlaceK.MusicTypeK > 1)
					{
						ArrayList musicQs = new ArrayList();
						MusicType mt = new MusicType(musicTypeAndPlaceK.MusicTypeK);
						musicQs.Add(new Q(Usr.Columns.FavouriteMusicTypeK, 1));
						musicQs.Add(new Q(UsrMusicTypeFavourite.Columns.MusicTypeK, 1));
						musicQs.Add(new Q(Usr.Columns.FavouriteMusicTypeK, musicTypeAndPlaceK.MusicTypeK));
						musicQs.Add(new Q(UsrMusicTypeFavourite.Columns.MusicTypeK, musicTypeAndPlaceK.MusicTypeK));
						foreach (MusicType mtChild in mt.Children)
						{
							musicQs.Add(new Q(Usr.Columns.FavouriteMusicTypeK, mtChild.K));
							musicQs.Add(new Q(UsrMusicTypeFavourite.Columns.MusicTypeK, mtChild.K));
						}
						musicQ = new Or((Q[])musicQs.ToArray(typeof(Q)));
					}

					Q restrictionQ = new Q(true);
					if (threadK > 0)
					{
						restrictionQ = new Q(ThreadUsr.Columns.UsrK, QueryOperator.IsNull, null);
					}
					else if (restrictionGroupK > 0)
					{
						restrictionQ = restrictionGroupQ;
					}

					q.QueryCondition = new And(
						new Q(Buddy.Columns.BuddyUsrK, Usr.Current.K),
						new Q(Buddy.Columns.FullBuddy, true),
						new Q(Buddy.Columns.CanBuddyInvite, true),
						musicQ,
						placeQ);
					if (restrictionGroupQ != null) q.QueryCondition = new And(q.QueryCondition, restrictionGroupQ);
					q.Columns = new ColumnSet(Usr.Columns.NickName, Usr.Columns.K, Usr.Columns.Pic, Usr.Columns.FacebookUID, Usr.Columns.Email);
					q.Distinct = true;
					q.OrderBy = new OrderBy(Usr.Columns.NickName);
					q.DistinctColumn = Usr.Columns.K;
					UsrSet us = new UsrSet(q);
					foreach (Usr u in us)
					{
						hash[u.NickName] = u.K;
					}

				}
				else if (item.IsNumeric())
				{
					int usrK = int.Parse(item);
					Usr usr = new Usr(usrK);
					if (usr.NickName == "")
					{
						hash["User" + usr.K] = usrK;
					}
					else
					{
						hash[usr.NickName] = usrK;
					}


				}
				else
				{
					throw new NotImplementedException();
				}
			}
			return hash;
		}
Exemplo n.º 18
0
		protected void AddAllNow_Click(object sender, System.EventArgs e)
		{

			Query q = new Query();
			Join j = new Join(
				Usr.BuddyUsrJoin,
				new TableElement(TablesEnum.UsrMusicTypeFavourite),
				QueryJoinType.Left,
				Usr.Columns.K,
				UsrMusicTypeFavourite.Columns.UsrK);
			q.TableElement = new Join(
				j,
				new TableElement(TablesEnum.UsrPlaceVisit),
				QueryJoinType.Left,
				Usr.Columns.K,
				UsrPlaceVisit.Columns.UsrK);

			if (ThreadK > 0)
			{
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.ThreadUsr),
					QueryJoinType.Left,
					new And(
						new Q(Usr.Columns.K, ThreadUsr.Columns.UsrK, true),
						new Q(ThreadUsr.Columns.ThreadK, ThreadK)
					)
				);

			}
			else if (RestrictionGroupK > 0)
			{
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.GroupUsr),
					QueryJoinType.Left,
					new And(
						new Q(Usr.Columns.K, GroupUsr.Columns.UsrK, true),
						new Q(GroupUsr.Columns.GroupK, RestrictionGroupK)
					)
				);
			}

			Q placeQ = new Q(true);
			if (!AddAllPlaceDrop.SelectedValue.Equals("0"))
			{
				placeQ = new Or(
					new Q(Usr.Columns.HomePlaceK, int.Parse(AddAllPlaceDrop.SelectedValue)),
					new Q(UsrPlaceVisit.Columns.PlaceK, int.Parse(AddAllPlaceDrop.SelectedValue)));
			}
			int musicTypeK = int.Parse(AddAllMusicDrop.SelectedValue);
			Q musicQ = new Q(true);
			if (musicTypeK > 1)
			{
				ArrayList musicQs = new ArrayList();
				MusicType mt = new MusicType(musicTypeK);
				musicQs.Add(new Q(Usr.Columns.FavouriteMusicTypeK, 1));
				musicQs.Add(new Q(UsrMusicTypeFavourite.Columns.MusicTypeK, 1));
				musicQs.Add(new Q(Usr.Columns.FavouriteMusicTypeK, musicTypeK));
				musicQs.Add(new Q(UsrMusicTypeFavourite.Columns.MusicTypeK, musicTypeK));
				foreach (MusicType mtChild in mt.Children)
				{
					musicQs.Add(new Q(Usr.Columns.FavouriteMusicTypeK, mtChild.K));
					musicQs.Add(new Q(UsrMusicTypeFavourite.Columns.MusicTypeK, mtChild.K));
				}
				musicQ = new Or((Q[])musicQs.ToArray(typeof(Q)));
			}

			Q restrictionQ = new Q(true);
			if (ThreadK > 0)
			{
				restrictionQ = new Q(ThreadUsr.Columns.UsrK, QueryOperator.IsNull, null);
			}
			else if (RestrictionGroupK > 0)
			{
				restrictionQ = RestrictionGroupQ;
			}

			q.QueryCondition = new And(
				new Q(Buddy.Columns.BuddyUsrK, Usr.Current.K),
				new Q(Buddy.Columns.FullBuddy, true),
				new Q(Buddy.Columns.CanBuddyInvite, true),
				restrictionQ,
				musicQ,
				placeQ);
			q.Columns = new ColumnSet(Usr.Columns.NickName, Usr.Columns.K, Usr.Columns.Pic, Usr.Columns.FacebookUID);
			q.Distinct = true;
			q.OrderBy = new OrderBy(Usr.Columns.NickName);
			q.DistinctColumn = Usr.Columns.K;
			UsrSet us = new UsrSet(q);
			int duplicate = 0;
			int done = 0;
			foreach (Usr u in us)
			{
				bool yes = this.AddUsr(u);
				if (yes)
					done++;
				else
					duplicate++;
			}
			string selectedDuplicate = "";
			if (duplicate > 0)
				selectedDuplicate = us.Count.ToString("#,##0") + " " + (us.Count == 1 ? "buddy" : "buddies") + " selected\n" + duplicate.ToString("#,##0") + " of them " + (duplicate == 1 ? "was" : "were") + " already in the list\n";

			AlertMessageAll(selectedDuplicate + done.ToString("#,##0") + " " + (done == 1 ? "buddy" : "buddies") + " added");

			if (done > 0)
			{
				MoreButton.InnerText = "More...";
				ShowMore = false;
				SetVisibility();
			}

			if (AnchorSkip.Length > 0)
				((Spotted.Master.DsiPage)Page).AnchorSkip(AnchorSkip);

		}
Exemplo n.º 19
0
        public void PrefsUpdateClick(object o, System.EventArgs e)
		{
			string PreviousUrlFilterPart = ThisUsr.UrlFilterPart;
			ChangePanel(PrefsUpdatePanel);
			Page.Validate();
			//bool doUpdate = false;
			bool sendVerifyEmail = false;
			if (Page.IsValid)
			{
				if (ThisUsr.Email != Email.Text)
				{
					//Email has changed - check email

					//Check for duplicates email addresses in the database
					UsrSet ds = new UsrSet(new Query(new Q(Usr.Columns.Email, Email.Text)));

					if (ds.Count == 0)
					{
						//No duplicate - update email address
						ThisUsr.AdminNote += "\nThis user changed their email address from " + ThisUsr.Email + " to " + Email.Text + " on " + DateTime.Now.ToString();
						ThisUsr.Email = Email.Text;
						ThisUsr.EmailDateTime = DateTime.Now;
						if (HttpContext.Current != null)
							ThisUsr.EmailIp = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);
						ThisUsr.IsEmailVerified = false;
						ThisUsr.IsEmailBroken = false;
						sendVerifyEmail = true;
						//doUpdate = true;
					}
					else
					{
						//Duplicate - display error
						emailDuplicateValidator.IsValid = false;
					}
				}
				Regex rNumbers = new Regex("[^0123456789]");
				string mobileNumber = rNumbers.Replace(MobileNumber.Text.Trim(), "");
				string dialingCode = rNumbers.Replace(DialingCodeDropDown.SelectedValue, "");
				string dialingCodeOther = rNumbers.Replace(DialingCodeOther.Text.Trim(), "");
				string fullMobile = "";
				if (mobileNumber.StartsWith("0"))
				{
					mobileNumber = mobileNumber.Substring(1);
				}
				if (dialingCode.Equals("0"))
				{
					dialingCode = dialingCodeOther;
				}
				if (mobileNumber.Length > 0)
				{
					fullMobile = dialingCode + mobileNumber;
				}
				if (MobileNumber.Text != mobileNumber)
					MobileNumber.Text = mobileNumber;
				if (DialingCodeDropDown.SelectedValue.Equals("0") && DialingCodeOther.Text != dialingCode)
					DialingCodeOther.Text = dialingCode;

				string nick = Usr.GetCompliantNickName(NickName.Text);
                if (ThisUsr.NickName != nick && nick.ToUpper().Contains("-DSI") && !ThisUsr.IsAdmin)
                {
                    throw new DsiUserFriendlyException("Invalid user name. Please try another.");
                }

				//Database will only update if all validators are valid and doUpdate has been set to true by a change
				if (Page.IsValid)
				{
					ThisUsr.FirstName = Cambro.Web.Helpers.StripHtml(FirstName.Text);
					ThisUsr.LastName = Cambro.Web.Helpers.StripHtml(LastName.Text);
					if (NickName.Text.Length > 20)
                        throw new DsiUserFriendlyException("Nickname must be 20 chars or less!");

					ThisUsr.NickName = nick;

					if (!ThisUsr.Mobile.Equals(fullMobile))
						ThisUsr.AdminNote += "\n\nUsr has changed mobile number from " + ThisUsr.Mobile + " to: " + fullMobile + " on " + DateTime.Now.ToString() + ".\n";

					ThisUsr.Mobile = fullMobile;
					ThisUsr.MobileCountryCode = dialingCode;
					ThisUsr.MobileNumber = mobileNumber;

					ThisUsr.AddressArea = Cambro.Web.Helpers.StripHtml(AddressAreaTextBox.Text);
					ThisUsr.AddressPostcode = Cambro.Web.Helpers.StripHtml(AddressPostcodeTextBox.Text);
					ThisUsr.AddressCountryK = Convert.ToInt32(AddressCountryDropDownList.SelectedValue);
					ThisUsr.AddressCounty = Cambro.Web.Helpers.StripHtml(AddressCountyTextBox.Text);
					ThisUsr.AddressStreet = Cambro.Web.Helpers.StripHtml(AddressStreetTextBox.Text);
					ThisUsr.AddressTown = Cambro.Web.Helpers.StripHtml(AddressTownTextBox.Text);
					
					ThisUsr.IsMale = SexMale.Checked;
					ThisUsr.IsFemale = SexFemale.Checked;
					ThisUsr.IsDj = IsDjYes.Checked;
					ThisUsr.DateOfBirth = new DateTime(int.Parse(DateOfBirthYear.Text), int.Parse(DateOfBirthMonth.Text), int.Parse(DateOfBirthDay.Text));
					
					//Place p = new Place(int.Parse(HomeTownDropDownList.SelectedValue));
					Place p = HomeTownPlacePicker.Place;
					if (ThisUsr.HomePlaceK != p.K)
					{
						ThisUsr.HomePlaceK = p.K;

						ThisUsr.Home = null;

						try
						{
							UsrPlaceVisit upv = new UsrPlaceVisit(ThisUsr.K, p.K);
						}
						catch
						{
							UsrPlaceVisit upv = new UsrPlaceVisit();
							upv.UsrK = ThisUsr.K;
							upv.PlaceK = p.K;
							upv.Update();
						}
						ThisUsr.UpdatePlacesVisitCount(false);
					}
					
					if (ThisUsr.K == Usr.Current.K && !ThisUsr.IsOfLegalDrinkingAgeInHomeCountry)
						Prefs.Current.Remove("Drink");

					bool changeMusicPref = false;
					MusicType mt = new MusicType(int.Parse(FavouriteMusicDropDownList.SelectedValue));
					if (ThisUsr.FavouriteMusicTypeK != mt.K)
					{
						changeMusicPref = true;
						ThisUsr.FavouriteMusicTypeK = mt.K;
					}

					if (sendVerifyEmail)
					{
						ThisUsr.LoginString = Cambro.Misc.Utility.GenRandomText(6);
					}

					ThisUsr.Update();
					Usr.Current = null;

					if (changeMusicPref)
					{
						if (ThisUsr.K == Usr.Current.K)
							Prefs.Current["MusicPref"] = mt.K;

						try
						{
							UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite(ThisUsr.K, mt.K);
						}
						catch
						{
							UsrMusicTypeFavourite newMtf = new UsrMusicTypeFavourite();
							newMtf.UsrK = ThisUsr.K;
							newMtf.MusicTypeK = mt.K;
							newMtf.Update();
						}
						ThisUsr.UpdateMusicTypesFavouriteCount(true);
					}


					SuccessDiv.Visible = true;
					if (sendVerifyEmail)
					{
						Mailer mail = new Mailer();
						mail.Subject = "You changed your DontStayIn registered email address...";
						mail.Body = @"<h1>You changed your email address...</h1><p>Please click the following link to verify your email address and allow posting to our discussion boards:</p>
<p align=""center"" style=""padding:8px 0px 9px 0px;""><a href=""[LOGIN]"" style=""font-size:14px;font-weight:bold;"">Click here to verify your email</a></p>";
						mail.To = ThisUsr.Email;
						mail.UsrRecipient = ThisUsr;
						mail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						mail.SendEvenIfUnverifiedOrBroken = true;
						mail.Send();
					}
					if (Request.QueryString["Url"] != null && Request.QueryString["Url"].Length > 0)
						Response.Redirect(Request.QueryString["Url"]);
					else
						Response.Redirect(ThisUsr.UrlApp("edit") + "?done=1");

					//if (!PreviousUrlFilterPart.Equals(ThisUsr.UrlFilterPart))
						//Response.Redirect(ThisUsr.UrlApp("edit"));
				}
			}
		}