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); }
public bool CanCreateDiscussion() { if (RequestContext.IsInConcreteProject()) { return(ProjectSecurity.CanCreateMessage(RequestContext.GetCurrentProject())); } return(ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID) ? RequestContext.HasAnyProjects() : Global.EngineFactory.GetProjectEngine().GetByParticipant(SecurityContext.CurrentAccount.ID).Where(ProjectSecurity.CanCreateMessage).Any()); }
protected override void PageLoad() { var action = UrlParameters.ActionType; var discussionId = UrlParameters.EntityID; if (discussionId >= 0) { var discussion = EngineFactory.MessageEngine.GetByID(discussionId); if (action.HasValue && action.Value == UrlAction.Edit) { if (ProjectSecurity.CanEdit(discussion)) { LoadDiscussionActionControl(discussion); } else { Response.Redirect("messages.aspx", true); } } else { if (discussion != null && (!ProjectSecurity.CanRead(discussion.Project) || discussion.Project.ID != Project.ID)) { RedirectNotFound(string.Format("messages.aspx?prjID={0}", Project.ID)); } } if (discussion != null) { Title = HeaderStringHelper.GetPageTitle(discussion.Title); } } else { if (action.HasValue && action.Value == UrlAction.Add) { if (!RequestContext.IsInConcreteProject || ProjectSecurity.CanCreateMessage(RequestContext.GetCurrentProject(false))) { LoadDiscussionActionControl(null); Title = HeaderStringHelper.GetPageTitle(MessageResource.CreateMessage); } else { Response.Redirect("messages.aspx", true); } } } }
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); }
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); }
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); }
protected override void PageLoad() { Project = RequestContext.GetCurrentProject(false); if (RequestContext.IsInConcreteProject()) { var project = RequestContext.GetCurrentProject(false); if (project == null) { Response.Redirect("messages.aspx", true); } else { if (!ProjectSecurity.CanReadMessages(Project)) { Response.Redirect("projects.aspx?prjID=" + project.ID, true); } } } ((IStudioMaster)Master).DisabledSidePanel = true; int discussionId; if (int.TryParse(UrlParameters.EntityID, out discussionId)) { if (Project == null) { return; } Discussion = Global.EngineFactory.GetMessageEngine().GetByID(discussionId); if (string.Compare(UrlParameters.ActionType, "edit", StringComparison.OrdinalIgnoreCase) == 0) { if (ProjectSecurity.CanEdit(Discussion)) { LoadDiscussionActionControl(Project, Discussion); } else { Response.Redirect("messages.aspx", true); } } else if (Discussion != null && ProjectSecurity.CanRead(Discussion.Project) && Discussion.Project.ID == Project.ID) { LoadDiscussionDetailsControl(Project, Discussion); } else { LoadElementNotFoundControl(Project.ID); } } else { if (string.Compare(UrlParameters.ActionType, "add", StringComparison.OrdinalIgnoreCase) == 0) { if (ProjectSecurity.CanCreateMessage(Project)) { LoadDiscussionActionControl(Project, null); } else { Response.Redirect("messages.aspx", true); } } else { LoadDiscussionsListControl(Project == null ? -1 : Project.ID); } } InitBreadCrumbs(); Title = HeaderStringHelper.GetPageTitle(MessageResource.Messages, Master.BreadCrumbs); }