public IEnumerable<ThreadPart> Get(ForumPart forumPart, VersionOptions versionOptions)
 {
     return GetForumQuery(forumPart, versionOptions)
         .OrderByDescending(cr => cr.CreatedUtc)
         .ForPart<ThreadPart>()
         .List();
 }
Example #2
0
        public ActionResult Item(int forumId, PagerParameters pagerParameters)
        {
            Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);

            ForumPart forum = _forumService.Get(forumId, VersionOptions.Latest);

            if (forum == null)
            {
                return(HttpNotFound());
            }

            if (!_orchardServices.Authorizer.Authorize(Permissions.ManageForums, forum, T("Not allowed to view forum")))
            {
                return(new HttpUnauthorizedResult());
            }

            var threads       = _threadService.Get(forum, pager.GetStartIndex(), pager.PageSize, VersionOptions.Latest).ToArray();
            var threadsShapes = threads.Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin")).ToArray();

            dynamic forumShape = _contentManager.BuildDisplay(forum, "DetailAdmin");

            var list = Shape.List();

            list.AddRange(threadsShapes);
            forumShape.Content.Add(Shape.Parts_Forums_Thread_ListAdmin(ContentItems: list), "5");

            var totalItemCount = _threadService.Count(forum, VersionOptions.Latest);

            forumShape.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
            return(View((object)forumShape));
        }
Example #3
0
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, int skip, int count, VersionOptions versionOptions) {
     return GetParentQuery(forumPart, versionOptions)
         .Join<ThreadPartRecord>()
         .OrderByDescending(o => o.IsSticky)
         .Join<CommonPartRecord>()
         .OrderByDescending(o => o.ModifiedUtc)
         .ForPart<ThreadPart>()
         .Slice(skip, count)
         .ToList();
 }
 public ThreadPart Get(ForumPart forumPart, string slug, VersionOptions versionOptions)
 {
     return _contentManager
         .Query<ThreadPart, ThreadPartRecord>()
         .Join<AutoroutePartRecord>()
         .Where(r => r.DisplayAlias.EndsWith(slug))
         .Join<CommonPartRecord>()
         .Where(cr => cr.Container == forumPart.Record.ContentItemRecord)
         .List()
         .FirstOrDefault();
 }
Example #5
0
 public IEnumerable <ThreadPart> Get(ForumPart forumPart, int skip, int count, VersionOptions versionOptions)
 {
     return(GetParentQuery(forumPart, versionOptions)
            .Join <ThreadPartRecord>()
            .OrderByDescending(o => o.IsSticky)
            .Join <CommonPartRecord>()
            .OrderByDescending(o => o.ModifiedUtc)
            .ForPart <ThreadPart>()
            .Slice(skip, count)
            .ToList());
 }
Example #6
0
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, IUser user) {
     return GetParentQuery(forumPart, VersionOptions.Published)
         .Where(o => o.OwnerId == user.Id)
         .Join<ThreadPartRecord>()
         .OrderByDescending(o => o.IsSticky)
         .Join<CommonPartRecord>()
         .OrderByDescending(o => o.ModifiedUtc)
         .ForPart<ThreadPart>()
         .List()
         .ToList();
 }
Example #7
0
 public IEnumerable <ThreadPart> Get(ForumPart forumPart, IUser user)
 {
     return(GetParentQuery(forumPart, VersionOptions.Published)
            .Where(o => o.OwnerId == user.Id)
            .Join <ThreadPartRecord>()
            .OrderByDescending(o => o.IsSticky)
            .Join <CommonPartRecord>()
            .OrderByDescending(o => o.ModifiedUtc)
            .ForPart <ThreadPart>()
            .List()
            .ToList());
 }
Example #8
0
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, bool includeInappropriate, IUser user) {
     var threads = GetParentQuery(forumPart, VersionOptions.Published)
         .Where(o => o.OwnerId == user.Id)
         .Join<ThreadPartRecord>();
     if ( includeInappropriate == false ) {
         threads.Where(threadRec => threadRec.IsInappropriate == false);
     }
     return threads.OrderByDescending(o => o.IsSticky)
         .Join<CommonPartRecord>()
         .OrderByDescending(o => o.ModifiedUtc)
         .ForPart<ThreadPart>()
         .List()
         .ToList();
 }
Example #9
0
        public IEnumerable<ThreadPart> Get(ForumPart forumPart, int skip, int count, bool includeInappropriate, VersionOptions versionOptions) {
            var threads= GetParentQuery(forumPart, versionOptions)
                .Join<ThreadPartRecord>();

            if ( includeInappropriate == false ) {
                threads.Where(threadRec => threadRec.IsInappropriate == false);
            }
            return threads.OrderByDescending(o => o.IsSticky)
                    .Join<CommonPartRecord>()
                    .OrderByDescending(o => o.ModifiedUtc)
                    .ForPart<ThreadPart>()
                    .Slice(skip, count)
                    .ToList();
        }
Example #10
0
        public ForumCategoryPart GetParentCategory( ForumPart forumPart ){
            ForumCategoryPart parentCategory = null;
            if( forumPart.As<CommonPart>().Container != null ) {
                parentCategory = forumPart.As<CommonPart>().Container.As<ForumCategoryPart>();
            }
            return parentCategory;
                

            /*
            var parentCategoryId = _categoryToForumMappingRepository.Table.Where(rec => rec.ForumPartRecord.Id == forumPart.Id).Select(rec => rec.ForumCategoryPartRecord.Id).FirstOrDefault();
            var parentCategory = _contentManager.Query<ForumCategoryPart, ForumCategoryPartRecord>().Where( cat=>cat.Id == parentCategoryId ).List().FirstOrDefault();
            return parentCategory;
             */
        }
Example #11
0
        private void UpdateForumPartCounters(ThreadPart threadPart)
        {
            var commonPart = threadPart.As <CommonPart>();

            if (commonPart != null &&
                commonPart.Record.Container != null)
            {
                ForumPart forumPart = threadPart.ForumPart ??
                                      _forumService.Get(commonPart.Record.Container.Id, VersionOptions.Published);

                forumPart.ThreadCount = _threadService.Count(forumPart, VersionOptions.Published);
                forumPart.PostCount   = _threadService
                                        .Get(forumPart, VersionOptions.Published)
                                        .Sum(publishedThreadPart =>
                                             publishedThreadPart.PostCount);
            }
        }
Example #12
0
 public void Delete(ForumPart forum)
 {
     _contentManager.Remove(forum.ContentItem);
 }
Example #13
0
 public void Delete(ForumPart forumPart)
 {
     Get(forumPart)
     .ToList()
     .ForEach(thread => _contentManager.Remove(thread.ContentItem));
 }
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, VersionOptions versionOptions)
 {
     return GetForumQuery(forumPart, versionOptions).List().Select(ci => ci.As<ThreadPart>());
 }
Example #15
0
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, bool includeInappropriate, VersionOptions versionOptions) {
     return Get(forumPart, 0, 0,includeInappropriate, versionOptions);
 }
Example #16
0
 public static string ThreadCreate(this UrlHelper urlHelper, ForumPart forumPart) {
     return urlHelper.Action("Create", "Thread", new { forumId = forumPart.Id, area = Constants.LocalArea, returnUrl = urlHelper.RequestContext.HttpContext.Request.ToUrlString() });
 }
Example #17
0
 public static string ForumEdit(this UrlHelper urlHelper, ForumPart forumPart) {
     return urlHelper.Action("Edit", "ForumAdmin", new { forumId = forumPart.Id, area = Constants.LocalArea });
 }
Example #18
0
 public void OpenForum(ForumPart forumPart)
 {
     forumPart.IsClosed = false;
 }
Example #19
0
 public static string ForumView(this UrlHelper urlHelper, ForumPart forumPart)
 {
     return(urlHelper.Action("Item", "Forum", new { forumId = forumPart.Id, area = Constants.LocalArea }));
 }
Example #20
0
 public static string ForumEdit(this UrlHelper urlHelper, ForumPart forumPart)
 {
     return(urlHelper.Action("Edit", "ForumAdmin", new { forumId = forumPart.Id, area = Constants.LocalArea }));
 }
 public static string CreateThread(this UrlHelper urlHelper, ForumPart forumPart)
 {
     return urlHelper.Action("Create", "Thread", new { forumId = forumPart.Id, area = Constants.LocalArea });
 }
 public static string AdminThreadsForForum(this UrlHelper urlHelper, ForumPart forumPart)
 {
     return urlHelper.Action("List", "ThreadAdmin", new { forumId = forumPart.Id, area = Constants.LocalArea });
 }
Example #23
0
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, int skip, int count, bool includeInappropriate) {
     return Get(forumPart, skip, count, includeInappropriate, VersionOptions.Published);
 }
Example #24
0
 public void CloseForum(ForumPart forumPart)
 {
     forumPart.IsClosed = true;
 }
Example #25
0
 public static string ThreadCreate(this UrlHelper urlHelper, ForumPart forumPart)
 {
     return(urlHelper.Action("Create", "Thread", new { forumId = forumPart.Id, area = Constants.LocalArea, returnUrl = urlHelper.RequestContext.HttpContext.Request.ToUrlString() }));
 }
Example #26
0
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, VersionOptions versionOptions) {
     return Get(forumPart, 0, 0, versionOptions);
 }
Example #27
0
 public int Count(ForumPart forumPart, VersionOptions versionOptions)
 {
     return(GetParentQuery(forumPart, versionOptions).Count());
 }
Example #28
0
 public static string ForumView(this UrlHelper urlHelper, ForumPart forumPart) {
     return urlHelper.Action("Item", "Forum", new { forumId = forumPart.Id, area = Constants.LocalArea });
 }
        public ThreadPart Get(ForumPart forumPart, string slug, VersionOptions versionOptions)
        {
            var threadPath = forumPart.As<IRoutableAspect>().GetChildPath(slug);

            return _contentManager.Query(versionOptions, ContentPartConstants.Thread).Join<RoutePartRecord>().Where(rr => rr.Path == threadPath).
                    Join<CommonPartRecord>().Where(cr => cr.Container == forumPart.Record.ContentItemRecord).List().
                    SingleOrDefault().As<ThreadPart>();
        }
Example #30
0
 public void Delete(ForumPart forum) {
     _contentManager.Remove(forum.ContentItem);
 }
Example #31
0
 public void Delete(ForumPart forumPart, bool includeInappropriate) {
     Get(forumPart, true)
         .ToList()
         .ForEach(thread => _contentManager.Remove(thread.ContentItem));
 }
Example #32
0
 // Default Route
 public static string Forums(this UrlHelper urlHelper, ForumPart forumPart) {
     return ContentItemExtensions.ItemDisplayUrl(urlHelper, forumPart.ContentItem);
     //return urlHelper.Action("List", "Forum", new { area = Constants.LocalArea });
 }
Example #33
0
 public void Delete(ForumPart forumPart) {
     Get(forumPart)
         .ToList()
         .ForEach(thread => _contentManager.Remove(thread.ContentItem));
 }
Example #34
0
 public int Count(ForumPart forumPart, VersionOptions versionOptions) {
     return GetParentQuery(forumPart, versionOptions).Count();
 }
 public int ThreadCount(ForumPart forumPart, VersionOptions versionOptions)
 {
     return GetForumQuery(forumPart, versionOptions).Count();
 }
Example #36
0
        public PostPart GetLatestPost(ForumPart forumPart, VersionOptions versionOptions)
        {
            var threadParts = _contentManager
                .Query<ThreadPart, ThreadPartRecord>(versionOptions)
                .Join<CommonPartRecord>().Where(cpr => cpr.Container == forumPart.ContentItem.Record)
                .List();

            return threadParts
                .Select(o => GetLatestPost(o, versionOptions))
                .OrderBy(o => o.As<ICommonPart>().PublishedUtc)
                .LastOrDefault();
        }
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, int skip, int count, VersionOptions versionOptions)
 {
     return GetForumQuery(forumPart, versionOptions).Slice(skip, count).ToList().Select(ci => ContentExtensions.As<ThreadPart>(ci));
 }
 public IEnumerable<ThreadPart> Get(ForumPart forumPart)
 {
     return Get(forumPart, VersionOptions.Published);
 }
Example #39
0
 public IEnumerable <ThreadPart> Get(ForumPart forumPart, VersionOptions versionOptions)
 {
     return(Get(forumPart, 0, 0, versionOptions));
 }
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, int skip, int count)
 {
     return Get(forumPart, skip, count, VersionOptions.Published);
 }
Example #41
0
 public IEnumerable <ThreadPart> Get(ForumPart forumPart, int skip, int count)
 {
     return(Get(forumPart, skip, count, VersionOptions.Published));
 }
 // The order by on this record needs to be revisited.
 public IEnumerable<ThreadPart> Get(ForumPart forumPart, int skip, int count, VersionOptions versionOptions)
 {
     return GetForumQuery(forumPart, versionOptions)
         .Join<ThreadPartRecord>()
         .OrderByDescending(t => t.IsSticky)
         .Join<CommonPartRecord>()
         .OrderByDescending(cr => cr.CreatedUtc)
         .ForPart<ThreadPart>()
         .Slice(skip, count);
 }
Example #43
0
 public IEnumerable <ThreadPart> Get(ForumPart forumPart)
 {
     return(Get(forumPart, VersionOptions.Published));
 }