private Control GetTopicAuthorIcon(int authorid) { var author = Members.GetAuthor(authorid); ProfileCommon prof = ProfileCommon.GetUserProfile(author.Username); if (prof.Gravatar) { Gravatar avatar = new Gravatar { Email = author.Email }; if (author.AvatarUrl != "" && author.AvatarUrl.StartsWith("http:")) { avatar.DefaultImage = author.AvatarUrl; } avatar.CssClass = "avatarsmall"; return(avatar); } else { SnitzMembershipUser mu = (SnitzMembershipUser)Membership.GetUser(author.Username); Literal avatar = new Literal { Text = author.AvatarImg }; if (mu != null && mu.IsActive && !(Config.AnonMembers.Contains(mu.UserName))) { avatar.Text = avatar.Text.Replace("'avatar'", "'avatarsmall online'"); } else { avatar.Text = avatar.Text.Replace("'avatar'", "'avatarsmall'"); } return(avatar); } }
private void SendPM() { MembershipUser currentUser = Membership.GetUser(_username); if (currentUser == null || currentUser.ProviderUserKey == null) { return; } string[] toMembers = Regex.Split(newTo.Text, ";"); foreach (string member in toMembers) { ProfileCommon profile = ProfileCommon.GetUserProfile(member); MembershipUser recipient = Membership.GetUser(member, false); if (recipient != null && recipient.ProviderUserKey != null) { var pm = new PrivateMessageInfo { FromMemberId = (int)currentUser.ProviderUserKey, Read = 0, Subject = newSubject.Text, Message = newMessage.Text, OutBox = _layout != "none" ? 1 : 0, SentDate = DateTime.UtcNow.ToForumDateStr(), ToMemberId = (int)recipient.ProviderUserKey, Mail = profile.PMEmail == null ? 0 : profile.PMEmail.Value }; Snitz.BLL.PrivateMessages.SendPrivateMessage(pm); } } //TODO: Send notify if required statusTxt.Text = Resources.PrivateMessage.PmSent; pnlMessage.Visible = false; }
private void DisplayMessage(PrivateMessageInfo pm) { MemberInfo member = Snitz.BLL.Members.GetMember(pm.FromMemberName); ProfileCommon prof = ProfileCommon.GetUserProfile(pm.FromMemberName); if (prof.Gravatar) { Gravatar avatar = new Gravatar { Email = member.Email }; if (member.AvatarUrl != "") { avatar.DefaultImage = member.AvatarUrl; } phAvatar.Controls.Add(avatar); } else { Literal avatar = new Literal { Text = member.AvatarUrl }; phAvatar.Controls.Add(avatar); } pmRecipients.Text = pm.Subject; pmSubject.Visible = false; pmFrom.Text = String.Format("<a href=\"/Account/profile.aspx?user={0}\">{0}</a>", pm.FromMemberName); pmTitle.Text = member.Title; pmCountry.Text = member.Country; pmPostcount.Text = member.PostCount.ToString(); pmDate.Text = pm.Sent.ToString(); pmBody.Text = pm.Message.ParseTags(); PMViews.ActiveViewIndex = 2; }
protected void btnSend_Click(object sender, EventArgs eventArgs) { MembershipUser currentUser = Membership.GetUser(username); if (currentUser == null || currentUser.ProviderUserKey == null) { return; } string[] toMembers = Regex.Split(tbxRecipient.Text, ";"); foreach (string member in toMembers) { ProfileCommon profile = ProfileCommon.GetUserProfile(member); MembershipUser recipient = Membership.GetUser(member, false); if (recipient != null && recipient.ProviderUserKey != null) { var pm = new PrivateMessageInfo { FromMemberId = (int)currentUser.ProviderUserKey, Read = 0, Subject = tbxSubject.Text, Message = qrMessage.Text, OutBox = _layout != "none" ? 1 : 0, SentDate = DateTime.UtcNow.ToForumDateStr(), ToMemberId = (int)recipient.ProviderUserKey, Mail = profile.PMEmail == null ? 0 : profile.PMEmail.Value }; Snitz.BLL.PrivateMessages.SendPrivateMessage(pm); } } //TODO: Send notify if required pmSuccess.Text = Resources.PrivateMessage.PmSent; ScriptManager.RegisterStartupScript(this, GetType(), "Startup", _redirectionScript, true); }
public ActionResult AddLogPage(AircraftLogModel viewModel, HttpPostedFileBase fileBase) { string relFolderUrl = Url.Content("~/Content/AircraftLogs/" + viewModel.RegistrationNumber); string absFolderUrl = Server.MapPath(relFolderUrl); string origFileUrl = Server.MapPath(Path.Combine(relFolderUrl, viewModel.EditPageNumber.ToString() + "orig.jpg")); string pageFileName = viewModel.EditPageNumber.ToString() + ".jpg"; string pageUrl = Server.MapPath(Path.Combine(relFolderUrl, pageFileName)); if (System.IO.File.Exists(pageUrl)) { ModelState.AddModelError(String.Empty, "The page number " + viewModel.EditPageNumber.ToString() + " already exists. Please delete it first or use different number."); return(ViewLog(viewModel.AircraftId, viewModel.RegistrationNumber)); } if (!System.IO.Directory.Exists(absFolderUrl)) { System.IO.Directory.CreateDirectory(absFolderUrl); } fileBase.SaveAs(origFileUrl); ImageHelper.ScaleToWidth(origFileUrl, pageUrl, 800); if (System.IO.File.Exists(pageUrl)) { Aircraft aircraft = _dataService.GetAircraftById(viewModel.AircraftId); aircraft.LogUpdloadedOn = DateTime.Now; aircraft.LogUploadedByMemberId = ProfileCommon.GetUserProfile().MemberId; _dataService.UpdateAircraft(aircraft); System.IO.File.Delete(origFileUrl); } ModelState.Clear(); return(ViewLog(viewModel.AircraftId, viewModel.RegistrationNumber)); }
public string SendPrivateMessage(string touser, string message, string subject, string layout) { string username = HttpContext.Current.User.Identity.Name; MembershipUser currentUser = Membership.GetUser(username); ProfileCommon profile = ProfileCommon.GetUserProfile(username); if (currentUser == null || currentUser.ProviderUserKey == null) { return(null); } var pm = new PrivateMessageInfo { Subject = subject, Message = message, ToMemberId = Convert.ToInt32(touser), FromMemberId = (int)currentUser.ProviderUserKey, Read = 0, OutBox = layout != "none" ? 1 : 0, SentDate = DateTime.UtcNow.ToForumDateStr(), Mail = profile.PMEmail == null ? 0 : profile.PMEmail.Value }; PrivateMessages.SendPrivateMessage(pm); //do we need to send an email MembershipUser toUser = Membership.GetUser(Convert.ToInt32(touser)); if (toUser != null && Config.UseEmail) { ProfileCommon toprofile = ProfileCommon.GetUserProfile(toUser.UserName); if (toprofile.PMEmail.HasValue) { if (toprofile.PMEmail.Value == 1) { SnitzEmail notification = new SnitzEmail { FromUser = "******", toUser = new MailAddress(toUser.Email), subject = Regex.Replace(Config.ForumTitle, @"&\w+;", "") + " - New Private message" }; string strMessage = "Hello " + toUser.UserName; strMessage = strMessage + username + " has sent you a private message at " + Config.ForumTitle + "." + Environment.NewLine; if (String.IsNullOrEmpty(subject)) { strMessage = strMessage + "Regarding - " + subject + "." + Environment.NewLine + Environment.NewLine; } else { strMessage = strMessage + "With the subject entitled - " + message + "." + Environment.NewLine + Environment.NewLine; } notification.msgBody = strMessage; notification.Send(); } } } return(PrivateMessage.PmSent); }
protected void RptItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; AuthorInfo author; if (Cache["M" + UserId] == null) { author = Members.GetAuthor(UserId); Cache.Insert("M" + UserId, author, null, DateTime.Now.AddMinutes(10d), System.Web.Caching.Cache.NoSlidingExpiration); } else { author = (AuthorInfo)Cache["M" + UserId]; } if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem)) { if (author != null) { Label litRank = (Label)item.FindControl("MemberTitleLabel"); if (litRank != null) { string title = ""; RankInfo rInf = new RankInfo(author.Username, ref title, author.PostCount, SnitzCachedLists.GetRankings()); if (Config.ShowRankTitle) { litRank.Text = title; } } ProfileCommon prof = ProfileCommon.GetUserProfile(author.Username); if (prof.Gravatar) { var avatar = (Literal)item.FindControl("AvatarLabel"); avatar.Visible = false; var ph = (PlaceHolder)item.FindControl("phAvatar"); ph.Visible = true; var grav = new Gravatar { Email = author.Email }; if (author.AvatarUrl != "" && author.AvatarUrl.StartsWith("http:")) { grav.DefaultImage = author.AvatarUrl; } ph.Controls.Add(grav); } else { var avatar = (Literal)item.FindControl("AvatarLabel"); var ph = (PlaceHolder)item.FindControl("phAvatar"); avatar.Text = author.AvatarImg; avatar.Visible = true; ph.Visible = false; } } } }
public static void SavePreferences(object user, string enabled, string notify, string layout) { ProfileCommon _profile = ProfileCommon.GetUserProfile((string)user); _profile.PMEmail = Convert.ToInt16(notify); _profile.PMReceive = Convert.ToInt16(enabled); _profile.PMLayout = layout; _profile.Save(); }
public static string LinkTarget(AuthorInfo author) { ProfileCommon prof = ProfileCommon.GetUserProfile(author.Username); if (String.IsNullOrEmpty(prof.LinkTarget)) { return("_blank"); } return(prof.LinkTarget); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (HttpContext.Current.Items["user"] != null) { _userProfile = HttpContext.Current.Items["user"].ToString(); } else { _userProfile = !String.IsNullOrEmpty(Request.Params["user"]) ? Request.Params["user"] : Member.Username; } _profile = ProfileCommon.GetUserProfile(_userProfile); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!IsAuthenticated) { throw new SecurityException("You must be a logged in member to view users profiles"); } editorCSS.Attributes.Add("href", "/css/" + Page.Theme + "/editor.css"); if (webResources.TextDirection == "rtl") { pageCSS.Attributes.Add("href", "/css/" + Page.Theme + "/profilepagertl.css"); } else { pageCSS.Attributes.Add("href", "/css/" + Page.Theme + "/profilepage.css"); } TabContainer1.ActiveTabIndex = 0; if (HttpContext.Current.Items["user"] != null) { _profileUser = HttpContext.Current.Items["user"].ToString(); } else { _profileUser = !String.IsNullOrEmpty(Request.Params["user"]) ? Request.Params["user"] : Member.Username; } if (Session["CurrentProfile"] == null) { Session.Add("CurrentProfile", _profileUser); } else { _profileUser = Session["CurrentProfile"].ToString(); } _user = Members.GetMember(_profileUser); _profile = ProfileCommon.GetUserProfile(_profileUser); Page.Title = String.Format(webResources.lblProfile, _profileUser); IsMyProfile = _profileUser == Member.Username; ddTheme.AutoPostBack = IsMyProfile; if (!IsPostBack) { _weblinks = _profile.FavLinks; Session.Add("WEBLINK", _weblinks); } else { _weblinks = (List <SnitzLink>)Session["WEBLINK"]; SetupDynamicControls(); } }
protected void Page_Load(object sender, EventArgs e) { if (Post == null) { return; } PageBase page = (PageBase)Page; PostPanel.CssClass = this.CssClass; TopicInfo topic = (TopicInfo)Post; lblSubject.Text = topic.Subject; msgBody.Text = topic.Message.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); litDate.Text = SnitzTime.TimeAgoTag(topic.Date, page.IsAuthenticated, page.Member); litAuthor.Text = topic.AuthorProfilePopup; ProfileCommon prof = ProfileCommon.GetUserProfile(topic.AuthorName); var author = Members.GetAuthor(topic.AuthorId); if (prof.Gravatar) { Gravatar avatar = new Gravatar { Email = author.Email }; if (author.AvatarUrl != "" && author.AvatarUrl.StartsWith("http:")) { avatar.DefaultImage = author.AvatarUrl; } phAvatar.Controls.Add(avatar); } else { SnitzMembershipUser mu = (SnitzMembershipUser)Membership.GetUser(author.Username); Literal avatar = new Literal { Text = author.AvatarImg }; if (mu != null && mu.IsActive && !(Config.AnonMembers.Contains(mu.UserName))) { avatar.Text = avatar.Text.Replace("'avatar'", "'avatar online'"); } phAvatar.Controls.Add(avatar); } litViews.Text = String.Format("viewed {0} times", topic.Views); blgDay.Text = topic.Date.Day.ToString(); blgMonth.Text = topic.Date.ToString("MMM"); hBookmark.OnClientClick = "confirmBookMark('Do you want to bookmark this Blog entry?'," + topic.Id + ",-1);return false;"; hComments.Text = String.Format("{0} {1}", topic.ReplyCount, webResources.lblComments); }
public void BookMarkTopic(int topicid) { var user = HttpContext.Current.User.Identity.Name; ProfileCommon prof = ProfileCommon.GetUserProfile(user); TopicInfo t = Topics.GetTopic(topicid); string url = String.Format("~/Content/Forums/topic.aspx?TOPIC={0}", t.Id); List <SnitzLink> bookmarks = prof.BookMarks; if (!bookmarks.Contains(new SnitzLink(t.Subject, url, 0))) { bookmarks.Add(new SnitzLink(t.Subject, url, bookmarks.Count)); prof.BookMarks = bookmarks; prof.Save(); } }
public void BookMarkReply(int replyid, int page) { ReplyInfo r = Replies.GetReply(replyid); TopicInfo rt = Topics.GetTopic(r.TopicId); var user = HttpContext.Current.User.Identity.Name; ProfileCommon prof = ProfileCommon.GetUserProfile(user); string rurl = String.Format("~/Content/Forums/topic.aspx?TOPIC={0}&whichpage={1}&#{2}", r.TopicId, page + 1, r.Id); List <SnitzLink> rbookmarks = prof.BookMarks; if (!rbookmarks.Contains(new SnitzLink(rt.Subject, rurl, 0))) { rbookmarks.Add(new SnitzLink(rt.Subject, rurl, rbookmarks.Count)); prof.BookMarks = rbookmarks; prof.Save(); } }
protected void Page_Load(object sender, EventArgs e) { if (Post == null) { return; } PageBase page = (PageBase)Page; PostPanel.CssClass = this.CssClass; ReplyInfo reply = (ReplyInfo)Post; msgBody.Text = reply.Message.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); litDate.Text = SnitzTime.TimeAgoTag(reply.Date, page.IsAuthenticated, page.Member); litAuthor.Text = reply.AuthorProfilePopup; ProfileCommon prof = ProfileCommon.GetUserProfile(reply.AuthorName); var author = Members.GetAuthor(reply.AuthorId); if (prof.Gravatar) { Gravatar avatar = new Gravatar { Email = author.Email }; if (author.AvatarUrl != "" && author.AvatarUrl.StartsWith("http:")) { avatar.DefaultImage = author.AvatarUrl; } avatar.CssClass = "avatar"; phAvatar.Controls.Add(avatar); } else { SnitzMembershipUser mu = (SnitzMembershipUser)Membership.GetUser(author.Username); Literal avatar = new Literal { Text = author.AvatarImg }; if (mu != null && mu.IsActive && !(Config.AnonMembers.Contains(mu.UserName))) { avatar.Text = avatar.Text.Replace("'avatar'", "'avatar online'"); } phAvatar.Controls.Add(avatar); } }
public static ProfileCommon GetPreferences(string user) { return(ProfileCommon.GetUserProfile(user)); }
private void SaveMemberProfile() { _profile = ProfileCommon.GetUserProfile(_profileUser); _profile.Gravatar = cbxGravatar.Checked; _profile.HideAge = cbxHideAge.Checked; _profile.Skype = tbxSkype.Text; _profile.PublicGallery = cbxPublic.Checked && Config.ShowGallery; _profile.LinkTarget = ddlTarget.SelectedValue; _profile.PMEmail = _profile.PMEmail; _profile.PMReceive = _profile.PMReceive; _profile.Save(); string folderPath = "/gallery/"; folderPath += _profileUser + "/public.txt"; string path = Server.MapPath("~" + folderPath); if (_profile.PublicGallery && Config.ShowGallery) { if (!File.Exists(path)) { File.Create(path); } } else { if (File.Exists(path)) { File.Delete(path); } } if (tbxRealName.Text.Trim() != "") { int i = tbxRealName.Text.IndexOf(" "); _user.Firstname = i > 0 ? tbxRealName.Text.Substring(0, tbxRealName.Text.IndexOf(" ")).Trim() : tbxRealName.Text.Trim(); _user.Lastname = tbxRealName.Text.Replace(_user.Firstname, "").Trim(); } _user.Age = Common.GetAgeFromDOB(DobPicker.DOBStr); _user.DateOfBirth = DobPicker.DOBStr; if (ddlMarStatus.SelectedIndex >= 0) { _user.MaritalStatus = ddlMarStatus.SelectedValue; } if (ddlGender.SelectedIndex >= 0) { _user.Gender = ddlGender.SelectedValue; } _user.State = tbxState.Text; _user.City = tbxCity.Text; _user.Country = tbxCountry.Text; _user.Occupation = tbxOccupation.Text; _user.Title = tbxForumTitle.Text.Trim(); if (ddlTimeZone.SelectedIndex >= 0) { TimeZoneInfo tzone = TimeZoneInfo.FindSystemTimeZoneById(ddlTimeZone.SelectedValue); _user.TimeZone = ddlTimeZone.SelectedValue; _user.TimeOffset = tzone.BaseUtcOffset.TotalHours; } _user.UseDaylightSaving = cbxDaylightSaving.Checked; //email _user.ReceiveEmails = cbxReceiveEmail.Checked; _user.HideEmail = cbxHideEmail.Checked; _user.Yahoo = tbxYAHOO.Text; _user.AIM = tbxAIM.Text; _user.Skype = tbxSkype.Text; _user.ICQ = tbxICQ.Text; TextBox favQ = phQuote.FindControl("tbxQuote") as TextBox; if (favQ != null) { _user.FavouriteQuote = favQ.Text; } TextBox sig = phSig.FindControl("tbxSig") as TextBox; if (sig != null) { _user.Signature = sig.Text; } TextBox bio = phBiog.FindControl("tbxSig") as TextBox; if (bio != null) { _user.Biography = bio.Text; } _user.UseSignature = cbxUseSig.Checked; _user.ViewSignatures = cbxViewSig.Checked; TextBox news = phNews.FindControl("tbxNews") as TextBox; if (news != null) { _user.LatestNews = news.Text; } TextBox hobby = phHobby.FindControl("tbxHobby") as TextBox; if (hobby != null) { _user.Hobbies = hobby.Text; } TextBox home = phHomePage.FindControl("tbxHomePage") as TextBox; if (home != null) { _user.HomePage = home.Text; } _user.Theme = ddTheme.Text; if (IsMyProfile) { Config.UserTheme = _user.Theme; } //fav links Members.SaveMember(_user); SetupTabs(); //SetupDynamicControls(); }
private void SetProperties() { if (Config.ShowRankStars || Config.ShowRankTitle) { Literal litRank = (Literal)FindControl("Rank"); if (litRank != null) { string title = ""; RankInfo rInf = new RankInfo(_author.Username, ref title, _author.PostCount, SnitzCachedLists.GetRankings()); if (Config.ShowRankTitle) { litRank.Text = title + @"<br/>"; } if (Config.ShowRankStars) { litRank.Text += rInf.Stars; } } } ProfileCommon prof = ProfileCommon.GetUserProfile(_author.Username); if (prof.Gravatar) { Gravatar avatar = new Gravatar { Email = _author.Email }; if (_author.AvatarUrl != "" && _author.AvatarUrl.StartsWith("http:")) { avatar.DefaultImage = _author.AvatarUrl; } avatar.CssClass = "avatar"; phAvatar.Controls.Add(avatar); } else { SnitzMembershipUser mu = (SnitzMembershipUser)Membership.GetUser(_author.Username); Literal avatar = new Literal { Text = _author.AvatarImg }; if (mu != null && mu.IsActive && !(Config.AnonMembers.Contains(mu.UserName))) { avatar.Text = avatar.Text.Replace("'avatar'", "'avatar online'"); } phAvatar.Controls.Add(avatar); } country.Text = _author.Country.Trim(); if (!String.IsNullOrEmpty(country.Text)) { country.Text += "<br/>"; } posts.Text = String.Format("{0} {1}", Common.TranslateNumerals(_author.PostCount), webResources.lblPosts); hProf.Visible = _loggedonuser; hProf.OnClientClick = String.Format( "mainScreen.LoadServerControlHtml('Public Profile',{{'pageID':1,'data':{0}}}, 'methodHandlers.BeginRecieve');return false;", _author.Id); if (!String.IsNullOrEmpty(_author.HomePage)) { hHome.Visible = _loggedonuser && (_author.HomePage.Replace("http://", "").Trim() != string.Empty); hHome.NavigateUrl = string.Format("http://{0}", _author.HomePage.Replace("http://", "")); hHome.Text = hHome.ToolTip = webResources.lblHomePage; } if (!String.IsNullOrEmpty(_author.ICQ)) { hICQ.Visible = _loggedonuser && (_author.ICQ.Trim() != ""); hICQ.NavigateUrl = string.Format("http://www.icq.com/people/webmsg.php?to={0}", _author.ICQ.Trim()); hICQ.Text = hICQ.ToolTip = webResources.lblICQ; } if (!String.IsNullOrEmpty(_author.Yahoo)) { hYAHOO.Visible = _loggedonuser && (_author.Yahoo.Trim() != ""); hYAHOO.NavigateUrl = string.Format("http://edit.yahoo.com/config/send_webmesg?.target={0}&;.src=pg", _author.Yahoo.Trim()); hYAHOO.Text = hYAHOO.ToolTip = webResources.lblYAHOO; } hEmail.Visible = (((_loggedonuser || !Config.LogonForEmail) && _author.ReceiveEmails)) && Config.UseEmail; hEmail.NavigateUrl = "#"; hEmail.Attributes.Add("onclick", string.Format( "mainScreen.LoadServerControlHtml('Email Member',{{'pageID':10,'data':{0}}},'methodHandlers.BeginRecieve');return false;", _author.Id)); hAIM.Visible = _loggedonuser && (_author.AIM.Trim() != ""); hAIM.NavigateUrl = string.Format("aim:goim?screenname={0}", _author.AIM.Trim()); hAIM.Text = hAIM.ToolTip = webResources.lblAIM; hSKYPE.Visible = _loggedonuser && !String.IsNullOrEmpty(_author.Skype.Trim()); hSKYPE.NavigateUrl = String.Format("skype:{0}?chat", _author.Skype.Trim()); hSKYPE.Text = hSKYPE.ToolTip = webResources.lblSkype; hSendPm.Visible = (_loggedonuser || !Config.PrivateMessaging) && prof.PMReceive == 1; hSendPm.NavigateUrl = "#"; hSendPm.Attributes.Add("onclick", string.Format( "mainScreen.LoadServerControlHtml('Send Private Message',{{'pageID':13,'data':{0}}},'methodHandlers.BeginRecieve');return false;", _author.Id)); }