Ejemplo n.º 1
0
		private static CommentStub CreateCommentStub(Comment comment, ThreadUsr threadUsr, GroupUsr groupUsr)
		{
			CommentStub c = new CommentStub()
			{
				k = comment.K,
				html = comment.GetHtml(null),
				script = comment.Script,
				usrName = comment.Usr.Name,
				usrPicSrc = comment.Usr.AnyPicPath,
				usrRollover = comment.Usr.RolloverMouseOverTextNoPic,
				usrUrl = comment.Usr.Url(),
				usrK = comment.Usr.K,
				isNew = comment.GetIsNew(threadUsr),
				friendlyTimeNoCaps = comment.FriendlyTimeNoCaps,
				editLinkVisible = Usr.Current != null && (comment.UsrK == Usr.Current.K || Usr.Current.IsAdmin),
				editedHtml = comment.EditedHtml,
				deleteLinkVisible = Usr.Current != null && Usr.Current.CanDelete(comment),
				deleteLinkOnClickConfirmText = Usr.Current == null ? "" :
					(groupUsr != null && groupUsr.Moderator) ? "You are using your group moderator power to delete this comment.\n\nAre you sure?" :
					(comment.UsrK != Usr.Current.K) ? "You are using your moderator power to delete this comment.\n\nAre you sure?" :
					"Are you sure?",

				threadK = comment.ThreadK
			};

			c.lolHtml = comment.LolUsrListHtml(out c.haveAlreadyLold, Usr.Current != null ? Usr.Current.K : -1);
			return c;
		}
Ejemplo n.º 2
0
		protected void Page_Load(object sender, EventArgs e)
		{
			Ph.Controls.Clear();
			Comment c = new Comment(21230296);

			Ph.Controls.Add(new LiteralControl(c.Text));
		}
Ejemplo n.º 3
0
		protected void Page_Load(object sender, EventArgs e)
		{

			FaqPh.Controls.Clear();
			Comment c = new Comment(20717915);

			FaqPh.Controls.Add(new LiteralControl(c.Text));
		}
Ejemplo n.º 4
0
		protected void Page_Load(object sender, EventArgs e)
		{
			//MixmagPh.Controls.Clear();
			//MixmagPh.Controls.Add(new LiteralControl(Common.Settings.MixmagPageHtml));


			MixmagPh.Controls.Clear();
			Comment c = new Comment(Vars.DevEnv ? 20690623 : 20717954);

			MixmagPh.Controls.Add(new LiteralControl(c.Text));
		}
Ejemplo n.º 5
0
		public void DeleteNow(object o, System.EventArgs e)
		{
			if (ObjectTypeDropDown.SelectedValue.Equals("Photo"))
			{
				Photo c = new Photo(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Gallery"))
			{
				Gallery c = new Gallery(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Venue"))
			{
				Venue c = new Venue(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Event"))
			{
				Event c = new Event(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Comment"))
			{
				Comment c = new Comment(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Thread"))
			{
				Thread c = new Thread(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Usr"))
			{
				Usr c = new Usr(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Article"))
			{
				Article c = new Article(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			DoneLabel.Visible = true;
		}
Ejemplo n.º 6
0
		protected void CommentEditClick(object o, EventArgs e)
		{
			if (!Usr.Current.CanGroupNewsAdmin(CurrentGroupUsr))
			{
				throw new Exception("Can't news admin!!!");
			}

			CurrentComment = new Comment(CurrentComment.K);
			EditCell.Visible = true;
			TextCell.Visible = false;
			CommentEditTextBox.Text = CurrentComment.Text;
			if (CurrentComment.K == CurrentComment.Thread.FirstComment.K)
			{
				SubjectPanel.Visible = true;
				ThreadSubjectEditBox.Text = CurrentComment.Thread.Subject;
			}
			else
			{
				SubjectPanel.Visible = false;
			}
			((Spotted.Master.DsiPage)Page).AnchorSkip("CommentK-" + CurrentComment.K.ToString());

		}
Ejemplo n.º 7
0
			public MakerReturn Post(Transaction transaction)
			{
				if (HttpContext.Current!=null)
					HttpContext.Current.Items["VisitComments"]=1;

				MakerReturn r = new MakerReturn();

				#region Look for duplicates
				Query qDuplicate = new Query();
				qDuplicate.QueryCondition=new Q(Comment.Columns.DuplicateGuid,(Guid)DuplicateGuid);
				qDuplicate.Columns=new ColumnSet(Comment.Columns.K, Comment.Columns.IndexInThread, Comment.Columns.ThreadK);
				CommentSet csDuplicate = new CommentSet(qDuplicate);
				if (csDuplicate.Count>0)
				{
					r.Success = false;
					r.Duplicate = true;
					r.Comment = csDuplicate[0];
					return r;
				}
				#endregion
				#region Check permission
				if (!NewThread && !ParentThread.CheckPermissionPost(PostingUsr, CurrentThreadUsr, CurrentGroupUsr))
				{
					r.Success=false;
					r.MessageHtml="You can't post in this topic.";
					return r;
				}
				#endregion
				#region Check for closed thread
				if (!NewThread && ParentThread.Closed)
				{
					r.Success=false;
					r.MessageHtml="This topic is closed - posting is disabled.";
					return r;
				}
				#endregion
			
				#region Create comment
				NewComment = new Comment();
				NewComment.DateTime = DateTime.Now;
				if (HttpContext.Current!=null)
					NewComment.Ip = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);

				if (ChatItemGuid == null)
					NewComment.ChatItemGuid = Guid.NewGuid();
				else
					NewComment.ChatItemGuid = ChatItemGuid;

				NewComment.Enabled = true;
				NewComment.Text = Body;
				NewComment.ThreadK = ParentThread.K;
				NewComment.UsrK = PostingUsr.K;
				if (!ParentThread.Private)
				{
					PostingUsr.CommentCount++;
					PostingUsr.Update(transaction);
				}
				NewComment.DuplicateGuid = (Guid)DuplicateGuid;
				NewComment.IndexInThread = ParentThread.TotalComments;
				NewComment.Update(transaction);
				#endregion

				#region Update thread
				ParentThread.LastPost=NewComment.DateTime;
				ParentThread.LastPostUsrK=NewComment.UsrK;
				ParentThread.Update(transaction);
				ParentThread.UpdateTotalComments(transaction);
				#endregion
				#region Update / create ThreadUsr
				CurrentThreadUsr.ChangeStatus(ThreadUsr.StatusEnum.Archived, NewComment.DateTime);
				CurrentThreadUsr.ViewDateTime = NewComment.DateTime;
				CurrentThreadUsr.ViewDateTimeLatest = NewComment.DateTime;
				CurrentThreadUsr.ViewComments = ParentThread.TotalComments;
				CurrentThreadUsr.ViewCommentsLatest = ParentThread.TotalComments;
				CurrentThreadUsr.Update(transaction);
				#endregion

				string chatMessageBody = "";
				bool alreadySentChatMessage = false;
				bool commentIsPrivate = ParentThread.Private || ParentThread.GroupPrivate || ParentThread.PrivateGroup;
				if (!DisableLiveChatMessage)
				{
					chatMessageBody = Chat.GetMessageFromCommentBody(Body);

					//If the thread is subject to group privacy and we are inviting people, we should wait until after all the invites have been processed before sending the 
					//message, or we might sent the chat message to people who don't have permission to see the thread
					bool commentIsSubjectToGroupPrivacy = ParentThread.GroupPrivate || ParentThread.PrivateGroup;
					bool canPostImmediatly = !commentIsSubjectToGroupPrivacy || InviteKs.Count == 0;
					if (!NewThread && canPostImmediatly)
					{
						//If we're NOT posting a new thread, we should post the chat message immediatly...
						//if we are posting a new thread, we should wait until after all the invites have been done, so we have a better list of participants.
						sendChatMessageToParticipantsNow(InviteKs, NewComment, ParentThread, PostingUsr, chatMessageBody);
						alreadySentChatMessage = true;
					}

					
					if (!commentIsPrivate)
					{
						//Since we don't invite anyone to this room, we can post immediatly to the random chat room.
						//CommentMessageStub ms = getChatMessage(
						//    //new Chat.RoomSpec(RoomType.RandomChat).Guid,
						//    new Chat.RoomSpec(RoomType.PublicStream).Guid,
						//    ParentThread.GetRoomSpec().Guid,
						//    NewComment,
						//    ParentThread,
						//    PostingUsr,
						//    chatMessageBody);
						//Chat.SendJsonChatItem(ms);

						CommentMessageStub ms1 = getChatMessage(
							new Chat.RoomSpec(RoomType.PublicStream).Guid,
							ParentThread.GetRoomSpec().Guid,
							NewComment,
							ParentThread,
							PostingUsr,
							chatMessageBody);
						Chat.SendJsonChatItem(ms1);
					}

				}

				try
				{
					if (NewThread && !commentIsPrivate && PostingUsr.FacebookConnected)
					{
						bool sentToFacebook = false;

						if (NewComment.Thread.IsReview && PostingUsr.FacebookStoryEventReview)
						{
							FacebookPost.CreateEventReview(PostingUsr, NewComment.Thread, NewComment);
							sentToFacebook = true;
						}

						if (!sentToFacebook && NewComment.Thread.IsNews && PostingUsr.FacebookStoryPostNews)
						{
							FacebookPost.CreateEventReview(PostingUsr, NewComment.Thread, NewComment);
							sentToFacebook = true;
						}

						if (!sentToFacebook && PostingUsr.FacebookStoryNewTopic)
						{
							FacebookPost.CreateNewTopic(PostingUsr, NewComment.Thread, NewComment);
						}
					}
				}
				catch { }

				SendCommentAlertsJob job = new SendCommentAlertsJob(
					this.ParentThread, 
					this.PostingUsr, 
					this.NewComment, 
					this.NewThread, 
					this.AlertedUsrs, 
					this.InviteKs,
					DisableLiveChatMessage,
					alreadySentChatMessage,
					chatMessageBody);

				if (Vars.DevEnv)
				{
					job.ExecuteSynchronously();
				}
				else
				{
					if (this.RunAsync)
						job.ExecuteAsynchronously();
					else
						job.ExecuteSynchronously();
				}

				if (Usr.Current != null && PostingUsr.K != Usr.DsiUsrK)
				{
					Usr.IncrementSpamBotDefeaterCounter(Usr.SpamBotDefeaterCounter.Comments, Usr.Current.K);
				}

				r.Success = true;
				r.Comment = NewComment;
				return r;

			}
Ejemplo n.º 8
0
		public bool DeleteComment(int commentK)
		{
			if (Usr.Current != null)
			{
				Comment comment = new Comment(commentK);
				if (Usr.Current.CanDelete(comment))
				{
					comment.RegisterDelete(Usr.Current);
					comment.DeleteAll(null);
					return true;
				}
			}
			return false;
		}
Ejemplo n.º 9
0
		public void AddQuestionsThread(Usr u, string promoterName)
		{
			#region Add a PM
			//string assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
			//string body = NVelocityEngineFactory.CreateNVelocityAssemblyEngine(assemblyName, true).Process(new Hashtable(), "Emails.NewPromoterEmail.vm");
			Comment c = new Comment(Vars.DevEnv ? 21036749 : 21053069);
			string body = c.Text;


			List<Usr> salesUsrs = new List<Usr>();
			if (this.SalesUsrK > 0)
				salesUsrs.Add(this.SalesUsr);
			else
			{
				foreach (Usr salesUsr in Usr.GetNewPromoterSalesUsrsNameAndK())
				{
					salesUsrs.Add(salesUsr);
				}
			}

			if (salesUsrs.Count > 0)
			{
				Thread.Maker m = new Thread.Maker();
				m.Subject = promoterName + " promoter questions";
				m.Body = body;
				m.ParentType = Model.Entities.ObjectType.None;
				m.DuplicateGuid = Guid.NewGuid();
				m.Private = true;
				m.PostingUsr = salesUsrs[0];
				for(int i=1; i<salesUsrs.Count; i++)
					m.InviteKs.Add(salesUsrs[i].K);
				m.InviteKs.Add(u.K);

				Thread.MakerReturn r = m.Post();

				this.QuestionsThreadK = r.Thread.K;
				Thread t = r.Thread;
			}
			#endregion
		}
Ejemplo n.º 10
0
		protected string CommentUrl(Comment c)
		{
			object page = null;
			if (c.Page > 1)
				page = c.Page;
			return Bobs.UrlInfo.MakeUrl(
				"",
				"chat",
				"u", ThisUsr.NickName.ToLower(),
				"d", CurrentDate,
				"y", ThreadPage,
				"k", c.ThreadK.ToString(),
				"c", page) + "#CommentK-" + c.K;
		}
Ejemplo n.º 11
0
		public string LolAtComment(int commentK)
		{
			if (Usr.Current != null)
			{
				Comment c = new Comment(commentK);
				Lol.CreateLol(c);
				bool me;
				return c.LolUsrListHtml(out me, Usr.Current.K);
			}
			// if nothing, don't change
			return "";
		}
Ejemplo n.º 12
0
		public static void CreateLaugh(Usr u, Comment c)
		{
			Query q = new Query();
			q.QueryCondition = new And(
				new Q(FacebookPost.Columns.DateTime, QueryOperator.GreaterThan, System.DateTime.Now.AddDays(-1)),
				new Q(FacebookPost.Columns.FacebookUid, u.Facebook.Uid),
				new Q(FacebookPost.Columns.Type, TypeEnum.Laugh));
			FacebookPostSet fps = new FacebookPostSet(q);
			if (fps.Count < 15)
			{
				Query q1 = new Query();
				q1.QueryCondition = new And(
					new Q(FacebookPost.Columns.FacebookUid, u.Facebook.Uid),
					new Q(FacebookPost.Columns.DataInt, c.K),
					new Q(FacebookPost.Columns.Type, TypeEnum.Laugh));
				FacebookPostSet fps1 = new FacebookPostSet(q1);
				if (fps1.Count == 0)
				{

					FacebookPost fp = new FacebookPost();
					fp.Hits = 0;
					fp.FacebookUid = u.Facebook.Uid;
					fp.DateTime = System.DateTime.Now;
					fp.Type = TypeEnum.Laugh;
					fp.Content = "CommentK=" + c.K.ToString();
					fp.DataInt = c.K;
					fp.UsrK = u.K;
					fp.Update();

					//send facebook message
					//http://developers.facebook.com/docs/reference/api/post
					Dictionary<string, object> par = new Dictionary<string, object>();
					if (c.Thread.PhotoK > 0 && c.Thread.Photo != null)
					{
						par["picture"] = c.Thread.Photo.IconPath;
					}
					par["link"] = "http://" + Vars.DomainName + c.Thread.Url() + "?fbpk=" + fp.K.ToString() + "#CommentK-" + c.K.ToString();
					par["name"] = c.Thread.Subject;
					par["caption"] = "Don't Stay In";

					par["description"] = c.Text.Strip().TruncateWithDots(990);
					u.Facebook.PutWallPost("This made me laugh...", par);
				}
			}
		}
Ejemplo n.º 13
0
		protected string DateString(Comment c)
		{
			if (ContainerPage.Url.HasDayFilter)
				return c.DateTime.ToString("HH:mm:ss");
			else
				return c.DateTime.ToString("HH:mm:ss (dd MMM yy)");
		}
Ejemplo n.º 14
0
		public void SendMatchNotification()
		{
			#region Init thread
			Thread t = new Thread();
			t.DateTime = DateTime.Now;
			t.Enabled = true;
			t.ParentObjectK = 0;
			t.ParentObjectType = Model.Entities.ObjectType.None;
			t.Subject = "DSI Date introduction - " + this.Usr.NickName + " and " + this.DateUsr.NickName;
			t.UsrK = this.UsrK;
			t.Private = true;
			t.IsNews = false;
			t.IsSticky = false;
			t.Update();
			t.UpdateAncestorLinks(null);

			ThreadUsr tu = new ThreadUsr();
			tu.DateTime = DateTime.Now;
			tu.InvitingUsrK = this.UsrK;
			tu.UsrK = this.DateUsrK;
			tu.ThreadK = t.K;
			tu.ChangeStatus(ThreadUsr.StatusEnum.NewInvite);
			tu.StatusChangeObjectK = this.UsrK;
			tu.StatusChangeObjectType = Model.Entities.ObjectType.Usr;
			tu.PrivateChatType = ThreadUsr.PrivateChatTypes.Popup;
			tu.Update();

			ThreadUsr tu1 = new ThreadUsr();
			tu1.DateTime = DateTime.Now;
			tu1.InvitingUsrK = this.DateUsrK;
			tu1.UsrK = this.UsrK;
			tu1.ThreadK = t.K;
			tu1.ChangeStatus(ThreadUsr.StatusEnum.NewInvite);
			tu1.PrivateChatType = ThreadUsr.PrivateChatTypes.Popup;
			tu1.StatusChangeObjectK = this.UsrK;
			tu1.StatusChangeObjectType = Model.Entities.ObjectType.Usr;
			tu1.Update();

			Comment c = new Comment();
			c.DateTime = DateTime.Now;
			if (HttpContext.Current != null)
				c.Ip = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);
			c.Enabled = true;
			string rel = "";
			if (this.Usr.Relationship1 && this.DateUsr.Relationship1)
				rel += " <b>just friends</b>";
			if (this.Usr.Relationship2 && this.DateUsr.Relationship2)
				rel += (rel.Length > 0 ? " or " : "") + " <b>a bit of a fling</b>";
			if (this.Usr.Relationship3 && this.DateUsr.Relationship3)
				rel += (rel.Length > 0 ? " or " : "") + " <b>love</b>";
			c.Text = "<b>You've both been matched by DSI Date.</b>\n\nYou've selected Yes to each others profiles on the DSI Date page. You're both looking for: " + rel + ".\n\nGet to know each other better in this private conversation.";
			c.ThreadK = t.K;
			c.UsrK = 3526;
			c.DuplicateGuid = Guid.NewGuid();
			c.Update();
			c = new Comment(c.K);

			CommentAlert.Enable(this.Usr, t.K, Model.Entities.ObjectType.Thread);
			CommentAlert.Enable(this.DateUsr, t.K, Model.Entities.ObjectType.Thread);

			t.LastPost = c.DateTime;
			t.LastPostUsrK = c.UsrK;
			t.Update();
			t.UpdateTotalComments(null);
			//t.UpdateTotalParticipants();
			UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob();
			job.ExecuteSynchronously();

			#endregion

			this.MatchThreadK = t.K;
			this.Update();
			UsrDate udRev = new UsrDate(this.DateUsrK, this.UsrK);
			udRev.MatchThreadK = t.K;
			udRev.Update();

			//Email
			Mailer sm = new Mailer();
			sm.RedirectUrl = t.Url();
			sm.Subject = "DSI Date has matched you to " + this.DateUsr.NickName;
			sm.Body = "<p>DSI Date has matched you to " + this.DateUsr.NickNameSafe + ". We've invited you both to a private conversation, where you can get to know each other better.</p>";
			sm.Body += "<p><a href=\"[LOGIN(" + t.Url() + ")]\">Click here to send " + this.DateUsr.NickNameSafe + " a message</a></p>";
			sm.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
			sm.UsrRecipient = this.Usr;
			sm.To = this.Usr.Email;
			sm.Send();

			Mailer sm1 = new Mailer();
			sm1.RedirectUrl = t.Url();
			sm1.Subject = "DSI Date has matched you to " + this.Usr.NickName;
			sm1.Body = "<p>DSI Date has matched you to " + this.Usr.NickNameSafe + ". We've invited you both to a private conversation, where you can get to know each other better.</p>";
			sm1.Body += "<p><a href=\"[LOGIN(" + t.Url() + ")]\">Click here to send " + this.Usr.NickNameSafe + " a message</a></p>";
			sm1.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
			sm1.UsrRecipient = this.DateUsr;
			sm1.To = this.DateUsr.Email;
			sm1.Send();

		}
Ejemplo n.º 15
0
		public static void CreateEventReview(Usr u, Thread t, Comment c)
		{
			Query q = new Query();
			q.QueryCondition = new And(
				new Q(FacebookPost.Columns.DateTime, QueryOperator.GreaterThan, System.DateTime.Now.AddDays(-1)),
				new Q(FacebookPost.Columns.FacebookUid, u.Facebook.Uid),
				new Q(FacebookPost.Columns.Type, TypeEnum.NewTopicReview));
			FacebookPostSet fps = new FacebookPostSet(q);
			if (fps.Count < 15)
			{
				Query q1 = new Query();
				q1.QueryCondition = new And(
					new Q(FacebookPost.Columns.FacebookUid, u.Facebook.Uid),
					new Q(FacebookPost.Columns.DataInt, t.K),
					new Or(new Q(FacebookPost.Columns.Type, TypeEnum.NewTopic), new Q(FacebookPost.Columns.Type, TypeEnum.NewTopicNews), new Q(FacebookPost.Columns.Type, TypeEnum.NewTopicReview)));
				FacebookPostSet fps1 = new FacebookPostSet(q1);
				if (fps1.Count == 0)
				{

					FacebookPost fp = new FacebookPost();
					fp.Hits = 0;
					fp.FacebookUid = u.Facebook.Uid;
					fp.DateTime = System.DateTime.Now;
					fp.Type = TypeEnum.NewTopicReview;
					fp.Content = "ThreadK=" + t.K.ToString();
					fp.DataInt = t.K;
					fp.UsrK = u.K;
					fp.Update();

					//send facebook message
					//http://developers.facebook.com/docs/reference/api/post
					Dictionary<string, object> par = new Dictionary<string, object>();
					par["link"] = "http://" + Vars.DomainName + t.Url() + "?fbpk=" + fp.K.ToString();
					par["name"] = t.Event.Name.TruncateWithDots(20) + " @ " + t.Event.Venue.Name.TruncateWithDots(20);
					par["caption"] = "Don't Stay In";

					par["description"] = c.Text.Strip().TruncateWithDots(990);
					u.Facebook.PutWallPost(t.Subject, par);
				}
			}
		}
Ejemplo n.º 16
0
		protected void CommentEditSaveClick(object o, EventArgs e)
		{
			if (!Usr.Current.CanGroupNewsAdmin(CurrentGroupUsr))
			{
				throw new Exception("Can't news admin!!!");
			}
			CurrentComment = new Comment(CurrentComment.K);
			if (CommentEditTextBox.Text.Trim().Length == 0)
				throw new DsiUserFriendlyException("No text in comment!");
			CurrentComment.Text = Cambro.Web.Helpers.CleanHtml(CommentEditTextBox.Text);
			if (CurrentComment.K == CurrentComment.Thread.FirstComment.K)
			{
				if (Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text).Trim().Length == 0)
					throw new DsiUserFriendlyException("No text in subject!");
				CurrentComment.Thread.Subject = Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text);
				CurrentComment.Thread.Update();
			}
			CurrentComment.Update();
			Response.Redirect(CurrentGroup.UrlApp("admin", "threadk", CurrentThread.K.ToString(), "mode", "news"));
			//((DsiPage)Page).AnchorSkip("CommentK-"+CurrentComment.K.ToString());

		}
Ejemplo n.º 17
0
		static LaughStub getLaughStub(ItemType itemType, Guid roomGuid, Comment fullComment)
		{
			return new LaughStub(
						Guid.NewGuid().Pack(),
						itemType,
						DateTime.Now.Ticks.ToString(),
						roomGuid.Pack(),
						Usr.Current.NickName,
						Usr.Current.StmuParams,
						Usr.Current.K,
						Usr.Current.HasPic ? Usr.Current.Pic.ToString() : "0",
						Usr.Current.HasChatPic ? Usr.Current.ChatPic.Value.ToString() : "0",
						Chat.GetMessageFromCommentBody(fullComment.Text),
						fullComment.Thread.GetRoomSpec().Guid.Pack(),
						fullComment.UrlRefresher(),
						fullComment.Thread.Subject.TruncateWithDots(50));
		}
Ejemplo n.º 18
0
		public void SendChatMessage(bool disableChatMessage, bool alreadySentChatMessage, Comment newComment, Thread parentThread, Usr postingUsr, string chatMessageBody)
		{
			if (!disableChatMessage && !alreadySentChatMessage)
			{
				Comment.sendChatMessageToParticipantsNow(null, newComment, parentThread, postingUsr, chatMessageBody);
			}
		}
Ejemplo n.º 19
0
		private static void SendInvites(Thread parentThread, Usr postingUsr, Comment newComment, bool isNewThread, List<int> alertedUsrKs, List<int> inviteKs)
		{
			#region Send invites
			try
			{
				if (inviteKs.Count > 0)
				{
					parentThread.Invite(
						inviteKs,
						postingUsr,
						newComment.DateTime,
						alertedUsrKs,
						isNewThread,
						newComment,
						false);
				}
			}
			catch (Exception ex) { Global.Log("8a0b951f-f1f2-4a08-9598-2093d7ccf938", ex); }
			#endregion
		}
Ejemplo n.º 20
0
		private static void SendTopicNotificationEmail(Thread parentThread, Usr postingUsr, Comment newComment, ThreadUsr tuAlert)
		{
			Mailer usrMail = new Mailer();
			Usr u = tuAlert.Usr;

			//Insert something in here to send chat items?...

			usrMail.Subject = postingUsr.NickName + " comments in: \"" + parentThread.SubjectSnip(40) + "\"";
			usrMail.Body += "<h1>" + postingUsr.NickName + " has posted a comment</h1>";
			usrMail.Body += "<p>The subject of the topic is: \"" + parentThread.Subject + "\"</p>";
			usrMail.Body += "<p>To read and reply, check out the <a href=\"[LOGIN]\">topic page</a>.</p>";
			usrMail.Body += "<p>We won't send you any more alerts about this topic until you move it out of your inbox. To stop receiving these emails, click the <i>Ignore this topic</i> button on the topic page.</p>";
			usrMail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
			usrMail.RedirectUrl = newComment.UrlRefresher(parentThread);
			usrMail.UsrRecipient = u;
			usrMail.To = u.Email;
			usrMail.Bulk = parentThread.TotalParticipants > 5;
			usrMail.Inbox = true;
			usrMail.Send();
		}
Ejemplo n.º 21
0
		private static void MoveToInboxWhereArchived(Thread parentThread, Usr postingUsr, Comment newComment)
		{
			Update updateCommand = new Update();
			updateCommand.Table = TablesEnum.ThreadUsr;
			updateCommand.Changes.Add(new Assign(ThreadUsr.Columns.Status, ThreadUsr.StatusEnum.NewComment));
			updateCommand.Changes.Add(new Assign(ThreadUsr.Columns.StatusChangeDateTime, newComment.DateTime));
			updateCommand.Where = new And(
				new Q(ThreadUsr.Columns.UsrK, QueryOperator.NotEqualTo, postingUsr.K),
				new Q(ThreadUsr.Columns.ThreadK, parentThread.K),
				new Q(ThreadUsr.Columns.Status, ThreadUsr.StatusEnum.Archived));
			updateCommand.Run();
		}
Ejemplo n.º 22
0
		private static void SendAlertsToUsersWatchingThisThread(Thread parentThread, Usr postingUsr, Comment newComment, bool isNewThread, List<int> alertedUsrKs)
		{
			#region Move to inbox and send inbox emails
			try
			{
				if (!isNewThread)
				{
					ThreadUsrSet tus = GetAllArchivedThreadUsrs(parentThread, postingUsr);
					MoveToInboxWhereArchived(parentThread, postingUsr, newComment);
					foreach (ThreadUsr tuAlert in tus)
					{
						if (!alertedUsrKs.Contains(tuAlert.UsrK))
						{
							SendTopicNotificationEmail(parentThread, postingUsr, newComment, tuAlert);
							alertedUsrKs.Add(tuAlert.UsrK);
						}
					}
				}
			}
			catch (Exception ex) { Global.Log("80811792-ac79-4130-ac2c-9902e79101f0", ex); }
			#endregion
		}
Ejemplo n.º 23
0
		public int Invite(
			List<int> inviteKs,
			Usr invitingUsr,
			DateTime inviteDateTime,
			List<int> alertedUsrs,
			bool isNewThread,
			Comment postedComment,
			bool joinChatRoom)
		{
			IDiscussable Parent = this.ParentForumObject;
			Query qInvites = new Query();

			List<Q> qList = new List<Q>();
			qList.Add(new Q(false));
			if (inviteKs != null && inviteKs.Count > 0)
				qList.Add(new InListQ(Usr.Columns.K, inviteKs));
			
			qInvites.QueryCondition = new Or(qList.ToArray());
			qInvites.Columns = new ColumnSet(
				Usr.EmailColumns,
				Usr.LinkColumns,
				Usr.Columns.IsLoggedOn,
				Usr.Columns.DateTimeLastPageRequest,
				Usr.Columns.AddedByGroupK);
			UsrSet usInvites = new UsrSet(qInvites);

			int count = 0;

			GroupUsr guInvitingUsr = null;
			if (this.GroupK > 0)
				guInvitingUsr = this.Group.GetGroupUsr(invitingUsr);

			List<int> addedThreadUsrsUsrKs = new List<int>();

			foreach (Usr u in usInvites)
			{
				if (!alertedUsrs.Contains(u.K))
				{
					try
					{
						ThreadUsr tuInvite = new ThreadUsr(this.K, u.K);
					}
					catch (Bobs.BobNotFound)
					{
						bool sendInviteAlerts = true;
						bool addThreadUsr = true;

						if (this.GroupK > 0)
						{
							GroupUsr gu = this.Group.GetGroupUsr(u);

							if (this.GroupPrivate || this.PrivateGroup)
							{
								//if this thread is private to the group or in a private group, there's a danger that we're 
								//inviting someone to a thread that they can't see. Also - if the group is made public, many 
								//threads may appear in peoples inboxes. This bit stops us sending these dodgy invites out...
								if (gu == null)
								{
									//if they don't have a GroupUsr record, lets send a group invite, but hold off on the thread alert
									sendInviteAlerts = false;
									this.Group.Invite(u, gu, invitingUsr, guInvitingUsr, "", false);
								}
								else if (gu.IsMember)
								{
									//if they are a member, we can send the thread invite
								}
								else if (gu.Status.Equals(GroupUsr.StatusEnum.Recommend) ||
									gu.Status.Equals(GroupUsr.StatusEnum.RecommendRejected) ||
									gu.Status.Equals(GroupUsr.StatusEnum.Request) ||
									gu.Status.Equals(GroupUsr.StatusEnum.RequestRejected))
								{
									//if we might be able to invite or join them to the group, we give it a try (the outcome will depend on some rather complex code)
									this.Group.Invite(u, gu, invitingUsr, guInvitingUsr, "", false);

									if (!gu.IsMember)
									{
										//if we didn't join them straight up, they still won't be able to see the thread, so we hold off on the thread alert email
										sendInviteAlerts = false;

										if (!gu.Status.Equals(GroupUsr.StatusEnum.Invite))
										{
											//if we didn't join them straight up AND we didn't invite them, lets not bother inviting them to the thread
											addThreadUsr = false;
										}
									}
								}
								else
								{
									//ok so they have a GroupUsr, but they're not a member, and we can't invite or join them, so we're not going to bother inviting them to the thread
									addThreadUsr = false;
								}
							}
						}

						//We still add this user to the alertedusers list (even if !addThreadUsr) - this just makes sure we don't attempt to send them an invite a second time.
						alertedUsrs.Add(u.K);

						if (addThreadUsr)
						{
							ThreadUsr tu = this.GetThreadUsr(u);
							tu.ChangeStatus(ThreadUsr.StatusEnum.NewInvite, DateTime.Now, false, false);
							try
							{
								addedThreadUsrsUsrKs.Add(u.K);
							}
							catch { }
							tu.InvitingUsrK = invitingUsr.K;
							tu.StatusChangeObjectK = invitingUsr.K;
							tu.StatusChangeObjectType = Model.Entities.ObjectType.Usr;
							tu.Update();

							count++;

							#region sendInviteAlerts
							if (sendInviteAlerts)
							{
								try
								{
									Mailer usrMail = new Mailer();
									if (isNewThread && this.Private && this.ParentObjectType.Equals(Model.Entities.ObjectType.Photo))
									{
										usrMail.Subject = invitingUsr.NickName + " sent you a photo";
										usrMail.Body += "<h1>" + invitingUsr.NickName + " sent you a photo</h1>";
										usrMail.Body += "<p align=\"center\"><a href=\"[LOGIN]\"><img border=\"0\" src=\"" + this.ParentPhoto.WebPath + "\" width=\"" + this.ParentPhoto.WebWidth + "\" height=\"" + this.ParentPhoto.WebHeight + "\" class=\"BorderBlack All\" /></a></p>";
									}
									else if (isNewThread)
									{
										usrMail.Subject = invitingUsr.NickName + " posts: \"" + this.SubjectSnip(40) + "\"";
										usrMail.Body += "<h1>" + invitingUsr.NickName + " has posted a new topic</h1>";
									}
									else
									{
										usrMail.Subject = invitingUsr.NickName + " invites you to: \"" + this.SubjectSnip(40) + "\"";
										usrMail.Body += "<h1>" + invitingUsr.NickName + " invites you to a topic</h1>";
									}

									usrMail.Body += "<p>The subject is: \"" + this.Subject + "\"</p>";
									usrMail.Body += "<p>To read " + invitingUsr.HisString(false) + " message, check out the <a href=\"[LOGIN]\">topic page</a>.</p>";
									usrMail.Body += "<p>If you want to stop " + invitingUsr.HimString(false) + " inviting you to topics, click the <i>Stop " + invitingUsr.NickName + " inviting me to chat topics</i> button on <a href=\"[LOGIN(" + invitingUsr.Url() + ")]\">" + invitingUsr.HisString(false) + " profile page</a>.</p>";
									usrMail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
									usrMail.RedirectUrl = this.UrlDiscussion();
									usrMail.UsrRecipient = u;
									//usrMail.Bulk=usInvites.Count>5;
									usrMail.Bulk = false; // This is interesting... if people are invited by email, they should get the invite really...
									usrMail.Inbox = true;
									usrMail.Send();
								}
								catch (Exception ex) { Global.Log("1d3726bf-0715-4404-9059-4e53ca9e3dc5", ex); }

								//try
								//{
								//    if (u.IsLoggedOn && u.DateTimeLastPageRequest > DateTime.Now.AddMinutes(-5))
								//    {
								//        XmlDocument xmlDoc = new XmlDocument();
								//        XmlNode n = xmlDoc.CreateElement("privateMessageAlert");
								//        n.AddAttribute("nickName", invitingUsr.NickNameSafe);
								//        n.AddAttribute("stmu", invitingUsr.StmuParams);
								//        n.AddAttribute("usrK", invitingUsr.K.ToString());
								//        if (invitingUsr.HasPic)
								//            n.AddAttribute("pic", invitingUsr.Pic.ToString());
								//        else
								//            n.AddAttribute("pic", "0");
								//        n.AddAttribute("k", this.K.ToString());
								//        if (postedComment == null)
								//        {
								//            n.InnerText = this.Url();
								//        }
								//        else
								//        {
								//            n.InnerText = postedComment.Url(this);
								//        }
								//        Chat.SendChatItem(ItemType.Invite, n, DateTime.Now.Ticks, u.K, Guid.NewGuid());

								//    }
								//}
								//catch (Exception ex) { Global.Log("2902fd82-e8a4-49c2-9e33-ccfca01ca1f9", ex); }
							}
							#endregion
						}
					}
				}
			}

			if (joinChatRoom)
			{
				Guid room = this.GetRoomSpec().Guid;
				Chat.JoinRoom(room, addedThreadUsrsUsrKs.ToArray());
			}

			return count;
		}
Ejemplo n.º 24
0
		internal static void sendChatMessageToParticipantsNow(List<int> inviteKs, Comment newComment, Thread parentThread, Usr postingUsr, string chatMessageBody)
		{
			//Lets send a chat alert...
			CommentMessageStub ms = getChatMessage(
				parentThread.GetRoomSpec().Guid,
				Guid.Empty,
				newComment,
				parentThread,
				postingUsr,
				chatMessageBody);

			List<int> sendTo = new List<int>();
			#region add logged inparticipants
			UsrSet usParticipants = Thread.GetAllLoggedInParticipants(parentThread);
			foreach (Usr u in usParticipants)
			{
				try
				{
					sendTo.Add(u.K);
				}
				catch { }
			}
			#endregion
			#region add all people that have been invited
			if (inviteKs != null)
			{
				bool checkGroupMembership = parentThread.GroupK > 0 && (parentThread.GroupPrivate || parentThread.PrivateGroup);
				foreach (int k in inviteKs)
				{
					try
					{
						if (checkGroupMembership)
						{
							GroupUsr gu = parentThread.Group.GetGroupUsr(k);
							if (parentThread.Group.IsMember(gu))
								sendTo.Add(k);
						}
						else
							sendTo.Add(k);
					}
					catch { }
				}
			}
			#endregion
			#region add posting user
			try
			{
				sendTo.Add(postingUsr.K);
			}
			catch { }
			#endregion
			Chat.SendJsonChatItem(ms, sendTo.ToArray());
		}
Ejemplo n.º 25
0
		public static void CreateLol(Comment comment)
		{
			LolSet ls = new LolSet(
				new Query(
					new And(
						new Q(Lol.Columns.CommentK,comment.K),
						new Q(Lol.Columns.UsrK,Usr.Current.K)
					)
				)
			);
			if (ls.Count==0)
			{
				Usr usr = new Usr(comment.UsrK);
				LolSet lolUniqueSet = new LolSet(new Query(new And(
					new Q(Lol.Columns.CommentUsrK,usr.K),
					new Q(Lol.Columns.UsrK,Usr.Current.K))));
				if (lolUniqueSet.Count==0)
					usr.UniqueMadeLol++;
				usr.TotalMadeLol++;
				usr.Update();

				comment.LolCount++;
				comment.Update();

				Lol l = new Lol();
				l.DateTime=DateTime.Now;
				l.CommentK=comment.K;
				l.UsrK=Usr.Current.K;
				l.CommentUsrK=comment.UsrK;
				l.Update();
				l = new Lol(l.K);
				
				//DateTime lastLolDateTime = Usr.Current.LastLol;
						
				Usr.Current.TotalLol++;
				Usr.Current.LastLol = l.DateTime;
				Usr.Current.Update();

				Comment fullComment = new Comment(comment.K);

				if (!fullComment.Thread.Private && !fullComment.Thread.GroupPrivate && !fullComment.Thread.PrivateGroup)
				{

					if (Usr.Current.FacebookConnected && Usr.Current.FacebookStoryLaugh)
					{
						FacebookPost.CreateLaugh(Usr.Current, comment);
					}

					////LaughStub randomChatLaughStub = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.Laughs).Guid, fullComment);
					//LaughStub randomChatLaughStub = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.PublicStream).Guid, fullComment);
					//Chat.SendJsonChatItem(randomChatLaughStub);

					LaughStub randomChatLaughStub1 = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.PublicStream).Guid, fullComment);
					Chat.SendJsonChatItem(randomChatLaughStub1);
				}
				else
				{
					//LaughStub laughStub = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.Normal, Model.Entities.ObjectType.Thread, fullComment.ThreadK).Guid, fullComment);
					//UsrSet us = Thread.GetAllLoggedInParticipants(fullComment.Thread);
					//Chat.SendJsonChatItem(laughStub, us);
				}

			}
		}
Ejemplo n.º 26
0
		static CommentMessageStub getChatMessage(Guid roomGuid, Guid pinRoomGuid, Comment newComment, Thread parentThread, Usr postingUsr, string chatMessageBody)
		{
			return new CommentMessageStub(
				newComment.ChatItemGuid.Value.Pack(),
				ItemType.CommentChatMessage,
				newComment.DateTime.Ticks.ToString(),
				roomGuid.Pack(),
				postingUsr.NickName,
				postingUsr.StmuParams,
				postingUsr.K,
				postingUsr.HasPic ? postingUsr.Pic.ToString() : "0",
				postingUsr.HasChatPic ? postingUsr.ChatPic.Value.ToString() : "0",
				chatMessageBody,
				pinRoomGuid.Pack(),
				newComment.UrlRefresher(),
				parentThread.Subject.TruncateWithDots(30)
			);
		}
Ejemplo n.º 27
0
		internal SendCommentAlertsJob(Thread parentThread, Usr postingUsr, Comment newComment, bool isNewThread, List<int> alertedUsrKs, List<int> inviteKs, bool disableChatMessage, bool alreadySentChatMessage, string chatMessageBody) : this()
		{
			ParentThreadK.Value = parentThread.K;
			PostingUsrK.Value = postingUsr.K;
			NewCommentK.Value = newComment.K;
			IsNewThread.Value = isNewThread;
			AlertedUsrKs.Value = alertedUsrKs;
			InviteKs.Value = inviteKs;
			DisableChatMessage.Value = disableChatMessage;
			AlreadySentChatMessage.Value = alreadySentChatMessage;
			ChatMessageBody.Value = chatMessageBody;
		}
Ejemplo n.º 28
0
		protected override void Execute()
		{
			#region Comment newComment
			Comment newComment = null;
			try
			{
				newComment = new Comment(this.NewCommentK.Value);
			}
			catch (BobNotFound ex)
			{
				return; //sometimes the user deletes the comment before this is executed
			}
			#endregion
			#region Thread parentThread
			Thread parentThread = null;
			try
			{
				parentThread = new Thread(this.ParentThreadK.Value);
			}
			catch (BobNotFound ex)
			{
				return; //sometimes the user deletes the thread before this is executed
			}
			#endregion
			Usr postingUsr = new Usr(this.PostingUsrK.Value);
			List<int> alertedUsrKs = this.AlertedUsrKs.Value;
			bool isNewThread = this.IsNewThread.Value;
			List<int> inviteKs = this.InviteKs.Value;

			DateTime dt = DateTime.Today;
			Log.Increment(Log.Items.DoAlertsStart, 1, dt);

			SendAlertsToUsersWatchingThisThread(parentThread, postingUsr, newComment, isNewThread, alertedUsrKs);
			SendInvites(parentThread, postingUsr, newComment, isNewThread, alertedUsrKs, inviteKs);

			if (IsNewThread)
			{
				ThreadSendMessagesToCommentAlerts(parentThread, postingUsr, alertedUsrKs);
				//ThreadSendInvites(parentThread, alertedUsrKs, postingUsr, inviteKs);
				ThreadSendGroupNewsAdminsAReminderIfIsRecommendedNews(parentThread);
				ThreadSendNewsAlerts(parentThread);
			}

			SendChatMessage(DisableChatMessage, AlreadySentChatMessage, newComment, parentThread, postingUsr, ChatMessageBody);
			UpdateTotalParticipants(parentThread);

			Log.Increment(Log.Items.DoAlertsEnd, 1, dt);
		}
Ejemplo n.º 29
0
		public void DeleteCommand(object o, CommandEventArgs e)
		{
			Usr.KickUserIfNotLoggedIn("Must be logged in to delete a post");
			if (e.CommandName.Equals("Delete"))
			{
				Comment CommentToDelete = new Comment(int.Parse(e.CommandArgument.ToString()));
				if (CurrentComment.ThreadK == CommentToDelete.ThreadK)
				{
					if (Usr.Current.CanDelete(CommentToDelete, CurrentThread, CurrentGroupUsr))
					{
						string redirect = CommentToDelete.Thread.UrlDiscussion();
						if (CommentToDelete.Thread.TotalComments == 1)
						{
							redirect = "/chat";
						}
						CommentToDelete.RegisterDelete(Usr.Current);
						CommentToDelete.DeleteAll(null);
						Response.Redirect(redirect);
					}
					else
					{
						throw new Exception("Can't delete");
					}
				}
			}
		}
Ejemplo n.º 30
0
		protected void CommentEditSaveClick(object o, EventArgs e)
		{
			if (!Usr.Current.CanNewsModerator())
			{
				throw new Exception("Can't news admin!!!");
			}
			CurrentComment = new Comment(CurrentComment.K);
			if (CommentEditTextBox.Text.Trim().Length == 0)
				throw new DsiUserFriendlyException("No text in comment!");
			CurrentComment.Text = Cambro.Web.Helpers.CleanHtml(CommentEditTextBox.Text);
			if (CurrentComment.K == CurrentComment.Thread.FirstComment.K)
			{
				if (Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text).Trim().Length == 0)
					throw new DsiUserFriendlyException("No text in subject!");
				CurrentComment.Thread.Subject = Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text);
				CurrentComment.Thread.Update();
			}
			CurrentComment.Update();
			((Spotted.Master.DsiPage)Page).AnchorSkip("CommentK-" + CurrentComment.K.ToString());

		}