Esempio n. 1
0
        public static List <ForumPost> GetUserLatestPosts(int StartIndex, int PageSize, out int totalRecords)
        {
            if (PageSize <= 0)
            {
                PageSize = 10;
            }
            if (PageSize == int.MaxValue)
            {
                PageSize = int.MaxValue - 1;
            }

            int PageIndex = StartIndex / PageSize;

            totalRecords = 0;
            //it's used on profile.aspx page, so we're using UserId query string parameter
            int userId = CommonHelper.QueryStringInt("UserId");
            var user   = CustomerManager.GetCustomerById(userId);

            if (user == null)
            {
                return(new List <ForumPost>());
            }

            var result = ForumManager.GetAllPosts(0,
                                                  user.CustomerId, string.Empty, false, PageSize, PageIndex, out totalRecords);

            return(result);
        }
Esempio n. 2
0
        private void BindData()
        {
            var customer = CustomerManager.GetCustomerById(this.CustomerId);

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

            if (CustomerManager.AllowCustomersToUploadAvatars)
            {
                phAvatar.Visible = true;
                var 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;
            }

            phFullName.Visible = false;

            if (CustomerManager.ShowCustomersLocation)
            {
                phLocation.Visible = true;
                var 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;
                }
                var 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 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());
            }
        }
Esempio n. 4
0
        private void BindData()
        {
            var 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);
                btnDelete.OnClientClick = string.Format("return confirm('{0}')", GetLocaleResourceString("Common.AreYouSure"));
                btnMoveTopic.Visible    = ForumManager.IsUserAllowedToMoveTopic(NopContext.Current.User, forumTopic);

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

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

                var 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))
                {
                    var 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());
            }
        }