예제 #1
0
		public PlaceStub[] GetSurroundingPlaces(int centredOnPlaceK, int numberOfPlacesToGet)
		{
			numberOfPlacesToGet = numberOfPlacesToGet < 100 ? numberOfPlacesToGet : 100;


			Place p = new Place(centredOnPlaceK);
			Query q = new Query();
			q.QueryCondition = new Q(Place.Columns.Enabled, true);
			q.OrderBy = p.NearestPlacesOrderBy;
			q.TopRecords = numberOfPlacesToGet;
			PlaceSet ps = new PlaceSet(q);
			return ps.Select(place => GetPlaceStub(place)).ToArray();
		}
예제 #2
0
		public static Venue Add(Usr currentUsr, string name, int? capacity, int placeK, string postcode, bool? regularEvents, Guid? duplicateGuid, string safeDetailsString)
		{
			Venue v = new Venue();


			v.AddedDateTime = DateTime.Now;
			v.Name = Cambro.Web.Helpers.StripHtml(name);
			v.Postcode = Cambro.Web.Helpers.StripHtml(postcode);
			Place selectedPlace = new Place(placeK);
			v.PlaceK = selectedPlace.K;
			v.Capacity = capacity ?? 0;
			v.RegularEvents = regularEvents ?? false;
			v.DetailsHtml = safeDetailsString;
			v.DuplicateGuid = duplicateGuid ?? Guid.NewGuid();

			v.AdminNote += "Venue added by owner " + DateTime.Now.ToString();
			v.OwnerUsrK = currentUsr.K;

			if (!currentUsr.IsSuper)
			{
				v.IsNew = true;
				v.ModeratorUsrK = Usr.GetEventModeratorUsrK();
			}

			v.Update();
			v.CreateUniqueUrlName(false);
			v.UpdateUrlFragment(false);
			v.Update();
			return v;
		}
예제 #3
0
		public void ChangePlace(int NewPlaceK, bool UpdateChildUrlFragments)
		{
			if (this.PlaceK!=NewPlaceK)
			{
				Place OldPlace = this.Place;
				Place NewPlace = new Place(NewPlaceK);
				
				Update uThreads = new Update();
				uThreads.Table = TablesEnum.Thread;
				uThreads.Where = new Q(Thread.Columns.VenueK,this.K);
				uThreads.Changes.Add(new Assign(Thread.Columns.PlaceK,NewPlace.K));
				uThreads.Changes.Add(new Assign(Thread.Columns.CountryK,NewPlace.CountryK));
				uThreads.Run();

				Update uArticle = new Update();
				uArticle.Table = TablesEnum.Article;
				uArticle.Where = new Q(Article.Columns.VenueK,this.K);
				uArticle.Changes.Add(new Assign(Article.Columns.PlaceK,NewPlace.K));
				uArticle.Changes.Add(new Assign(Article.Columns.CountryK, NewPlace.CountryK));
				uArticle.Run();

				this.PlaceK = NewPlace.K;
				this.Update();

				OldPlace.UpdateTotalComments(null);
				OldPlace.UpdateTotalEvents(null);
				this.Place=null;
				this.UpdateTotalComments(null);
				
				Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Venue, this.K, UpdateChildUrlFragments);
				job.ExecuteAsynchronously();

				this.Place.UpdateTotalEvents(null);
			}
		}
예제 #4
0
		public string dsiTagReplacement(Match m)
		{
			string tagName = "dsi";
			try
			{
				//string[] arrParts = m.Groups[1].Value.Split[" "];
				//Dictionary<string, string> parts = new Dictionary<string, string>();
				SgmlReader sgml = new SgmlReader();
				string inStr = m.Groups[0].Value;
				if (inStr.StartsWith("<dsi:link"))
					inStr += "</dsi:link>";
				sgml.InputStream = new StringReader(inStr);
				sgml.DocType = "HTML";
				sgml.Read();

				tagName = sgml.Name;
				string uniqueId = Guid.NewGuid().ToString("N");

				#region Parse attributes
				Dictionary<string, string> attributes = new Dictionary<string, string>();
				while (sgml.MoveToNextAttribute())
				{
					attributes.Add(sgml.Name.ToLower(), sgml.Value);
				}
				#endregion

				string typeAtt = attributes.ContainsKey("type") ? attributes["type"] : null;
				string refAtt = attributes.ContainsKey("ref") ? attributes["ref"] : null;

				#region Parse styles
				Dictionary<string, string> style = new Dictionary<string, string>();
				if (attributes.ContainsKey("style"))
				{
					foreach (string s in attributes["style"].Split(';'))
					{
						try
						{
							if (s.Contains(":"))
								style[s.Split(':')[0].Trim()] = s.Split(':')[1].Trim();
						}
						catch
						{
						}
					}
				}
				#endregion

				#region Parse class
				List<string> classes = new List<string>();
				if (attributes.ContainsKey("class"))
				{
					foreach (string s in attributes["class"].Split(' '))
					{
						try
						{
							classes.Add(s);
						}
						catch
						{
						}
					}
				}
				#endregion

				if (tagName == "dsi:video")
				{
					#region dsi:video
					/*
					<dsi:video 
						type = [dsi | flv | youtube | google | metacafe | myspace | break | collegehumor | redtube | ebaumsworld | dailymotion] 
						ref = [dsi-photo-k | site-ref]
						src = [flv-url]
						width = [width] (optional)
						height = [height] (optional)
						nsfw = [true | false] (optional)
						/> 
					*/
					bool nsfw = attributes.ContainsKey("nsfw") ? bool.Parse(attributes["nsfw"].ToLower()) : false;
					string draw = attributes.ContainsKey("draw") ? attributes["draw"].ToLower() : "auto";
					if (typeAtt == "youtube")
					{
						#region youtube
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 425;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 355;

						//<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/8VtWo8tFdPQ&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/8VtWo8tFdPQ&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.youtube.com/v/" + refAtt + "&rel=1");
						#endregion
					}
					else if (typeAtt == "metacafe")
					{
						#region metacafe
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 400;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 345;

						//<embed src="http://www.metacafe.com/fplayer/1029494/how_to_make_fire_balls.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> </embed><br><font size = 1><a href="http://www.metacafe.com/watch/1029494/how_to_make_fire_balls/">How To Make Fire Balls</a> - <a href="http://www.metacafe.com/">The funniest videos clips are here</a></font>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.metacafe.com/fplayer/" + refAtt + ".swf");
						#endregion
					}
					else if (typeAtt == "google")
					{
						#region google
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 400;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 326;

						//<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-7477616603879486362&hl=en-GB" flashvars=""> </embed>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://video.google.com/googleplayer.swf?docId=" + refAtt + "&hl=en-GB");
						#endregion
					}
					else if (typeAtt == "flv")
					{
						#region flv
						string flvUrl = attributes.ContainsKey("src") ? attributes["src"] : null;
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
						int height = attributes.ContainsKey("height") ? (int.Parse(attributes["height"]) + 20) : 357;

						return GetFlash(uniqueId, height, width, nsfw, draw, "/misc/flvplayer.swf", "file", flvUrl, "autoStart", "0");
						#endregion
					}
					else if (typeAtt == "dsi")
					{
						#region dsi
						try
						{
							Photo p = new Photo(int.Parse(refAtt));
							if (p.MediaType != Photo.MediaTypes.Video)
							{
								return "[Invalid ref " + refAtt + " - this is not a video]";
							}
							else
							{
								if (p.ContentDisabled)
								{
									return "[Invalid ref " + refAtt + " - video disabled]";
								}
								else
								{
									if (p.Status == Photo.StatusEnum.Enabled)
									{
										//int width = p.VideoMedWidth;
										//int height = p.VideoMedHeight + 20;

										int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : p.VideoMedWidth;
										int height = attributes.ContainsKey("height") ? (int.Parse(attributes["height"]) + 20) : (p.VideoMedHeight + 20);

										return GetFlash(uniqueId, height, width, nsfw, draw, "/misc/flvplayer.swf", "file", p.VideoMedPath, "autoStart", "0", "jpg", p.WebPath);
									}
									else if (p.Status == Photo.StatusEnum.Moderate)
									{
										return "[Invalid ref " + refAtt + " - video waiting for moderation]";
									}
									else if (p.Status == Photo.StatusEnum.Processing)
									{
										return "[Invalid ref " + refAtt + " - video still processing]";
									}
								}
							}
						}
						catch
						{
							return "[Invalid ref " + refAtt + " - video not found]";
						}
						return "[Invalid ref " + refAtt + " - error]";
						#endregion
					}
					else if (typeAtt == "collegehumor")
					{
						#region collegehumor
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 337;

						//<object type="application/x-shockwave-flash" data="http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=1754304&fullscreen=1" width="480" height="360" ><param name="allowfullscreen" value="true" /><param name="movie" quality="best" value="http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=1754304&fullscreen=1" /></object>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=" + refAtt + "&fullscreen=1");
						#endregion
					}
					else if (typeAtt == "myspace")
					{
						#region myspace
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 430;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 346;

						//<embed src="http://lads.myspace.com/videos/vplayer.swf" flashvars="m=25330587&v=2&type=video" type="application/x-shockwave-flash" width="430" height="346"></embed>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://lads.myspace.com/videos/vplayer.swf", "m", refAtt, "v", "2", "type", "video");
						#endregion
					}
					else if (typeAtt == "break")
					{
						#region break
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 464;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 392;

						//<object width="464" height="392"><param name="movie" value="http://embed.break.com/NDMyNjg3"></param><embed src="http://embed.break.com/NDMyNjg3" type="application/x-shockwave-flash" width="464" height="392"></embed></object>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://embed.break.com/" + refAtt);
						#endregion
					}
					else if (typeAtt == "redtube")
					{
						#region redtube
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 434;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 344;

						//<object height="344" width="434"><param name="movie" value="http://embed.redtube.com/player/"><param name="FlashVars" value="id=2394&style=redtube"><embed src="http://embed.redtube.com/player/?id=2394&style=redtube" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="344" width="434"></object>
						return GetFlash(uniqueId, height, width, true, draw, "http://embed.redtube.com/player/?id=" + refAtt + "&style=redtube", "id", refAtt, "style", "redtube");
						#endregion
					}
					else if (typeAtt == "ebaumsworld")
					{
						#region ebaumsworld
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 425;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 345;

						//<embed src="http://www.ebaumsworld.com/mediaplayer.swf" flashvars="file=http://media.ebaumsworld.com/2008/01/trouble-leaving-parking-lot.flv&displayheight=321&image=http://media.ebaumsworld.com/2008/01/trouble-leaving-parking-lot.jpg" loop="false" menu="false" quality="high" bgcolor="#ffffff" width="425" height="345" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.ebaumsworld.com/mediaplayer.swf", "file", "http://media.ebaumsworld.com/" + refAtt + ".flv", "displayheight", (height - 24).ToString(), "image", "http://media.ebaumsworld.com/" + refAtt + ".jpg");
						#endregion
					}
					else if (typeAtt == "dailymotion")
					{
						#region dailymotion
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 420;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 331;

						//<div><object width="420" height="331"><param name="movie" value="http://www.dailymotion.com/swf/x3xmzx"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x3xmzx" type="application/x-shockwave-flash" width="420" height="331" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x3xmzx_time-attack-evo-crash-knockhill-200_auto">TIME ATTACK EVO CRASH KNOCKHILL 2007</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/TIMEATTACKTV">TIMEATTACKTV</a></i></div>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.dailymotion.com/swf/" + refAtt);
						#endregion
					}
					else if (typeAtt == "veoh")
					{
						return "[Veoh videos disabled]";
						#region veoh
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 365;

						//<embed src="http://www.veoh.com/videodetails2.swf?player=videodetailsembedded&type=v&permalinkId=v1644215kQ3H8PG2&id=anonymous" allowFullScreen="true" width="540" height="438" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed><br/><a href="http://www.veoh.com/">Online Videos by Veoh.com</a>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.veoh.com/videodetails2.swf?player=videodetailsembedded&type=v&permalinkId=" + refAtt + "&id=anonymous");
						#endregion
					}
					else
					{
						return "[Invalid type attribute]";
					}
					#endregion
				}
				else if (tagName == "dsi:audio")
				{
					#region dsi:audio
					/*
					<dsi:audio 
						type = [mp3]
						src = [mp3-url]
						nsfw = [true | false] (optional)
					/>
					*/
					if (typeAtt == "mp3")
					{
						#region mp3
						string mp3Url = attributes.ContainsKey("src") ? attributes["src"] : null;
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 290;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 24;

						string audioPlayerSwfPath = Storage.Path(new Guid("7abb3119-f8ad-43ff-be01-764b2ae111fc"), "swf", Storage.Stores.Pix);

						return GetFlash(uniqueId, height, width, false, "load", audioPlayerSwfPath, "soundFile", mp3Url, "autoStart", "no") +
								@"<a href=""" + mp3Url + @"""><img src=""/gfx/download-button2.png"" width=""73"" height=""16"" border=""0"" /></a>";
						#endregion
					}
					else
					{
						return "[Invalid type attribute]";
					}
					#endregion
				}
				else if (tagName == "dsi:flash")
				{
					#region dsi:flash
					/*
					<dsi:flash 
						src = [swf-url]
						width = [width] 
						height = [height]
						nsfw = [true | false] (optional)
						play = [true | false] (optional)
						loop = [true | false] (optional)
						menu = [true | false] (optional)
						quality = [low | autolow | autohigh | medium | high | best] (optional)
						scale = [default | noorder | exactfit] (optional)
						align = [l | t | r | b] (optional)
						salign = [l | t | r | b | tl | tr | bl | br] (optional)
						wmode = [window | opaque | transparent] (optional)
						bgcolor = [colour] (optional)
						base = [base-url] (optional)
						flashvars = [flashvars] (optional)
						/>
					*/
					string swfUrl = attributes.ContainsKey("src") ? attributes["src"] : null;
					return getFlashAttributesFromSgml(uniqueId, swfUrl, attributes);
					#endregion
				}
				else if (tagName == "dsi:quote")
				{
					#region dsi:quote
					Usr u = null;
					try
					{
						u = new Usr(int.Parse(refAtt));
					}
					catch { }

					if (u != null)
					{
						StringBuilder sb = new StringBuilder();
						sb.Append("<div class=\"QuoteName\">");
						sb.Append(u.Link());
						sb.Append(" said:");
						sb.Append("</div>");
						sb.Append("<div class=\"QuoteBody\">");
						return sb.ToString();
					}
					else
					{
						return "<div class=\"QuoteBody\">";
					}
					#endregion
				}
				else if (tagName == "dsi:object" || tagName == "dsi:link")
				{
					#region dsi:object, dsi:link
					/*
					<dsi:object
						type = [usr | event | venue | place | group | brand | photo | misc]
						ref = [object-k]
						style = [
							content: {text* | icon | text-under-icon};   // for type=usr, event, venue, place, group, brand
							details: {none* | venue | place | country};  // for type=event, venue, place
							date: {false* | true};                       // for type=event
							snip: {number};                              // for type=event
							rollover: {true* | false}                    // for type=usr, photo
							photo: {icon* | thumb | web}                 // for type=photo
							link: {true* | false}
						]
					/>
					*/

					string app = attributes.ContainsKey("app") ? (attributes["app"] == "home" ? null : attributes["app"]) : null;
					string date = attributes.ContainsKey("date") ? attributes["date"].Replace('-', '/') : null;
					string jump = attributes.ContainsKey("jump") ? "#" + attributes["jump"] : "";
					string parStr = attributes.ContainsKey("par") ? attributes["par"] : null;
					#region Decode par array
					string[] par = null;
					if (parStr != null)
					{
						List<string> parList = new List<string>();
						foreach (string s in parStr.Split('&'))
						{
							if (s.Contains("="))
							{
								parList.Add(System.Web.HttpUtility.UrlDecode(s.Split('=')[0]));
								parList.Add(System.Web.HttpUtility.UrlDecode(s.Split('=')[1]));
							}
							else
							{
								parList.Add(System.Web.HttpUtility.UrlDecode(s));
								parList.Add("");
							}
						}
						par = parList.ToArray();
					}
					#endregion

					string styleContent = style.ContainsKey("content") ? style["content"] : "text";
					string styleDetails = style.ContainsKey("details") ? style["details"] : "none";
					bool styleDate = style.ContainsKey("date") ? bool.Parse(style["date"]) : false;
					int styleSnip = style.ContainsKey("snip") ? int.Parse(style["snip"]) : 0;
					bool styleRollover = style.ContainsKey("rollover") ? bool.Parse(style["rollover"]) : true;
					string stylePhoto = style.ContainsKey("photo") ? style["photo"] : "icon";
					bool styleLink = style.ContainsKey("link") ? bool.Parse(style["link"]) : true;

					string extraHtmlAttributes = "";
					string extraStyleAttribute = "";
					string extraStyleElements = "";
					string extraClassAttribute = "";
					string extraClassElements = "";
					foreach (string k in attributes.Keys)
					{
						if (k != "href" && k != "src" && k != "type" && k != "ref" && k != "style" && k != "app" && k != "date" && k != "par" && k != "class")
						{
							extraHtmlAttributes += " " + k + "=\"" + attributes[k] + "\"";
						}
					}

					foreach (string s in style.Keys)
					{
						if (s != "content" && s != "details" && s != "date" && s != "snip" && s != "rollover" && s != "photo" && s != "link")
						{
							extraStyleElements += s + ":" + style[s] + ";";
						}
					}
					if (extraStyleElements.Length > 0)
					{
						extraStyleAttribute = " style=\"" + extraStyleElements + "\"";
					}

					foreach (string s in classes)
					{
						extraClassElements += " " + s;
					}
					if (extraClassElements.Length > 0)
					{
						extraClassAttribute = " class=\"" + extraClassElements + "\"";
					}

					if (typeAtt == "usr")
					{
						#region Usr
						Usr u = new Usr(int.Parse(refAtt));
						string url = getObectPageUrl(u, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						string rolloverHtml = styleRollover ? ((styleContent == "icon" || styleContent == "text-under-icon") ? u.RolloverNoPic : u.Rollover) : "";

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(rolloverHtml);
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(u.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");
							if (styleLink)
								sb.Append("</a>");
							if (styleContent == "text-under-icon")
								sb.Append("<br />");
							#endregion
						}
						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Nickname
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(rolloverHtml);
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append(getObjectName(u.NickNameDisplay, app, styleSnip));
							if (styleLink)
								sb.Append("</a>");
							#endregion
						}
						return sb.ToString();
						#endregion
					}
					else if (typeAtt == "event")
					{
						#region Event
						Event e = new Event(int.Parse(refAtt));
						string url = getObectPageUrl(e, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDate || styleDetails == "venue" || styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("<span");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(e.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");

							if (styleLink)
								sb.Append("</a>");

							if (styleContent == "text-under-icon")
								sb.Append("<br />");

							#endregion
						}
						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Event link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}

							sb.Append(getObjectName(e.Name, app, styleSnip));

							if (styleLink)
								sb.Append("</a>");
							#endregion

							#region Venue link
							if (styleDetails == "venue" || styleDetails == "place" || styleDetails == "country")
							{
								sb.Append(" @ ");
								if (styleLink)
								{
									sb.Append("<a href=\"");
									sb.Append(e.Venue.Url());
									sb.Append("\"");
									sb.Append(extraHtmlAttributes);
									sb.Append(extraStyleAttribute);
									sb.Append(extraClassAttribute);
									sb.Append(">");
								}
								sb.Append(Cambro.Misc.Utility.Snip(e.Venue.Name, styleSnip));
								if (styleLink)
									sb.Append("</a>");
							}
							#endregion

							#region Place link
							if (styleDetails == "place" || styleDetails == "country")
							{
								sb.Append(" in ");
								if (styleLink)
								{
									sb.Append("<a href=\"");
									sb.Append(e.Venue.Place.Url());
									sb.Append("\"");
									sb.Append(extraHtmlAttributes);
									sb.Append(extraStyleAttribute);
									sb.Append(extraClassAttribute);
									sb.Append(">");
								}
								if (styleDetails == "country")
								{
									sb.Append(Cambro.Misc.Utility.Snip(e.Venue.Place.Name, styleSnip));
								}
								else
								{
									sb.Append(Cambro.Misc.Utility.Snip(e.Venue.Place.NamePlain, styleSnip));
								}
								if (styleLink)
									sb.Append("</a>");

							}
							#endregion

							#region Date
							if (styleDate)
							{
								sb.Append(", ");
								sb.Append(e.FriendlyDate(false));
							}
							#endregion
						}

						#region End container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDetails == "venue" || styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("</span>");
						}
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "venue")
					{
						#region Venue
						Venue v = new Venue(int.Parse(refAtt));
						string url = getObectPageUrl(v, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("<span");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(v.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");
							if (styleLink)
								sb.Append("</a>");

							if (styleContent == "text-under-icon")
								sb.Append("<br />");
							#endregion
						}

						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Venue link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}

							sb.Append(getObjectName(v.Name, app, styleSnip));

							if (styleLink)
								sb.Append("</a>");
							#endregion

							#region Place link
							if (styleDetails == "place" || styleDetails == "country")
							{
								sb.Append(" in ");
								if (styleLink)
								{
									sb.Append("<a href=\"");
									sb.Append(v.Place.Url());
									sb.Append("\"");
									sb.Append(extraHtmlAttributes);
									sb.Append(extraStyleAttribute);
									sb.Append(extraClassAttribute);
									sb.Append(">");
								}
								if (styleDetails == "country")
								{
									sb.Append(Cambro.Misc.Utility.Snip(v.Place.Name, styleSnip));
								}
								else
								{
									sb.Append(Cambro.Misc.Utility.Snip(v.Place.NamePlain, styleSnip));
								}
								if (styleLink)
									sb.Append("</a>");
							}
							#endregion
						}

						#region End container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("</span>");
						}
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "place")
					{
						#region Place
						Place p = new Place(int.Parse(refAtt));
						string url = getObectPageUrl(p, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0))
						{
							sb.Append("<span");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(p.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								if (style.ContainsKey("border"))
								{
									sb.Append(extraClassAttribute);
								}
								else
								{
									sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								}
								
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");
							if (styleLink)
								sb.Append("</a>");
							if (styleContent == "text-under-icon")
								sb.Append("<br />");
							#endregion
						}

						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Place link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							if (styleDetails == "country")
							{
								sb.Append(getObjectName(p.Name, app, styleSnip));
							}
							else
							{
								sb.Append(getObjectName(p.NamePlain, app, styleSnip));
							}
							if (styleLink)
								sb.Append("</a>");
							#endregion
						}

						#region End container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0))
						{
							sb.Append("</span>");
						}
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "group")
					{
						#region Group
						Group g = new Group(int.Parse(refAtt));
						string url = getObectPageUrl(g, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Group link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						sb.Append(getObjectName(g.FriendlyName, app, styleSnip));
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "brand")
					{
						#region Brand
						Brand b = new Brand(int.Parse(refAtt));
						string url = getObectPageUrl(b, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Brand link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						sb.Append(getObjectName(b.FriendlyName, app, styleSnip));
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "photo")
					{
						#region Photo
						Photo p = new Photo(int.Parse(refAtt));
						string url = getObectPageUrl(p, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (app != null && app == "chat")
						{
							#region For chat app, just show the name of the parent...
							sb.Append(Cambro.Misc.Utility.Snip(((IName)p.ParentObject).Name, styleSnip) + " (chat)");
							#endregion
						}
						else
						{
							#region Image tag
							sb.Append("<img");

							#region Src attribute
							sb.Append(" src=\"");
							if (stylePhoto == "thumb")
								sb.Append(p.ThumbPath);
							else if (stylePhoto == "icon")
								sb.Append(p.IconPath);
							else if (stylePhoto == "web")
								sb.Append(p.WebPath);
							sb.Append("\"");
							#endregion

							#region Width attribute
							if (styleLink || !attributes.ContainsKey("width"))
							{
								sb.Append(" width=\"");
								if (stylePhoto == "thumb")
									sb.Append(p.ThumbWidth);
								else if (stylePhoto == "icon")
									sb.Append("100");
								else if (stylePhoto == "web")
									sb.Append(p.WebWidth);
								sb.Append("\"");
							}
							#endregion

							#region Height attribute
							if (styleLink || !attributes.ContainsKey("height"))
							{
								sb.Append(" height=\"");
								if (stylePhoto == "thumb")
									sb.Append(p.ThumbHeight);
								else if (stylePhoto == "icon")
									sb.Append("100");
								else if (stylePhoto == "web")
									sb.Append(p.WebHeight);
								sb.Append("\"");
							}
							#endregion

							#region Extra html attributes
							if (!styleLink)
							{
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
							}
							#endregion

							#region Style attribute
							if (styleLink)
							{
								
								sb.Append(" class=\"BorderBlack All\"");
							}
							else if (style.ContainsKey("border"))
							{
								sb.Append(extraClassAttribute);
							}
							else
							{
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
							}
							#endregion

							#region Rollover
							if (styleRollover && stylePhoto != "web")
							{
								sb.Append(" onmouseover=\"stm('<img src=" + p.WebPath + " width=" + p.WebWidth + " height=" + p.WebHeight + " class=Block />');\" onmouseout=\"htm();\"");
							}
							#endregion

							sb.Append(" />");
							#endregion
						}

						#region End link
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "misc")
					{
						#region Misc
						Misc mi = new Misc(int.Parse(refAtt));

						if (tagName == "dsi:link")
							return "<a href=\"" + mi.Url() + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						if (mi.Extention.ToLower() == "jpg" || mi.Extention.ToLower() == "jpeg" || mi.Extention.ToLower() == "gif" || mi.Extention.ToLower() == "png")
						{
							StringBuilder sb = new StringBuilder();

							#region Width and height
							int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : mi.Width;
							int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : mi.Height;
							#endregion

							#region Image tag
							sb.Append("<img src=\"");
							sb.Append(mi.Url());
							sb.Append("\" width=\"");
							sb.Append(width);
							sb.Append("\" height=\"");
							sb.Append(height);
							sb.Append("\" border=\"0\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(" />");
							#endregion

							return sb.ToString();

						}
						else if (mi.Extention.ToLower() == "swf")
						{
							#region Swf
							return getFlashAttributesFromSgml(uniqueId, mi.Url(), attributes);
							#endregion
						}
						#endregion
					}
					else if (typeAtt == "article")
					{
						#region Article
						Article a = new Article(int.Parse(refAtt));
						string url = getObectPageUrl(a, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Article link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						sb.Append(getObjectName(a.FriendlyName, app, styleSnip));
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "url") //if (attributes.ContainsKey("href"))
					{
						#region Url
						string url = attributes.ContainsKey("href") ? attributes["href"] : "";
						#region Get name
						string name = url;
						string path = url;
						string domain = url;
						string targetAttribute = "";
						try
						{
							if (UrlRegex.IsMatch(url))
							{
								Match urlMatch = UrlRegex.Match(url);
								if (urlMatch.Groups[3].Value.StartsWith("www."))
									name = urlMatch.Groups[3].Value.Substring(4);
								else
									name = urlMatch.Groups[3].Value;

								domain = urlMatch.Groups[3].Value;
								path = urlMatch.Groups[4].Value;
								if (!domain.ToLower().EndsWith(".dontstayin.com") && !attributes.ContainsKey("target"))
									targetAttribute = " target=\"_blank\"";

							}
						}
						catch
						{ }
						#endregion

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + targetAttribute + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						if (path.ToLower().EndsWith(".jpg") || path.ToLower().EndsWith(".jpeg") || path.ToLower().EndsWith(".gif") || path.ToLower().EndsWith(".png"))
						{
							#region Image tag
							sb.Append("<img");

							#region Src attribute
							sb.Append(" src=\"");
							sb.Append(url);
							sb.Append("\"");
							#endregion

							sb.Append(extraHtmlAttributes);

							#region Style attribute
							if (domain.EndsWith(".dontstayin.com") && !style.ContainsKey("border"))
							{
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
							}
							else
							{
								sb.Append(extraClassAttribute);
							}
							#endregion

							sb.Append(extraStyleAttribute);

							sb.Append(" />");
							#endregion
						}
						else if (path.ToLower().EndsWith(".mp3") || path.ToLower().EndsWith(".wav"))
						{
							#region Audio
							int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 290;
							int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 24;
							string audioPlayerSwfPath = Storage.Path(new Guid("7abb3119-f8ad-43ff-be01-764b2ae111fc"), "swf", Storage.Stores.Pix);
							return GetFlash(uniqueId, height, width, false, "load", audioPlayerSwfPath, "soundFile", url, "autoStart", "no") +
								@"<a href=""" + url + @"""><img src=""/gfx/download-button2.png"" width=""73"" height=""16"" border=""0"" /></a>";
							#endregion
						}
						else if (path.ToLower().EndsWith(".swf"))
						{
							#region Swf
							return getFlashAttributesFromSgml(uniqueId, path, attributes);
							#endregion
						}
						else if (path.ToLower().EndsWith(".flv"))
						{
							#region Flv
							int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
							int height = attributes.ContainsKey("height") ? (int.Parse(attributes["height"]) + 20) : 357;
							bool nsfw = attributes.ContainsKey("nsfw") ? bool.Parse(attributes["nsfw"].ToLower()) : false;
							string draw = attributes.ContainsKey("draw") ? attributes["draw"].ToLower() : "auto";
							return GetFlash(uniqueId, height, width, nsfw, draw, "/misc/flvplayer.swf", "file", url, "autoStart", "0");
							#endregion
						}
						else
						{
							#region Link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(targetAttribute);
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							#endregion
							#region Name
							sb.Append(name);
							#endregion
							#region End link
							if (styleLink)
								sb.Append("</a>");
							#endregion
						}

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "room")
					{
						#region Chat room
						Guid guid = refAtt.UnPackGuid();
						Chat.RoomSpec room = Chat.RoomSpec.FromGuid(guid);

						if (room == null)
							return "[Room not found]";
						
						StringBuilder sb = new StringBuilder();
						
						if (tagName == "dsi:link")
							room.LinkHtmlAppendJustStartOfAnchorTag(sb, "selected-onyellow", extraHtmlAttributes, extraStyleAttribute, extraClassAttribute);
						else
							room.LinkHtmlAppend(sb, "selected-onyellow", extraHtmlAttributes, extraStyleAttribute, extraClassAttribute);

						return sb.ToString();

						#endregion
					}
					#endregion
				}
				return "[Invalid tag " + tagName + "]";
			}
			catch (Exception ex)
			{
				if (Vars.DevEnv)
					throw ex;

				return "[Error in " + tagName + " tag]";
			}
		}
예제 #5
0
		PlaceStub GetPlaceStub(Place place)
		{
			return new PlaceStub() { k = place.K, lat = place.Lat, lng = place.Lon, name = place.FriendlyName };
		}
예제 #6
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			Usr.KickUserIfNotLoggedIn("You must be logged in to view your user preferences.");
			if (!Page.IsPostBack && !Usr.Current.IsSkeleton && !Vars.DevEnv)
				throw new DsiUserFriendlyException("You can't view this page, you've already completed your details");

			LogOffButton.Attributes["onclick"] = "return confirm('Are you sure?');";
			UnsubscribeButton.Attributes["onclick"] = "return confirm('Are you sure?');";
			EmailRegex.ValidationExpression = Cambro.Misc.RegEx.Email;
			DialingCodeDropDown.Attributes["onclick"] = "if (document.forms[0].elements['" + DialingCodeDropDown.ClientID + "'][document.forms[0].elements['" + DialingCodeDropDown.ClientID + "'].selectedIndex].value=='0') {document.getElementById('" + DialingCodeOtherSpan.ClientID + "').style.display=''}else{document.getElementById('" + DialingCodeOtherSpan.ClientID + "').style.display='none'}";

			#region Set up page... don't show options 2 and 3 to people who have come from the sign-up page unless they have verified their email

			WelcomeHeaderInvite.Visible = !Usr.Current.IsSkeletonFromSignup;
			WelcomeHeaderSignUp.Visible = Usr.Current.IsSkeletonFromSignup;

			if (ContainerPage.Url[0] == "Signup")
			{
				WelcomePart2And3.Visible = false;
				WelcomePart1Header.Visible = false;
			}

			//if (Usr.Current.IsSkeletonFromSignup && !Usr.Current.IsEmailVerified)
			//{
				//WelcomePart2And3.Visible = false;
				//WelcomePart1Header.Visible = false;
			//}
			#endregion

			if (!Page.IsPostBack)
			{
				string text = Cambro.Misc.Utility.GenRandomChars(5).ToUpper();
				string encryptedText = Cambro.Misc.Utility.Encrypt(text, DateTime.Now.AddHours(1));
				this.ViewState["HipChallengeExcryptedText"] = encryptedText;
				HipImage.Src = "/support/hipimage.aspx?a=" + encryptedText;
			}

			#region Auto add group / buddy
			uiAddedByGroupsDiv.Visible = false;
			uiAddedByUsrsDiv.Visible = false;
			try
			{
				int groupsCount = Usr.Current.GroupsWhoHavePendingInvitationsForMe.Count;
				if (groupsCount > 0)
				{
					uiAddedByGroupsDiv.Visible = true;

					if (groupsCount == 1)
					{
						uiAddedByGroupLabel.Text = "<b>" + Usr.Current.GroupsWhoHavePendingInvitationsForMe[0].FriendlyName + "</b> group";
					}
					else
					{
						uiAddedByGroupLabel.Text = "following groups";
					}

					int height = 36 + Math.Min(groupsCount, 2) * 60 + 20;
					uiAddedByGroupsDiv.Attributes["style"] = "border-top:3px solid #000000;padding-top:10px;padding-bottom:10px; height:" + height + "; overflow:auto;";

					foreach (GridViewRow gvr in uiAddedByGroupsGridView.Rows)
					{
						if (!((CheckBox)gvr.FindControl("uiCheckBox")).Checked) uncheckedGroupKs.Add((int)uiAddedByGroupsGridView.DataKeys[gvr.RowIndex].Value);
					}
					uiAddedByGroupsGridView.DataSource = Usr.Current.GroupsWhoHavePendingInvitationsForMe;
					uiAddedByGroupsGridView.DataBind();
				}
				int usrsCount = Usr.Current.UsrsWhoHavePendingBuddyRequestsForMe.Count;
				if (usrsCount > 0)
				{
					if (usrsCount == 1)
					{
						uiAddedByUsrLabel.Text = "<b>" + Usr.Current.UsrsWhoHavePendingBuddyRequestsForMe[0].NickName + "</b>";
					}
					else
					{
						uiAddedByUsrLabel.Text = "the following people";
					}

					int height = 36 + Math.Min(usrsCount, 2) * 60 + 20;
					uiAddedByUsrsDiv.Attributes["style"] = "border-top:3px solid #000000;padding-top:10px;padding-bottom:10px; height:" + height + "; overflow:auto;";

					foreach (GridViewRow gvr in uiAddedByUsrsGridView.Rows)
					{
						if (!((CheckBox)gvr.FindControl("uiCheckBox")).Checked) uncheckedBuddyUsrKs.Add((int)uiAddedByUsrsGridView.DataKeys[gvr.RowIndex].Value);
					}
					uiAddedByUsrsDiv.Visible = true;
					uiAddedByUsrsGridView.DataSource = Usr.Current.UsrsWhoHavePendingBuddyRequestsForMe;
					uiAddedByUsrsGridView.DataBind();

				}
			}
			catch
			{
				uiAddedByGroupsDiv.Visible = false;
				uiAddedByUsrsDiv.Visible = false;
			}
			#endregion

			#region Populate hometown drop-down
			int selectedHomeTown = 0;
			if (!HomeTownDropDownList.SelectedValue.Equals("0") && !HomeTownDropDownList.SelectedValue.Equals(""))
				selectedHomeTown = int.Parse(HomeTownDropDownList.SelectedValue);

			//	OrderBy o = new OrderBy(Bobs.Place.Columns.Name,OrderBy.OrderDirection.Ascending);

			if (!Page.IsPostBack)
			{
				PlaceSet ts = new PlaceSet(
					new Query(
						new And(
						new Q(Place.Columns.Enabled, true),
						Country.PlaceFilterQ),
						new OrderBy(Bobs.Place.Columns.Name, OrderBy.OrderDirection.Ascending)
					)
				);
				HomeTownDropDownList.DataSource = ts;
				HomeTownDropDownList.DataValueField = "K";
				HomeTownDropDownList.DataTextField = "Name";
				HomeTownDropDownList.DataBind();
			}

			if (selectedHomeTown > 0)
			{
				try
				{
					HomeTownDropDownList.SelectedValue = selectedHomeTown.ToString();
				}
				catch
				{
					try
					{
						Place p = new Place(selectedHomeTown);
						HomeTownDropDownList.Items.Insert(1, new ListItem(p.Name, p.K.ToString()));
						HomeTownDropDownList.SelectedValue = selectedHomeTown.ToString();
					}
					catch { }
				}
			}
			#endregion

			#region Populate favourite music drop-down
			int selectedFavouriteMusic = 0;
			if (!FavouriteMusicDropDownList.SelectedValue.Equals("0") && !FavouriteMusicDropDownList.SelectedValue.Equals(""))
				selectedFavouriteMusic = int.Parse(FavouriteMusicDropDownList.SelectedValue);


			if (!Page.IsPostBack)
			{
				MusicTypeSet mts = new MusicTypeSet(
					new Query(
						new Or(
						new Q(MusicType.Columns.ParentK, 1),
						new Q(MusicType.Columns.ParentK, 0)
						)
						,
						new OrderBy(MusicType.Columns.Order)
					)
				);
				FavouriteMusicDropDownList.DataSource = mts;
				FavouriteMusicDropDownList.DataValueField = "K";
				FavouriteMusicDropDownList.DataTextField = "DescriptiveText";
				FavouriteMusicDropDownList.DataBind();
			}

			if (selectedFavouriteMusic > 0)
			{
				FavouriteMusicDropDownList.SelectedValue = selectedFavouriteMusic.ToString();
			}

			#endregion

			if (!Page.IsPostBack)
			{
				FirstName.Text = Usr.Current.FirstName;
				LastName.Text = Usr.Current.LastName;
				NickName.Text = Usr.Current.NickName;
				Email.Text = Usr.Current.Email;
				SexMale.Checked = Usr.Current.IsMale;
				SexFemale.Checked = Usr.Current.IsFemale;
				SendSpottedEmails.Checked = Usr.Current.SendSpottedEmails;
				SendSpottedTexts.Checked = Usr.Current.SendSpottedTexts;
				SendFlyers.Checked = Usr.Current.SendFlyers;
				SendInvites.Checked = Usr.Current.SendInvites;
				IsDjYes.Checked = Usr.Current.IsDj.HasValue && Usr.Current.IsDj.Value;
				IsDjNo.Checked = Usr.Current.IsDj.HasValue && !Usr.Current.IsDj.Value;



				#region Initialise hometown drop-down
				if (Usr.Current.HomePlaceK > 0)
				{
					try
					{
						HomeTownDropDownList.SelectedValue = Usr.Current.HomePlaceK.ToString();
					}
					catch
					{
						HomeTownDropDownList.Items.Insert(1, new ListItem(Usr.Current.Home.Name, Usr.Current.HomePlaceK.ToString()));
						HomeTownDropDownList.SelectedValue = Usr.Current.HomePlaceK.ToString();
					}
				}
				#endregion
				#region Initialise favourite music drop-down
				if (Usr.Current.FavouriteMusicTypeK > 0)
				{
					FavouriteMusicDropDownList.SelectedValue = Usr.Current.FavouriteMusicTypeK.ToString();
				}
				#endregion
				#region Initialise mobile number box
				if (Usr.Current.Mobile.Length > 0)
				{
					if (
						Usr.Current.MobileCountryCode.Equals("44") ||
						Usr.Current.MobileCountryCode.Equals("61") ||
						Usr.Current.MobileCountryCode.Equals("33") ||
						Usr.Current.MobileCountryCode.Equals("49") ||
						Usr.Current.MobileCountryCode.Equals("353") ||
						Usr.Current.MobileCountryCode.Equals("39") ||
						Usr.Current.MobileCountryCode.Equals("34") ||
						Usr.Current.MobileCountryCode.Equals("1")
						)
					{
						DialingCodeDropDown.SelectedValue = Usr.Current.MobileCountryCode;
						DialingCodeOtherSpan.Style["display"] = "none";
					}
					else
					{
						DialingCodeDropDown.SelectedValue = "0";
						DialingCodeOtherSpan.Style["display"] = null;
						DialingCodeOther.Text = Usr.Current.MobileCountryCode;
					}
					MobileNumber.Text = Usr.Current.MobileNumber;
				}
				else
				{
					if (Country.Current != null && Country.Current.DialingCode > 0)
					{
						DialingCodeDropDown.SelectedValue = Country.Current.DialingCode.ToString();
						DialingCodeOtherSpan.Style["display"] = "none";
					}
					else
					{
						DialingCodeDropDown.SelectedValue = "0";
						DialingCodeOtherSpan.Style["display"] = null;
					}
				}
				#endregion

			}

			DialingCodeOtherSpan.Style["display"] = DialingCodeDropDown.SelectedValue.Equals("0") ? null : "none";

			this.DataBind();
			if (!Page.IsPostBack)
			{
				HomeTownDropDownList.Items.Insert(0, new ListItem(" ", "0"));
				FavouriteMusicDropDownList.Items.Insert(0, new ListItem(" ", "0"));
			}
		}
예제 #7
0
		public void PanelDetailsLoad(object o, System.EventArgs e)
		{
			bool passedPlaceHasPostcode = false;
			if (ContainerPage.Url["PlaceK"].IsInt)
			{
				Place passedPlace = new Place(ContainerPage.Url["PlaceK"]);
				if (passedPlace.Country.PostcodeType == 1)
					passedPlaceHasPostcode = true;
			}

			if (IsEdit)
			{
				PanelDetailsPostcodeDiv.Visible = CurrentVenue.Place.Country.PostcodeType == 1 || passedPlaceHasPostcode;
			}
			else
			{
				PanelDetailsPostcodeDiv.Visible = (Country.Current != null && Country.Current.PostcodeType == 1) || passedPlaceHasPostcode;
			}

			if (CanEditPlace)
			{
				PanelDetailsPlaceDiv.Visible = true;
				PanelDetailsPlaceLockedDiv.Visible = false;

				if (!Page.IsPostBack)
				{
					Query q = new Query();
					q.NoLock = true;
					q.Columns = new ColumnSet(Place.Columns.K, Place.Columns.Name, Place.Columns.CountryK, Place.Columns.RegionAbbreviation);
					q.QueryCondition = new And(Country.PlaceFilterQ, new Q(Place.Columns.Enabled, true));
					q.OrderBy = new OrderBy(Place.Columns.Name);
					PlaceSet ts = new PlaceSet(q);
					
					Place placeToSelect = null;
					if (IsEdit)
					{
						placeToSelect = CurrentVenue.Place;
					}
					else if (ContainerPage.Url["PlaceK"].IsInt)
					{
						placeToSelect = new Place(ContainerPage.Url["PlaceK"]);
					}
					if (placeToSelect != null)
					{
						PanelDetailsPlacePicker.Place = placeToSelect;
					}
				}
			}
			else
			{
				PanelDetailsPlacePicker.Place = CurrentVenue.Place;

				PanelDetailsPlaceDiv.Visible = false;
				PanelDetailsPlaceLockedDiv.Visible = true;

				PanelDetailsPlaceLockedLabel.Text = CurrentVenue.Place.Name;
			}
			if (IsEdit)
			{

			}
			if (IsEdit && !Page.IsPostBack)
			{

				PanelDetailsPostcodeTextBox.Text = CurrentVenue.Postcode;
				PanelDetailsVenueName.Text = CurrentVenue.Name;
				PanelDetailsVenueCapacity.Text = CurrentVenue.Capacity.ToString();
				PanelDetailsVenueDetailsHtml.LoadHtml(CurrentVenue.DetailsHtml);
				PanelDetailsVenueRegularEventsYes.Checked = CurrentVenue.RegularEvents;
				PanelDetailsVenueRegularEventsNo.Checked = !CurrentVenue.RegularEvents;
			}
		}
예제 #8
0
		public static IBob Get(Model.Entities.ObjectType type, int k)
		{
			IBob b = null;
			bool wrongType = false;
			try
			{
				switch (type)
				{
					case Model.Entities.ObjectType.Photo:
						b = new Photo(k);
						break;
					case Model.Entities.ObjectType.Event:
						b = new Event(k);
						break;
					case Model.Entities.ObjectType.Venue:
						b = new Venue(k);
						break;
					case Model.Entities.ObjectType.Place:
						b = new Place(k);
						break;
					case Model.Entities.ObjectType.Thread:
						b = new Thread(k);
						break;
					case Model.Entities.ObjectType.Country:
						b = new Country(k);
						break;
					case Model.Entities.ObjectType.Article:
						b = new Article(k);
						break;
					case Model.Entities.ObjectType.Para:
						b = new Para(k);
						break;
					case Model.Entities.ObjectType.Brand:
						b = new Brand(k);
						break;
					case Model.Entities.ObjectType.Promoter:
						b = new Promoter(k);
						break;
					case Model.Entities.ObjectType.Usr:
						b = new Usr(k);
						break;
					case Model.Entities.ObjectType.Region:
						b = new Region(k);
						break;
					case Model.Entities.ObjectType.Gallery:
						b = new Gallery(k);
						break;
					case Model.Entities.ObjectType.Group:
						b = new Group(k);
						break;
					case Model.Entities.ObjectType.Banner:
						b = new Banner(k);
						break;
					case Model.Entities.ObjectType.GuestlistCredit:
						b = new GuestlistCredit(k);
						break;
					case Model.Entities.ObjectType.Ticket:
						b = new Ticket(k);
						break;
					case Model.Entities.ObjectType.Invoice:
						b = new Invoice(k);
						break;
					case Model.Entities.ObjectType.InsertionOrder:
						b = new InsertionOrder(k);
						break;
					case Model.Entities.ObjectType.CampaignCredit:
						b = new CampaignCredit(k);
						break;
					case Model.Entities.ObjectType.UsrDonationIcon:
						b = new UsrDonationIcon(k);
						break;
					default:
						wrongType = true;
						b = null;
						break;
				}
			}
			catch { }
			if (wrongType)
				throw new Exception("Bob.Get attempted to get " + type.ToString() + " - can't do it!!! DUH!");
			return b;
		}
예제 #9
0
		public void PanelLocation_Val(object o, ServerValidateEventArgs e)
		{
			Country c = new Country();
			bool validRadio = LocationTypeNone.Checked || LocationTypeCountry.Checked || LocationTypePlace.Checked;
			bool validCountry = true;
			bool validPlace = true;
			int selectedCountryK = 0;
			if (LocationTypeCountry.Checked || LocationTypePlace.Checked)
			{
				try
				{
					Country country = new Country(int.Parse(LocationCountryDropDown.SelectedValue));
					if (!country.Enabled)
						validCountry = false;
					selectedCountryK = country.K;
				}
				catch
				{
					validCountry = false;
				}
			}
			if (LocationTypePlace.Checked)
			{
				try
				{
					Place place = new Place(int.Parse(LocationPlaceDropDown.SelectedValue));
					if (!place.Enabled)
						validPlace = false;
					if (selectedCountryK != place.CountryK)
						validPlace = false;
				}
				catch
				{
					validPlace = false;
				}
			}
			e.IsValid = validRadio && validCountry && validPlace;
		}
예제 #10
0
		protected void Page_Load(object sender, EventArgs e)
		{
			StringBuilder sb = new StringBuilder();
		//	if (Vars.DevEnv)
		//		System.Threading.Thread.Sleep(new Random().Next(2000));

			if (Request.QueryString["type"] == "calendar")
			{
				bool freeGuestlist = Request.QueryString["freeGuestlist"] == null || Request.QueryString["freeGuestlist"].Length == 0 || Request.QueryString["freeGuestlist"] == "0" ? false : true;
				Brand brand = Request.QueryString["brandk"] == null || Request.QueryString["brandk"].Length == 0 || Request.QueryString["brandk"] == "0" ? null : new Brand(int.Parse(Request.QueryString["brandk"]));
				Place place = Request.QueryString["placek"] == null || Request.QueryString["placek"].Length == 0 || Request.QueryString["placek"] == "0" ? null : new Place(int.Parse(Request.QueryString["placek"]));
				Venue venue = Request.QueryString["venuek"] == null || Request.QueryString["venuek"].Length == 0 || Request.QueryString["venuek"] == "0" || Request.QueryString["venuek"] == "1" ? null : new Venue(int.Parse(Request.QueryString["venuek"]));
				int key = Request.QueryString["key"] == null || Request.QueryString["key"].Length == 0 || Request.QueryString["key"] == "0" ? 0 : int.Parse(Request.QueryString["key"]);
				MusicType music = Request.QueryString["musictypek"] == null || Request.QueryString["musictypek"].Length == 0 || Request.QueryString["musictypek"] == "0" ? null : new MusicType(int.Parse(Request.QueryString["musictypek"]));
				bool me = Request.QueryString["me"] != null && Request.QueryString["me"] == "1";
				bool addGalleryButton = Request.QueryString["addgallery"] != null && Request.QueryString["addgallery"] == "1";
				bool allVenues = Request.QueryString["venuek"] != null && Request.QueryString["venuek"] == "1";
				DateTime date = new DateTime(
					int.Parse(Request.QueryString["date"].Substring(0, 4)),
					int.Parse(Request.QueryString["date"].Substring(4, 2)),
					int.Parse(Request.QueryString["date"].Substring(6, 2)) > 0 ? int.Parse(Request.QueryString["date"].Substring(6, 2)) : 1 );
				//if (date == DateTime.Today)
				//	System.Threading.Thread.Sleep(1000);
				DateTime from = date.Previous(DayOfWeek.Monday, true);
				DateTime to = date.Next(DayOfWeek.Sunday, true);
				Event.EventsForDisplay events = new Event.EventsForDisplay();
				events.IgnoreMusicType = true;

				if (me)
				{
					events.AttendedUsrK = Usr.Current.K;
				}
				else if (brand != null)
				{
					events.BrandK = brand.K;
				}
				else if (venue != null)
				{
					events.VenueK = venue.K;
				}
				else if (place != null && music != null)
				{
					events.PlaceK = place.K;
					events.MusicTypeK = music.K;
				}
				else if (place != null && freeGuestlist)
				{
					events.PlaceK = place.K;
					events.FreeGuestlist = freeGuestlist;
				}
				else if (key > 0)
				{

				}
				else
					throw new Exception();

				

				EventSet es;
				if (key == 0)
					es = events.GetEventsBetweenDates(from, to);
				else
					es = new EventSet(new Query(new Q(Event.Columns.K, key)));

				CustomControls.DsiCalendar calendar = new Spotted.CustomControls.DsiCalendar();

				calendar.AllEvents = es;
				calendar.Month = date.Month;
				
				calendar.ShowCountryFriendlyName = !(events.FilterByCountry || events.FilterByPlace || events.FilterByVenue);
				calendar.ShowPlace = !(events.FilterByPlace || events.FilterByVenue);
				calendar.ShowVenue = !events.FilterByVenue;
				calendar.ShowAddGalleryButton = addGalleryButton;

				calendar.Tickets = true;
				calendar.StartDate = from;
				calendar.EndDate = to;

				Out.Controls.Add(calendar);
				
			}
			else
			{
				sb.AppendLine("{");
				if (Request.QueryString["type"] == "music")
				{
					#region Music types

					Query q = new Query();
					q.QueryCondition = new Q(MusicType.Columns.K, QueryOperator.NotEqualTo, 1);
					q.Columns = new ColumnSet(MusicType.Columns.Name, MusicType.Columns.ParentK, MusicType.Columns.K);
					q.OrderBy = new OrderBy(MusicType.Columns.Order, OrderBy.OrderDirection.Ascending);
					q.CacheDuration = TimeSpan.FromDays(1);
					MusicTypeSet mts = new MusicTypeSet(q);
					append(sb, "Select your music...", "0");
					append(sb, "", "");
					foreach (MusicType mt in mts)
					{
						append(sb, (mt.ParentK == 1 ? "" : "... ") + mt.Name, mt.K.ToString());
					}

					#endregion
				}
				else if (Request.QueryString["type"] == "country")
				{
					#region Countries

					append(sb, "Select a country...", "0");
					Query qTop = new Query();
					qTop.Columns = new ColumnSet(Country.Columns.FriendlyName, Country.Columns.K);
					qTop.OrderBy = new OrderBy(Country.Columns.TotalEvents, OrderBy.OrderDirection.Descending);
					qTop.QueryCondition = new Q(Country.Columns.Enabled, true);
					qTop.TopRecords = 10;
					qTop.CacheDuration = TimeSpan.FromDays(1);
					CountrySet csTop = new CountrySet(qTop);
					append(sb, "", "");
					append(sb, "--- TOP COUNTRIES ---", "0");
					foreach (Country c in csTop)
					{
						append(sb, c.FriendlyName.TruncateWithDots(maxLength), c.K.ToString());
					}
					Query qAll = new Query();
					qAll.Columns = new ColumnSet(Country.Columns.FriendlyName, Country.Columns.K);
					qAll.OrderBy = new OrderBy(Country.Columns.FriendlyName);
					qAll.QueryCondition = new And(new Q(Country.Columns.Enabled, true), new StringQueryCondition("(SELECT COUNT(*) FROM [Place] WHERE [Place].[Enabled] = 1 AND [Place].[CountryK] = [Country].[K]) > 0"));
					qAll.CacheDuration = TimeSpan.FromDays(1);
					CountrySet csAll = new CountrySet(qAll);
					append(sb, "", "");
					append(sb, "--- ALL COUNTRIES ---", "0");
					foreach (Country c in csAll)
					{
						append(sb, c.FriendlyName.TruncateWithDots(maxLength), c.K.ToString());
					}

					#endregion
				}
				else if (Request.QueryString["type"] == "place")
				{
					#region Places

					int countryK = int.Parse(Request.QueryString["countryk"]);
					Country country = new Country(countryK);

					Query qTop = new Query();
					qTop.Columns = new ColumnSet(Place.Columns.Name, Place.Columns.K, Place.LinkColumns);
					qTop.TopRecords = 10;
					qTop.QueryCondition = new And(new Q(Place.Columns.CountryK, country.K), new Q(Place.Columns.Enabled, true));
					qTop.OrderBy = new OrderBy(Place.Columns.TotalEvents, OrderBy.OrderDirection.Descending);
					PlaceSet psTop = new PlaceSet(qTop);
					if (psTop.Count == 0)
					{
						append(sb, "No towns in our database for this country", "");
					}
					else
					{
						append(sb, "Towns in " + country.FriendlyName.Truncate(maxLength) + "...", "");
						append(sb, "", "");
						if (psTop.Count < 10)
						{
							foreach (Place p in psTop)
								append(sb, p.NamePlainRegion.TruncateWithDots(maxLength), Request.QueryString["return"] == "k" ? p.K.ToString() : p.Url());
						}
						else
						{
							append(sb, "--- TOP TOWNS ---", "");

							foreach (Place p in psTop)
								append(sb, p.NamePlainRegion.TruncateWithDots(maxLength), Request.QueryString["return"] == "k" ? p.K.ToString() : p.Url());

							Query qAll = new Query();
							qAll.Columns = new ColumnSet(Place.Columns.Name, Place.Columns.K, Place.LinkColumns);
							qAll.OrderBy = new OrderBy(Place.Columns.UrlName);
							qAll.QueryCondition = new And(new Q(Place.Columns.CountryK, countryK), new Q(Place.Columns.Enabled, true));
							PlaceSet psAll = new PlaceSet(qAll);
							append(sb, "", "");
							append(sb, "--- ALL TOWNS ---", "");

							foreach (Place p in psAll)
								append(sb, p.NamePlainRegion.TruncateWithDots(maxLength), Request.QueryString["return"] == "k" ? p.K.ToString() : p.Url());

						}
					}
					#endregion
				}
				else if (Request.QueryString["type"] == "venue")
				{
					#region Venues

					int placeK = int.Parse(Request.QueryString["placek"]);
					Place place = new Place(placeK);

					Query qTop = new Query();
					qTop.Columns = new ColumnSet(Venue.Columns.Name, Venue.Columns.K, Venue.LinkColumns);
					qTop.TopRecords = 10;
					qTop.QueryCondition = new Q(Venue.Columns.PlaceK, place.K);
					qTop.OrderBy = new OrderBy(Venue.Columns.TotalEvents, OrderBy.OrderDirection.Descending);
					VenueSet vsTop = new VenueSet(qTop);
					if (vsTop.Count == 0)
					{
						append(sb, "No venues in our database for this town", "");
					}
					else
					{
						append(sb, "Venues in " + place.NamePlainRegion.Truncate(maxLength) + "...", "");
						append(sb, "", "");
						if (Request.QueryString["all"] == "1")
						{
							append(sb, "All venues", "1");
							append(sb, "", "");
						}
						if (vsTop.Count < 10)
						{
							appendVenues(sb, vsTop);
						}
						else
						{
							append(sb, "--- TOP VENUES ---", "");

							appendVenues(sb, vsTop);

							Query qAll = new Query();
							qAll.Columns = new ColumnSet(Venue.Columns.Name, Venue.Columns.K, Venue.LinkColumns);
							qAll.OrderBy = new OrderBy("( CASE WHEN [Venue].[UrlName] LIKE 'the-%' THEN SUBSTRING([Venue].[UrlName], 4, LEN([Venue].[UrlName]) - 4) ELSE [Venue].[UrlName] END )");
							qAll.QueryCondition = new Q(Venue.Columns.PlaceK, placeK);
							VenueSet vsAll = new VenueSet(qAll);
							append(sb, "", "");
							append(sb, "--- ALL VENUES ---", "");

							if (vsAll.Count <= 300)
							{
								appendVenues(sb, vsAll);

							}
							else
							{
								append(sb, "Select the first letter:", "");
								append(sb, "", "");
								append(sb, "0-9", "*0");

								string ch;
								for (int i = 65; i <= 90; i++)
								{
									ch = char.ConvertFromUtf32(i);
									append(sb, ch.ToUpper() + "...", "*" + ch.ToLower());

								}
							}
						}
					}
					#endregion
				}
				else if (Request.QueryString["type"] == "venuebyletter")
				{
					#region Venues

					int placeK = int.Parse(Request.QueryString["placek"]);
					string letter = Request.QueryString["letter"];
					if (letter.Length > 1)
						throw new Exception();
					Place place = new Place(placeK);

					string qu = "";
					if (letter.ToLower() == "0")
					{
						qu = "([Venue].[UrlName] LIKE '[0-9]%' OR [Venue].[UrlName] LIKE 'the-[0-9]%')";
					}
					else if (letter.ToLower() == "t")
					{
						qu = "(([Venue].[UrlName] LIKE 't%' AND [Venue].[UrlName] NOT LIKE 'the-%' ) OR [Venue].[UrlName] LIKE 'the-t%')";
					}
					else
					{
						qu = "([Venue].[UrlName] LIKE '" + letter.ToLower() + "%' OR [Venue].[UrlName] LIKE 'the-" + letter.ToLower() + "%')";
					}
					Query q = new Query();
					q.Columns = new ColumnSet(Venue.Columns.Name, Venue.Columns.K, Venue.LinkColumns);
					//q.OrderBy = new OrderBy(Venue.Columns.UrlName);
					q.OrderBy = new OrderBy("( CASE WHEN [Venue].[UrlName] LIKE 'the-%' THEN SUBSTRING([Venue].[UrlName], 4, LEN([Venue].[UrlName]) - 4) ELSE [Venue].[UrlName] END )");
					q.QueryCondition = new And(
						new Q(Venue.Columns.PlaceK, placeK),
						new StringQueryCondition(qu));
					VenueSet vs = new VenueSet(q);


					if (vs.Count == 0)
					{
						append(sb, "No venues starting with " + letter.ToUpper(), "");
					}
					else
					{
						append(sb, "Venues starting with " + letter.ToUpper() + "...", "");
						append(sb, "", "");

						appendVenues(sb, vs);
					}
					#endregion
				}
				else if (Request.QueryString["type"] == "event")
				{
					#region Events

					int venueK = int.Parse(Request.QueryString["venuek"]);
					int brandK = int.Parse(Request.QueryString["brandk"]);
					int key = int.Parse(Request.QueryString["key"]);
					int year = int.Parse(Request.QueryString["date"].Substring(0, 4));
					int month = int.Parse(Request.QueryString["date"].Substring(4, 2));
					DateTime dateFrom = new DateTime(year, month, 1);
					DateTime dateTo = dateFrom.AddMonths(1);
					Venue venue = venueK > 1 ? new Venue(venueK) : null;
					Brand brand = brandK > 0 ? new Brand(brandK) : null;

					EventSet es;
					if (key == 0)
					{
						Query q = new Query();
						if (brand == null)
							q.Columns = new ColumnSet(Event.Columns.DateTime, Event.Columns.Name, Event.Columns.K);
						else
							q.Columns = new ColumnSet(Event.Columns.DateTime, Event.Columns.Name, Event.Columns.K, Event.FriendlyLinkColumns);
						q.QueryCondition = new And(
							new Q(Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, dateFrom),
							new Q(Event.Columns.DateTime, QueryOperator.LessThan, dateTo),
							venue != null ? new Q(Event.Columns.VenueK, venue.K) : new Q(true),
							brand != null ? new Q(EventBrand.Columns.BrandK, brand.K) : new Q(true));
						q.OrderBy = Event.FutureEventOrder;
						if (brandK > 0)
						{
							q.TableElement = new Join(
							Event.CountryAllJoin,
							new TableElement(TablesEnum.EventBrand),
							QueryJoinType.Inner,
							Event.Columns.K,
							EventBrand.Columns.EventK);
						}
						es = new EventSet(q);
					}
					else
						es = new EventSet(new Query(new Q(Event.Columns.K, key)));

					if (es.Count == 0)
					{
						append(sb, "No events in our database for this selection", "");
					}
					else
					{
						//append(sb, "Events at " + venue.FriendlyName.Truncate(maxLength) + ", " + dateFrom.ToString("MMM yyyy") + "...", "");
						//append(sb, "", "");
						Dictionary<string, int> counter = new Dictionary<string, int>();
						foreach (Event ev in es)
						{
							string key1 = eventString(ev, brand != null);
							if (counter.ContainsKey(key1.ToLower()))
								counter[key1.ToLower()]++;
							else
								counter[key1.ToLower()] = 1;
						}


						foreach (Event ev in es)
						{
							string key1 = eventString(ev, brand != null);
							if (counter[key1.ToLower()] > 1)
								key1 = key1.Substring(0, 8) + " - #" + ev.K.ToString() + key1.Substring(8);

							append(sb, key1, ev.K.ToString());
						}

					}
					#endregion
				}
				sb.AppendLine("");
				sb.Append("}");
			}

			Out.Controls.Add(new LiteralControl(sb.ToString()));
		}
예제 #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
		}
예제 #12
0
		static Place getPlaceFromString(string homeTownName, ref bool goodMatch)
		{
			if (homeTownName.Trim().Length == 0)
				return null;

			string placeName = "";
			string countryName = "";
			Place homePlace = null;
			Country homeCountry = null;

			#region split into country and place name
			if (homeTownName.Length > 0 && homeTownName.Contains(","))
			{
				placeName = homeTownName.Substring(0, homeTownName.LastIndexOf(',')).Trim();
				countryName = homeTownName.Substring(homeTownName.LastIndexOf(',') + 1).Trim();
			}
			else
			{
				placeName = homeTownName;
			}
			#endregion

			if (countryName.Length > 0)
			{
				#region get country by name
				CountrySet csName = new CountrySet(
					new Query(
						new Q(Country.Columns.Name, countryName.Trim())
					)
				);
				if (csName.Count > 0)
				{
					homeCountry = csName[0];
				}
				#endregion
				else
				{
					#region get country by friendly name (abbreviation)
					CountrySet csFriendlyName = new CountrySet(
						new Query(
							new Q(Country.Columns.FriendlyName, countryName.Trim())
						)
					);
					if (csFriendlyName.Count > 0)
					{
						homeCountry = csFriendlyName[0];
					}
					#endregion
				}
			}
			#region if we haven't found a country yet, use the IPcountry
			if (homeCountry == null)
			{
				try
				{
					homeCountry = new Country(IpCountry.ClientCountryK());
				}
				catch
				{
					homeCountry = new Country(224);
				}
			}
			#endregion

			if (placeName.Length > 0)
			{
				#region lookup enabled places in the home country
				PlaceSet psNameWithCountry = new PlaceSet(
					new Query(
						new And(
							new Q(Place.Columns.Name, placeName.Trim()),
							new Q(Place.Columns.CountryK, homeCountry.K),
							new Q(Place.Columns.Enabled, true)
						)
					)
				);
				if (psNameWithCountry.Count > 0)
				{
					homePlace = psNameWithCountry[0];
					goodMatch = true;
				}
				#endregion
				else
				{
					#region lookup non-enabled places and find the nearest enabled place
					PlaceSet psNameWithCountryNotEnalbed = new PlaceSet(
						new Query(
							new And(
								new Q(Place.Columns.Name, placeName.Trim()),
								new Q(Place.Columns.CountryK, homeCountry.K)
							)
						)
					);
					if (psNameWithCountryNotEnalbed.Count > 0)
					{
						PlaceSet ps = new PlaceSet(
							new Query(
								new Q(Place.Columns.Enabled, true),
								psNameWithCountryNotEnalbed[0].NearestPlacesOrderBy,
								1
							)
						);
						if (ps.Count > 0)
						{
							homePlace = ps[0];
							goodMatch = true;
						}
					}
					#endregion
					else
					{
						#region lookup global enabled places by name
						PlaceSet psName = new PlaceSet(
							new Query(
								new And(
									new Q(Place.Columns.Name, placeName.Trim()),
									new Q(Place.Columns.Enabled, true)
								),
								new OrderBy(Place.Columns.Population, OrderBy.OrderDirection.Descending),
								1
							)
						);
						if (psName.Count > 0)
						{
							homePlace = psName[0];
						}
						#endregion
						else
						{
							#region lookup global non-enabled places and find the nearest enabled place
							PlaceSet psNameNotEnalbed = new PlaceSet(
								new Query(
									new Q(Place.Columns.Name, placeName.Trim())
								)
							);
							if (psNameNotEnalbed.Count > 0)
							{
								PlaceSet ps = new PlaceSet(
									new Query(
										new Q(Place.Columns.Enabled, true),
										psNameNotEnalbed[0].NearestPlacesOrderBy,
										1
									)
								);
								if (ps.Count > 0)
								{
									homePlace = ps[0];
								}
							}
							#endregion
						}
					}
				}
			}
			#region if we haven't found a place yet, use the capital (or largest enabled place) from the home country. If all fails, use London.
			if (homePlace == null)
			{
				if (homeCountry != null)
				{
					homePlace = homeCountry.GetCapitalOrLargestEnabledPlace();
				}
			}

			if (homePlace == null)
				homePlace = new Place(1);
			#endregion

			return homePlace;
		}
예제 #13
0
		static Hashtable getHomePlaceFromFacebookInternal(JObject user)
		{

			bool locationGoodMatch = false;
			Place locationPlace = null;

			try
			{
				locationPlace = getPlaceFromString(user["location"].Value<string>("name"), ref locationGoodMatch);
			}
			catch { }

			bool homeTownGoodMatch = false;
			Place homeTownPlace = null;
			if (locationPlace == null || !locationGoodMatch)
			{
				try
				{
					homeTownPlace = getPlaceFromString(user["hometown"].Value<string>("name"), ref homeTownGoodMatch);
				}
				catch { }
			}

			Place place = null;
			bool goodMatch = false;
			if (locationPlace != null)
			{
				if (homeTownGoodMatch && !locationGoodMatch)
				{
					place = homeTownPlace;
					goodMatch = homeTownGoodMatch;
				}
				else
				{
					place = locationPlace;
					goodMatch = locationGoodMatch;
				}
			}
			else if (homeTownPlace != null)
			{
				place = homeTownPlace;
				goodMatch = homeTownGoodMatch;
			}
			else
			{
				place = new Place(1); // if all else fails, use London.
				goodMatch = false;
			}


			Hashtable ret = new Hashtable();
			ret["PlaceName"] = place.NamePlain;
			ret["CountryName"] = place.Country.FriendlyName;
			ret["PlaceK"] = place.K;
			ret["CountryK"] = place.CountryK;
			ret["GoodMatch"] = goodMatch;
			return ret;
		}
예제 #14
0
		public void CountUsrs_PlaceConditionsAndMusicConditionsAndPromotersOnly()
		{
			new Delete(TablesEnum.Usr, new Q(true)).Run();
			Place p = new Place
			{
				MeridianFeatureId = 1,
				Lat = 1,
				Lon = 1
			};
			p.Update();
			CreateUsr(0, 1, 1, 1); //no
			CreateUsr(1, 1, p.K, p.K, false); //no
			CreateUsr(1, p.K, 1, p.K, true); //yes
			CreateUsr(1, p.K, p.K, 1, false); //no
			CreateUsr(4, 1, p.K, p.K, false); //no
			CreateUsr(4, p.K, 1, p.K, false); //no
			CreateUsr(4, p.K, p.K, 1, true); //yes
			CreateUsr(5, 1, p.K, p.K, true); //yes
			CreateUsr(5, p.K, 1, p.K, true); //yes
			CreateUsr(5, p.K, p.K, 1, true); //yes
			CreateUsr(4, 2, p.K, p.K); //no
			CreateUsr(4, p.K, 2, p.K); //no
			CreateUsr(4, p.K, p.K, 2); //no
			CreateUsr(5, 2, p.K, p.K); //no
			CreateUsr(5, p.K, 2, p.K); //no
			CreateUsr(5, p.K, p.K, 2); //no

			Assert.AreEqual(5, Flyer.CountUsrs(new List<int>() { 1 }, new List<int>() { 4 }, true));
		}
예제 #15
0
		public void MergeAndDelete(Venue merge)
		{
			if (this.K == merge.K)
				throw new DsiUserFriendlyException("Can't merge a venue into itself!");

			Cambro.Web.Helpers.WriteAlertHeader();

			//throw new Exception("This function isn't finished yet!");

			Cambro.Web.Helpers.WriteAlert("Starting merge...", true);

			#region Promoter
			Cambro.Web.Helpers.WriteAlert("Merging promoter...", true);
			if (merge.PromoterK > 0 && merge.PromoterStatus.Equals(Venue.PromoterStatusEnum.Confirmed) && merge.Promoter.IsEnabled)
			{
				this.PromoterK = merge.PromoterK;
				this.PromoterStatus = Venue.PromoterStatusEnum.Confirmed;
			}
			else if (this.PromoterK == 0 && merge.PromoterK > 0)
			{
				this.PromoterK = merge.PromoterK;
				this.PromoterStatus = merge.PromoterStatus;
			}
			Cambro.Web.Helpers.WriteAlert("Done merging promoter...");
			#endregion

			#region Articles
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Moving articles...", true);
				Query q = new Query();
				q.QueryCondition = new And(new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Venue),new Q(Article.Columns.ParentObjectK, merge.K));
				ArticleSet ars = new ArticleSet(q);
				foreach (Article a in ars)
				{
					Cambro.Web.Helpers.WriteAlert("Moving article " + a.K + "...");
					a.ParentObjectK = this.K;
					a.VenueK = this.K;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place)
						a.PlaceK = this.PlaceK;
					else
						a.PlaceK = 0;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country)
						a.CountryK = this.Place.CountryK;
					else
						a.CountryK = 0;

					a.UrlFragment = this.UrlFilterPart;
					a.Update();

					#region Threads
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Thread;
						u.Where = new Q(Thread.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Thread.Columns.UrlFragment, a.UrlFilterPart));
						u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K));
						u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.PlaceK));
						u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Place.CountryK));
						u.Run();
					}
					#endregion
					#region Galleries
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Gallery;
						u.Where = new Q(Gallery.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
					#region Photos
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Photo;
						u.Where = new Q(Photo.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Photo.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
				}
				Cambro.Web.Helpers.WriteAlert("Done moving articles...", true);
			}
			#endregion

			#region Events
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Moving events...", true);
				EventSet es = new EventSet(new Query(new Q(Event.Columns.VenueK, merge.K)));
				int count = 0;
				foreach (Event ev in es)
				{
					count++;
					Cambro.Web.Helpers.WriteAlert("Moving event "+ev.K+" ("+count+" / "+es.Count+")...");
					ev.ChangeVenue(this.K, true);
				}
				Cambro.Web.Helpers.WriteAlert("Done moving events...");
			}
			#endregion

			#region Thread ParentObjects
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (1/2)...", true);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Venue),
					new Q(Thread.Columns.ParentObjectK, merge.K));
				u.Changes.Add(new Assign(Thread.Columns.ParentObjectK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (1/2)...");
			}
			#endregion

			#region Thread
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (2/2)...", true);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.VenueK, merge.K),
					new Q(Thread.Columns.EventK, 0),
					new Q(Thread.Columns.ArticleK, 0));
				u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K));
				u.Changes.Add(new Assign(Thread.Columns.UrlFragment, this.UrlFilterPart));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (2/2)...");
			}
			#endregion

			#region Pic
			if (!this.HasPic)
			{
				Cambro.Web.Helpers.WriteAlert("Merging picture...", true);
				this.Pic = merge.Pic;
				this.PicMiscK = merge.PicMiscK;
				this.PicPhotoK = merge.PicPhotoK;
				this.PicState = merge.PicState;
				merge.Pic = Guid.Empty;
				merge.PicMiscK = 0;
				merge.PicPhotoK = 0;
				merge.PicState = "";
				merge.Update();
				Cambro.Web.Helpers.WriteAlert("Done merging picture...");
			}
			#endregion

			this.AdminNote += "Venue " + merge.K + " was merged with this one " + DateTime.Now.ToString() + ". The admin note from venue " + merge.K + " is:\n********************\n" + merge.AdminNote + "\n********************\n";

			this.Update();

			int mergePlaceK = merge.PlaceK;

			Cambro.Web.Helpers.WriteAlert("Deleting old venue...", true);
			merge.DeleteAll(null);
			Cambro.Web.Helpers.WriteAlert("Done deleting old venue...");

			if (mergePlaceK != this.PlaceK)
			{
				Place mergePlace = new Place(mergePlaceK);
				Cambro.Web.Helpers.WriteAlert("Updating stats for old place...", true);
				mergePlace.UpdateTotalComments(null);
				mergePlace.UpdateTotalEvents(null);
				Cambro.Web.Helpers.WriteAlert("Done updating stats for old place...");
			}

			Cambro.Web.Helpers.WriteAlert("Updating stats for new venue...", true);
			this.UpdateTotalComments(null);
			this.UpdateTotalEvents(null);
			Cambro.Web.Helpers.WriteAlert("Done updating stats for new venue...");

			this.Update();
			Cambro.Web.Helpers.WriteAlert("Done merging venues!", true);


		}
예제 #16
0
		public static VenueSet SimilarVenuesStatic(string name, Place place, int excludeVenueK, string postCode)
		{
			//split name into words and get all > 3 chars...
			ArrayList al = new ArrayList();
			ArrayList commonWords = new ArrayList(Q.CommonWords);
			commonWords.Add("bar");
			commonWords.Add("club");
			string[] words = name.Split(' ');
			int wordsCount = 0;
			foreach (string word in words)
			{
				if (!commonWords.Contains(word.ToLower()) && word.Length>1)
				{
					al.Add(new Q(Columns.Name,QueryOperator.TextContains,word));
					wordsCount++;
				}
			}
			Q wordsOr = new Q(true);
			if (wordsCount>0)
				wordsOr = new Or((Q[])al.ToArray(typeof(Q)));
			else
				wordsOr = new Q(false);

			//10 nearest places also
			Query qPlaces = new Query();
			qPlaces.TopRecords=10;
			qPlaces.OrderBy=place.NearestPlacesOrderBy;
			PlaceSet ps = new PlaceSet(qPlaces);
			ArrayList al1 = new ArrayList();
			foreach (Place p in ps)
			{
				al1.Add(new Q(Columns.PlaceK,p.K));
			}
			Or placesOr = new Or((Q[])al1.ToArray(typeof(Q)));

			Q thisVenue = new Q(true);
			if (excludeVenueK>0)
				thisVenue = new Q(Columns.K,QueryOperator.NotEqualTo,excludeVenueK);

			Q postCodeQ = null;
			if (postCode.Length>0)
				postCodeQ = new Q(Columns.Postcode,postCode);
			else
				postCodeQ = new Q(false);

			Query qSimilar = new Query();
			qSimilar.QueryCondition = new And(new Or(new And(wordsOr, placesOr), postCodeQ), thisVenue);
			VenueSet vsSimilar = new VenueSet(qSimilar);
			return vsSimilar;



		
		}
예제 #17
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", ""));
				}
			}
		}
예제 #18
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (this.Visible)
			{
				if (Personalise)
					Usr.KickUserIfNotLoggedIn("You must be logged in to use the My Calendar or Buddy Calendar pages.");

				if (BuddyDisplay)
					selectTab(BuddyCalendarTab);
				else if (Personalise)
					selectTab(MyCalendarTab);
				//else
					//CalendarTab.Visible=true;


				HotTicketsIntroPanel.Visible = HotTickets;
				NotHotTicketsIntroPanel.Visible = !HotTickets;

				if (Personalise && !BuddyDisplay)
				{
					if (Usr.Current.MusicTypesFavouriteCount == 0)
						Response.Redirect("/pages/mymusic");
					if (Usr.Current.PlacesVisitCount == 0)
						Response.Redirect("/pages/placesivisit");
				}
				
				
				MusicTypeDropDownPanel.Visible = !Personalise && !(eventsForDisplay.FilterByVenue || eventsForDisplay.FilterByBrand || eventsForDisplay.FilterByGroup);
				MusicFilterLabel1.Visible = MusicTypeDropDownPanel.Visible;
				MusicFilterLabel2.Visible = MusicTypeDropDownPanel.Visible;
				if (eventsForDisplay.FilterByVenue || eventsForDisplay.FilterByBrand || eventsForDisplay.FilterByGroup)
					eventsForDisplay.IgnoreMusicType = true;

				#region //Set up intro panel
				if (HotTickets)
				{
					TopIcon.Src = "/gfx/icon-hottickets.png";
					EventFinderTab.InnerText = "Hot tickets";
					

					HotTicketsIntroPanelWorldwideP.Visible = eventsForDisplay.FilterWorldwide;
					HotTicketsIntroPanelBrandP.Visible = eventsForDisplay.FilterByBrand;
					HotTicketsIntroPanelNonBrandP.Visible = eventsForDisplay.FilterByVenue || eventsForDisplay.FilterByPlace || eventsForDisplay.FilterByCountry || eventsForDisplay.FilterByGroup;

					if (eventsForDisplay.FilterWorldwide)
					{
						HotTicketsIntroPanelWorldwideHomeCountryLink.InnerText = HotTicketsIntroPanelWorldwideHomeCountryLink.InnerText.Replace("???", Country.Current.FriendlyName);
						HotTicketsIntroPanelWorldwideHomeCountryLink.HRef = Country.Current.UrlApp("hottickets");
					}
				}
				else
				{
					AllEventsIntroPanel.Visible = eventsForDisplay.FilterWorldwide;
					ObjectCalendarIntroPanel.Visible = eventsForDisplay.FilterByVenue || eventsForDisplay.FilterByPlace || eventsForDisplay.FilterByCountry || eventsForDisplay.FilterByBrand || eventsForDisplay.FilterByGroup;
					MyCalendarIntroPanel.Visible = Personalise && !Tickets && !BuddyDisplay;
					BuddyCalendarIntroPanel.Visible = BuddyDisplay;
					TicketsCalendarIntroPanel.Visible = Personalise && Tickets;

					if (Tickets)
						TopIcon.Src = "/gfx/icon-tickets.png";
					else if (FreeGuestlist)
						TopIcon.Src = "/gfx/icon-freeguestlist.png";

					if (Tickets)
						EventFinderTab.InnerText = "Tickets";
					else if (FreeGuestlist)
						EventFinderTab.InnerText = "Free Guestlist";

					if (Tickets)
					{
						AllEventsIntroPanelEventsLabel1.Text = "events with tickets available";
						AllEventsIntroPanelEventsLabel2.Text = "events with tickets available";
						AllEventsIntroPanelEventsLabel3.Text = "events with tickets available";
					}
					else if (FreeGuestlist)
					{
						AllEventsIntroPanelEventsLabel1.Text = "Free Guestlist events";
						AllEventsIntroPanelEventsLabel2.Text = "Free Guestlist events";
						AllEventsIntroPanelEventsLabel3.Text = "Free Guestlist events";
					}
					else
					{
						AllEventsIntroPanelEventsLabel1.Text = "events";
						AllEventsIntroPanelEventsLabel2.Text = "events";
						AllEventsIntroPanelEventsLabel3.Text = "events";
					}

					AllEventsIntroPanelHomeCountryLink.InnerText = AllEventsIntroPanelHomeCountryLink.InnerText.Replace("???", Country.Current.FriendlyName);
					if (DateTime.Now.Month == Month && DateTime.Now.Year == Year && Day == 0)
						AllEventsIntroPanelHomeCountryLink.HRef = Country.Current.UrlCalendar(Tickets, FreeGuestlist);
					else
						AllEventsIntroPanelHomeCountryLink.HRef = Country.Current.UrlCalendarDay(Tickets, FreeGuestlist, Year, Month, Day);


				}
				#endregion


				string dateFilterString = "";

				if (HotTickets)
				{
					MonthViewPanel.Visible = false;
					DayViewPanel.Visible = false;
					HotTicketsEventListPanel.Visible = true;

					EventSet es = eventsForDisplay.GetTopHotTicketEvents();

					HotTicketsEventListNoEventsP.Visible = es.Count == 0;
					HotTicketsEventListEventsDiv.Visible = es.Count > 0;
					if (es.Count > 0)
					{
						HotTicketsEventList.DataSource = es;
						HotTicketsEventList.ItemTemplate = this.LoadTemplate("/Templates/Events/EventList0.ascx");
						HotTicketsEventList.DataBind();
					}
				}
				else if (Day == 0)
				{
					MonthViewPanel.Visible = true;
					DayViewPanel.Visible = false;
					HotTicketsEventListPanel.Visible = false;

					#region firstCellDate, lastCellDate
					DateTime firstOfMonth = new DateTime(Year, Month, 1);
					DateTime firstCellDate = firstOfMonth.Previous(DayOfWeek.Monday, true);

					DateTime lastOfMonth = firstOfMonth.AddDays(DateTime.DaysInMonth(Year, Month) - 1);
					DateTime lastCellDate = lastOfMonth.Next(DayOfWeek.Sunday, true);
					#endregion


					dateFilterString = firstOfMonth.ToString("MMMM yyyy");

					#region get event set
					EventSet es = eventsForDisplay.GetEventsBetweenDates(firstCellDate, lastCellDate);
					#endregion

					#region bind to calendar
					CustomControls.DsiCalendar uiCal = this.BuddyDisplay ? new CustomControls.BuddyCalendar() : new CustomControls.DsiCalendar();
					uiCalPlaceHolder.Controls.Add(uiCal);

					uiCal.ShowCountryFriendlyName = !(eventsForDisplay.FilterByCountry || eventsForDisplay.FilterByPlace || eventsForDisplay.FilterByVenue);
					uiCal.ShowPlace = !(eventsForDisplay.FilterByPlace || eventsForDisplay.FilterByVenue);
					uiCal.ShowVenue = !eventsForDisplay.FilterByVenue;
					uiCal.Tickets = Tickets;
					uiCal.Month = Month;
					uiCal.AllEvents = es;
					uiCal.StartDate = firstCellDate;
					uiCal.EndDate = lastCellDate;
					#endregion

					#region set up next / prev month links

					string nextMonthUrl = ChangeMonthUrl(lastOfMonth.AddDays(1).Month, lastOfMonth.AddDays(1).Year);
					string prevMonthUrl = ChangeMonthUrl(firstOfMonth.AddDays(-1).Month, firstOfMonth.AddDays(-1).Year);

					#region set up links
					uiCal.NextMonthUrl = nextMonthUrl;
					uiCal.PrevMonthUrl = prevMonthUrl;

					MonthNameLabel.Text = firstOfMonth.ToString("MMMM") + " " + Year.ToString();
					MonthNameLabel1.Text = firstOfMonth.ToString("MMMM") + " " + Year.ToString();

					BackLink.InnerHtml = "&lt; " + firstOfMonth.AddDays(-1).ToString("MMMM");
					BackLink1.InnerHtml = "&lt; " + firstOfMonth.AddDays(-1).ToString("MMMM");
					BackLink.HRef = prevMonthUrl;
					BackLink1.HRef = prevMonthUrl;

					NextLink.InnerHtml = lastOfMonth.AddDays(1).ToString("MMMM") + " &gt;";
					NextLink1.InnerHtml = lastOfMonth.AddDays(1).ToString("MMMM") + " &gt;";
					NextLink.HRef = nextMonthUrl;
					NextLink1.HRef = nextMonthUrl;
					#endregion

					if (uiCal.AllEvents.Count == 0)
					{
						Event latestPastEvent = eventsForDisplay.GetLatestPastEvent(firstOfMonth);
						if (latestPastEvent == null)
						{
							#region disable the back link if we have no past events
							BackLink.HRef = "";
							BackLink1.HRef = "";
							BackLink.Disabled = true;
							BackLink1.Disabled = true;
							#endregion
						}
						else
						{
							#region set up the back link with the month of the latest past event
							BackLink.HRef = ChangeMonthUrl(latestPastEvent.DateTime.Month, latestPastEvent.DateTime.Year);
							BackLink1.HRef = ChangeMonthUrl(latestPastEvent.DateTime.Month, latestPastEvent.DateTime.Year);
							BackLink.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("MMMM");
							BackLink1.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("MMMM");
							if (latestPastEvent.DateTime.Year != Year)
							{
								BackLink.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("MMMM") + " " + latestPastEvent.DateTime.Year.ToString();
								BackLink1.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("MMMM") + " " + latestPastEvent.DateTime.Year.ToString();
							}
							#endregion
						}

						Event nextFutureEvent = eventsForDisplay.GetNextFutureEvent(lastOfMonth);
						if (nextFutureEvent == null)
						{
							#region disable the forward link if we have no future events
							NextLink.HRef = "";
							NextLink1.HRef = "";
							NextLink.Disabled = true;
							NextLink1.Disabled = true;
							#endregion
						}
						else
						{
							#region set up the back link with the month of the first future event
							NextLink.HRef = ChangeMonthUrl(nextFutureEvent.DateTime.Month, nextFutureEvent.DateTime.Year);
							NextLink1.HRef = ChangeMonthUrl(nextFutureEvent.DateTime.Month, nextFutureEvent.DateTime.Year);
							NextLink.InnerHtml = nextFutureEvent.DateTime.ToString("MMMM") + " &gt;";
							NextLink1.InnerHtml = nextFutureEvent.DateTime.ToString("MMMM") + " &gt;";
							if (nextFutureEvent.DateTime.Year != Year)
							{
								NextLink.InnerHtml = nextFutureEvent.DateTime.ToString("MMMM") + " " + nextFutureEvent.DateTime.Year.ToString() + " &gt;";
								NextLink1.InnerHtml = nextFutureEvent.DateTime.ToString("MMMM") + " " + nextFutureEvent.DateTime.Year.ToString() + " &gt;";
							}
							#endregion
						}

						#region ensure links are fully disabled
						if (BackLink.Disabled)
							BackLink.Attributes["class"] = "DisabledAnchor";
						if (BackLink1.Disabled)
							BackLink1.Attributes["class"] = "DisabledAnchor";
						if (NextLink.Disabled)
							NextLink.Attributes["class"] = "DisabledAnchor";
						if (NextLink1.Disabled)
							NextLink1.Attributes["class"] = "DisabledAnchor";
						#endregion
					}
					#endregion
				}
				else
				{
					MonthViewPanel.Visible = false;
					DayViewPanel.Visible = true;
					HotTicketsEventListPanel.Visible = false;

					DateTime day = new DateTime(Year, Month, Day);
					dateFilterString = day.ToString("dddd dd MMMM yyyy");

					#region get event set
					EventSet es = eventsForDisplay.GetEventsForDay(day);
					#endregion

					DayViewNoEventsP.Visible = es.Count == 0;
					DayViewEventsDiv.Visible = es.Count > 0;
					if (es.Count > 0)
					{
						DayViewDataList.DataSource = es;

						if (es.Count < 20)
							DayViewDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/EventList0.ascx");
						else if (es.Count < 50)
							DayViewDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/EventList1.ascx");
						else
							DayViewDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/EventList2.ascx");

						//DayViewDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/EventList2.ascx");

						DayViewDataList.DataBind();

					}

					#region set up next / prev day links

					DayMonthLink.InnerText = "Show calendar for " + day.ToString("MMMM yyyy");
					DayMonthLink1.InnerText = "Show calendar for " + day.ToString("MMMM yyyy");
					DayMonthLink.HRef = ChangeMonthUrl(day.Month, day.Year);
					DayMonthLink1.HRef = ChangeMonthUrl(day.Month, day.Year);

					string nextDayUrl = ChangeDayUrl(day.AddDays(1).Month, day.AddDays(1).Year, day.AddDays(1).Day);
					string prevDayUrl = ChangeDayUrl(day.AddDays(-1).Month, day.AddDays(-1).Year, day.AddDays(-1).Day);

					#region set up links
					DayNameLabel.Text = dateFilterString;
					DayNameLabel1.Text = dateFilterString;

					DayBackLink.InnerHtml = "&lt; " + day.AddDays(-1).ToString("dddd dd");
					DayBackLink1.InnerHtml = "&lt; " + day.AddDays(-1).ToString("dddd dd");
					DayBackLink.HRef = prevDayUrl;
					DayBackLink1.HRef = prevDayUrl;

					DayNextLink.InnerHtml = day.AddDays(1).ToString("dddd dd") + " &gt;";
					DayNextLink1.InnerHtml = day.AddDays(1).ToString("dddd dd") + " &gt;";
					DayNextLink.HRef = nextDayUrl;
					DayNextLink1.HRef = nextDayUrl;
					#endregion

					if (es.Count == 0)
					{
						Event latestPastEvent = eventsForDisplay.GetLatestPastEvent(day);
						if (latestPastEvent == null)
						{
							#region disable the back link if we have no past events
							DayBackLink.HRef = "";
							DayBackLink1.HRef = "";
							DayBackLink.Disabled = true;
							DayBackLink1.Disabled = true;
							#endregion
						}
						else
						{
							#region set up the back link with the month of the latest past event
							DayBackLink.HRef = ChangeDayUrl(latestPastEvent.DateTime.Month, latestPastEvent.DateTime.Year, latestPastEvent.DateTime.Day);
							DayBackLink1.HRef = ChangeDayUrl(latestPastEvent.DateTime.Month, latestPastEvent.DateTime.Year, latestPastEvent.DateTime.Day);

							if (latestPastEvent.DateTime.Year != Year)
							{
								DayBackLink.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("dddd dd MMMM yyyy");
								DayBackLink1.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("dddd dd MMMM yyyy");
							}
							else if (latestPastEvent.DateTime.Month != Month)
							{
								DayBackLink.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("dddd dd MMMM");
								DayBackLink1.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("dddd dd MMMM");
							}
							else
							{
								DayBackLink.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("dddd dd");
								DayBackLink1.InnerHtml = "&lt; " + latestPastEvent.DateTime.ToString("dddd dd");
							}
							#endregion
						}

						Event nextFutureEvent = eventsForDisplay.GetNextFutureEvent(day);
						if (nextFutureEvent == null)
						{
							#region disable the forward link if we have no future events
							DayNextLink.HRef = "";
							DayNextLink1.HRef = "";
							DayNextLink.Disabled = true;
							DayNextLink1.Disabled = true;
							#endregion
						}
						else
						{
							#region set up the back link with the month of the first future event
							DayNextLink.HRef = ChangeDayUrl(nextFutureEvent.DateTime.Month, nextFutureEvent.DateTime.Year, nextFutureEvent.DateTime.Day);
							DayNextLink1.HRef = ChangeDayUrl(nextFutureEvent.DateTime.Month, nextFutureEvent.DateTime.Year, nextFutureEvent.DateTime.Day);

							if (nextFutureEvent.DateTime.Year != Year)
							{
								DayNextLink.InnerHtml = nextFutureEvent.DateTime.ToString("dddd dd MMMM yyyy") + " &gt;";
								DayNextLink1.InnerHtml = nextFutureEvent.DateTime.ToString("dddd dd MMMM yyyy") + " &gt;";
							}
							if (nextFutureEvent.DateTime.Month != Month)
							{
								DayNextLink.InnerHtml = nextFutureEvent.DateTime.ToString("dddd dd MMMM") + " &gt;";
								DayNextLink1.InnerHtml = nextFutureEvent.DateTime.ToString("dddd dd MMMM") + " &gt;";
							}
							else
							{
								DayNextLink.InnerHtml = nextFutureEvent.DateTime.ToString("dddd dd") + " &gt;";
								DayNextLink1.InnerHtml = nextFutureEvent.DateTime.ToString("dddd dd") + " &gt;";
							}
							#endregion
						}

						#region ensure links are fully disabled
						if (DayBackLink.Disabled)
							DayBackLink.Attributes["class"] = "DisabledAnchor";
						if (DayBackLink1.Disabled)
							DayBackLink1.Attributes["class"] = "DisabledAnchor";
						if (DayNextLink.Disabled)
							DayNextLink.Attributes["class"] = "DisabledAnchor";
						if (DayNextLink1.Disabled)
							DayNextLink1.Attributes["class"] = "DisabledAnchor";
						#endregion
					}
					#endregion
				}

				#region Set up intro text and page title
				if (HotTickets)
				{
					if (eventsForDisplay.FilterByBrand)
					{
						Brand b = new Brand(BrandK);
						HotTicketsIntroPanelBrandLink.HRef = b.Url();
						HotTicketsIntroPanelBrandLink.InnerText = b.Name;
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("Hot tickets for " + b.FriendlyName + " events", b.FriendlyName);
						HotTicketsIntroPanelTicketsCalendarLink.HRef = b.UrlCalendar(true, false);

					}
					else if (eventsForDisplay.FilterByGroup)
					{
						Group g = new Group(GroupK);
						HotTicketsIntroPanelNonBrandInAtLabel.Text = "recommended by";
						HotTicketsIntroPanelNonBrandObjectLink.HRef = g.Url();
						HotTicketsIntroPanelNonBrandObjectLink.InnerText = g.FriendlyName;
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("Hot tickets recommended by " + g.FriendlyName, g.FriendlyName);
						HotTicketsIntroPanelTicketsCalendarLink.HRef = g.UrlCalendar(true, false);
					}
					else if (eventsForDisplay.FilterByVenue)
					{
						HotTicketsIntroPanelNonBrandInAtLabel.Text = "at";
						Venue v = new Venue(VenueK);
						HotTicketsIntroPanelNonBrandObjectLink.InnerText = v.FriendlyName;
						HotTicketsIntroPanelNonBrandObjectLink.HRef = v.Url();
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("Hot tickets for events at " + v.FriendlyName, v.Name);
						HotTicketsIntroPanelTicketsCalendarLink.HRef = v.UrlCalendar(true, false);
					}
					else if (eventsForDisplay.FilterByPlace)
					{
						HotTicketsIntroPanelNonBrandInAtLabel.Text = "in";
						Place p = new Place(PlaceK);
						HotTicketsIntroPanelNonBrandObjectLink.InnerText = p.FriendlyName;
						HotTicketsIntroPanelNonBrandObjectLink.HRef = p.Url();
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("Hot tickets for events in " + p.FriendlyName, p.Name);
						HotTicketsIntroPanelTicketsCalendarLink.HRef = p.UrlCalendar(true, false);
					}
					else if (eventsForDisplay.FilterByCountry)
					{
						HotTicketsIntroPanelNonBrandInAtLabel.Text = "in";
						HotTicketsIntroPanelNonBrandObjectLink.InnerText = FilterCountry.FriendlyName;
						HotTicketsIntroPanelNonBrandObjectLink.HRef = FilterCountry.Url();
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("Hot tickets for events in " + FilterCountry.FriendlyName, FilterCountry.Name);
						HotTicketsIntroPanelTicketsCalendarLink.HRef = FilterCountry.UrlCalendar(true, false);
					}
					else if (eventsForDisplay.FilterWorldwide)
					{
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("Hot tickets worldwide");
						HotTicketsIntroPanelTicketsCalendarLink.HRef = Calendar.UrlCalendar(true, false);
					}
				}
				else
				{
					ObjectCalendarIntroBrand.Visible = eventsForDisplay.FilterByBrand;
					ObjectCalendarIntroNonBrand.Visible = !eventsForDisplay.FilterByBrand;
					if (eventsForDisplay.FilterByBrand)
					{
						Brand b = new Brand(BrandK);
						ObjectCalendarIntroBrandAnchor.HRef = b.Url();
						ObjectCalendarIntroBrandAnchor.InnerText = b.Name;
						((Spotted.Master.DsiPage)this.Page).SetPageTitle(b.FriendlyName + (FreeGuestlist ? " Free Guestlist" : "") + " calendar for " + dateFilterString, b.FriendlyName);

					}
					else if (eventsForDisplay.FilterByGroup)
					{
						Group g = new Group(GroupK);
						ObjectCalendarIntroInAtLabel.Text = "recommended by";
						ObjectCalendarIntroObjectLink.HRef = g.Url();
						ObjectCalendarIntroObjectLink.InnerText = g.FriendlyName;
						((Spotted.Master.DsiPage)this.Page).SetPageTitle(g.FriendlyName + (FreeGuestlist ? " Free Guestlist" : "") + " calendar for " + dateFilterString, g.FriendlyName);
					}
					else if (eventsForDisplay.FilterByVenue)
					{
						ObjectCalendarIntroInAtLabel.Text = "at";
						Venue v = new Venue(VenueK);
						ObjectCalendarIntroObjectLink.InnerText = v.FriendlyName;
						ObjectCalendarIntroObjectLink.HRef = v.Url();
						((Spotted.Master.DsiPage)this.Page).SetPageTitle(v.FriendlyName + (FreeGuestlist ? " Free Guestlist" : "") + " events calendar for " + dateFilterString, v.Name);
					}
					else if (eventsForDisplay.FilterByPlace)
					{
						ObjectCalendarIntroInAtLabel.Text = "in";
						Place p = new Place(PlaceK);
						ObjectCalendarIntroObjectLink.InnerText = p.FriendlyName;
						ObjectCalendarIntroObjectLink.HRef = p.Url();
						((Spotted.Master.DsiPage)this.Page).SetPageTitle(p.FriendlyName + (FreeGuestlist ? " Free Guestlist" : "") + " events calendar for " + dateFilterString, p.Name);
					}
					else if (eventsForDisplay.FilterByCountry)
					{
						ObjectCalendarIntroInAtLabel.Text = "in";
						ObjectCalendarIntroObjectLink.InnerText = FilterCountry.FriendlyName;
						ObjectCalendarIntroObjectLink.HRef = FilterCountry.Url();
						((Spotted.Master.DsiPage)this.Page).SetPageTitle((FreeGuestlist ? "Free Guestlist calendar" : " Calendar") + " for " + FilterCountry.FriendlyName + ", " + dateFilterString, FilterCountry.Name);
					}
					else if (eventsForDisplay.FilterWorldwide)
					{
						((Spotted.Master.DsiPage)this.Page).SetPageTitle((FreeGuestlist ? "Free Guestlist calendar" : " Calendar") + " for " + dateFilterString);
					}
					if (Personalise && !BuddyDisplay)
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("My calendar");
					else if (BuddyDisplay)
						((Spotted.Master.DsiPage)this.Page).SetPageTitle("Buddy calendar");
				}
				#endregion
			}
		}
예제 #19
0
		void UpdateAncestors(Place p)
		{
			this.PlaceK = p.K;
			UpdateAncestors(p.Country);
		}
예제 #20
0
		public void ForumInfo_Load(object o, System.EventArgs e)
		{
			if (!CurrentForumCheck)
				return;

			PanelThreadDescTypeNone.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.None);
			PanelThreadDescTypeEvent.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Event);
			PanelThreadDescTypeVenue.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Venue);
			PanelThreadDescTypePlace.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Place);
			PanelThreadDescTypeCountry.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Country);
			PanelThreadDescTypeArticle.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Article);
			PanelThreadDescTypeBrand.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Brand);
			PanelThreadDescTypeGroup.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Group);
			PanelThreadDescRelatedPanel.Visible = false;
			PanelThreadDescGroupBrandPanel.Visible = false;
			PanelThreadDescBrandPanel.Visible = false;
			FavouriteGroupPanel.Visible = (ThreadParentType.Equals(Model.Entities.ObjectType.Group) && CurrentGroupUsr != null && CurrentGroupUsr.IsMember);

			SetPageTitle("General discussions");

			if (ThreadParentType.Equals(Model.Entities.ObjectType.None))
			{
				ThreadDescWorldwideHomeCountryLink.InnerText = ThreadDescWorldwideHomeCountryLink.InnerText.Replace("???", Country.Current.FriendlyName);
				ThreadDescWorldwideHomeCountryLink.HRef = Country.Current.UrlDiscussion();
			}
			if (ThreadParentType.Equals(Model.Entities.ObjectType.Event))
			{
				Event ev = new Event(ObjectK);
				ThreadDescEventEventLink.InnerText = ev.Name;
				ThreadDescEventEventLink.HRef = ev.Url();

				ThreadDescEventVenueLink.InnerText = ev.Venue.Name;
				ThreadDescEventVenueLink.HRef = ev.Venue.Url();

				ThreadDescEventPlaceLink.InnerText = ev.Venue.Place.Name;
				ThreadDescEventPlaceLink.HRef = ev.Venue.Place.Url();

				ThreadDescEventDateLabel.Text = ev.FriendlyDate(false);

				PanelThreadDescRelatedPanel.Visible = ev.Brands.Count > 0;
				string brandsHtml = "";
				for (int i = 0; i < ev.Brands.Count; i++)
				{
					brandsHtml += (i == 0 ? "" : (i == (ev.Brands.Count - 1) ? " or " : ", ")) + "the <b><a href=\"" + ev.Brands[i].UrlDiscussion() + "\">" + ev.Brands[i].Name + " forum</a></b>";
				}
				PanelThreadDescRelatedPh.Controls.Add(new LiteralControl(brandsHtml));

				SetPageTitle(ev.Name + " discussions");


			}
			if (ThreadParentType.Equals(Model.Entities.ObjectType.Venue))
			{
				Venue v = new Venue(ObjectK);

				ThreadDescVenueVenueLink.InnerText = v.Name;
				ThreadDescVenueVenueLink.HRef = v.Url();

				ThreadDescVenuePlaceLink.InnerText = v.Place.Name;
				ThreadDescVenuePlaceLink.HRef = v.Place.Url();
				SetPageTitle(v.Name + " discussions");
			}
			if (ThreadParentType.Equals(Model.Entities.ObjectType.Place))
			{
				Place t = new Place(ObjectK);

				ThreadDescPlacePlaceLink.InnerText = t.Name;
				ThreadDescPlacePlaceLink.HRef = t.Url();
				SetPageTitle(t.Name + " discussions");
			}
			if (ThreadParentType.Equals(Model.Entities.ObjectType.Country))
			{
				Country c = new Country(ObjectK);

				ThreadDescCountryLabel.Text = c.FriendlyName;
				ThreadDescCountryLink.HRef = c.Url();
				SetPageTitle(c.FriendlyName + " discussions");
			}
			if (ThreadParentType.Equals(Model.Entities.ObjectType.Article))
			{
				Article a = new Article(ObjectK);
				ThreadDescArticleArticleLink.InnerText = a.Title;
				ThreadDescArticleArticleLink.HRef = a.Url();
				SetPageTitle(a.Title + " discussions");
			}
			if (ThreadParentType.Equals(Model.Entities.ObjectType.Brand))
			{
				Brand b = new Brand(ObjectK);
				ThreadDescBrandBrandLink.InnerText = b.Name;
				ThreadDescBrandBrandLink.HRef = b.Url();
				SetPageTitle(b.Name + " discussions");
				if (b.Group.TotalComments > 0)
				{
					PanelThreadDescBrandPanel.Visible = true;
					PanelThreadDescBrandGroupChatAnchor.InnerText = b.Group.FriendlyName + " group chat";
					PanelThreadDescBrandGroupChatAnchor.HRef = b.Group.UrlDiscussion();
					PanelThreadDescBrandGroupChatCommentsLabel.Text = b.Group.TotalComments.ToString("#,##0") + " comment" + (b.Group.TotalComments == 1 ? "" : "s");
				}
			}
			if (ThreadParentType.Equals(Model.Entities.ObjectType.Group))
			{
				ThreadDescGroupGroupLink.InnerText = CurrentGroup.FriendlyName + " group";
				ThreadDescGroupGroupLink.HRef = CurrentGroup.Url();
				SetPageTitle(CurrentGroup.FriendlyName + " discussions");
				if (CurrentGroup.BrandK > 0)
				{
					PanelThreadDescGroupBrandPanel.Visible = true;
					PanelThreadDescGroupBrandAnchor.HRef = CurrentGroup.Brand.UrlDiscussion();
					PanelThreadDescGroupBrandAnchor.InnerText = CurrentGroup.Brand.Name + " public chat";
					PanelThreadDescGroupBrandCommentsLabel.Text = CurrentGroup.Brand.TotalComments.ToString("#,##0") + " comment" + (CurrentGroup.Brand.TotalComments == 1 ? "" : "s");
				}
			}
		}
예제 #21
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");
					}
				}
			}
		}