Ejemplo n.º 1
0
        /// <summary>
        /// The display post_ pre render.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void DisplayPost_PreRender([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.PageContext.IsGuest)
            {
                this.PostFooter.TogglePost.Visible = false;
            }
            else if (this.Get <IUserIgnored>().IsIgnored(this.PostData.UserId))
            {
                this.panMessage.Attributes["style"] = "display:none";
                this.PostFooter.TogglePost.Visible  = true;
                this.PostFooter.TogglePost.Attributes["onclick"] =
                    "toggleMessage('{0}'); return false;".FormatWith(this.panMessage.ClientID);
            }
            else if (!this.Get <IUserIgnored>().IsIgnored(this.PostData.UserId))
            {
                this.panMessage.Attributes["style"] = "display:block";
                this.panMessage.Visible             = true;
            }

            this.Retweet.Visible = this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ShowRetweetMessageTo);

            this.Edit.Visible     = !this.PostData.PostDeleted && this.PostData.CanEditPost && !this.PostData.IsLocked;
            this.Edit.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.postmessage, "m={0}", this.PostData.MessageId);
            this.MovePost.Visible     = this.PageContext.ForumModeratorAccess && !this.PostData.IsLocked;
            this.MovePost.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.movemessage, "m={0}", this.PostData.MessageId);
            this.Delete.Visible     = !this.PostData.PostDeleted && this.PostData.CanDeletePost && !this.PostData.IsLocked;
            this.Delete.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.deletemessage, "m={0}&action=delete", this.PostData.MessageId);
            this.UnDelete.Visible     = this.PostData.CanUnDeletePost && !this.PostData.IsLocked;
            this.UnDelete.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.deletemessage, "m={0}&action=undelete", this.PostData.MessageId);

            this.Quote.Visible      = !this.PostData.PostDeleted && this.PostData.CanReply && !this.PostData.IsLocked;
            this.MultiQuote.Visible = !this.PostData.PostDeleted && this.PostData.CanReply && !this.PostData.IsLocked;

            this.Quote.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.postmessage,
                "t={0}&f={1}&q={2}&page={3}",
                this.PageContext.PageTopicID,
                this.PageContext.PageForumID,
                this.PostData.MessageId,
                this.CurrentPage);

            // setup jQuery and YAF JS...
            YafContext.Current.PageElements.RegisterJsBlock("toggleMessageJs", JavaScriptBlocks.ToggleMessageJs);

            // Setup Ceebox js
            YafContext.Current.PageElements.RegisterJsBlock("ceeboxloadjs", JavaScriptBlocks.CeeBoxLoadJs);

            if (this.MultiQuote.Visible)
            {
                this.MultiQuote.Attributes.Add(
                    "onclick",
                    "handleMultiQuoteButton(this, '{0}', '{1}')".FormatWith(
                        this.PostData.MessageId,
                        this.PostData.TopicId));

                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "MultiQuoteButtonJs", JavaScriptBlocks.MultiQuoteButtonJs);
                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "MultiQuoteCallbackSuccessJS", JavaScriptBlocks.MultiQuoteCallbackSuccessJS);

                this.MultiQuote.Text    = this.GetText("BUTTON_MULTI_QUOTE");
                this.MultiQuote.ToolTip = this.GetText("BUTTON_MULTI_QUOTE_TT");
            }

            if (this.Get <YafBoardSettings>().EnableUserReputation)
            {
                // Setup UserBox Reputation Script Block
                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "reputationprogressjs", JavaScriptBlocks.RepuatationProgressLoadJs);

                this.AddReputationControls();
            }

            // Is User Suspended
            var suspended = this.DataRow["Suspended"].ToType <DateTime?>();

            if (suspended.HasValue && suspended.Value > DateTime.UtcNow)
            {
                this.ThemeImgSuspended.LocalizedTitle =
                    this.GetText("POSTS", "USERSUSPENDED").FormatWith(
                        this.Get <IDateTime>().FormatDateTimeShort(suspended.Value));

                this.ThemeImgSuspended.Visible = true;
                this.OnlineStatusImage.Visible = false;
            }

            YafContext.Current.PageElements.RegisterJsBlockStartup("asynchCallFailedJs", "function CallFailed(res){ alert('Error Occurred'); }");

            this.FormatThanksRow();

            this.ShowIPInfo();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The admins list_ on item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void AdminsList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var adminAvatar = e.Item.FindControlAs <Image>("AdminAvatar");

            var itemDataItem = (DataRowView)e.Item.DataItem;
            var userid       = itemDataItem["UserID"].ToType <int>();
            var displayName  = this.Get <YafBoardSettings>().EnableDisplayName ? itemDataItem.Row["DisplayName"].ToString() : itemDataItem.Row["Name"].ToString();

            adminAvatar.ImageUrl = this.GetAvatarUrlFileName(
                itemDataItem.Row["UserID"].ToType <int>(),
                itemDataItem.Row["Avatar"].ToString(),
                itemDataItem.Row["AvatarImage"].ToString().IsSet(),
                itemDataItem.Row["Email"].ToString());

            adminAvatar.AlternateText = displayName;
            adminAvatar.ToolTip       = displayName;

            // User Buttons
            var adminUserButton = e.Item.FindControlAs <ThemeButton>("AdminUserButton");
            var pm    = e.Item.FindControlAs <ThemeButton>("PM");
            var email = e.Item.FindControlAs <ThemeButton>("Email");

            adminUserButton.Visible = this.PageContext.IsAdmin;

            if (userid == this.PageContext.PageUserID)
            {
                return;
            }

            var blockFlags = new UserBlockFlags(itemDataItem.Row["BlockFlags"].ToType <int>());
            var isFriend   = this.GetRepository <Buddy>().CheckIsFriend(this.PageContext.PageUserID, userid);

            pm.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <YafBoardSettings>().AllowPrivateMessages;

            if (pm.Visible)
            {
                if (blockFlags.BlockPMs)
                {
                    pm.Visible = false;
                }

                if (this.PageContext.IsAdmin || isFriend)
                {
                    pm.Visible = true;
                }
            }

            pm.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, "u={0}", userid);
            pm.ParamTitle0 = displayName;

            // email link
            email.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <YafBoardSettings>().AllowEmailSending;

            if (email.Visible)
            {
                if (blockFlags.BlockEmails)
                {
                    email.Visible = false;
                }

                if (this.PageContext.IsAdmin && isFriend)
                {
                    email.Visible = true;
                }

                email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_email, "u={0}", userid);
                email.ParamTitle0 = displayName;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Mods Grid Data Bound Set up all Controls
        /// </summary>
        /// <param name="sender">
        /// The Databound sender.
        /// </param>
        /// <param name="e">
        /// The Databound Eventargs.
        /// </param>
        private void ModeratorsGridItemDataBound([NotNull] object sender, [NotNull] DataGridItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var modForums = (DropDownList)e.Item.FindControl("ModForums");

            var modLink = (UserLink)e.Item.FindControl("ModLink");

            Moderator mod = this.completeModsList.Find(m => m.ModeratorID.Equals(modLink.UserID));

            foreach (var forumsItem in from forumsItem in mod.ForumIDs
                     let forumListItem =
                         new ListItem
            {
                Value = forumsItem.ForumID.ToString(), Text = forumsItem.ForumName
            }
                     where !modForums.Items.Contains(forumListItem)
                     select forumsItem)
            {
                modForums.Items.Add(new ListItem {
                    Value = forumsItem.ForumID.ToString(), Text = forumsItem.ForumName
                });
            }

            if (modForums.Items.Count > 0)
            {
                modForums.Items.Insert(
                    0, new ListItem(this.GetTextFormatted("VIEW_FORUMS", modForums.Items.Count), "intro"));
                modForums.Items.Insert(1, new ListItem("--------------------------", "break"));
            }
            else
            {
                modForums.Visible = false;
            }

            // User Buttons
            var adminUserButton = (ThemeButton)e.Item.FindControl("AdminUserButton");
            var pm    = (ThemeButton)e.Item.FindControl("PM");
            var email = (ThemeButton)e.Item.FindControl("Email");

            adminUserButton.Visible = this.PageContext.IsAdmin;

            /*try
             * {*/
            Moderator drowv       = (Moderator)e.Item.DataItem;
            long      userid      = drowv.ModeratorID;
            string    displayName = this.Get <YafBoardSettings>().EnableDisplayName ? drowv.DisplayName : drowv.Name;

            var modAvatar = (Image)e.Item.FindControl("ModAvatar");

            modAvatar.ImageUrl = this.GetAvatarUrlFileName(
                userid.ToType <int>(), drowv.Avatar, drowv.AvatarImage, drowv.Email);

            modAvatar.AlternateText = displayName;
            modAvatar.ToolTip       = displayName;

            if (userid == this.PageContext.PageUserID)
            {
                return;
            }

            pm.Visible = !this.PageContext.IsGuest && this.User != null &&
                         this.Get <YafBoardSettings>().AllowPrivateMessages;
            pm.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, "u={0}", userid);
            pm.ParamTitle0 = displayName;

            // email link
            email.Visible = !this.PageContext.IsGuest && this.User != null &&
                            this.Get <YafBoardSettings>().AllowEmailSending;
            email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_email, "u={0}", userid);
            email.ParamTitle0 = displayName;

            /*}
             * catch (Exception)
             * {
             *  return;
             * }*/
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sends notification about new PM in user's inbox.
        /// </summary>
        /// <param name="toUserId">
        /// User supposed to receive notification about new PM.
        /// </param>
        /// <param name="subject">
        /// Subject of PM user is notified about.
        /// </param>
        public void ToPrivateMessageRecipient(int toUserId, [NotNull] string subject)
        {
            try
            {
                // user's PM notification setting
                var privateMessageNotificationEnabled = false;

                // user's email
                var toEMail = string.Empty;

                var userList =
                    LegacyDb.UserList(YafContext.Current.PageBoardID, toUserId, true, null, null, null).ToList();

                if (userList.Any())
                {
                    privateMessageNotificationEnabled = userList.First().PMNotification ?? false;
                    toEMail = userList.First().Email;
                }

                if (!privateMessageNotificationEnabled)
                {
                    return;
                }

                // get the PM ID
                // Ederon : 11/21/2007 - PageBoardID as parameter of DB.pmessage_list?
                // using (DataTable dt = DB.pmessage_list(toUserID, PageContext.PageBoardID, null))
                var userPMessageId =
                    LegacyDb.pmessage_list(toUserId, null, null).GetFirstRow().Field <int>("UserPMessageID");

                /*// get the sender e-mail -- DISABLED: too much information...
                 *  // using ( DataTable dt = YAF.Classes.Data.DB.user_list( PageContext.PageBoardID, PageContext.PageUserID, true ) )
                 *  // senderEmail = ( string ) dt.Rows [0] ["Email"];*/

                var languageFile = UserHelper.GetUserLanguageFile(toUserId);

                // send this user a PM notification e-mail
                var notificationTemplate = new YafTemplateEmail("PMNOTIFICATION")
                {
                    TemplateLanguageFile = languageFile
                };

                var displayName = this.Get <IUserDisplayName>().GetName(YafContext.Current.PageUserID);

                // fill the template with relevant info
                notificationTemplate.TemplateParams["{fromuser}"] = displayName;

                notificationTemplate.TemplateParams["{link}"] =
                    "{0}\r\n\r\n".FormatWith(
                        YafBuildLink.GetLinkNotEscaped(ForumPages.cp_message, true, "pm={0}", userPMessageId));
                notificationTemplate.TemplateParams["{forumname}"] = this.BoardSettings.Name;
                notificationTemplate.TemplateParams["{subject}"]   = subject;

                // create notification email subject
                var emailSubject =
                    this.Get <ILocalization>()
                    .GetText("COMMON", "PM_NOTIFICATION_SUBJECT", languageFile)
                    .FormatWith(displayName, this.BoardSettings.Name, subject);

                // send email
                notificationTemplate.SendEmail(new MailAddress(toEMail), emailSubject, true);
            }
            catch (Exception x)
            {
                // report exception to the forum's event log
                this.Get <ILogger>()
                .Error(x, "Send PM Notification Error for UserID {0}".FormatWith(YafContext.Current.PageUserID));

                // tell user about failure
                YafContext.Current.AddLoadMessage(
                    this.Get <ILocalization>().GetTextFormatted("Failed", x.Message),
                    MessageTypes.Error);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Render The User related Links
        /// </summary>
        private void RenderUserContainer()
        {
            RenderMenuItem(
                this.MyProfile,
                "<i class=\"fa fa-user fa-fw\"></i>  {0}".FormatWith(this.GetText("TOOLBAR", "MYPROFILE")),
                this.GetText("TOOLBAR", "MYPROFILE_TITLE"),
                YafBuildLink.GetLink(ForumPages.cp_profile),
                false,
                this.PageContext.UnreadPrivate > 0,
                this.PageContext.UnreadPrivate.ToString(),
                this.GetText("TOOLBAR", "NEWPM").FormatWith(this.PageContext.UnreadPrivate));

            // My Inbox
            if (this.Get <YafBoardSettings>().AllowPrivateMessages)
            {
                RenderMenuItem(
                    this.MyInboxItem,
                    "<i class=\"fa fa-envelope fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("TOOLBAR", "INBOX")),
                    this.GetText("TOOLBAR", "INBOX_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_pm),
                    false,
                    false,
                    null,
                    null);
            }

            // My Buddies
            if (this.Get <YafBoardSettings>().EnableBuddyList&& this.PageContext.UserHasBuddies)
            {
                RenderMenuItem(
                    this.MyBuddiesItem,
                    "<i class=\"fa fa-users fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("TOOLBAR", "BUDDIES")),
                    this.GetText("TOOLBAR", "BUDDIES_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_editbuddies),
                    false,
                    this.PageContext.PendingBuddies > 0,
                    this.PageContext.PendingBuddies.ToString(),
                    this.GetText("TOOLBAR", "BUDDYREQUEST").FormatWith(this.PageContext.PendingBuddies));
            }

            // My Albums
            if (this.Get <YafBoardSettings>().EnableAlbum&& (this.PageContext.UsrAlbums > 0 || this.PageContext.NumAlbums > 0))
            {
                RenderMenuItem(
                    this.MyAlbumsItem,
                    "<i class=\"fa fa-image fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("TOOLBAR", "MYALBUMS")),
                    this.GetText("TOOLBAR", "MYALBUMS_TITLE"),
                    YafBuildLink.GetLinkNotEscaped(ForumPages.albums, "u={0}", this.PageContext.PageUserID),
                    false,
                    false,
                    null,
                    null);
            }

            // My Topics
            RenderMenuItem(
                this.MyTopicItem,
                "<i class=\"fa fa-comment fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("TOOLBAR", "MYTOPICS")),
                this.GetText("TOOLBAR", "MYTOPICS"),
                YafBuildLink.GetLink(ForumPages.mytopics),
                false,
                false,
                string.Empty,
                string.Empty);

            // Logout
            if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
            {
                this.LogoutItem.Visible   = true;
                this.LogOutButton.Text    = "<i class=\"fa fa-sign-out-alt fa-fw\"></i>&nbsp;{0}".FormatWith(this.GetText("TOOLBAR", "LOGOUT"));
                this.LogOutButton.ToolTip = this.GetText("TOOLBAR", "LOGOUT");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sends Notifications to Moderators that Message Needs Approval
        /// </summary>
        /// <param name="forumId">The forum id.</param>
        /// <param name="newMessageId">The new message id.</param>
        /// <param name="isSpamMessage">if set to <c>true</c> [is spam message].</param>
        public void ToModeratorsThatMessageNeedsApproval(int forumId, int newMessageId, bool isSpamMessage)
        {
            var moderatorsFiltered = this.Get <YafDbBroker>().GetAllModerators().Where(f => f.ForumID.Equals(forumId));
            var moderatorUserNames = new List <string>();

            foreach (var moderator in moderatorsFiltered)
            {
                if (moderator.IsGroup)
                {
                    moderatorUserNames.AddRange(this.Get <RoleProvider>().GetUsersInRole(moderator.Name));
                }
                else
                {
                    moderatorUserNames.Add(moderator.Name);
                }
            }

            // send each message...
            foreach (var userName in moderatorUserNames.Distinct())
            {
                // add each member of the group
                var membershipUser = UserMembershipHelper.GetUser(userName);
                var userId         = UserMembershipHelper.GetUserIDFromProviderUserKey(membershipUser.ProviderUserKey);

                var languageFile = UserHelper.GetUserLanguageFile(userId);

                var subject =
                    this.Get <ILocalization>()
                    .GetText(
                        "COMMON",
                        isSpamMessage
                                ? "NOTIFICATION_ON_MODERATOR_SPAMMESSAGE_APPROVAL"
                                : "NOTIFICATION_ON_MODERATOR_MESSAGE_APPROVAL",
                        languageFile)
                    .FormatWith(this.BoardSettings.Name);

                var notifyModerators =
                    new YafTemplateEmail(
                        isSpamMessage
                            ? "NOTIFICATION_ON_MODERATOR_SPAMMESSAGE_APPROVAL"
                            : "NOTIFICATION_ON_MODERATOR_MESSAGE_APPROVAL")
                {
                    // get the user localization...
                    TemplateLanguageFile = languageFile,
                    TemplateParams       =
                    {
                        ["{adminlink}"] =
                            YafBuildLink.GetLinkNotEscaped(
                                ForumPages.moderate_unapprovedposts,
                                true,
                                "f={0}",
                                forumId),
                        ["{forumname}"] = this.BoardSettings.Name
                    }
                };


                notifyModerators.SendEmail(
                    new MailAddress(membershipUser.Email, membershipUser.UserName),
                    subject,
                    true);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets the page URL.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns>
        /// The get page url.
        /// </returns>
        protected string GetPageURL(int page)
        {
            /*string url;
            *
            *  // create proper query string...
            *  var parser = new SimpleURLParameterParser(this.Get<HttpRequestBase>().QueryString.ToString());
            *
            *  // get the current page
            *  var currentPage = (ForumPages)Enum.Parse(typeof(ForumPages), parser["g"], true);
            *
            *  if (parser["m"] != null)
            *  {
            *   // must be converted to by topic...
            *   parser.Parameters.Remove("m");
            *   parser.Parameters.Add("t", YafContext.Current.PageTopicID.ToString());
            *  }
            *
            *  if (page > 1)
            *  {
            *   string tmp = parser.CreateQueryString(new[] { "g", "p", "tabid", "find" });
            *   if (tmp.Length > 0)
            *   {
            *       tmp += "&";
            *   }
            *
            *   tmp += "p={0}";
            *
            *   url = YafBuildLink.GetLink(currentPage, tmp, page);
            *  }
            *  else
            *  {
            *   url = YafBuildLink.GetLink(currentPage, parser.CreateQueryString(new[] { "g", "p", "tabid", "find" }));
            *  }
            *
            *  return url;*/

            var url = string.Empty;

            switch (this.PageContext.ForumPageType)
            {
            case ForumPages.topics:
                url = page > 1
                              ? YafBuildLink.GetLinkNotEscaped(
                    ForumPages.topics,
                    "f={0}&p={1}",
                    this.PageContext.PageForumID,
                    page)
                              : YafBuildLink.GetLinkNotEscaped(ForumPages.topics, "f={0}", this.PageContext.PageForumID);

                break;

            case ForumPages.posts:
                url = page > 1
                              ? YafBuildLink.GetLinkNotEscaped(
                    ForumPages.posts,
                    "t={0}&p={1}",
                    this.PageContext.PageTopicID,
                    page)
                              : YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "t={0}", this.PageContext.PageTopicID);

                break;
            }

            return(url);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// The latest posts_ item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void LatestPosts_ItemDataBound([NotNull] object sender, [NotNull] RepeaterItemEventArgs e)
        {
            // populate the controls here...
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var currentRow = (DataRowView)e.Item.DataItem;

            // make message url...
            string messageUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.posts, "m={0}#post{0}", currentRow["LastMessageID"]);

            // get the controls
            var newPostIcon                = (Image)e.Item.FindControl("NewPostIcon");
            var textMessageLink            = (HyperLink)e.Item.FindControl("TextMessageLink");
            var imageMessageLink           = (HyperLink)e.Item.FindControl("ImageMessageLink");
            var lastPostedImage            = (ThemeImage)e.Item.FindControl("LastPostedImage");
            var imageLastUnreadMessageLink = (HyperLink)e.Item.FindControl("ImageLastUnreadMessageLink");
            var lastUnreadImage            = (ThemeImage)e.Item.FindControl("LastUnreadImage");
            var lastUserLink               = (UserLink)e.Item.FindControl("LastUserLink");
            var lastPostedDateLabel        = (DisplayDateTime)e.Item.FindControl("LastPostDate");
            var forumLink = (HyperLink)e.Item.FindControl("ForumLink");

            imageLastUnreadMessageLink.Visible = this.Get <YafBoardSettings>().ShowLastUnreadPost;

            // populate them...
            newPostIcon.AlternateText = this.GetText("NEW_POSTS");
            newPostIcon.ToolTip       = this.GetText("NEW_POSTS");

            var topicSubject = this.Get <IBadWordReplace>().Replace(this.HtmlEncode(currentRow["Topic"]));

            var styles = this.Get <YafBoardSettings>().UseStyledTopicTitles
                             ? this.Get <IStyleTransform>().DecodeStyleByString(currentRow["Styles"].ToString())
                             : string.Empty;

            if (styles.IsSet())
            {
                textMessageLink.Attributes.Add("style", styles);
            }

            if (currentRow["Status"].ToString().IsSet() && this.Get <YafBoardSettings>().EnableTopicStatus)
            {
                var topicStatusIcon = this.Get <ITheme>().GetItem("TOPIC_STATUS", currentRow["Status"].ToString());

                if (topicStatusIcon.IsSet() && !topicStatusIcon.Contains("[TOPIC_STATUS."))
                {
                    textMessageLink.Text =
                        @"<img src=""{0}"" alt=""{1}"" title=""{1}"" class=""topicStatusIcon"" />&nbsp;{2}"
                        .FormatWith(
                            this.Get <ITheme>().GetItem("TOPIC_STATUS", currentRow["Status"].ToString()),
                            this.GetText("TOPIC_STATUS", currentRow["Status"].ToString()),
                            topicSubject);
                }
                else
                {
                    textMessageLink.Text =
                        "[{0}]&nbsp;{1}".FormatWith(
                            this.GetText("TOPIC_STATUS", currentRow["Status"].ToString()), topicSubject);
                }
            }
            else
            {
                textMessageLink.Text = topicSubject;
            }

            textMessageLink.ToolTip =
                "{0}".FormatWith(
                    this.GetTextFormatted(
                        "VIEW_TOPIC_STARTED_BY",
                        currentRow[this.Get <YafBoardSettings>().EnableDisplayName ? "UserDisplayName" : "UserName"]
                        .ToString()));

            textMessageLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.posts, "t={0}&find=unread", currentRow["TopicID"]);

            imageMessageLink.NavigateUrl   = messageUrl;
            lastPostedImage.LocalizedTitle = this.lastPostToolTip;

            if (imageLastUnreadMessageLink.Visible)
            {
                imageLastUnreadMessageLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.posts,
                    "t={0}&find=unread",
                    currentRow["TopicID"]);

                lastUnreadImage.LocalizedTitle = this.firstUnreadPostToolTip;
            }

            // Just in case...
            if (currentRow["LastUserID"] != DBNull.Value)
            {
                lastUserLink.UserID      = currentRow["LastUserID"].ToType <int>();
                lastUserLink.Style       = currentRow["LastUserStyle"].ToString();
                lastUserLink.ReplaceName = this.Get <YafBoardSettings>().EnableDisplayName
                              ? currentRow["LastUserDisplayName"].ToString()
                              : currentRow["LastUserName"].ToString();
            }

            if (currentRow["LastPosted"] != DBNull.Value)
            {
                lastPostedDateLabel.DateTime = currentRow["LastPosted"];

                DateTime lastRead =
                    this.Get <IReadTrackCurrentUser>().GetForumTopicRead(
                        forumId: currentRow["ForumID"].ToType <int>(),
                        topicId: currentRow["TopicID"].ToType <int>(),
                        forumReadOverride: currentRow["LastForumAccess"].ToType <DateTime?>() ?? DateTimeHelper.SqlDbMinTime(),
                        topicReadOverride: currentRow["LastTopicAccess"].ToType <DateTime?>() ?? DateTimeHelper.SqlDbMinTime());

                if (DateTime.Parse(currentRow["LastPosted"].ToString()) > lastRead)
                {
                    this.Get <IYafSession>().UnreadTopics++;
                }

                lastUnreadImage.ThemeTag = (DateTime.Parse(currentRow["LastPosted"].ToString()) > lastRead)
                                               ? "ICON_NEWEST_UNREAD"
                                               : "ICON_LATEST_UNREAD";
                lastPostedImage.ThemeTag = (DateTime.Parse(currentRow["LastPosted"].ToString()) > lastRead)
                                               ? "ICON_NEWEST"
                                               : "ICON_LATEST";

                newPostIcon.ImageUrl = this.Get <ITheme>().GetItem(
                    "ICONS", (DateTime.Parse(currentRow["LastPosted"].ToString()) > lastRead) ? "TOPIC_NEW" : "TOPIC");
            }

            forumLink.Text        = this.HtmlEncode(currentRow["Forum"].ToString());
            forumLink.ToolTip     = this.GetText("COMMON", "VIEW_FORUM");
            forumLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.topics, "f={0}&name={1}", currentRow["ForumID"], currentRow["Forum"].ToString());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// The display post_ pre render.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void DisplayPost_PreRender([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.PageContext.IsGuest)
            {
                this.ShowHideIgnoredUserPost.Visible = false;
                this.MessageRow.CssClass             = "collapse show";
            }
            else if (this.Get <IUserIgnored>().IsIgnored(this.PostData.UserId))
            {
                this.MessageRow.CssClass             = "collapse";
                this.ShowHideIgnoredUserPost.Visible = true;
            }
            else if (!this.Get <IUserIgnored>().IsIgnored(this.PostData.UserId))
            {
                this.MessageRow.CssClass = "collapse show";
            }

            this.Edit.Visible     = !this.PostData.PostDeleted && this.PostData.CanEditPost && !this.PostData.IsLocked;
            this.Edit.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.postmessage,
                "m={0}",
                this.PostData.MessageId);
            this.MovePost.Visible     = this.PageContext.ForumModeratorAccess && !this.PostData.IsLocked;
            this.MovePost.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.movemessage,
                "m={0}",
                this.PostData.MessageId);
            this.Delete.Visible     = !this.PostData.PostDeleted && this.PostData.CanDeletePost && !this.PostData.IsLocked;
            this.Delete.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.deletemessage,
                "m={0}&action=delete",
                this.PostData.MessageId);
            this.UnDelete.Visible     = this.PostData.CanUnDeletePost && !this.PostData.IsLocked;
            this.UnDelete.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.deletemessage,
                "m={0}&action=undelete",
                this.PostData.MessageId);

            this.Quote.Visible      = !this.PostData.PostDeleted && this.PostData.CanReply && !this.PostData.IsLocked;
            this.MultiQuote.Visible = !this.PostData.PostDeleted && this.PostData.CanReply && !this.PostData.IsLocked;

            this.Quote.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                ForumPages.postmessage,
                "t={0}&f={1}&q={2}",
                this.PageContext.PageTopicID,
                this.PageContext.PageForumID,
                this.PostData.MessageId);

            if (this.MultiQuote.Visible)
            {
                this.MultiQuote.Attributes.Add(
                    "onclick",
                    $"handleMultiQuoteButton(this, '{this.PostData.MessageId}', '{this.PostData.TopicId}')");

                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "MultiQuoteButtonJs",
                    JavaScriptBlocks.MultiQuoteButtonJs);
                YafContext.Current.PageElements.RegisterJsBlockStartup(
                    "MultiQuoteCallbackSuccessJS",
                    JavaScriptBlocks.MultiQuoteCallbackSuccessJs);

                this.MultiQuote.Text    = this.GetText("BUTTON_MULTI_QUOTE");
                this.MultiQuote.ToolTip = this.GetText("BUTTON_MULTI_QUOTE_TT");
            }

            if (this.Get <YafBoardSettings>().EnableUserReputation)
            {
                this.AddReputationControls();
            }

            if (this.Edit.Visible || this.Delete.Visible || this.MovePost.Visible)
            {
                this.Manage.Visible = true;
            }
            else
            {
                this.Manage.Visible = false;
            }

            YafContext.Current.PageElements.RegisterJsBlockStartup(
                "asynchCallFailedJs",
                "function CallFailed(res){console.log(res);  }");

            this.FormatThanksRow();

            this.ShowIpInfo();

            this.panMessage.CssClass = "col";

            var userId = this.PostData.UserId;

            var avatarUrl   = this.Get <IAvatars>().GetAvatarUrlForUser(userId);
            var displayName = this.Get <YafBoardSettings>().EnableDisplayName
                                  ? UserMembershipHelper.GetDisplayNameFromID(userId)
                                  : UserMembershipHelper.GetUserNameFromID(userId);

            if (avatarUrl.IsSet())
            {
                this.Avatar.Visible       = true;
                this.Avatar.AlternateText = displayName;
                this.Avatar.ToolTip       = displayName;
                this.Avatar.ImageUrl      = avatarUrl;
            }
            else
            {
                this.Avatar.Visible = false;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Render The User related Links
        /// </summary>
        private void RenderUserContainer()
        {
            if (this.PageContext.IsGuest)
            {
                return;
            }

            this.UserContainer.Visible = true;

            // My Profile
            this.MyProfile.ToolTip     = this.GetText("TOOLBAR", "MYPROFILE_TITLE");
            this.MyProfile.NavigateUrl = YafBuildLink.GetLink(ForumPages.cp_profile);
            this.MyProfile.Text        = this.GetText("TOOLBAR", "MYPROFILE");

            // My Inbox
            if (this.Get <YafBoardSettings>().AllowPrivateMessages)
            {
                RenderMenuItem(
                    this.MyInboxItem,
                    "menuMy myPm",
                    null,
                    this.GetText("TOOLBAR", "INBOX"),
                    this.GetText("TOOLBAR", "INBOX_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_pm),
                    false,
                    this.PageContext.UnreadPrivate > 0,
                    this.PageContext.UnreadPrivate.ToString(),
                    this.GetText("TOOLBAR", "NEWPM").FormatWith(this.PageContext.UnreadPrivate));
            }

            // My Buddies
            if (this.Get <YafBoardSettings>().EnableBuddyList&& this.PageContext.UserHasBuddies)
            {
                RenderMenuItem(
                    this.MyBuddiesItem,
                    "menuMy myBuddies",
                    null,
                    this.GetText("TOOLBAR", "BUDDIES"),
                    this.GetText("TOOLBAR", "BUDDIES_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_editbuddies),
                    false,
                    this.PageContext.PendingBuddies > 0,
                    this.PageContext.PendingBuddies.ToString(),
                    this.GetText("TOOLBAR", "BUDDYREQUEST").FormatWith(this.PageContext.PendingBuddies));
            }

            // My Albums
            if (this.Get <YafBoardSettings>().EnableAlbum&& (this.PageContext.UsrAlbums > 0 || this.PageContext.NumAlbums > 0))
            {
                RenderMenuItem(
                    this.MyAlbumsItem,
                    "menuMy myAlbums",
                    null,
                    this.GetText("TOOLBAR", "MYALBUMS"),
                    this.GetText("TOOLBAR", "MYALBUMS_TITLE"),
                    YafBuildLink.GetLinkNotEscaped(ForumPages.albums, "u={0}", this.PageContext.PageUserID),
                    false,
                    false,
                    null,
                    null);
            }

            var unread = this.PageContext.UnreadPrivate > 0 || this.PageContext.PendingBuddies > 0 /* ||
                                                                                                    * this.PageContext.UnreadTopics > 0*/;

            // My Topics
            RenderMenuItem(
                this.MyTopicItem,
                "menuMy myTopics",
                null,
                this.GetText("TOOLBAR", "MYTOPICS"),
                this.GetText("TOOLBAR", "MYTOPICS"),
                YafBuildLink.GetLink(ForumPages.mytopics),
                false,
                false,         //this.PageContext.UnreadTopics > 0,
                string.Empty,  //this.PageContext.UnreadTopics.ToString(),
                string.Empty); //this.GetText("TOOLBAR", "UNREADTOPICS").FormatWith(this.PageContext.UnreadTopics));

            // Logout
            if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
            {
                this.LogutItem.Visible    = true;
                this.LogOutButton.Text    = this.GetText("TOOLBAR", "LOGOUT");
                this.LogOutButton.ToolTip = this.GetText("TOOLBAR", "LOGOUT");
            }

            // Logged in as : username
            this.LoggedInUserPanel.Visible = true;

            if (unread)
            {
                this.LoggedInUserPanel.CssClass = "loggedInUser unread";
            }

            this.LoggedInUserPanel.Controls.Add(
                new Label {
                Text = this.GetText("TOOLBAR", "LOGGED_IN_AS").FormatWith("&nbsp;")
            });

            var userLink = new UserLink
            {
                ID              = "UserLoggedIn",
                UserID          = this.PageContext.PageUserID,
                CssClass        = "currentUser",
                EnableHoverCard = false
            };

            this.LoggedInUserPanel.Controls.Add(userLink);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Render The GuestBar
        /// </summary>
        private void RenderGuestControls()
        {
            if (!this.PageContext.IsGuest)
            {
                return;
            }

            this.GuestUserMessage.Visible = true;

            this.GuestMessage.Text = this.GetText("TOOLBAR", "WELCOME_GUEST_FULL");

            var endPoint = new Label {
                Text = "."
            };

            var isLoginAllowed    = false;
            var isRegisterAllowed = false;

            if (Config.IsAnyPortal)
            {
                this.GuestMessage.Text = this.GetText("TOOLBAR", "WELCOME_GUEST");
            }
            else
            {
                if (Config.AllowLoginAndLogoff)
                {
                    // show login
                    var loginLink = new HyperLink
                    {
                        Text    = this.GetText("TOOLBAR", "LOGIN"),
                        ToolTip = this.GetText("TOOLBAR", "LOGIN")
                    };

                    if (this.Get <YafBoardSettings>().UseLoginBox&& !(this.Get <IYafSession>().UseMobileTheme ?? false))
                    {
                        loginLink.NavigateUrl = "javascript:void(0);";

                        loginLink.CssClass = "LoginLink";
                    }
                    else
                    {
                        var returnUrl = this.GetReturnUrl().IsSet()
                                               ? "ReturnUrl={0}".FormatWith(this.GetReturnUrl())
                                               : string.Empty;

                        loginLink.NavigateUrl = !this.Get <YafBoardSettings>().UseSSLToLogIn
                                                    ? YafBuildLink.GetLinkNotEscaped(ForumPages.login, returnUrl)
                                                    : YafBuildLink.GetLinkNotEscaped(ForumPages.login, true, returnUrl)
                                                .Replace("http:", "https:");
                    }

                    this.GuestUserMessage.Controls.Add(loginLink);

                    isLoginAllowed = true;
                }

                if (!this.Get <YafBoardSettings>().DisableRegistrations)
                {
                    if (isLoginAllowed)
                    {
                        this.GuestUserMessage.Controls.Add(
                            new Label {
                            Text = "&nbsp;{0}&nbsp;".FormatWith(this.GetText("COMMON", "OR"))
                        });
                    }

                    // show register link
                    var registerLink = new HyperLink
                    {
                        Text        = this.GetText("TOOLBAR", "REGISTER"),
                        NavigateUrl =
                            this.Get <YafBoardSettings>().ShowRulesForRegistration
                                ? YafBuildLink.GetLink(ForumPages.rules)
                                : (!this.Get <YafBoardSettings>().UseSSLToRegister
                                       ? YafBuildLink.GetLink(ForumPages.register)
                                       : YafBuildLink.GetLink(ForumPages.register, true).Replace("http:", "https:"))
                    };

                    this.GuestUserMessage.Controls.Add(registerLink);

                    this.GuestUserMessage.Controls.Add(endPoint);

                    isRegisterAllowed = true;
                }
                else
                {
                    this.GuestUserMessage.Controls.Add(endPoint);

                    this.GuestUserMessage.Controls.Add(
                        new Label {
                        Text = this.GetText("TOOLBAR", "DISABLED_REGISTER")
                    });
                }

                // If both disallowed
                if (isLoginAllowed || isRegisterAllowed)
                {
                    return;
                }

                this.GuestUserMessage.Controls.Clear();
                this.GuestUserMessage.Controls.Add(
                    new Label {
                    Text = this.GetText("TOOLBAR", "WELCOME_GUEST_NO")
                });
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Render the Main Header Menu Links
        /// </summary>
        private void RenderMainHeaderMenu()
        {
            // Forum
            RenderMenuItem(
                this.menuListItems,
                "menuGeneral",
                null,
                this.GetText("DEFAULT", "FORUM"),
                this.GetText("TOOLBAR", "FORUM_TITLE"),
                YafBuildLink.GetLink(ForumPages.forum),
                false,
                false,
                null,
                null);

            // Active Topics
            if (this.PageContext.IsGuest)
            {
                RenderMenuItem(
                    this.menuListItems,
                    "menuGeneral",
                    null,
                    this.GetText("TOOLBAR", "ACTIVETOPICS"),
                    this.GetText("TOOLBAR", "ACTIVETOPICS_TITLE"),
                    YafBuildLink.GetLink(ForumPages.mytopics),
                    false,
                    false,
                    null,
                    null);
            }

            // Search
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ExternalSearchPermissions) || this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().SearchPermissions))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "menuGeneral",
                    null,
                    this.GetText("TOOLBAR", "SEARCH"),
                    this.GetText("TOOLBAR", "SEARCH_TITLE"),
                    YafBuildLink.GetLink(ForumPages.search),
                    false,
                    false,
                    null,
                    null);
            }

            // Members
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().MembersListViewPermissions))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "menuGeneral",
                    null,
                    this.GetText("TOOLBAR", "MEMBERS"),
                    this.GetText("TOOLBAR", "MEMBERS_TITLE"),
                    YafBuildLink.GetLink(ForumPages.members),
                    false,
                    false,
                    null,
                    null);
            }

            // Team
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ShowTeamTo))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "menuGeneral",
                    null,
                    this.GetText("TOOLBAR", "TEAM"),
                    this.GetText("TOOLBAR", "TEAM_TITLE"),
                    YafBuildLink.GetLink(ForumPages.team),
                    false,
                    false,
                    null,
                    null);
            }

            // Help
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ShowHelpTo))
            {
                RenderMenuItem(
                    this.menuListItems,
                    "menuGeneral",
                    null,
                    this.GetText("TOOLBAR", "HELP"),
                    this.GetText("TOOLBAR", "HELP_TITLE"),
                    YafBuildLink.GetLink(ForumPages.help_index),
                    false,
                    false,
                    null,
                    null);
            }

            if (!this.PageContext.IsGuest || Config.IsAnyPortal)
            {
                return;
            }

            // Login
            if (Config.AllowLoginAndLogoff)
            {
                if (this.Get <YafBoardSettings>().UseLoginBox&& !(this.Get <IYafSession>().UseMobileTheme ?? false))
                {
                    RenderMenuItem(
                        this.menuListItems,
                        "menuAccount",
                        "LoginLink",
                        this.GetText("TOOLBAR", "LOGIN"),
                        this.GetText("TOOLBAR", "LOGIN_TITLE"),
                        "javascript:void(0);",
                        true,
                        false,
                        null,
                        null);
                }
                else
                {
                    var returnUrl = this.GetReturnUrl().IsSet()
                                           ? "ReturnUrl={0}".FormatWith(this.GetReturnUrl())
                                           : string.Empty;

                    RenderMenuItem(
                        this.menuListItems,
                        "menuAccount",
                        null,
                        this.GetText("TOOLBAR", "LOGIN"),
                        this.GetText("TOOLBAR", "LOGIN_TITLE"),
                        !this.Get <YafBoardSettings>().UseSSLToLogIn
                            ? YafBuildLink.GetLinkNotEscaped(ForumPages.login, returnUrl)
                            : YafBuildLink.GetLinkNotEscaped(ForumPages.login, true, returnUrl)
                        .Replace("http:", "https:"),
                        true,
                        false,
                        null,
                        null);
                }
            }

            // Register
            if (!this.Get <YafBoardSettings>().DisableRegistrations)
            {
                RenderMenuItem(
                    this.menuListItems,
                    "menuGeneral",
                    null,
                    this.GetText("TOOLBAR", "REGISTER"),
                    this.GetText("TOOLBAR", "REGISTER_TITLE"),
                    this.Get <YafBoardSettings>().ShowRulesForRegistration
                        ? YafBuildLink.GetLink(ForumPages.rules)
                        : (!this.Get <YafBoardSettings>().UseSSLToRegister
                               ? YafBuildLink.GetLink(ForumPages.register)
                               : YafBuildLink.GetLink(ForumPages.register, true).Replace("http:", "https:")),
                    true,
                    false,
                    null,
                    null);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// The password recovery 1_ verifying user.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void PasswordRecovery1_VerifyingUser([NotNull] object sender, [NotNull] LoginCancelEventArgs e)
        {
            MembershipUser user = null;

            if (this.PasswordRecovery1.UserName.Contains("@") && this.Get <MembershipProvider>().RequiresUniqueEmail)
            {
                // Email Login
                var username = this.Get <MembershipProvider>().GetUserNameByEmail(this.PasswordRecovery1.UserName);
                if (username != null)
                {
                    user = this.Get <MembershipProvider>().GetUser(username, false);

                    // update the username
                    this.PasswordRecovery1.UserName = username;
                }
            }
            else
            {
                // Standard user name login
                if (this.Get <YafBoardSettings>().EnableDisplayName)
                {
                    // Display name login
                    var id = this.Get <IUserDisplayName>().GetId(this.PasswordRecovery1.UserName);

                    if (id.HasValue)
                    {
                        // get the username associated with this id...
                        var username = UserMembershipHelper.GetUserNameFromID(id.Value);

                        // update the username
                        this.PasswordRecovery1.UserName = username;
                    }

                    user = this.Get <MembershipProvider>().GetUser(this.PasswordRecovery1.UserName, false);
                }
            }

            if (user == null)
            {
                return;
            }

            // verify the user is approved, etc...
            if (user.IsApproved)
            {
                return;
            }

            if (this.Get <YafBoardSettings>().EmailVerification)
            {
                // get the hash from the db associated with this user...
                var checkTyped = this.GetRepository <CheckEmail>().ListTyped(user.Email).FirstOrDefault();

                if (checkTyped != null)
                {
                    // re-send verification email instead of lost password...
                    var verifyEmail = new YafTemplateEmail("VERIFYEMAIL");

                    var subject = this.GetTextFormatted(
                        "VERIFICATION_EMAIL_SUBJECT",
                        this.Get <YafBoardSettings>().Name);

                    verifyEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(
                        ForumPages.approve,
                        true,
                        "k={0}",
                        checkTyped.Hash);
                    verifyEmail.TemplateParams["{key}"]       = checkTyped.Hash;
                    verifyEmail.TemplateParams["{forumname}"] = this.Get <YafBoardSettings>().Name;
                    verifyEmail.TemplateParams["{forumlink}"] = $"{YafForumInfo.ForumURL}";

                    verifyEmail.SendEmail(new MailAddress(user.Email, user.UserName), subject, true);

                    this.PageContext.LoadMessage.AddSession(
                        this.GetTextFormatted("ACCOUNT_NOT_APPROVED_VERIFICATION", user.Email),
                        MessageTypes.warning);
                }
            }
            else
            {
                // explain they are not approved yet...
                this.PageContext.LoadMessage.AddSession(this.GetText("ACCOUNT_NOT_APPROVED"), MessageTypes.warning);
            }

            // just in case cancel the verification...
            e.Cancel = true;

            // nothing they can do here... redirect to login...
            YafBuildLink.Redirect(ForumPages.login);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Handles post moderation events/buttons.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        private void List_ItemCommand([NotNull] object sender, [NotNull] RepeaterCommandEventArgs e)
        {
            // which command are we handling
            switch (e.CommandName.ToLower())
            {
            case "delete":

                // delete message
                LegacyDb.message_delete(e.CommandArgument, true, string.Empty, 1, true);

                // Update statistics
                this.Get <IDataCache>().Remove(Constants.Cache.BoardStats);

                // re-bind data
                this.BindData();

                // tell user message was deleted
                this.PageContext.AddLoadMessage(this.GetText("DELETED"));
                break;

            case "view":

                // go to the message
                YafBuildLink.Redirect(ForumPages.posts, "m={0}#post{0}", e.CommandArgument);
                break;

            case "copyover":

                // re-bind data
                this.BindData();

                // update message text
                LegacyDb.message_reportcopyover(e.CommandArgument);
                break;

            case "viewhistory":

                // go to history page
                string[] ff = e.CommandArgument.ToString().Split(',');
                YafContext.Current.Get <HttpResponseBase>().Redirect(
                    YafBuildLink.GetLinkNotEscaped(ForumPages.messagehistory, "f={0}&m={1}", ff[0], ff[1]));
                break;

            case "resolved":

                // mark message as resolved
                LegacyDb.message_reportresolve(7, e.CommandArgument, this.PageContext.PageUserID);

                // re-bind data
                this.BindData();

                // tell user message was flagged as resolved
                this.PageContext.AddLoadMessage(this.GetText("RESOLVEDFEEDBACK"), MessageTypes.Success);
                break;

            case "spam":

                this.ReportSpam((string)e.CommandArgument);

                break;
            }

            // see if there are any items left...
            DataTable dt = LegacyDb.message_listreported(this.PageContext.PageForumID);

            if (dt.Rows.Count == 0)
            {
                // nope -- redirect back to the moderate main...
                YafBuildLink.Redirect(ForumPages.moderate_index);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Handles the ItemCommand event of the UserList control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        public void UserListItemCommand([NotNull] object source, [NotNull] RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "edit":
                YafBuildLink.Redirect(ForumPages.admin_edituser, "u={0}", e.CommandArgument);
                break;

            case "resendEmail":
                var commandArgument = e.CommandArgument.ToString().Split(';');

                var checkMail = this.GetRepository <CheckEmail>().ListTyped(commandArgument[0]).FirstOrDefault();

                if (checkMail != null)
                {
                    var verifyEmail = new YafTemplateEmail("VERIFYEMAIL");

                    var subject = this.Get <ILocalization>()
                                  .GetTextFormatted("VERIFICATION_EMAIL_SUBJECT", this.Get <YafBoardSettings>().Name);

                    verifyEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(
                        ForumPages.approve,
                        true,
                        "k={0}",
                        checkMail.Hash);
                    verifyEmail.TemplateParams["{key}"]       = checkMail.Hash;
                    verifyEmail.TemplateParams["{forumname}"] = this.Get <YafBoardSettings>().Name;
                    verifyEmail.TemplateParams["{forumlink}"] = YafForumInfo.ForumURL;

                    verifyEmail.SendEmail(new MailAddress(checkMail.Email, commandArgument[1]), subject, true);

                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_MESSAGE_SEND"));
                }
                else
                {
                    var userFound = this.Get <IUserDisplayName>().Find(commandArgument[1]).FirstOrDefault();

                    var user = this.Get <MembershipProvider>().GetUser(userFound.Name, false);

                    this.Get <ISendNotification>().SendVerificationEmail(user, commandArgument[0], userFound.ID);
                }

                break;

            case "delete":
                var daysValue =
                    this.PageContext.CurrentForumPage.FindControlRecursiveAs <TextBox>("DaysOld").Text.Trim();
                if (!ValidationHelper.IsValidInt(daysValue))
                {
                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_VALID_DAYS"));
                    return;
                }

                if (!Config.IsAnyPortal)
                {
                    UserMembershipHelper.DeleteUser(e.CommandArgument.ToType <int>());
                }

                this.GetRepository <User>().Delete(e.CommandArgument.ToType <int>());

                this.BindData();
                break;

            case "approve":
                UserMembershipHelper.ApproveUser(e.CommandArgument.ToType <int>());
                this.BindData();
                break;

            case "deleteall":

                // vzrus: Should not delete the whole providers portal data? Under investigation.
                var daysValueAll =
                    this.PageContext.CurrentForumPage.FindControlRecursiveAs <TextBox>("DaysOld").Text.Trim();
                if (!ValidationHelper.IsValidInt(daysValueAll))
                {
                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_VALID_DAYS"));
                    return;
                }

                if (!Config.IsAnyPortal)
                {
                    UserMembershipHelper.DeleteAllUnapproved(DateTime.UtcNow.AddDays(-daysValueAll.ToType <int>()));
                }

                this.GetRepository <User>().DeleteOld(this.PageContext.PageBoardID, daysValueAll.ToType <int>());
                this.BindData();
                break;

            case "approveall":
                UserMembershipHelper.ApproveAll();

                // vzrus: Should delete users from send email list
                this.GetRepository <User>().ApproveAll(this.PageContext.PageBoardID);
                this.BindData();
                break;
            }
        }
Ejemplo n.º 16
0
        private void BindData()
        {
            int userID = ( int )Security.StringToLongOrRedirect(Request.QueryString ["u"]);

            MembershipUser user = UserMembershipHelper.GetMembershipUser(userID);

            if (user == null)
            {
                YafBuildLink.AccessDenied(/*No such user exists*/);
            }

            YafCombinedUserData userData = new YafCombinedUserData(user, userID);

            // populate user information controls...
            UserName.Text        = HtmlEncode(userData.Membership.UserName);
            Name.Text            = HtmlEncode(userData.Membership.UserName);
            Joined.Text          = String.Format("{0}", YafDateTime.FormatDateLong(Convert.ToDateTime(userData.Joined)));
            LastVisit.Text       = YafDateTime.FormatDateTime(userData.LastVisit);
            Rank.Text            = userData.RankName;
            Location.Text        = HtmlEncode(General.BadWordReplace(userData.Profile.Location));
            RealName.InnerHtml   = HtmlEncode(General.BadWordReplace(userData.Profile.RealName));
            Interests.InnerHtml  = HtmlEncode(General.BadWordReplace(userData.Profile.Interests));
            Occupation.InnerHtml = HtmlEncode(General.BadWordReplace(userData.Profile.Occupation));
            Gender.InnerText     = GetText("GENDER" + userData.Profile.Gender);

            PageLinks.Clear();
            PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
            PageLinks.AddLink(GetText("MEMBERS"), YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.members));
            PageLinks.AddLink(userData.Membership.UserName, "");

            double dAllPosts = 0.0;

            if (SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]) > 0)
            {
                dAllPosts = 100.0 * SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]);
            }

            Stats.InnerHtml = String.Format("{0:N0}<br/>[{1} / {2}]",
                                            userData.DBRow ["NumPosts"],
                                            String.Format(GetText("NUMALL"), dAllPosts),
                                            String.Format(GetText("NUMDAY"), (double)SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumDays"]))
                                            );

            // private messages
            ///CHANGED THIS ON 12/1/2010
            //PM.Visible = !userData.IsGuest && User != null && PageContext.BoardSettings.AllowPrivateMessages;
            PM.Visible = false;

            PM.NavigateUrl = YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.pmessage, "u={0}", userData.UserID);

            // email link
            Email.Visible     = !userData.IsGuest && User != null && PageContext.BoardSettings.AllowEmailSending;
            Email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.im_email, "u={0}", userData.UserID);
            if (PageContext.IsAdmin)
            {
                Email.TitleNonLocalized = userData.Membership.Email;
            }

            // homepage link
            Home.Visible = !String.IsNullOrEmpty(userData.Profile.Homepage);
            SetupThemeButtonWithLink(Home, userData.Profile.Homepage);

            // blog link
            Blog.Visible = !String.IsNullOrEmpty(userData.Profile.Blog);
            SetupThemeButtonWithLink(Blog, userData.Profile.Blog);

            MSN.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.MSN));
            MSN.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_email, "u={0}", userData.UserID);

            YIM.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.YIM));
            YIM.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_yim, "u={0}", userData.UserID);

            AIM.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.AIM));
            AIM.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_aim, "u={0}", userData.UserID);

            ICQ.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.ICQ));
            ICQ.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_icq, "u={0}", userData.UserID);

            Skype.Visible     = (User != null && !String.IsNullOrEmpty(userData.Profile.Skype));
            Skype.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_skype, "u={0}", userData.UserID);

            // localize tab titles...
            AboutTab.HeaderText       = GetText("ABOUT");
            StatisticsTab.HeaderText  = GetText("STATISTICS");
            AvatarTab.HeaderText      = GetText("AVATAR");
            Last10PostsTab.HeaderText = GetText("LAST10");

            if (PageContext.BoardSettings.AvatarUpload && userData.HasAvatarImage)
            {
                Avatar.ImageUrl = YafForumInfo.ForumRoot + "resource.ashx?u=" + (userID);
            }
            else if (!String.IsNullOrEmpty(userData.Avatar))                 // Took out PageContext.BoardSettings.AvatarRemote
            {
                Avatar.ImageUrl = String.Format("{3}resource.ashx?url={0}&width={1}&height={2}",
                                                Server.UrlEncode(userData.Avatar),
                                                PageContext.BoardSettings.AvatarWidth,
                                                PageContext.BoardSettings.AvatarHeight,
                                                YafForumInfo.ForumRoot);
            }
            else
            {
                Avatar.Visible    = false;
                AvatarTab.Visible = false;
            }

            Groups.DataSource = Roles.GetRolesForUser(UserMembershipHelper.GetUserNameFromID(userID));

            //EmailRow.Visible = PageContext.IsAdmin;
            ModerateTab.Visible     = PageContext.IsAdmin || PageContext.IsForumModerator;
            AdminUserButton.Visible = PageContext.IsAdmin;

            if (LastPosts.Visible)
            {
                LastPosts.DataSource   = YAF.Classes.Data.DB.post_last10user(PageContext.PageBoardID, Request.QueryString ["u"], PageContext.PageUserID);
                SearchUser.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.search,
                                                                                          "postedby={0}",
                                                                                          userData.Membership.UserName);
            }

            DataBind();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.Get <IYafSession>().UnreadTopics = 0;

            this.RssFeed.AdditionalParameters = $"f={this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("f")}";

            this.ForumJumpHolder.Visible = this.Get <YafBoardSettings>().ShowForumJump &&
                                           this.PageContext.Settings.LockedForum == 0;

            this.LastPostImageTT = this.GetText("DEFAULT", "GO_LAST_POST");

            if (this.ForumSearchHolder.Visible)
            {
                this.forumSearch.Attributes["onkeydown"] =
                    $"if(event.which || event.keyCode){{if ((event.which == 13) || (event.keyCode == 13)) {{document.getElementById('{this.forumSearchOK.ClientID}').click();return false;}}}} else {{return true}}; ";
            }

            if (!this.IsPostBack)
            {
                // PageLinks.Clear();
                if (this.PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddRoot();
                    this.PageLinks.AddLink(
                        this.PageContext.PageCategoryName,
                        YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                }

                this.PageLinks.AddForum(this.PageContext.PageForumID, true);

                this.ShowList.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowList.DataTextField  = "TopicText";
                this.ShowList.DataValueField = "TopicValue";
                this.showTopicListSelected   = this.Get <IYafSession>().ShowList == -1
                                                  ? this.Get <YafBoardSettings>().ShowTopicsDefault
                                                  : this.Get <IYafSession>().ShowList;

                this.moderate1.NavigateUrl     =
                    this.moderate2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.moderating, "f={0}", this.PageContext.PageForumID);

                this.NewTopic1.NavigateUrl     =
                    this.NewTopic2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.postmessage, "f={0}", this.PageContext.PageForumID);

                this.HandleWatchForum();
            }

            if (this.Request.QueryString.GetFirstOrDefault("f") == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get <IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            var dt = this.GetRepository <Types.Models.Forum>().List(
                this.PageContext.PageBoardID,
                this.PageContext.PageForumID);

            this.forum = dt.FirstOrDefault();

            if (this.forum.RemoteURL.IsSet())
            {
                this.Response.Clear();
                this.Response.Redirect(this.forum.RemoteURL);
            }

            this.PageTitle.Text = this.forum.Description.IsSet()
                                      ? $"{this.HtmlEncode(this.forum.Name)} - <em>{this.HtmlEncode(this.forum.Description)}</em>"
                                      : this.HtmlEncode(this.forum.Name);

            this.BindData(); // Always because of yaf:TopicLine

            if (!this.PageContext.ForumPostAccess ||
                this.forum.ForumFlags.IsLocked && !this.PageContext.ForumModeratorAccess)
            {
                this.NewTopic1.Visible = false;
                this.NewTopic2.Visible = false;
            }

            if (this.PageContext.IsGuest)
            {
                this.WatchForum.Visible = false;
                this.MarkRead.Visible   = false;
            }

            if (this.PageContext.ForumModeratorAccess)
            {
                return;
            }

            this.moderate1.Visible = false;
            this.moderate2.Visible = false;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            MembershipUser user = null;

            try
            {
                user = UserMembershipHelper.GetMembershipUserById(this.UserId);
            }
            catch (Exception ex)
            {
                this.Get <ILogger>().Error(ex, this.UserId.ToString());
            }

            if (user == null || user.ProviderUserKey.ToString() == "0")
            {
                // No such user exists or this is an nntp user ("0")
                YafBuildLink.AccessDenied();
            }

            var userData = new CombinedUserDataHelper(user, this.UserId);

            // populate user information controls...
            // Is BuddyList feature enabled?
            if (this.Get <YafBoardSettings>().EnableBuddyList)
            {
                this.SetupBuddyList(this.UserId, userData);
            }
            else
            {
                // BuddyList feature is disabled. don't show any link.
                this.BuddyLi.Visible      = false;
                this.BuddyListTab.Visible = false;
                this.lnkBuddy.Visible     = false;
                this.ltrApproval.Visible  = false;
            }

            // Is album feature enabled?
            if (this.Get <YafBoardSettings>().EnableAlbum)
            {
                this.AlbumList1.UserID = this.UserId;
            }
            else
            {
                this.AlbumList1.Dispose();
            }

            var userNameOrDisplayName = this.HtmlEncode(this.Get <YafBoardSettings>().EnableDisplayName
                                            ? userData.DisplayName
                                            : userData.UserName);

            this.SetupUserProfileInfo(this.UserId, user, userData, userNameOrDisplayName);

            this.AddPageLinks(userNameOrDisplayName);

            this.SetupUserStatistics(userData);

            this.SetupUserLinks(userData, userNameOrDisplayName);

            this.SetupAvatar(this.UserId, userData);

            this.Groups.DataSource = RoleMembershipHelper.GetRolesForUser(userData.UserName);

            // EmailRow.Visible = PageContext.IsAdmin;
            this.ModerateTab.Visible = this.PageContext.IsAdmin || this.PageContext.IsForumModerator;
            this.ModerateLi.Visible  = this.PageContext.IsAdmin || this.PageContext.IsForumModerator;

            this.AdminUserButton.Visible = this.PageContext.IsAdmin;

            if (this.LastPosts.Visible)
            {
                this.LastPosts.DataSource =
                    LegacyDb.post_alluser(this.PageContext.PageBoardID, this.UserId, this.PageContext.PageUserID, 10)
                    .AsEnumerable();

                this.SearchUser.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.search,
                    "postedby={0}",
                    userNameOrDisplayName);
            }

            this.DataBind();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// The display post footer_ pre render.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void DisplayPostFooter_PreRender([NotNull] object sender, [NotNull] EventArgs e)
        {
            // report posts
            if (this.Get <IPermissions>().Check(this.Get <YafBoardSettings>().ReportPostPermissions) &&
                !this.PostData.PostDeleted)
            {
                if (this.PageContext.IsGuest || (!this.PageContext.IsGuest && this.PageContext.User != null))
                {
                    this.ReportPost.Visible = true;

                    this.ReportPost.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                        ForumPages.reportpost, "m={0}", this.PostData.MessageId);
                }
            }

            string userName = this.Get <YafBoardSettings>().EnableDisplayName
                                  ? this.DataRow["DisplayName"].ToString()
                                  : this.DataRow["UserName"].ToString();

            userName = this.Get <HttpServerUtilityBase>().HtmlEncode(userName);

            // albums link
            if (this.PostData.UserId != this.PageContext.PageUserID && !this.PostData.PostDeleted &&
                this.PageContext.User != null && this.Get <YafBoardSettings>().EnableAlbum)
            {
                var numAlbums =
                    this.Get <IDataCache>().GetOrSet <int?>(
                        Constants.Cache.AlbumCountUser.FormatWith(this.PostData.UserId),
                        () =>
                {
                    DataTable usrAlbumsData = LegacyDb.user_getalbumsdata(
                        this.PostData.UserId, YafContext.Current.PageBoardID);
                    return(usrAlbumsData.GetFirstRowColumnAsValue <int?>("NumAlbums", null));
                },
                        TimeSpan.FromMinutes(5));

                this.Albums.Visible     = numAlbums.HasValue && numAlbums > 0;
                this.Albums.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.albums, "u={0}", this.PostData.UserId);
                this.Albums.ParamTitle0 = userName;
            }

            // private messages
            this.Pm.Visible = this.PostData.UserId != this.PageContext.PageUserID && !this.IsGuest &&
                              !this.PostData.PostDeleted && this.PageContext.User != null &&
                              this.Get <YafBoardSettings>().AllowPrivateMessages&& !this.PostData.IsSponserMessage;
            this.Pm.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, "u={0}", this.PostData.UserId);
            this.Pm.ParamTitle0 = userName;

            // emailing
            this.Email.Visible = this.PostData.UserId != this.PageContext.PageUserID && !this.IsGuest &&
                                 !this.PostData.PostDeleted && this.PageContext.User != null &&
                                 this.Get <YafBoardSettings>().AllowEmailSending&& !this.PostData.IsSponserMessage;
            this.Email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_email, "u={0}", this.PostData.UserId);
            this.Email.ParamTitle0 = userName;

            // home page
            this.Home.Visible = !this.PostData.PostDeleted && this.PostData.UserProfile.Homepage.IsSet();
            this.SetupThemeButtonWithLink(this.Home, this.PostData.UserProfile.Homepage);
            this.Home.ParamTitle0 = userName;

            // blog page
            this.Blog.Visible = !this.PostData.PostDeleted && this.PostData.UserProfile.Blog.IsSet();
            this.SetupThemeButtonWithLink(this.Blog, this.PostData.UserProfile.Blog);
            this.Blog.ParamTitle0 = userName;

            if (!this.PostData.PostDeleted && this.PageContext.User != null &&
                (this.PostData.UserId != this.PageContext.PageUserID))
            {
                // MSN
                this.Msn.Visible     = this.PostData.UserProfile.MSN.IsSet();
                this.Msn.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_msn, "u={0}", this.PostData.UserId);
                this.Msn.ParamTitle0 = userName;

                // Yahoo IM
                this.Yim.Visible     = this.PostData.UserProfile.YIM.IsSet();
                this.Yim.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_yim, "u={0}", this.PostData.UserId);
                this.Yim.ParamTitle0 = userName;

                // AOL IM
                this.Aim.Visible     = this.PostData.UserProfile.AIM.IsSet();
                this.Aim.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_aim, "u={0}", this.PostData.UserId);
                this.Aim.ParamTitle0 = userName;

                // ICQ
                this.Icq.Visible     = this.PostData.UserProfile.ICQ.IsSet();
                this.Icq.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_icq, "u={0}", this.PostData.UserId);
                this.Icq.ParamTitle0 = userName;

                // XMPP
                this.Xmpp.Visible     = this.PostData.UserProfile.XMPP.IsSet();
                this.Xmpp.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.im_xmpp, "u={0}", this.PostData.UserId);
                this.Xmpp.ParamTitle0 = userName;

                // Skype
                this.Skype.Visible     = this.PostData.UserProfile.Skype.IsSet();
                this.Skype.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.im_skype, "u={0}", this.PostData.UserId);
                this.Skype.ParamTitle0 = userName;
            }

            var loadHoverCardJs = false;

            // Facebook
            if (this.PostData.UserProfile.Facebook.IsSet())
            {
                this.Facebook.Visible = this.PostData.UserProfile.Facebook.IsSet();

                if (this.PostData.UserProfile.Facebook.IsSet())
                {
                    this.Facebook.NavigateUrl =
                        ValidationHelper.IsNumeric(this.PostData.UserProfile.Facebook)
                                                ? "https://www.facebook.com/profile.php?id={0}".FormatWith(
                            this.PostData.UserProfile.Facebook)
                                                : this.PostData.UserProfile.Facebook;
                }

                this.Facebook.ParamTitle0 = userName;

                if (this.Get <YafBoardSettings>().EnableUserInfoHoverCards)
                {
                    this.Facebook.Attributes.Add("data-hovercard", this.PostData.UserProfile.Facebook);
                    this.Facebook.CssClass += " Facebook-HoverCard";

                    loadHoverCardJs = true;
                }
            }

            // Twitter
            if (this.PostData.UserProfile.Twitter.IsSet())
            {
                this.Twitter.Visible     = this.PostData.UserProfile.Twitter.IsSet();
                this.Twitter.NavigateUrl = "http://twitter.com/{0}".FormatWith(this.HtmlEncode(this.PostData.UserProfile.Twitter));
                this.Twitter.ParamTitle0 = userName;

                if (this.Get <YafBoardSettings>().EnableUserInfoHoverCards&& Config.IsTwitterEnabled)
                {
                    this.Twitter.Attributes.Add("data-hovercard", this.HtmlEncode(this.PostData.UserProfile.Twitter));
                    this.Twitter.CssClass += " Twitter-HoverCard";

                    loadHoverCardJs = true;
                }
            }

            // Google+
            if (this.PostData.UserProfile.Google.IsSet())
            {
                this.Google.Visible     = this.PostData.UserProfile.Google.IsSet();
                this.Google.NavigateUrl = this.PostData.UserProfile.Google;
                this.Google.ParamTitle0 = userName;
            }

            if (!loadHoverCardJs || !this.Get <YafBoardSettings>().EnableUserInfoHoverCards)
            {
                return;
            }

            var hoverCardLoadJs = new StringBuilder();

            if (this.Facebook.Visible)
            {
                hoverCardLoadJs.Append(
                    JavaScriptBlocks.HoverCardLoadJs(
                        ".Facebook-HoverCard",
                        "Facebook",
                        this.GetText("DEFAULT", "LOADING_FB_HOVERCARD"),
                        this.GetText("DEFAULT", "ERROR_FB_HOVERCARD")));
            }

            if (this.Twitter.Visible && Config.IsTwitterEnabled)
            {
                hoverCardLoadJs.Append(
                    JavaScriptBlocks.HoverCardLoadJs(
                        ".Twitter-HoverCard",
                        "Twitter",
                        this.GetText("DEFAULT", "LOADING_TWIT_HOVERCARD"),
                        this.GetText("DEFAULT", "ERROR_TWIT_HOVERCARD"),
                        "{0}{1}resource.ashx?twitterinfo=".FormatWith(
                            BaseUrlBuilder.BaseUrl.TrimEnd('/'),
                            BaseUrlBuilder.AppPath)));
            }

            // Setup Hover Card JS
            YafContext.Current.PageElements.RegisterJsBlockStartup("hovercardjs", hoverCardLoadJs.ToString());
        }
Ejemplo n.º 20
0
        /// <summary>
        /// The setup user links.
        /// </summary>
        /// <param name="userData">The user data.</param>
        /// <param name="userName">Name of the user.</param>
        private void SetupUserLinks([NotNull] IUserData userData, string userName)
        {
            // homepage link
            this.Home.Visible = userData.Profile.Homepage.IsSet();
            this.SetupThemeButtonWithLink(this.Home, userData.Profile.Homepage);
            this.Home.ParamTitle0 = userName;

            // blog link
            this.Blog.Visible = userData.Profile.Blog.IsSet();
            this.SetupThemeButtonWithLink(this.Blog, userData.Profile.Blog);
            this.Blog.ParamTitle0 = userName;

            this.Facebook.Visible = this.User != null && userData.Profile.Facebook.IsSet();

            if (userData.Profile.Facebook.IsSet())
            {
                this.Facebook.NavigateUrl = ValidationHelper.IsNumeric(userData.Profile.Facebook)
                                                ? "https://www.facebook.com/profile.php?id={0}".FormatWith(
                    userData.Profile.Facebook)
                                                : userData.Profile.Facebook;
            }

            this.Facebook.ParamTitle0 = userName;

            this.Twitter.Visible     = this.User != null && userData.Profile.Twitter.IsSet();
            this.Twitter.NavigateUrl = "http://twitter.com/{0}".FormatWith(this.HtmlEncode(userData.Profile.Twitter));
            this.Twitter.ParamTitle0 = userName;

            this.Google.Visible     = this.User != null && userData.Profile.Google.IsSet();
            this.Google.NavigateUrl = userData.Profile.Google;
            this.Google.ParamTitle0 = userName;

            if (userData.UserID == this.PageContext.PageUserID)
            {
                return;
            }

            this.PM.Visible = !userData.IsGuest && this.User != null &&
                              this.Get <YafBoardSettings>().AllowPrivateMessages;
            this.PM.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, "u={0}", userData.UserID);
            this.PM.ParamTitle0 = userName;

            // email link
            this.Email.Visible = !userData.IsGuest && this.User != null &&
                                 this.Get <YafBoardSettings>().AllowEmailSending;
            this.Email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_email, "u={0}", userData.UserID);
            if (this.PageContext.IsAdmin)
            {
                this.Email.TitleNonLocalized = userData.Membership.Email;
            }

            this.Email.ParamTitle0 = userName;

            this.MSN.Visible     = this.User != null && userData.Profile.MSN.IsSet();
            this.MSN.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_msn, "u={0}", userData.UserID);
            this.MSN.ParamTitle0 = userName;

            this.YIM.Visible     = this.User != null && userData.Profile.YIM.IsSet();
            this.YIM.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_yim, "u={0}", userData.UserID);
            this.YIM.ParamTitle0 = userName;

            this.AIM.Visible     = this.User != null && userData.Profile.AIM.IsSet();
            this.AIM.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_aim, "u={0}", userData.UserID);
            this.AIM.ParamTitle0 = userName;

            this.ICQ.Visible     = this.User != null && userData.Profile.ICQ.IsSet();
            this.ICQ.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_icq, "u={0}", userData.UserID);
            this.ICQ.ParamTitle0 = userName;

            this.XMPP.Visible     = this.User != null && userData.Profile.XMPP.IsSet();
            this.XMPP.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_xmpp, "u={0}", userData.UserID);
            this.XMPP.ParamTitle0 = userName;

            this.Skype.Visible     = this.User != null && userData.Profile.Skype.IsSet();
            this.Skype.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_skype, "u={0}", userData.UserID);
            this.Skype.ParamTitle0 = userName;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Sends Notifications to Moderators that a Message was Reported
        /// </summary>
        /// <param name="pageForumID">
        /// The page Forum ID.
        /// </param>
        /// <param name="reportedMessageId">
        /// The reported message id.
        /// </param>
        /// <param name="reporter">
        /// The reporter.
        /// </param>
        /// <param name="reportText">
        /// The report Text.
        /// </param>
        public void ToModeratorsThatMessageWasReported(
            int pageForumID,
            int reportedMessageId,
            int reporter,
            string reportText)
        {
            try
            {
                var moderatorsFiltered =
                    this.Get <YafDbBroker>().GetAllModerators().Where(f => f.ForumID.Equals(pageForumID));
                var moderatorUserNames = new List <string>();

                foreach (var moderator in moderatorsFiltered)
                {
                    if (moderator.IsGroup)
                    {
                        moderatorUserNames.AddRange(this.Get <RoleProvider>().GetUsersInRole(moderator.Name));
                    }
                    else
                    {
                        moderatorUserNames.Add(moderator.Name);
                    }
                }

                // send each message...
                foreach (var userName in moderatorUserNames.Distinct())
                {
                    // add each member of the group
                    var membershipUser = UserMembershipHelper.GetUser(userName);
                    var userId         = UserMembershipHelper.GetUserIDFromProviderUserKey(membershipUser.ProviderUserKey);

                    var languageFile = UserHelper.GetUserLanguageFile(userId);

                    var subject =
                        this.Get <ILocalization>()
                        .GetText("COMMON", "NOTIFICATION_ON_MODERATOR_REPORTED_MESSAGE", languageFile)
                        .FormatWith(this.BoardSettings.Name);

                    var notifyModerators = new YafTemplateEmail("NOTIFICATION_ON_MODERATOR_REPORTED_MESSAGE")
                    {
                        // get the user localization...
                        TemplateLanguageFile
                            =
                                languageFile
                    };

                    notifyModerators.TemplateParams["{reason}"]    = reportText;
                    notifyModerators.TemplateParams["{reporter}"]  = this.Get <IUserDisplayName>().GetName(reporter);
                    notifyModerators.TemplateParams["{adminlink}"] =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.moderate_reportedposts, true, "f={0}", pageForumID);
                    notifyModerators.TemplateParams["{forumname}"] = this.BoardSettings.Name;

                    notifyModerators.SendEmail(
                        new MailAddress(membershipUser.Email, membershipUser.UserName),
                        subject,
                        true);
                }
            }
            catch (Exception x)
            {
                // report exception to the forum's event log
                this.Get <ILogger>()
                .Error(
                    x,
                    "Send Message Report Notification Error for UserID {0}".FormatWith(
                        YafContext.Current.PageUserID));
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Handles the PreRender event of the ForumLastPost control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ForumLastPost_PreRender([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.DataRow == null)
            {
                return;
            }

            var showLastLinks = true;

            if (this.DataRow["ReadAccess"].ToType <int>() == 0)
            {
                this.TopicInPlaceHolder.Visible = false;
                showLastLinks = false;
            }

            if (this.DataRow["LastPosted"] != DBNull.Value)
            {
                // Last Post Date
                this.LastPostDate.DateTime = this.DataRow["LastPosted"];

                // Topic Link
                this.topicLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.posts, "t={0}", this.DataRow["LastTopicID"]);

                this.topicLink.ToolTip = this.GetText("COMMON", "VIEW_TOPIC");

                var styles = this.Get <YafBoardSettings>().UseStyledTopicTitles
                                 ? this.Get <IStyleTransform>().DecodeStyleByString(
                    this.DataRow["LastTopicStyles"].ToString(), false)
                                 : string.Empty;

                if (styles.IsSet())
                {
                    this.topicLink.Attributes.Add("style", styles);
                }

                // Topic Status
                if (this.DataRow["LastTopicStatus"].ToString().IsSet() && this.Get <YafBoardSettings>().EnableTopicStatus)
                {
                    var topicStatusIcon = this.Get <ITheme>().GetItem(
                        "TOPIC_STATUS", this.DataRow["LastTopicStatus"].ToString());

                    if (topicStatusIcon.IsSet() && !topicStatusIcon.Contains("[TOPIC_STATUS."))
                    {
                        this.topicLink.Text =
                            "<img src=\"{0}\" alt=\"{1}\" title=\"{1}\" class=\"topicStatusIcon\" />&nbsp;{2}"
                            .FormatWith(
                                this.Get <ITheme>().GetItem(
                                    "TOPIC_STATUS", this.DataRow["LastTopicStatus"].ToString()),
                                this.GetText("TOPIC_STATUS", this.DataRow["LastTopicStatus"].ToString()),
                                this.Get <IBadWordReplace>().Replace(this.HtmlEncode(this.DataRow["LastTopicName"])).Truncate(50));
                    }
                    else
                    {
                        this.topicLink.Text =
                            "[{0}]&nbsp;{1}".FormatWith(
                                this.GetText("TOPIC_STATUS", this.DataRow["LastTopicStatus"].ToString()),
                                this.Get <IBadWordReplace>().Replace(this.HtmlEncode(this.DataRow["LastTopicName"])).Truncate(50));
                    }
                }
                else
                {
                    this.topicLink.Text =
                        this.Get <IBadWordReplace>().Replace(this.HtmlEncode(this.DataRow["LastTopicName"].ToString())).Truncate(50);
                }

                // Last Topic User
                this.ProfileUserLink.UserID = this.DataRow["LastUserID"].ToType <int>();
                this.ProfileUserLink.Style  = this.Get <YafBoardSettings>().UseStyledNicks
                                                 ? this.Get <IStyleTransform>().DecodeStyleByString(
                    this.DataRow["Style"].ToString(), false)
                                                 : string.Empty;
                this.ProfileUserLink.ReplaceName =
                    this.DataRow[this.Get <YafBoardSettings>().EnableDisplayName ? "LastUserDisplayName" : "LastUser"]
                    .ToString();

                if (string.IsNullOrEmpty(this.Alt))
                {
                    this.Alt = this.GetText("GO_LAST_POST");
                }

                this.LastTopicImgLink.ToolTip = this.Alt;

                var lastRead =
                    this.Get <IReadTrackCurrentUser>().GetForumTopicRead(
                        forumId: this.DataRow["ForumID"].ToType <int>(),
                        topicId: this.DataRow["LastTopicID"].ToType <int>(),
                        forumReadOverride: this.DataRow["LastForumAccess"].ToType <DateTime?>(),
                        topicReadOverride: this.DataRow["LastTopicAccess"].ToType <DateTime?>());

                var showNewIcon = DateTime.Parse(Convert.ToString(this.DataRow["LastPosted"])) > lastRead;

                this.LastTopicImgLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.posts, "m={0}#post{0}", this.DataRow["LastMessageID"]);

                this.Icon.ThemeTag = showNewIcon ? "ICON_NEWEST" : "ICON_LATEST";

                this.Icon.Alt = this.LastTopicImgLink.ToolTip;

                this.ImageLastUnreadMessageLink.Visible = this.Get <YafBoardSettings>().ShowLastUnreadPost;

                if (this.ImageLastUnreadMessageLink.Visible)
                {
                    this.ImageLastUnreadMessageLink.NavigateUrl = YafBuildLink.GetLinkNotEscaped(
                        ForumPages.posts, "t={0}&find=unread", this.DataRow["LastTopicID"]);

                    this.LastUnreadImage.LocalizedTitle = this.GetText("DEFAULT", "GO_LASTUNREAD_POST");

                    this.LastUnreadImage.ThemeTag = showNewIcon ? "ICON_NEWEST_UNREAD" : "ICON_LATEST_UNREAD";
                }

                this.LastPostedHolder.Visible = showLastLinks;
                this.NoPostsLabel.Visible     = false;
            }
            else
            {
                // show "no posts"
                this.LastPostedHolder.Visible = false;
                this.NoPostsLabel.Visible     = true;
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// The to watching users.
        /// </summary>
        /// <param name="newMessageId">
        /// The new message id.
        /// </param>
        public void ToWatchingUsers(int newMessageId)
        {
            IList <User> usersWithAll = new List <User>();

            if (this.BoardSettings.AllowNotificationAllPostsAllTopics)
            {
                usersWithAll = this.GetRepository <User>()
                               .FindUserTyped(filter: false, notificationType: UserNotificationSetting.AllTopics.ToInt());
            }

            // TODO : Rewrite Watch Topic code to allow watch mails in the users language, as workaround send all messages in the default board language
            var languageFile = this.BoardSettings.Language;
            var boardName    = this.BoardSettings.Name;
            var forumEmail   = this.BoardSettings.ForumEmail;

            var message = LegacyDb.MessageList(newMessageId).FirstOrDefault();

            var messageAuthorUserID = message.UserID ?? 0;

            var watchEmail = new YafTemplateEmail("TOPICPOST")
            {
                TemplateLanguageFile = languageFile
            };

            // cleaned body as text...
            var bodyText =
                BBCodeHelper.StripBBCode(HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(message.Message)))
                .RemoveMultipleWhitespace();

            // Send track mails
            var subject =
                this.Get <ILocalization>()
                .GetText("COMMON", "TOPIC_NOTIFICATION_SUBJECT", languageFile)
                .FormatWith(boardName);

            watchEmail.TemplateParams["{forumname}"]     = boardName;
            watchEmail.TemplateParams["{topic}"]         = HttpUtility.HtmlDecode(message.Topic);
            watchEmail.TemplateParams["{postedby}"]      = UserMembershipHelper.GetDisplayNameFromID(messageAuthorUserID);
            watchEmail.TemplateParams["{body}"]          = bodyText;
            watchEmail.TemplateParams["{bodytruncated}"] = bodyText.Truncate(160);
            watchEmail.TemplateParams["{link}"]          = YafBuildLink.GetLinkNotEscaped(
                ForumPages.posts,
                true,
                "m={0}#post{0}",
                newMessageId);

            watchEmail.CreateWatch(
                message.TopicID ?? 0,
                messageAuthorUserID,
                new MailAddress(forumEmail, boardName),
                subject);

            // create individual watch emails for all users who have All Posts on...
            foreach (var user in usersWithAll.Where(x => x.UserID != messageAuthorUserID && x.ProviderUserKey != null))
            {
                var membershipUser = UserMembershipHelper.GetUser(user.Name);

                if (membershipUser == null || membershipUser.Email.IsNotSet())
                {
                    continue;
                }

                watchEmail.TemplateLanguageFile = user.LanguageFile.IsSet()
                                                      ? user.LanguageFile
                                                      : this.Get <ILocalization>().LanguageFileName;
                watchEmail.SendEmail(
                    new MailAddress(forumEmail, boardName),
                    new MailAddress(membershipUser.Email, membershipUser.UserName),
                    subject,
                    true);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Render The User related Links
        /// </summary>
        private void RenderUserContainer()
        {
            if (this.PageContext.IsGuest)
            {
                return;
            }

            // My Profile
            this.MyProfile.ToolTip     = this.GetText("TOOLBAR", "MYPROFILE_TITLE");
            this.MyProfile.NavigateUrl = YafBuildLink.GetLink(ForumPages.cp_profile);
            this.MyProfile.Text        = $"<i class=\"fa fa-user fa-fw\"></i>  {this.GetText("TOOLBAR", "MYPROFILE")}";

            // My Inbox
            if (this.Get <YafBoardSettings>().AllowPrivateMessages)
            {
                RenderMenuItem(
                    this.MyInboxItem,
                    "dropdown-item",
                    this.GetText("TOOLBAR", "INBOX"),
                    this.GetText("TOOLBAR", "INBOX_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_pm),
                    false,
                    this.PageContext.UnreadPrivate > 0,
                    this.PageContext.UnreadPrivate.ToString(),
                    this.GetTextFormatted("TOOLBAR", "NEWPM", this.PageContext.UnreadPrivate),
                    "envelope");
            }

            // My Buddies
            if (this.Get <YafBoardSettings>().EnableBuddyList&& this.PageContext.UserHasBuddies)
            {
                RenderMenuItem(
                    this.MyBuddiesItem,
                    "dropdown-item",
                    this.GetText("TOOLBAR", "BUDDIES"),
                    this.GetText("TOOLBAR", "BUDDIES_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_editbuddies),
                    false,
                    this.PageContext.PendingBuddies > 0,
                    this.PageContext.PendingBuddies.ToString(),
                    this.GetTextFormatted("TOOLBAR", "BUDDYREQUEST", this.PageContext.PendingBuddies),
                    "users");
            }

            // My Albums
            if (this.Get <YafBoardSettings>().EnableAlbum &&
                (this.PageContext.UsrAlbums > 0 || this.PageContext.NumAlbums > 0))
            {
                RenderMenuItem(
                    this.MyAlbumsItem,
                    "dropdown-item",
                    this.GetText("TOOLBAR", "MYALBUMS"),
                    this.GetText("TOOLBAR", "MYALBUMS_TITLE"),
                    YafBuildLink.GetLinkNotEscaped(ForumPages.albums, "u={0}", this.PageContext.PageUserID),
                    false,
                    false,
                    null,
                    null,
                    "images");
            }

            // My Topics
            RenderMenuItem(
                this.MyTopicItem,
                "dropdown-item",
                this.GetText("TOOLBAR", "MYTOPICS"),
                this.GetText("TOOLBAR", "MYTOPICS"),
                YafBuildLink.GetLink(ForumPages.mytopics),
                false,
                false,
                string.Empty,
                string.Empty,
                "comment");

            // Logout
            if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
            {
                this.LogutItem.Visible = true;
                this.LogOutButton.Text =
                    $"<i class=\"fa fa-sign-out-alt fa-fw\"></i>&nbsp;{this.GetText("TOOLBAR", "LOGOUT")}";
                this.LogOutButton.ToolTip = this.GetText("TOOLBAR", "LOGOUT");
            }

            // Logged in as : username
            this.LoggedInUserPanel.Visible = true;

            this.UnreadPlaceHolder.Visible = this.PageContext.UnreadPrivate + this.PageContext.PendingBuddies > 0;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.PageContext.QueryIDs = new QueryStringIDHelper("u");

            if (this._adminEditMode && this.PageContext.IsAdmin && this.PageContext.QueryIDs.ContainsKey("u"))
            {
                this._currentUserID = this.PageContext.QueryIDs["u"].ToType <int>();
            }
            else
            {
                this._currentUserID = this.PageContext.PageUserID;
            }

            if (this.IsPostBack)
            {
                return;
            }

            // check if it's a link from the avatar picker
            if (this.Request.QueryString.GetFirstOrDefault("av") != null)
            {
                // save the avatar right now...
                LegacyDb.user_saveavatar(
                    this._currentUserID,
                    "{0}{1}".FormatWith(
                        BaseUrlBuilder.BaseUrl, this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("av")),
                    null,
                    null);

                // clear the cache for this user...
                this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this._currentUserID));
            }

            this.UpdateRemote.Text = this.GetText("COMMON", "UPDATE");
            this.UpdateUpload.Text = this.GetText("COMMON", "UPDATE");
            this.Back.Text         = this.GetText("COMMON", "BACK");

            this.NoAvatar.Text = this.GetText("CP_EDITAVATAR", "NOAVATAR");

            this.DeleteAvatar.Text = this.GetText("CP_EDITAVATAR", "AVATARDELETE");
            this.DeleteAvatar.Attributes["onclick"] =
                "return confirm('{0}?')".FormatWith(this.GetText("CP_EDITAVATAR", "AVATARDELETE"));

            string addAdminParam = string.Empty;

            if (this._adminEditMode)
            {
                addAdminParam = "u={0}".FormatWith(this._currentUserID);
            }

            this.OurAvatar.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.avatar, addAdminParam);
            this.OurAvatar.Text        = this.GetText("CP_EDITAVATAR", "OURAVATAR_SELECT");

            this.noteRemote.Text = this.GetTextFormatted(
                "NOTE_REMOTE",
                this.Get <YafBoardSettings>().AvatarWidth.ToString(),
                this.Get <YafBoardSettings>().AvatarHeight.ToString());
            this.noteLocal.Text = this.GetTextFormatted(
                "NOTE_LOCAL",
                this.Get <YafBoardSettings>().AvatarWidth.ToString(),
                this.Get <YafBoardSettings>().AvatarHeight,
                (this.Get <YafBoardSettings>().AvatarSize / 1024).ToString());

            this.BindData();
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Redirect to the changed post
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 protected void ReturnBtn_OnClick([NotNull] object sender, [NotNull] EventArgs e)
 {
     this.Response.Redirect(YafBuildLink.GetLinkNotEscaped(ForumPages.posts, "m={0}#post{0}", this.messageID));
 }
Ejemplo n.º 27
0
        /// <summary>
        /// The moderators list_ on item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void ModeratorsList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var modForums = e.Item.FindControlAs <DropDownList>("ModForums");

            var modLink = e.Item.FindControlAs <UserLink>("ModLink");

            var mod = this.completeModsList.Find(m => m.ModeratorID.Equals(modLink.UserID));

            (from forumsItem in mod.ForumIDs
             let forumListItem = new ListItem {
                Value = forumsItem.ForumID.ToString(), Text = forumsItem.ForumName
            }
             where !modForums.Items.Contains(forumListItem)
             select forumsItem).ForEach(
                forumsItem => modForums.Items.Add(
                    new ListItem {
                Value = forumsItem.ForumID.ToString(), Text = forumsItem.ForumName
            }));

            if (modForums.Items.Count > 0)
            {
                modForums.Items.Insert(0, new ListItem(this.GetTextFormatted("VIEW_FORUMS", modForums.Items.Count), "intro"));
                modForums.Items.Insert(1, new ListItem("--------------------------", "break"));
            }
            else
            {
                modForums.Visible = false;
            }

            // User Buttons
            var adminUserButton = e.Item.FindControlAs <ThemeButton>("AdminUserButton");
            var pm    = e.Item.FindControlAs <ThemeButton>("PM");
            var email = e.Item.FindControlAs <ThemeButton>("Email");

            adminUserButton.Visible = this.PageContext.IsAdmin;

            var itemDataItem = (Moderator)e.Item.DataItem;
            var userid       = itemDataItem.ModeratorID.ToType <int>();
            var displayName  = this.Get <YafBoardSettings>().EnableDisplayName ? itemDataItem.DisplayName : itemDataItem.Name;

            var modAvatar = e.Item.FindControlAs <Image>("ModAvatar");

            modAvatar.ImageUrl = this.GetAvatarUrlFileName(userid, itemDataItem.Avatar, itemDataItem.AvatarImage, itemDataItem.Email);

            modAvatar.AlternateText = displayName;
            modAvatar.ToolTip       = displayName;

            if (userid == this.PageContext.PageUserID)
            {
                return;
            }


            var isFriend = this.GetRepository <Buddy>().CheckIsFriend(this.PageContext.PageUserID, userid);

            pm.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <YafBoardSettings>().AllowPrivateMessages;

            if (pm.Visible)
            {
                if (mod.Block.BlockPMs)
                {
                    pm.Visible = false;
                }

                if (this.PageContext.IsAdmin || isFriend)
                {
                    pm.Visible = true;
                }
            }

            pm.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.pmessage, "u={0}", userid);
            pm.ParamTitle0 = displayName;

            // email link
            email.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <YafBoardSettings>().AllowEmailSending;

            if (email.Visible)
            {
                if (mod.Block.BlockEmails && !this.PageContext.IsAdmin)
                {
                    email.Visible = false;
                }

                if (this.PageContext.IsAdmin || isFriend)
                {
                    email.Visible = true;
                }

                email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.im_email, "u={0}", userid);
                email.ParamTitle0 = displayName;
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Redirect to the changed post
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 protected void ReturnModBtn_OnClick([NotNull] object sender, [NotNull] EventArgs e)
 {
     this.Response.Redirect(
         YafBuildLink.GetLinkNotEscaped(ForumPages.moderate_reportedposts, "f={0}", this.forumID));
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            var endPoint = new Literal {
                Text = "."
            };

            var isLoginAllowed    = false;
            var isRegisterAllowed = false;

            if (Config.IsAnyPortal)
            {
                this.Visible = false;
            }
            else
            {
                if (Config.AllowLoginAndLogoff)
                {
                    this.ConnectHolder.Controls.Add(
                        new Literal {
                        Text = this.GetText("TOOLBAR", "WELCOME_GUEST_CONNECT")
                    });

                    // show login
                    var loginLink = new ThemeButton
                    {
                        TextLocalizedTag   = "LOGIN_CONNECT",
                        TextLocalizedPage  = "TOOLBAR",
                        ParamText0         = this.Get <YafBoardSettings>().Name,
                        TitleLocalizedTag  = "LOGIN",
                        TitleLocalizedPage = "TOOLBAR",
                        // CssClass = "yaflittlebutton"
                    };

                    if (this.Get <YafBoardSettings>().UseLoginBox&& !(this.Get <IYafSession>().UseMobileTheme ?? false))
                    {
                        loginLink.NavigateUrl = "javascript:void(0);";

                        loginLink.CssClass = "LoginLink";
                    }
                    else
                    {
                        var returnUrl = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("ReturnUrl").IsSet()
                                            ? "ReturnUrl={0}".FormatWith(
                            this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("ReturnUrl"))
                                            : string.Empty;

                        loginLink.NavigateUrl = !this.Get <YafBoardSettings>().UseSSLToLogIn
                                                    ? YafBuildLink.GetLinkNotEscaped(ForumPages.login, returnUrl)
                                                    : YafBuildLink.GetLinkNotEscaped(ForumPages.login, true, returnUrl)
                                                .Replace("http:", "https:");
                    }

                    this.ConnectHolder.Controls.Add(loginLink);

                    isLoginAllowed = true;
                }

                if (!this.Get <YafBoardSettings>().DisableRegistrations)
                {
                    // show register link
                    var registerLink = new ThemeButton
                    {
                        TextLocalizedTag   = "REGISTER_CONNECT",
                        TextLocalizedPage  = "TOOLBAR",
                        TitleLocalizedTag  = "REGISTER",
                        TitleLocalizedPage = "TOOLBAR",
                        // CssClass = "yaflittlebutton",
                        NavigateUrl =
                            this.Get <YafBoardSettings>().ShowRulesForRegistration
                                                       ? YafBuildLink.GetLink(ForumPages.rules)
                                                       : (!this.Get <YafBoardSettings>().UseSSLToRegister
                                                              ? YafBuildLink.GetLink(ForumPages.register)
                                                              : YafBuildLink.GetLink(
                                                              ForumPages.register,
                                                              true).Replace("http:", "https:"))
                    };

                    this.ConnectHolder.Controls.Add(new Literal {
                        Text = ",&nbsp;"
                    });

                    this.ConnectHolder.Controls.Add(registerLink);

                    this.ConnectHolder.Controls.Add(endPoint);

                    isRegisterAllowed = true;
                }
                else
                {
                    this.ConnectHolder.Controls.Add(endPoint);

                    this.ConnectHolder.Controls.Add(new Literal {
                        Text = this.GetText("TOOLBAR", "DISABLED_REGISTER")
                    });
                }

                // If both disallowed
                if (!isLoginAllowed && !isRegisterAllowed)
                {
                    this.ConnectHolder.Controls.Clear();

                    this.ConnectHolder.Visible = false;

                    return;
                }

                if (this.Get <YafBoardSettings>().AllowSingleSignOn &&
                    (Config.FacebookAPIKey.IsSet() || Config.TwitterConsumerKey.IsSet() ||
                     Config.GoogleClientID.IsSet()))
                {
                    this.ConnectHolder.Controls.Add(
                        new Literal {
                        Text = "&nbsp;{0}&nbsp;".FormatWith(this.GetText("LOGIN", "CONNECT_VIA"))
                    });

                    if (Config.FacebookAPIKey.IsSet() && Config.FacebookSecretKey.IsSet())
                    {
                        var linkButton = new LinkButton
                        {
                            Text    = "Facebook",
                            ToolTip =
                                this.GetTextFormatted("AUTH_CONNECT_HELP", "Facebook"),
                            ID       = "FacebookRegister",
                            CssClass = "authLogin facebookLogin"
                        };

                        linkButton.Click += this.FacebookFormClick;

                        this.ConnectHolder.Controls.Add(linkButton);
                    }

                    this.ConnectHolder.Controls.Add(new Literal {
                        Text = "&nbsp;"
                    });

                    if (Config.TwitterConsumerKey.IsSet() && Config.TwitterConsumerSecret.IsSet())
                    {
                        var linkButton = new LinkButton
                        {
                            Text    = "Twitter",
                            ToolTip =
                                this.GetTextFormatted("AUTH_CONNECT_HELP", "Twitter"),
                            ID       = "TwitterRegister",
                            CssClass = "authLogin twitterLogin"
                        };

                        linkButton.Click += this.TwitterFormClick;

                        this.ConnectHolder.Controls.Add(linkButton);
                    }

                    this.ConnectHolder.Controls.Add(new Literal {
                        Text = "&nbsp;"
                    });

                    if (Config.GoogleClientID.IsSet() && Config.GoogleClientSecret.IsSet())
                    {
                        var linkButton = new LinkButton
                        {
                            Text     = "Google",
                            ToolTip  = this.GetTextFormatted("AUTH_CONNECT_HELP", "Google"),
                            ID       = "GoogleRegister",
                            CssClass = "authLogin googleLogin"
                        };

                        linkButton.Click += this.GoogleFormClick;

                        this.ConnectHolder.Controls.Add(linkButton);
                    }
                }
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// The to watching users.
        /// </summary>
        /// <param name="newMessageId">
        /// The new message id.
        /// </param>
        public void ToWatchingUsers(int newMessageId)
        {
            // Always send watch mails with boards default language
            var languageFile = this.BoardSettings.Language;

            var boardName  = this.BoardSettings.Name;
            var forumEmail = this.BoardSettings.ForumEmail;

            var message = this.GetRepository <Message>().MessageList(newMessageId).FirstOrDefault();

            var messageAuthorUserID = message.UserID ?? 0;

            var watchEmail = new YafTemplateEmail("TOPICPOST")
            {
                TemplateLanguageFile = languageFile
            };

            // cleaned body as text...
            var bodyText = this.Get <IBadWordReplace>()
                           .Replace(BBCodeHelper.StripBBCode(HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(message.Message))))
                           .RemoveMultipleWhitespace();

            // Send track mails
            var subject = string.Format(
                this.Get <ILocalization>().GetText("COMMON", "TOPIC_NOTIFICATION_SUBJECT", languageFile),
                boardName);

            var logoUrl =
                $"{YafForumInfo.ForumClientFileRoot}{YafBoardFolders.Current.Logos}/{this.BoardSettings.ForumLogo}";
            var themeCss =
                $"{this.Get<YafBoardSettings>().BaseUrlMask}{this.Get<ITheme>().BuildThemePath("bootstrap-forum.min.css")}";

            watchEmail.TemplateParams["{forumname}"] = boardName;
            watchEmail.TemplateParams["{topic}"]     =
                HttpUtility.HtmlDecode(this.Get <IBadWordReplace>().Replace(message.Topic));
            watchEmail.TemplateParams["{postedby}"]      = UserMembershipHelper.GetDisplayNameFromID(messageAuthorUserID);
            watchEmail.TemplateParams["{body}"]          = bodyText;
            watchEmail.TemplateParams["{bodytruncated}"] = bodyText.Truncate(160);
            watchEmail.TemplateParams["{link}"]          = YafBuildLink.GetLinkNotEscaped(
                ForumPages.posts,
                true,
                "m={0}#post{0}",
                newMessageId);
            watchEmail.TemplateParams["{subscriptionlink}"] =
                YafBuildLink.GetLinkNotEscaped(ForumPages.cp_subscriptions, true);
            watchEmail.TemplateParams["{forumname}"] = this.BoardSettings.Name;
            watchEmail.TemplateParams["{forumlink}"] = $"{YafForumInfo.ForumURL}";
            watchEmail.TemplateParams["{themecss}"]  = themeCss;
            watchEmail.TemplateParams["{logo}"]      = $"{this.Get<YafBoardSettings>().BaseUrlMask}{logoUrl}";

            watchEmail.CreateWatch(
                message.TopicID ?? 0,
                messageAuthorUserID,
                new MailAddress(forumEmail, boardName),
                subject);

            if (!this.BoardSettings.AllowNotificationAllPostsAllTopics)
            {
                return;
            }

            var usersWithAll = this.GetRepository <User>().FindUserTyped(
                false,
                notificationType: UserNotificationSetting.AllTopics.ToInt());

            // create individual watch emails for all users who have All Posts on...
            usersWithAll.Where(x => x.ID != messageAuthorUserID && x.ProviderUserKey != null).ForEach(
                user =>
            {
                if (user.Email.IsNotSet())
                {
                    return;
                }

                watchEmail.TemplateLanguageFile = user.LanguageFile.IsSet()
                                                              ? user.LanguageFile
                                                              : this.Get <ILocalization>().LanguageFileName;
                watchEmail.SendEmail(
                    new MailAddress(forumEmail, boardName),
                    new MailAddress(
                        user.Email,
                        this.BoardSettings.EnableDisplayName ? user.DisplayName : user.Name),
                    subject,
                    true);
            });
        }