Exemplo n.º 1
0
        /// <summary>
        /// Bind data for this control.
        /// </summary>
        private void BindData()
        {
            // get user's info
            using (DataTable dt = YAF.Classes.Data.DB.user_list(PageContext.PageBoardID, CurrentUserID, null))
            {
                // there is no such user
                if (dt.Rows.Count < 1)
                {
                    YafBuildLink.AccessDenied(/*No such user exists*/);
                }

                // get user's data in form of data row
                DataRow user = dt.Rows [0];

                // if user is not suspended, hide row with suspend information and remove suspension button
                SuspendedRow.Visible = !user.IsNull("Suspended");

                // is user suspended?
                if (!user.IsNull("Suspended"))
                {
                    // get time when his suspension expires to the view state
                    ViewState ["SuspendedUntil"] = YafDateTime.FormatDateTime(user ["Suspended"]);

                    // localize remove suspension button
                    RemoveSuspension.Text = PageContext.Localization.GetText("PROFILE", "REMOVESUSPENSION");
                }

                // localize suspend button
                Suspend.Text = PageContext.Localization.GetText("PROFILE", "SUSPEND");
            }
        }
Exemplo n.º 2
0
        private void BindData()
        {
            Groups.DataSource = YAF.Classes.Data.DB.usergroup_list(PageContext.PageUserID);

            // Bind
            DataBind();

            YafCombinedUserData userData = new YafCombinedUserData(PageContext.PageUserID);

            //TitleUserName.Text = HtmlEncode( userData.Membership.UserName );
            AccountEmail.Text = userData.Membership.Email;
            Name.Text         = HtmlEncode(userData.Membership.UserName);
            Joined.Text       = YafDateTime.FormatDateTime(userData.Joined);
            NumPosts.Text     = String.Format("{0:N0}", userData.NumPosts);

            if (PageContext.BoardSettings.AvatarUpload && userData.HasAvatarImage)
            {
                AvatarImage.ImageUrl = String.Format("{0}resource.ashx?u={1}", YafForumInfo.ForumRoot, PageContext.PageUserID);
            }
            else if (!String.IsNullOrEmpty(userData.Avatar))                 // Took out PageContext.BoardSettings.AvatarRemote
            {
                AvatarImage.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
            {
                AvatarImage.Visible = false;
            }
        }
        protected string FormatLastPosted(object o)
        {
            DataRowView row = ( DataRowView )o;

            if (row ["LastPosted"].ToString().Length == 0)
            {
                return("&nbsp;");
            }

            string link = String.Format("<a href=\"{0}\">{1}</a>",
                                        YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.profile, "u={0}", row ["LastUserID"]),
                                        row ["LastUserName"]
                                        );
            string by = String.Format(GetText("lastpostlink"),
                                      YafDateTime.FormatDateTime(( DateTime )row ["LastPosted"]),
                                      link);

            string html = String.Format("{0} <a href=\"{1}\"><img src=\"{2}\"'></a>",
                                        by,
                                        YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.posts, "m={0}#{0}", row ["LastMessageID"]),
                                        GetThemeContents("ICONS", "ICON_LATEST")
                                        );

            return(html);
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (PageContext.IsPrivate && User == null)
            {
                // Ederon : guess we don't need this if anymore
                //if ( CanLogin )
                YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.login, "ReturnUrl={0}", Request.RawUrl);
                //else
                //	YAF.Classes.Utils.YafBuildLink.Redirect( YAF.Classes.Utils.ForumPages.forum );
            }

            if (PageContext.BoardSettings.ShowRSSLink)
            {
                RssFeed.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.rsstopic, "pg=active");
                RssFeed.Text        = GetText("RSSFEED");
                RssFeed.Visible     = true;
            }
            else
            {
                RssFeed.Visible = false;
            }

            if (!IsPostBack)
            {
                PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                PageLinks.AddLink(GetText("TITLE"), "");

                ForumJumpHolder.Visible = PageContext.BoardSettings.ShowForumJump && PageContext.Settings.LockedForum == 0;

                Since.Items.Add(new ListItem(String.Format(GetText("last_visit"), YafDateTime.FormatDateTime(Mession.LastVisit)), "0"));
                Since.Items.Add(new ListItem(GetText("last_hour"), "-1"));
                Since.Items.Add(new ListItem(GetText("last_two_hours"), "-2"));
                Since.Items.Add(new ListItem(GetText("last_day"), "1"));
                Since.Items.Add(new ListItem(GetText("last_two_days"), "2"));
                Since.Items.Add(new ListItem(GetText("last_week"), "7"));
                Since.Items.Add(new ListItem(GetText("last_two_weeks"), "14"));
                Since.Items.Add(new ListItem(GetText("last_month"), "31"));
            }
            BindData();
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        void ForumWelcome_PreRender(object sender, EventArgs e)
        {
            TimeNow.Text       = String.Format(PageContext.Localization.GetText("Current_Time"), YafDateTime.FormatTime(DateTime.Now));
            TimeLastVisit.Text = String.Format(PageContext.Localization.GetText("last_visit"), YafDateTime.FormatDateTime(Mession.LastVisit));

            if (PageContext.UnreadPrivate > 0)
            {
                UnreadMsgs.Visible     = true;
                UnreadMsgs.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.cp_pm);
                if (PageContext.UnreadPrivate == 1)
                {
                    UnreadMsgs.Text = String.Format(PageContext.Localization.GetText("unread1"), PageContext.UnreadPrivate);
                }
                else
                {
                    UnreadMsgs.Text = String.Format(PageContext.Localization.GetText("unread0"), PageContext.UnreadPrivate);
                }
            }
        }
Exemplo n.º 7
0
        protected string GetPrintHeader(object o)
        {
            DataRowView row = ( DataRowView )o;

            return(String.Format("<b>{2}: {0}</b> - {1}", row ["UserName"], YafDateTime.FormatDateTime(( DateTime )row ["Posted"]), GetText("postedby")));
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            if (!IsPostBack)
            {
                // localize button label
                Continue.Text = GetText("continue");

                // get redirect URL from parameter
                if (Request.QueryString["url"] != null)
                {
                    // unescape ampersands
                    RefreshURL = Request.QueryString["url"].Replace("&amp;", "&");
                }

                // try to get infomessage code from parameter
                try
                {
                    // compare it converted to enumeration
                    switch ((InfoMessage)int.Parse(Request.QueryString["i"]))
                    {
                    case InfoMessage.Moderated:                             /// Moderated
                        Title.Text = GetText("title_moderated");
                        Info.Text  = GetText("moderated");
                        break;

                    case InfoMessage.Suspended:                             /// Suspended
                        Title.Text = GetText("title_suspended");
                        Info.Text  = String.Format(GetText("suspended"), YafDateTime.FormatDateTime(PageContext.SuspendedUntil));
                        break;

                    case InfoMessage.RegistrationEmail:                             /// Registration email
                        Title.Text  = GetText("title_registration");
                        Info.Text   = GetText("registration");
                        RefreshTime = 10;
                        RefreshURL  = YafBuildLink.GetLink(ForumPages.login);
                        break;

                    case InfoMessage.AccessDenied:                             /// Access Denied
                        Title.Text  = GetText("title_accessdenied");
                        Info.Text   = GetText("accessdenied");
                        RefreshTime = 10;
                        RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                        break;

                    case InfoMessage.Disabled:                             /// Disabled feature
                        Title.Text  = GetText("TITLE_ACCESSDENIED");
                        Info.Text   = GetText("DISABLED");
                        RefreshTime = 10;
                        RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                        break;

                    case InfoMessage.Invalid:                             /// Invalid argument!
                        Title.Text  = GetText("TITLE_INVALID");
                        Info.Text   = GetText("INVALID");
                        RefreshTime = 10;
                        RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                        break;

                    case InfoMessage.Failure:                             // some sort of failure
                        Title.Text  = GetText("TITLE_FAILURE");
                        Info.Text   = GetText("FAILURE");
                        RefreshTime = 10;
                        RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                        break;
                    }
                }
                // exception was thrown
                catch (Exception)
                {
                    // get title for exception message
                    Title.Text = GetText("title_exception");
                    // exception message
                    Info.Text = string.Format("{1} <b>{0}</b>.", PageContext.PageUserName, GetText("exception"));

                    // redirect to forum main after 2 seconds
                    RefreshTime = 2;
                    RefreshURL  = YafBuildLink.GetLink(ForumPages.forum);
                }

                // set continue button URL and visibility
                Continue.NavigateUrl = RefreshURL;
                Continue.Visible     = RefreshURL != null;

                // create page links - must be placed after switch to display correct title (last breadcrumb trail)
                CreatePageLinks();
            }
        }