private void BindData()
        {
            ForumTopic forumTopic = ForumManager.GetTopicByID(this.TopicID, true);

            if (forumTopic != null)
            {
                btnEdit.Visible      = ForumManager.IsUserAllowedToEditTopic(NopContext.Current.User, forumTopic);
                btnDelete.Visible    = ForumManager.IsUserAllowedToDeleteTopic(NopContext.Current.User, forumTopic);
                btnMoveTopic.Visible = ForumManager.IsUserAllowedToMoveTopic(NopContext.Current.User, forumTopic);
                //btnReply.Visible = ForumManager.IsUserAllowedToCreatePost(NopContext.Current.User, forumTopic);

                lblTopicSubject.Text = Server.HtmlEncode(forumTopic.Subject);

                int totalRecords = 0;
                int pageSize     = 10;
                if (ForumManager.PostsPageSize > 0)
                {
                    pageSize = ForumManager.PostsPageSize;
                }

                ForumPostCollection forumPosts = ForumManager.GetAllPosts(forumTopic.ForumTopicID, 0, string.Empty,
                                                                          pageSize, this.CurrentPageIndex, out totalRecords);
                if (forumPosts.Count > 0)
                {
                    this.postsPager1.PageSize     = pageSize;
                    this.postsPager1.TotalRecords = totalRecords;
                    this.postsPager1.PageIndex    = this.CurrentPageIndex;

                    this.postsPager2.PageSize     = pageSize;
                    this.postsPager2.TotalRecords = totalRecords;
                    this.postsPager2.PageIndex    = this.CurrentPageIndex;

                    rptrPosts.DataSource = forumPosts;
                    rptrPosts.DataBind();
                }

                //subsciption
                if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User))
                {
                    ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                           0, forumTopic.ForumTopicID, 1, 0).FirstOrDefault();

                    if (forumSubscription == null)
                    {
                        btnWatchTopic.Text  = GetLocaleResourceString("Forum.WatchTopic");
                        btnWatchTopic2.Text = GetLocaleResourceString("Forum.WatchTopic");
                    }
                    else
                    {
                        btnWatchTopic.Text  = GetLocaleResourceString("Forum.UnwatchTopic");
                        btnWatchTopic2.Text = GetLocaleResourceString("Forum.UnwatchTopic");
                    }
                }
                else
                {
                    btnWatchTopic.Visible  = false;
                    btnWatchTopic2.Visible = false;
                }
            }
            else
            {
                Response.Redirect(SEOHelper.GetForumMainURL());
            }
        }
Beispiel #2
0
        private void BindData()
        {
            Customer customer = CustomerManager.GetCustomerByID(this.CustomerID);

            if (customer == null)
            {
                this.Visible = false;
                return;
            }

            if (CustomerManager.AllowCustomersToUploadAvatars)
            {
                phAvatar.Visible = true;
                Picture customerAvatar = customer.Avatar;
                int     avatarSize     = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85);
                if (customerAvatar != null)
                {
                    string pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false);
                    this.imgAvatar.ImageUrl = pictureUrl;
                }
                else
                {
                    if (CustomerManager.DefaultAvatarEnabled)
                    {
                        string pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize);
                        this.imgAvatar.ImageUrl = pictureUrl;
                    }
                    else
                    {
                        phAvatar.Visible = false;
                    }
                }
            }
            else
            {
                phAvatar.Visible = false;
            }

            //TODO make configurable
            //if (false)
            //{
            //    lblFullName.Text = Server.HtmlEncode(customer.FullName);
            //}
            //else
            //{
            phFullName.Visible = false;
            //}


            if (CustomerManager.ShowCustomersLocation)
            {
                phLocation.Visible = true;
                Country country = CountryManager.GetCountryByID(customer.CountryID);
                if (country != null)
                {
                    lblCountry.Text = Server.HtmlEncode(country.Name);
                }
                else
                {
                    phLocation.Visible = false;
                }
            }
            else
            {
                phLocation.Visible = false;
            }

            if (ForumManager.AllowPrivateMessages)
            {
                if (customer != null && !customer.IsGuest)
                {
                    btnSendPM.CustomerID = customer.CustomerID;
                    phPM.Visible         = true;
                }
                else
                {
                    phPM.Visible = false;
                }
            }
            else
            {
                phPM.Visible = false;
            }

            if (ForumManager.ForumsEnabled && ForumManager.ShowCustomersPostCount)
            {
                phTotalPosts.Visible = true;
                lblTotalPosts.Text   = customer.TotalForumPosts.ToString();
            }
            else
            {
                phTotalPosts.Visible = false;
            }

            if (CustomerManager.ShowCustomersJoinDate)
            {
                phJoinDate.Visible = true;
                lblJoinDate.Text   = DateTimeHelper.ConvertToUserTime(customer.RegistrationDate).ToString("f");
            }
            else
            {
                phJoinDate.Visible = false;
            }


            if (customer.DateOfBirth.HasValue)
            {
                lblDateOfBirth.Text = customer.DateOfBirth.Value.ToString("D");
            }
            else
            {
                phDateOfBirth.Visible = false;
            }

            if (ForumManager.ForumsEnabled)
            {
                int totaRecords = 0;
                int pageSize    = 5;
                if (ForumManager.LatestUserPostsPageSize > 0)
                {
                    pageSize = ForumManager.LatestUserPostsPageSize;
                }
                ForumPostCollection forumPosts = ForumManager.GetAllPosts(0, customer.CustomerID, string.Empty,
                                                                          false, pageSize, 0, out totaRecords);
                if (forumPosts.Count > 0)
                {
                    rptrLatestPosts.DataSource = forumPosts;
                    rptrLatestPosts.DataBind();
                }
                else
                {
                    phLatestPosts.Visible = false;
                }
            }
            else
            {
                phLatestPosts.Visible = false;
            }
        }
        private static ForumPostCollection DBMapping(DBForumPostCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            ForumPostCollection collection = new ForumPostCollection();
            foreach (DBForumPost dbItem in dbCollection)
            {
                ForumPost item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }