protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { return(new List <KeyValuePair <string, object> >(1) { RegisterObject( new { CanCreateProject = ProjectSecurity.CanCreate <Project>(null), IsModuleAdmin = ProjectSecurity.CurrentUserAdministrator, StartModule.GetInstance(ProjectsCommonSettings.LoadForCurrentUser().StartModuleType).StartModuleType }) }); }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { var filter = new TaskFilter { SortBy = "title", SortOrder = true, ProjectStatuses = new List <ProjectStatus> { ProjectStatus.Open } }; using (var scope = DIHelper.Resolve()) { var engineFactory = scope.Resolve <EngineFactory>(); var projects = engineFactory.ProjectEngine.GetByFilter(filter) .Select(pr => new { id = pr.ID, title = pr.Title, responsible = pr.Responsible, //created = (ApiDateTime) pr.CreateOn, security = new { canCreateMilestone = ProjectSecurity.CanCreate <Milestone>(pr), canCreateMessage = ProjectSecurity.CanCreate <Message>(pr), canCreateTask = ProjectSecurity.CanCreate <Task>(pr), canCreateTimeSpend = ProjectSecurity.CanCreate <TimeSpend>(pr), canEditTeam = ProjectSecurity.CanEditTeam(pr), canReadFiles = ProjectSecurity.CanReadFiles(pr), canReadMilestones = ProjectSecurity.CanRead <Milestone>(pr), canReadMessages = ProjectSecurity.CanRead <Message>(pr), canReadTasks = ProjectSecurity.CanRead <Task>(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 = 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 = engineFactory.ProjectEngine.GetByFilterCount(new TaskFilter()) }) }; filter = new TaskFilter { SortBy = "deadline", SortOrder = false, MilestoneStatuses = new List <MilestoneStatus> { MilestoneStatus.Open } }; var milestones = 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); } }
public CommonSecurityInfo() { CanCreateProject = ProjectSecurity.CanCreate <Project>(null); }