Exemplo n.º 1
0
 public ProjectSecurityInfo(Project project)
 {
     CanCreateMessage   = ProjectSecurity.CanCreateMessage(project);
     CanCreateMilestone = ProjectSecurity.CanCreateMilestone(project);
     CanCreateTask      = ProjectSecurity.CanCreateTask(project);
     CanEditTeam        = ProjectSecurity.CanEditTeam(project);
     CanReadFiles       = ProjectSecurity.CanReadFiles(project);
     CanReadMilestones  = ProjectSecurity.CanReadMilestones(project);
     CanReadMessages    = ProjectSecurity.CanReadMessages(project);
     CanReadTasks       = ProjectSecurity.CanReadTasks(project);
 }
Exemplo n.º 2
0
 public ProjectSecurityInfo(Project project)
 {
     CanCreateMilestone = ProjectSecurity.CanCreateMilestone(project);
     CanCreateMessage   = ProjectSecurity.CanCreateMessage(project);
     CanCreateTask      = ProjectSecurity.CanCreateTask(project);
     CanEditTeam        = ProjectSecurity.CanEditTeam(project);
     CanReadFiles       = ProjectSecurity.CanReadFiles(project);
     CanReadMilestones  = ProjectSecurity.CanReadMilestones(project);
     CanReadMessages    = ProjectSecurity.CanReadMessages(project);
     CanReadTasks       = ProjectSecurity.CanReadTasks(project);
     IsInTeam           = ProjectSecurity.IsInTeam(project, SecurityContext.CurrentAccount.ID, false);
     CanLinkContact     = ProjectSecurity.CanLinkContact(project);
 }
Exemplo n.º 3
0
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            var result = new List <KeyValuePair <string, object> >(5)
            {
                RegisterObject("EntryCountOnPage", Global.EntryCountOnPage),
                RegisterObject("VisiblePageCount", Global.VisiblePageCount)
            };

            var filter = new TaskFilter
            {
                SortBy          = "title",
                SortOrder       = true,
                ProjectStatuses = new List <ProjectStatus> {
                    ProjectStatus.Open
                }
            };

            var projects = Global.EngineFactory.ProjectEngine.GetByFilter(filter)
                           .Select(pr => new
            {
                id          = pr.ID,
                title       = pr.Title,
                responsible = pr.Responsible,
                //created = (ApiDateTime) pr.CreateOn,
                security = new
                {
                    canCreateMilestone = ProjectSecurity.CanCreateMilestone(pr),
                    canCreateMessage   = ProjectSecurity.CanCreateMessage(pr),
                    canCreateTask      = ProjectSecurity.CanCreateTask(pr),
                    canEditTeam        = ProjectSecurity.CanEditTeam(pr),
                    canReadFiles       = ProjectSecurity.CanReadFiles(pr),
                    canReadMilestones  = ProjectSecurity.CanReadMilestones(pr),
                    canReadMessages    = ProjectSecurity.CanReadMessages(pr),
                    canReadTasks       = ProjectSecurity.CanReadTasks(pr),
                    isInTeam           = ProjectSecurity.IsInTeam(pr, SecurityContext.CurrentAccount.ID, false),
                    canLinkContact     = ProjectSecurity.CanLinkContact(pr),
                },
                isPrivate = pr.Private,
                status    = pr.Status
            });

            var tags = Global.EngineFactory.TagEngine.GetTags().Select(r => new { value = r.Key, title = r.Value.HtmlEncode() });

            result.Add(RegisterObject("Projects", new { response = projects }));
            result.Add(RegisterObject("Tags", new { response = tags }));


            if (context.Request.UrlReferrer != null && string.IsNullOrEmpty(HttpUtility.ParseQueryString(context.Request.GetUrlRewriter().Query)["prjID"]) && string.IsNullOrEmpty(HttpUtility.ParseQueryString(context.Request.UrlReferrer.Query)["prjID"]))
            {
                filter = new TaskFilter
                {
                    SortBy            = "deadline",
                    SortOrder         = false,
                    MilestoneStatuses = new List <MilestoneStatus> {
                        MilestoneStatus.Open
                    }
                };

                var milestones = Global.EngineFactory.MilestoneEngine.GetByFilter(filter)
                                 .Select(m => new
                {
                    id           = m.ID,
                    title        = m.Title,
                    deadline     = SetDate(m.DeadLine, TimeZoneInfo.Local),
                    projectOwner = new { id = m.Project.ID }
                });

                result.Add(RegisterObject("Milestones", new { response = milestones }));
            }

            return(result);
        }
Exemplo n.º 4
0
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            var filter = new TaskFilter
            {
                SortBy          = "title",
                SortOrder       = true,
                ProjectStatuses = new List <ProjectStatus> {
                    ProjectStatus.Open
                }
            };

            var projects = Global.EngineFactory.ProjectEngine.GetByFilter(filter)
                           .Select(pr => new
            {
                id          = pr.ID,
                title       = pr.Title,
                responsible = pr.Responsible,
                //created = (ApiDateTime) pr.CreateOn,
                security = new
                {
                    canCreateMilestone = ProjectSecurity.CanCreateMilestone(pr),
                    canCreateMessage   = ProjectSecurity.CanCreateMessage(pr),
                    canCreateTask      = ProjectSecurity.CanCreateTask(pr),
                    canCreateTimeSpend = ProjectSecurity.CanCreateTimeSpend(pr),
                    canEditTeam        = ProjectSecurity.CanEditTeam(pr),
                    canReadFiles       = ProjectSecurity.CanReadFiles(pr),
                    canReadMilestones  = ProjectSecurity.CanReadMilestones(pr),
                    canReadMessages    = ProjectSecurity.CanReadMessages(pr),
                    canReadTasks       = ProjectSecurity.CanReadTasks(pr),
                    isInTeam           = ProjectSecurity.IsInTeam(pr, SecurityContext.CurrentAccount.ID, false),
                    canLinkContact     = ProjectSecurity.CanLinkContact(pr)
                },
                isPrivate      = pr.Private,
                status         = pr.Status,
                taskCountTotal = pr.TaskCountTotal
            }).ToList();

            var tags = Global.EngineFactory.TagEngine.GetTags().Select(r => new { value = r.Key, title = r.Value.HtmlEncode() }).ToList();

            var result = new List <KeyValuePair <string, object> >(1)
            {
                RegisterObject(
                    new
                {
                    Global.EntryCountOnPage,
                    Global.VisiblePageCount,
                    Projects      = new { response = projects },
                    Tags          = new { response = tags },
                    ProjectsCount = Global.EngineFactory.ProjectEngine.GetByFilterCount(new TaskFilter())
                })
            };

            filter = new TaskFilter
            {
                SortBy            = "deadline",
                SortOrder         = false,
                MilestoneStatuses = new List <MilestoneStatus> {
                    MilestoneStatus.Open
                }
            };

            var milestones = Global.EngineFactory.MilestoneEngine.GetByFilter(filter)
                             .Select(m => new
            {
                id           = m.ID,
                title        = m.Title,
                deadline     = SetDate(m.DeadLine, TimeZoneInfo.Local),
                projectOwner = new { id = m.Project.ID },
                status       = (int)m.Status
            }).ToList();

            result.Add(RegisterObject(new { Milestones = new { response = milestones } }));

            return(result);
        }