예제 #1
0
        private void PopulateControls()
        {
            if (siteUser != null)
            {
                this.lblCreatedDate.Text = siteUser.DateCreated.AddHours(timeOffset).ToString();
                this.lblTotalPosts.Text  = siteUser.TotalPosts.ToString(CultureInfo.InvariantCulture);

                this.lblUserName.Text = Server.HtmlEncode(siteUser.Name);

                Title = SiteUtils.FormatPageTitle(siteSettings, string.Format(CultureInfo.InvariantCulture,
                                                                              Resource.PageTitleFormatProfilePage, Server.HtmlEncode(siteUser.Name)));

                MetaDescription = string.Format(CultureInfo.InvariantCulture,
                                                Resource.ProfileViewMetaFormat, Server.HtmlEncode(siteUser.Name));

                userAvatar.UseGravatar      = allowGravatars;
                userAvatar.Email            = siteUser.Email;
                userAvatar.UserName         = siteUser.Name;
                userAvatar.UserId           = siteUser.UserId;
                userAvatar.AvatarFile       = siteUser.AvatarUrl;
                userAvatar.MaxAllowedRating = MaxAllowedGravatarRating;
                userAvatar.Disable          = disableAvatars;
                userAvatar.SiteId           = siteSettings.SiteId;
                userAvatar.UseLink          = false;

                if (disableAvatars)
                {
                    divAvatar.Visible = false;
                }


                //if (allowGravatars)
                //{
                //    imgAvatar.Visible = false;
                //    gravatar1.Visible = true;
                //    gravatar1.Email = siteUser.Email;
                //    //gravatar1.MaxAllowedRating = MaxAllowedGravatarRating;
                //}
                //else
                //{
                //    gravatar1.Visible = false;
                //    if (disableAvatars)
                //    {
                //        divAvatar.Visible = false;
                //    }
                //    else
                //    {
                //        if (siteUser.AvatarUrl.Length > 0)
                //        {
                //            imgAvatar.Src = avatarPath + siteUser.AvatarUrl;
                //        }
                //        else
                //        {
                //            imgAvatar.Src = Page.ResolveUrl(WebConfigSettings.DefaultBlankAvatarPath);
                //        }
                //    }
                //}

                lnkUserPosts.UserId     = siteUser.UserId;
                lnkUserPosts.TotalPosts = siteUser.TotalPosts;

                if (siteUser.TimeZoneId.Length > 0)
                {
                    TimeZoneInfo userTz = SiteUtils.GetTimeZone(siteUser.TimeZoneId);
                    if (userTz != null)
                    {
                        pnlTimeZone.Visible = true;

                        if (userTz.IsDaylightSavingTime(DateTime.UtcNow))
                        {
                            lblTimeZone.Text = userTz.DaylightNameWithOffset();
                        }
                        else
                        {
                            lblTimeZone.Text = userTz.DisplayName;
                        }
                    }
                }

                if (WebConfigSettings.UseRelatedSiteMode)
                {
                    // this can't be used in related site mode
                    // because we can't assume forum posts were in this site.
                    divForumPosts.Visible = false;
                }

                if (Request.IsAuthenticated)
                {
                    ShowAuthenticatedProperties(siteUser);
                }
                else
                {
                    ShowAnonymousProperties(siteUser);
                }


                PopulateMessenger();
            }
            else
            {
                this.lblUserName.Text = "User not found";
                divAvatar.Visible     = false;
            }
        }