Пример #1
0
 /// <summary>
 /// Checks is the recipient is online and sends the online event notification.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="recipient">The recipient.</param>
 /// <param name="text">The text.</param>
 /// <param name="thumbnailUrl">The thumbnail URL.</param>
 /// <param name="redirectUrl">The redirect URL.</param>
 public static void SendOnlineEventNotification(string sender, string recipient, string text, string thumbnailUrl, string redirectUrl)
 {
     if (IsOnline(recipient) || IsUsingNotifier(recipient))
     {
         var notification = new GenericEventNotification
         {
             Recipient = recipient,
             Sender = sender,
             Text = text,
             ThumbnailUrl = thumbnailUrl,
             RedirectUrl = redirectUrl
         };
         RealtimeNotification.SendNotification(notification);
     }
 }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MatchToFriend1.IsVisible = MatchmakerHelper.IsMatchmakerState;

            if (CurrentUserSession == null && Config.Users.RegistrationRequiredToBrowse)
                Response.Redirect("LoginThroughFacebook.aspx?back_url=" + Request.Url.PathAndQuery.Substring(1));
            //Response.Redirect("LoginThroughFacebook.aspx?back_url=" + Server.UrlEncode(Request.Url.PathAndQuery.Substring(1)));

            if (Config.Users.CompletedProfileRequiredToBrowseSearch &&
                CurrentUserSession != null && !CurrentUserSession.HasProfile)
                Response.Redirect("ManageProfile.aspx?err=profnotcompl");

            if (!Page.IsPostBack)
            {
                LoadStrings();

                if (Request.Params["uid"] != null)
                {
                    try
                    {
                        User user = Classes.User.Load(Request.Params["uid"]);

                        if (user.Deleted)
                        {
                            if (user.DeleteReason == null || user.DeleteReason.Trim().Length == 0)
                                Page.StatusPageMessage = "This user has been deleted!".Translate();
                            else
                                Page.StatusPageMessage =
                                    String.Format(
                                        "This user has been deleted for the following reason:<br><br>{0}".Translate(),
                                        user.DeleteReason);
                            Response.Redirect(MatchmakerHelper.CurrentHomePage);
                        }

                        ViewedUser = user;

                        if (Page is ShowUserPage && CurrentUserSession != null)
                        {
                            if (StrTargetUserID == StrUserID)
                                Response.Redirect("ManageProfile.aspx");

                            // Save profile view
                            if (!CurrentUserSession.IsOptionEnabled(eUserOptions.DisableProfileViews))
                            {
                                Classes.User.SaveProfileView(
                                    CurrentUserSession.Username, ViewedUser.Username);

                                Classes.User.AddScore(CurrentUserSession.Username,
                                              Config.UserScores.ViewingProfile, "ViewingProfile");
                                Classes.User.AddScore(ViewedUser.Username,
                                              Config.UserScores.ViewedProfile, "ViewedProfile");

                                if (Config.Users.NewEventNotification &&
                                    CurrentUserSession.Username != ViewedUser.Username
                                    && (ViewedUser.IsOnline() || Classes.User.IsUsingNotifier(ViewedUser.Username)))
                                {
                                    var text = String.Format("User {0} is viewing your profile!".Translate(),
                                                             "<b>" + CurrentUserSession.Username + "</b>");
                                    int imageID;
                                    try
                                    {
                                        imageID = CurrentUserSession.GetPrimaryPhoto().Id;
                                    }
                                    catch (NotFoundException)
                                    {
                                        imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender);
                                    }
                                    var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                                    var notification = new GenericEventNotification
                                                           {
                                                               Recipient = ViewedUser.Username,
                                                               Sender = CurrentUserSession.Username,
                                                               Text = text,
                                                               ThumbnailUrl = thumbnailUrl,
                                                               RedirectUrl =
                                                                   UrlRewrite.CreateShowUserUrl(
                                                                       CurrentUserSession.Username)
                                                           };
                                    RealtimeNotification.SendNotification(notification);
                                }
                            }
                        }

                        #region show/hide IM link

                        string reason;
                        if (Config.Misc.EnableIntegratedIM &&
                            CurrentUserSession != null &&
                            !CurrentUserSession.StealthMode &&
                            ViewedUser.IsOnline() &&
                            CurrentUserSession.Username != ViewedUser.Username &&
                            Classes.User.CanSendMessage(CurrentUserSession, ViewedUser, out reason))
                        {
                            pnlInstantMessenger.Visible = true;

                            var permissionCheckResult = CurrentUserSession.CanIM();

                            if (permissionCheckResult == PermissionCheckResult.No)
                                pnlInstantMessenger.Visible = false;
                            else
                            {
                                string root = HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/');
                                var sectionUnlocked = UnlockedSection.IsSectionUnlocked(CurrentUserSession.Username, ViewedUser.Username, UnlockedSection.SectionType.IM, null);
                                if (permissionCheckResult == PermissionCheckResult.Yes || sectionUnlocked)
                                {
                                    lnkInstantMessenger.HRef = "#";
                                    lnkInstantMessenger.Attributes.Add("onclick",
                                                                       String.Format(
                                                                           "window.open('AjaxChat/MessengerWindow.aspx?init=1&target={0}', 'ajaxim_{1}_{0}', 'width=650,height=400,resizable=1,menubar=0,status=0,toolbar=0'); return false;",
                                                                           ViewedUser.Username,
                                                                           CurrentUserSession.Username));
                                    lnkInstantMessenger.Target = "AjaxIM_" + ViewedUser.Username;
                                }
                                else if (permissionCheckResult == PermissionCheckResult.YesWithCredits)
                                {
                                    string url = String.Format(
                                        "if (confirm('{4}')) window.open('{0}/LaunchIM.aspx?targetUsername={1}', 'ajaxim_{2}_{3}', 'width=650,height=400,resizable=1,menubar=0,status=0,toolbar=0'); return false;",
                                        root, StrTargetUserID,
                                        Regex.Replace(StrUserID, @"[^A-Za-z0-9]", "_"),
                                        Regex.Replace(StrTargetUserID, @"[^A-Za-z0-9]", "_"),
                                        String.Format(Lang.Trans("Opening the chat session will subtract {0} credits from your balance."), CurrentUserSession.BillingPlanOptions.CanIM.Credits /*Config.Credits.CreditsForIM*/));

                                    lnkInstantMessenger.Attributes.Add("onclick", url);
                                    lnkInstantMessenger.Attributes.Add("href", "");
                                }
                                else if (permissionCheckResult == PermissionCheckResult.YesButMoreCreditsNeeded ||
                                        permissionCheckResult == PermissionCheckResult.YesButPlanUpgradeNeeded)
                                {
                                    lnkInstantMessenger.Visible = false;
                                    lnkInstantMessengerPay.Visible = true;
                                }
                            }
                        }
                        else pnlInstantMessenger.Visible = false;

                        #endregion

                        #region set "allow/disallow user to view your private photos" links

                        if (Config.Photos.EnablePrivatePhotos &&
                            CurrentUserSession != null &&
                            CurrentUserSession.HasPrivatePhotos())
                        {
                            if (CurrentUserSession.HasUserAccessToPrivatePhotos(user.Username))
                                pnlGrantAccessToPrivatePhotos.Visible = false;
                            else
                                pnlDenyAccessToPrivatePhotos.Visible = false;
                        }
                        else
                        {
                            pnlGrantAccessToPrivatePhotos.Visible = false;
                            pnlDenyAccessToPrivatePhotos.Visible = false;
                        }

                        #endregion

                        #region set "allow/disallow user to view your private video" links

                        if (
                            CurrentUserSession != null &&
                            (CurrentUserSession.HasPrivateVideo()
                             || CurrentUserSession.HasPrivateVideoUpload()))
                        {
                            if (CurrentUserSession.HasUserAccessToPrivateVideo(user.Username))
                                pnlGrantAccessToPrivateVideo.Visible = false;
                            else
                                pnlDenyAccessToPrivateVideo.Visible = false;
                        }
                        else
                        {
                            pnlGrantAccessToPrivateVideo.Visible = false;
                            pnlDenyAccessToPrivateVideo.Visible = false;
                        }

                        #endregion

                        #region set "allow/disallow user to view your private audio" links

                        if (Config.Misc.EnableAudioUpload && CurrentUserSession != null &&
                            CurrentUserSession.HasPrivateAudio())
                        {
                            if (CurrentUserSession.HasUserAccessToPrivateAudio(user.Username))
                                pnlGrantAccessToPrivateAudio.Visible = false;
                            else
                                pnlDenyAccessToPrivateAudio.Visible = false;
                        }
                        else
                        {
                            pnlGrantAccessToPrivateAudio.Visible = false;
                            pnlDenyAccessToPrivateAudio.Visible = false;
                        }

                        #endregion

                        #region activate/deactivate RealPerson Verification links

                        if (Config.Users.EnableRealPersonVerificationFunctionality &&
                            CurrentUserSession != null)
                        {

                            using (var db = new Model.ezFixUpDataContext())
                            {
                                var verifiedByThisUser =
                                    db.VerifiedUsers.Any(u => u.vu_verifiedby == CurrentUserSession.Username
                                                                   && u.vu_verifieduser == ViewedUser.Username);

                                if (verifiedByThisUser || CurrentUserSession.IsUserVerified(user.Username))
                                    pnlCertifyUserIsGenuine.Visible = false;
                                else
                                    pnlRemoveVerifiedUserStatus.Visible = false;
                            }
                        }
                        else
                        {
                            pnlCertifyUserIsGenuine.Visible = false;
                            pnlRemoveVerifiedUserStatus.Visible = false;
                        }

                        #endregion

                        #region Set "block/unlblock user" links

                        if (CurrentUserSession != null)
                        {
                            if (CurrentUserSession.IsUserBlocked(ViewedUser.Username))
                                pnlBlockUser.Visible = false;
                            else
                                pnlUnblockUser.Visible = false;
                        }
                        else
                        {
                            pnlBlockUser.Visible = false;
                            pnlUnblockUser.Visible = false;
                        }

                        #endregion

                        #region Enable/Disable ViewBlog

                        pnlBlog.Visible = Config.Misc.EnableBlogs && Blog.HasPosts(ViewedUser.Username);

                        #endregion

                        #region Enable/Disable ViewEvents

                        pnlViewEvents.Visible = Config.Users.EnableUserEventsPage;

                        #endregion

                        #region Add report abuse option

                        if (Config.AbuseReports.UserCanReportProfileAbuse
                            && (CurrentUserSession != null && (CurrentUserSession.BillingPlanOptions.UserCanReportAbuse.Value
                            || CurrentUserSession.Level != null && CurrentUserSession.Level.Restrictions.UserCanReportAbuse)))
                        {
                            pnlReportAbuseLink.Visible = true;
                        }

                        #endregion

                        #region Show blog if param is supplied

                        // Left for compatibility with old links to blog posts
                        if (Request.Params["bpid"] != null && !(Page is ShowUserBlog))
                        {
                            try
                            {
                                int blogPostId = Convert.ToInt32(Request.Params["bpid"]);
                                Response.Redirect(UrlRewrite.CreateShowUserBlogUrl(ViewedUser.Username,
                                    blogPostId));
                                return;
                            }
                            catch (ArgumentException)
                            {
                            }
                        }

                        #endregion

                        #region Set meta tags

                        Parser parse = delegate(string text)
                                           {
                                               string result = text
                                                   .Replace("%%USERNAME%%", user.Username)
                                                   .Replace("%%AGE%%", user.Age.ToString())
                                                   .Replace("%%GENDER%%", Lang.Trans(user.Gender.ToString()))
                                                   .Replace("%%COUNTRY%%", user.Country)
                                                   .Replace("%%STATE%%", user.State)
                                                   .Replace("%%ZIP%%", user.ZipCode)
                                                   .Replace("%%CITY%%", user.City);

                                               var regex = new Regex(@"%%Q_(\d+)%%");
                                               Match match = regex.Match(result);
                                               while (match.Success)
                                               {
                                                   foreach (Capture capture in match.Groups[1].Captures)
                                                   {
                                                       int questionId;
                                                       if (!int.TryParse(capture.Value, out questionId)) continue;
                                                       try
                                                       {
                                                           ProfileAnswer answer =
                                                               ProfileAnswer.Fetch(user.Username, questionId);
                                                           result =
                                                               result.Replace(String.Format("%%Q_{0}%%", questionId),
                                                                              Server.HtmlEncode(answer.Value));
                                                       }
                                                       catch (NotFoundException)
                                                       {
                                                           continue;
                                                       }
                                                   }
                                                   match = match.NextMatch();
                                               }

                                               return result;
                                           };

                        Page.Header.Title = parse(Config.SEO.ShowUserTitleTemplate);

                        var metaDesc = new HtmlMeta
                                           {
                                               ID = "Description",
                                               Name = "description",
                                               Content = parse(Config.SEO.ShowUserMetaDescriptionTemplate)
                                           };
                        Page.Header.Controls.Add(metaDesc);

                        var metaKeywords = new HtmlMeta
                                               {
                                                   ID = "Keywords",
                                                   Name = "keywords",
                                                   Content = parse(Config.SEO.ShowUserMetaKeywordsTemplate)
                                               };
                        Page.Header.Controls.Add(metaKeywords);

                        #endregion

                        #region Show AddThis link

                        if (Config.ThirdPartyServices.UseAddThis)
                        {
                            divAddThis.Visible = true;
                            divAddThis.InnerHtml = Config.ThirdPartyServices.AddThisCode;
                        }

                        #endregion
                    }
                    catch (ThreadAbortException)
                    {
                    }
                    catch (ArgumentException)
                    {
                        Response.Redirect(MatchmakerHelper.CurrentHomePage);
                    }
                    catch (NotFoundException)
                    {
                        Response.Redirect(MatchmakerHelper.CurrentHomePage);
                    }
                    catch (Exception err)
                    {
                        Global.Logger.LogError(err);
                        Response.Redirect(MatchmakerHelper.CurrentHomePage);
                    }
                }
                else
                {
                    Response.Redirect(MatchmakerHelper.CurrentHomePage);
                }

                #region Show/Hide links

                if (CurrentUserSession != null)
                {
                    if (Config.Users.EnableFavorites)
                    {
                        bool isFavorite = CurrentUserSession.IsUserInFavouriteList(ViewedUser.Username);
                        pnlRemoveFromFavourites.Visible = isFavorite;
                        pnlAddToFavourites.Visible = !isFavorite;
                    }
                    else
                    {
                        pnlRemoveFromFavourites.Visible = false;
                        pnlAddToFavourites.Visible = false;
                    }

                    if (Config.Users.EnableFriends)
                    {
                        bool isFriend = CurrentUserSession.IsUserInFriendList(ViewedUser.Username);
                        pnlRemoveFromFriends.Visible = isFriend;
                        pnlAddToFriends.Visible = !isFriend;
                        //pnlViewMutualFriends.Visible = isFriend;
                    }
                    else
                    {
                        pnlAddToFriends.Visible = false;
                        pnlRemoveFromFriends.Visible = false;
                        //pnlViewMutualFriends.Visible = false;
                    }
                }
                else
                {
                    pnlRemoveFromFavourites.Visible = false;
                    pnlAddToFavourites.Visible = false;
                    pnlAddToFriends.Visible = false;
                    pnlRemoveFromFriends.Visible = false;
                    //pnlViewMutualFriends.Visible = false;
                }

                if (Page is ShowUserPage && Config.ThirdPartyServices.UseGoogleTranslateForMessages)
                {
                    divTranslate.Visible = true;
                }

                #endregion
            }

            #region Apply profile skin

            if (ViewedUser.ProfileSkin != null || Request.Params["skin"] != null)
            {
                var cssSkinCommon = new HtmlLink();
                cssSkinCommon.Attributes.Add("rel", "stylesheet");
                cssSkinCommon.Attributes.Add("type", "text/css");
                cssSkinCommon.Href = "Skins/common.css";
                Page.Header.Controls.Add(cssSkinCommon);

                var cssSkin = new HtmlLink();
                cssSkin.Attributes.Add("rel", "stylesheet");
                cssSkin.Attributes.Add("type", "text/css");
                cssSkin.Href = Request.Params["skin"] ?? ViewedUser.ProfileSkin;
                Page.Header.Controls.Add(cssSkin);
            }

            #endregion

            PrepareLinks();
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (CurrentUserSession == null && Config.Users.RegistrationRequiredToBrowse)
                    Response.Redirect("LoginThroughFacebook.aspx?back_url=" + Server.UrlEncode(Request.Url.AbsoluteUri));

                if (Config.Users.CompletedProfileRequiredToBrowseSearch &&
                    CurrentUserSession != null && !CurrentUserSession.HasProfile)
                    Response.Redirect("ManageProfile.aspx?err=profnotcompl");
                
                loadPhotos = true;

                if (Request.Params["uid"] != null)
                {
                    try
                    {
                        User user = User.Load(Request.Params["uid"]);

                        if (user.Deleted)
                        {
                            if (user.DeleteReason == null || user.DeleteReason.Trim().Length == 0)
                                StatusPageMessage = "This user has been deleted!".Translate();
                            else
                                StatusPageMessage =
                                    String.Format(
                                        "This user has been deleted for the following reason:<br><br>{0}".Translate(),
                                        user.DeleteReason);
                            Response.Redirect("Home.aspx");
                        }

                        User = user;

                        #region Show/hide profile

                        if (CurrentUserSession == null)
                        {
                            if (!User.IsOptionEnabled(eUserOptions.VisitorsCanViewProfile))
                            {
                                if (User.IsOptionEnabled(eUserOptions.UsersCanViewProfile))
                                {
                                    StatusPageMessage = "This profile is visible for registered users only!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                                else if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewProfile))
                                {
                                    StatusPageMessage = "This profile is visible for friends of friends!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                                else
                                {
                                    StatusPageMessage = "This profile is visible for friends only!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (User.Username != CurrentUserSession.Username
                                && !User.IsOptionEnabled(eUserOptions.VisitorsCanViewProfile)
                                && !User.IsOptionEnabled(eUserOptions.UsersCanViewProfile))
                            {
                                if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewProfile))
                                {
                                    if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                    {
                                        bool areFriends = false;
                                        string[] friends = User.FetchMutuallyFriends(User.Username);
                                        foreach (string friend in friends)
                                        {
                                            if (User.IsUserInFriendList(friend, CurrentUserSession.Username))
                                            {
                                                areFriends = true;
                                                break;
                                            }
                                        }
                                        if (!areFriends)
                                        {
                                            StatusPageMessage = "This profile is visible for friends of friends!".Translate();
                                            Response.Redirect("Home.aspx");
                                            return;
                                        }
                                    }
                                }
                                else if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                {
                                    StatusPageMessage = "This profile is visible for friends only!".Translate();
                                    Response.Redirect("Home.aspx");
                                    return;
                                }
                            }
                        }

                        #endregion

                        #region Show/hide photos

                        if (!Config.Photos.FreeMembersCanViewPhotosOfPaidMembers)
                        {
                            if (CurrentUserSession == null)
                            {
                                if (Classes.User.IsPaidMember(User.Username))
                                {
                                    StatusPageMessage = "Only paid members can view those photos".Translate();
                                    loadPhotos = false;
                                }
                            }
                            else if (!Classes.User.IsPaidMember(CurrentUserSession.Username)
                                        && Classes.User.IsPaidMember(User.Username))
                            {
                                StatusPageMessage = "Only paid members can view those photos".Translate();
                                loadPhotos = false;
                            }
                        }

                        if (CurrentUserSession == null)
                        {
                            if (!User.IsOptionEnabled(eUserOptions.VisitorsCanViewPhotos))
                            {
                                if (User.IsOptionEnabled(eUserOptions.UsersCanViewPhotos))
                                {
                                    StatusPageMessage = "This photos are visible for registered users only!".Translate();
                                    loadPhotos = false;
                                }
                                else if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewPhotos))
                                {
                                    StatusPageMessage = "This photos are visible for friends of friends!".Translate();
                                    loadPhotos = false;
                                }
                                else
                                {
                                    StatusPageMessage = "This photos are visible for friends only!".Translate();
                                    loadPhotos = false;
                                }
                            }
                        }
                        else
                        {
                            if (User.Username != CurrentUserSession.Username
                                && !User.IsOptionEnabled(eUserOptions.VisitorsCanViewPhotos)
                                && !User.IsOptionEnabled(eUserOptions.UsersCanViewPhotos))
                            {
                                if (User.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewPhotos))
                                {
                                    if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                    {
                                        bool areFriends = false;
                                        string[] friends = Classes.User.FetchMutuallyFriends(User.Username);
                                        foreach (string friend in friends)
                                        {
                                            if (Classes.User.IsUserInFriendList(friend, CurrentUserSession.Username))
                                            {
                                                areFriends = true;
                                                break;
                                            }
                                        }
                                        if (!areFriends)
                                        {
                                            StatusPageMessage = "This photos are visible for friends of friends!".Translate();
                                            loadPhotos = false;
                                        }
                                    }
                                }
                                else if (!User.IsUserInFriendList(CurrentUserSession.Username))
                                {
                                    StatusPageMessage = "This photos are visible for friends only!".Translate();
                                    loadPhotos = false;
                                }
                            }
                        }

                        #endregion

                        #region Save profile view

                        if (CurrentUserSession != null &&
                            !CurrentUserSession.IsOptionEnabled(eUserOptions.DisableProfileViews))
                        {
                            User.SaveProfileView(
                                CurrentUserSession.Username, User.Username);

                            User.AddScore(CurrentUserSession.Username,
                                          Config.UserScores.ViewingProfile, "ViewingProfile");
                            User.AddScore(User.Username,
                                          Config.UserScores.ViewedProfile, "ViewedProfile");

                            if (Config.Users.NewEventNotification && 
                                (User.IsOnline() || User.IsUsingNotifier(User.Username)))
                            {
                                var text = String.Format("User {0} is viewing your profile!".Translate(),
                                                         "<b>" + CurrentUserSession.Username + "</b>");
                                int imageID;
                                try
                                {
                                    imageID = CurrentUserSession.GetPrimaryPhoto().Id;
                                }
                                catch (NotFoundException)
                                {
                                    imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender);
                                }
                                var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                                var notification = new GenericEventNotification
                                {
                                    Recipient = User.Username,
                                    Sender = CurrentUserSession.Username,
                                    Text = text,
                                    ThumbnailUrl = thumbnailUrl,
                                    RedirectUrl = UrlRewrite.CreateMobileShowUserUrl(CurrentUserSession.Username)
                                };
                                RealtimeNotification.SendNotification(notification);
                            }
                        }

                        #endregion

                        LoadStrings();
                        LoadProfile();
                    }
                    catch (ThreadAbortException)
                    {
                    }
                    catch (ArgumentException)
                    {
                        Response.Redirect("Home.aspx");
                    }
                    catch (NotFoundException)
                    {
                        Response.Redirect("Home.aspx");
                    }
                    catch (Exception err)
                    {
                        Global.Logger.LogError(err);
                        Response.Redirect("Home.aspx");
                    }
                }
                else
                {
                    Response.Redirect("Home.aspx");
                }
            }

            ScriptManager scriptManager = ScriptManager.GetCurrent(Page);
            if (scriptManager != null)
                scriptManager.Navigate += scriptManager_Navigate;
        }
Пример #4
0
        protected void lnkUpdateStatusText_Click(object sender, EventArgs e)
        {
            string status = String.Empty;

            status = txtStatusText.Text.Trim();

            if (status.Length > 0)
            {
                lblStatusText.Text = Server.HtmlEncode(status);
                _currentUserSession.StatusText = status;
                _currentUserSession.Update();

                #region Add FriendUpdatedStatus Event & realtime notifications

                Event newEvent = new Event(_currentUserSession.Username) { Type = Event.eType.FriendUpdatedStatus };

                var friendUpdatedStatus = new FriendUpdatedStatus { Status = status };
                newEvent.DetailsXML = Misc.ToXml(friendUpdatedStatus);

                newEvent.Save();

                string[] usernames = Classes.User.FetchMutuallyFriends(_currentUserSession.Username);

                foreach (string friendUsername in usernames)
                {
                    if (Config.Users.NewEventNotification &&
                        (Classes.User.IsOnline(friendUsername) || Classes.User.IsUsingNotifier(friendUsername)))
                    {
                        var text = String.Format("Your friend {0} has changed their status to \"{1}\"".Translate(),
                                                 "<b>" + _currentUserSession.Username + "</b>", status);
                        var imageID = 0;
                        try
                        {
                            imageID = _currentUserSession.GetPrimaryPhoto().Id;
                        }
                        catch (NotFoundException)
                        {
                            imageID = ImageHandler.GetPhotoIdByGender(_currentUserSession.Gender);
                        }
                        var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true);
                        var notification = new GenericEventNotification
                        {
                            Recipient = friendUsername,
                            Sender = _currentUserSession.Username,
                            Text = text,
                            ThumbnailUrl = thumbnailUrl,
                            RedirectUrl = UrlRewrite.CreateShowUserUrl(_currentUserSession.Username)
                        };
                        RealtimeNotification.SendNotification(notification);
                    }
                }

                #endregion

                // Update Twitter status
                if (Config.Misc.EnableTwitterIntegration && Twitter.HasCredentials(_currentUserSession.Username))
                {
                    try
                    {
                        Twitter.PublishTweet(_currentUserSession.Username, status);
                    }
                    catch (Exception err)
                    {
                        Global.Logger.LogError("Twitter", err);
                    }
                }
            }
            else
            {
                lblStatusText.Text = "Not set".Translate();
                _currentUserSession.StatusText = null;
                _currentUserSession.Update();
            }

            pnlEditStatusText.Visible = false;
            pnlViewStatusText.Visible = true;
        }