Exemple #1
0
        private XRpcArray MetaWecAseGetRecentPosts(
            UrlHelper urlHelper,
            string cAseId,
            string userName,
            string password,
            int numberOfPosts,
            IEnumerable <IXmlRpcDriver> drivers)
        {
            IUser user = ValidateUser(userName, password);

            // User needs to at least have permission to edit its own cAse posts to access the service
            _authorizationService.CheckAccess(Permissions.EditCasePost, user, null);

            CasePart cAse = _contentManager.Get <CasePart>(Convert.ToInt32(cAseId));

            if (cAse == null)
            {
                throw new ArgumentException();
            }

            var array = new XRpcArray();

            foreach (var cAsePost in _cAsePostService.Get(cAse, 0, numberOfPosts, VersionOptions.Latest))
            {
                var postStruct = CreateCaseStruct(cAsePost, urlHelper);

                foreach (var driver in drivers)
                {
                    driver.Process(postStruct);
                }

                array.Add(postStruct);
            }
            return(array);
        }
Exemple #2
0
        //todo: the content shape template has extra bits that the core contents module does not (remove draft functionality)
        //todo: - move this extra functionality there or somewhere else that's appropriate?
        public ActionResult Edit(int cAseId, int postId)
        {
            var cAse = _cAseService.Get(cAseId, VersionOptions.Latest);

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

            var post = _cAsePostService.Get(postId, VersionOptions.Latest);

            if (post == null)
            {
                return(HttpNotFound());
            }
            CasePostAttribPart attri      = post.Get <CasePostAttribPart>();
            Boolean            isAcquired = attri.CaseAcquiredBy == 0 ? false : true;

            bool isMe = false;
            //Check isit accuired by me

            int userId = _workContextAccessor.GetContext().CurrentUser.Id;

            isMe = userId == attri.CaseAcquiredBy;

            bool icanEdit = isAcquired && isMe;

            if (!icanEdit)
            {
                if (!Services.Authorizer.Authorize(Permissions.EditCasePost, post, T("Couldn't edit cAse post")))
                {
                    return(new HttpUnauthorizedResult());
                }
            }

            var model = Services.ContentManager.BuildEditor(post);

            return(View(model));
        }
Exemple #3
0
        public ActionResult Item(int cAseId, PagerParameters pagerParameters)
        {
            Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);

            var cAsePart = _cAseService.Get(cAseId, VersionOptions.Published).As <CasePart>();

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

            if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, cAsePart, T("Cannot view content")))
            {
                return(new HttpUnauthorizedResult());
            }

            pager.PageSize = cAsePart.PostsPerPage;

            _feedManager.Register(cAsePart, _services.ContentManager.GetItemMetadata(cAsePart).DisplayText);
            var cAsePosts = _cAsePostService.Get(cAsePart, pager.GetStartIndex(), pager.PageSize)
                            .Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
            dynamic cAse = _services.ContentManager.BuildDisplay(cAsePart);

            var list = Shape.List();

            list.AddRange(cAsePosts);

            cAse.Content.Add(Shape.Parts_Cases_CasePost_List(ContentItems: list), "5");

            var totalItemCount = _cAsePostService.PostCount(cAsePart);

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


            return(new ShapeResult(this, cAse));
        }
Exemple #4
0
        public ActionResult ListByArchive(string path)
        {
            var cAsePath = _archiveConstraint.FindPath(path);
            var archive  = _archiveConstraint.FindArchiveData(path);

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

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

            CasePart cAsePart = _cAseService.Get(cAsePath);

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


            if (archive.ToDateTime() == DateTime.MinValue)
            {
                // render the archive data
                return(new ShapeResult(this, Shape.Parts_Cases_CaseArchives(Case: cAsePart, Archives: _cAsePostService.GetArchives(cAsePart))));
            }

            var list = Shape.List();

            list.AddRange(_cAsePostService.Get(cAsePart, archive).Select(b => _services.ContentManager.BuildDisplay(b, "Summary")));

            _feedManager.Register(cAsePart, _services.ContentManager.GetItemMetadata(cAsePart).DisplayText);

            var viewModel = Shape.ViewModel()
                            .ContentItems(list)
                            .Case(cAsePart)
                            .ArchiveData(archive);

            return(View(viewModel));
        }
Exemple #5
0
        public CasePostPartHandler(ICaseService CaseService, ICasePostService CasePostService, RequestContext requestContext)
        {
            _CaseService = CaseService;

            OnGetDisplayShape <CasePostPart>(SetModelProperties);
            OnGetEditorShape <CasePostPart>(SetModelProperties);
            OnUpdateEditorShape <CasePostPart>(SetModelProperties);

            OnCreated <CasePostPart>((context, part) => ProcessCasePostsCount(part));
            OnPublished <CasePostPart>((context, part) => ProcessCasePostsCount(part));
            OnUnpublished <CasePostPart>((context, part) => ProcessCasePostsCount(part));
            OnVersioned <CasePostPart>((context, part, newVersionPart) => ProcessCasePostsCount(newVersionPart));
            OnRemoved <CasePostPart>((context, part) => ProcessCasePostsCount(part));

            OnRemoved <CasePart>(
                (context, b) =>
                CasePostService.Get(context.ContentItem.As <CasePart>()).ToList().ForEach(
                    CasePost => context.ContentManager.Remove(CasePost.ContentItem)));

            OnInitializing <CasePostPart>((context, casePart) => {
            });
        }
        public ActionResult Item(int caseId, PagerParameters pagerParameters)
        {
            IUser   user    = _workContextAccessor.GetContext().CurrentUser;
            dynamic dynUser = user.ContentItem;

            if (dynUser.UserRolesPart != null)
            {
                IEnumerable <string> userRoles = dynUser.UserRolesPart.Roles;
                //  isInRole = userRoles.Any(roles.Contains);
            }

            Pager    pager    = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            CasePart casePart = _caseService.Get(caseId, VersionOptions.Latest).As <CasePart>();

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

            var casePosts = _casePostService.Get(casePart, pager.GetStartIndex(), pager.PageSize, VersionOptions.Latest);

            //filtrt all not for intern


            //   var cAses = _cAseService.Get().Where(x => _authorizationService.TryCheckAccess(Permissions.MetaListCases, _workContextAccessor.GetContext().CurrentUser, x)).ToArray();
            //    bool isLawInter=_authorizationService.TryCheckAccess(Permissions.ListunpublishedCases, _workContextAccessor.GetContext().CurrentUser, casePart);
            //  if (isLawInter)
            // //   {
            //         casePosts = casePosts.Where(pub => pub.IsPublished == false).Where(  pub=> _casePostService.isInterAcquiered(pub.ContentItem.Id));
            //   }



            casePosts = casePosts.ToArray();
            foreach (CasePostPart postpart in casePosts)
            {
                _casePostService.GetCurrentState(postpart);
            }

            //_authorizationService.TryCheckAccess()


            var casePostsShapes = casePosts.Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin")).ToArray();


            var cAse = Services.ContentManager.BuildDisplay(casePart, "DetailAdmin");

            var list = Shape.List();

            list.AddRange(casePostsShapes);
            cAse.Content.Add(Shape.Parts_Cases_CasePost_ListAdmin(ContentItems: list), "5");

            var totalItemCount = _casePostService.PostCount(casePart, VersionOptions.Latest);

            //if (isLawInter)
            //   totalItemCount = _casePostService.PostCount(casePart, VersionOptions.Draft);

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

            return(View(cAse));
        }