public override void Init() { context = new ProductContext { MasterPageFile = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master"), DisabledIconFileName = "product_disabled_logo.png", IconFileName = "product_logo.png", LargeIconFileName = "product_logolarge.png", SubscriptionManager = new ProductSubscriptionManager(), DefaultSortOrder = 20, SpaceUsageStatManager = new ProjectsSpaceUsageStatManager(), AdminOpportunities = () => ProjectsCommonResource.ProductAdminOpportunities.Split('|').ToList(), UserOpportunities = () => ProjectsCommonResource.ProductUserOpportunities.Split('|').ToList(), HasComplexHierarchyOfAccessRights = true, }; FilesIntegration.RegisterFileSecurityProvider("projects", "project", new SecurityAdapterProvider()); SearchHandlerManager.Registry(new SearchHandler()); var securityInterceptor = new SendInterceptorSkeleton( "ProjectInterceptorSecurity", InterceptorPlace.DirectSend, InterceptorLifetime.Global, (r, p) => { HttpContext.Current = null; try { HttpContext.Current = new HttpContext( new HttpRequest("hack", CommonLinkUtility.GetFullAbsolutePath("/"), string.Empty), new HttpResponse(new StringWriter())); var data = r.ObjectID.Split('_'); var entityType = data[0]; var entityId = Convert.ToInt32(data[1]); var projectId = 0; if (data.Length == 3) { projectId = Convert.ToInt32(r.ObjectID.Split('_')[2]); } switch (entityType) { case "Task": var task = Global.EngineFactory.GetTaskEngine().GetByID(entityId, false); if (task == null && projectId != 0) { var project = Global.EngineFactory.GetProjectEngine().GetByID(projectId, false); return(!ProjectSecurity.CanRead(project, new Guid(r.Recipient.ID))); } return(!ProjectSecurity.CanRead(task, new Guid(r.Recipient.ID))); case "Message": var discussion = Global.EngineFactory.GetMessageEngine().GetByID(entityId, false); if (discussion == null && projectId != 0) { var project = Global.EngineFactory.GetProjectEngine().GetByID(projectId, false); return(!ProjectSecurity.CanRead(project, new Guid(r.Recipient.ID))); } return(!ProjectSecurity.CanRead(discussion, new Guid(r.Recipient.ID))); case "Milestone": var milestone = Global.EngineFactory.GetMilestoneEngine().GetByID(entityId, false); if (milestone == null && projectId != 0) { var project = Global.EngineFactory.GetProjectEngine().GetByID(projectId, false); return(!ProjectSecurity.CanRead(project, new Guid(r.Recipient.ID))); } return(!ProjectSecurity.CanRead(milestone, new Guid(r.Recipient.ID))); } } catch (Exception ex) { LogManager.GetLogger("ASC.Projects.Tasks").Error("Send", ex); } finally { if (HttpContext.Current != null) { new DisposableHttpContext(HttpContext.Current).Dispose(); HttpContext.Current = null; } } return(false); }); NotifyClient.Instance.Client.AddInterceptor(securityInterceptor); }
protected bool CanReadDiscussion(Guid id) { return(ProjectSecurity.CanRead(Discussion, id)); }
protected override void PageLoad() { Utility.RegisterTypeForAjax(typeof(CommonControlsConfigurer), Page); var messageEngine = Global.EngineFactory.GetMessageEngine(); CanCreate = RequestContext.CanCreateDiscussion(true); int discussionId; if (int.TryParse(UrlParameters.EntityID, out discussionId)) { Discussion = messageEngine.GetByID(discussionId); if (string.Compare(UrlParameters.ActionType, "edit", StringComparison.OrdinalIgnoreCase) == 0) { if (ProjectSecurity.CanEdit(Discussion)) { LoadDiscussionActionControl(Discussion); } else { Response.Redirect("messages.aspx", true); } Title = HeaderStringHelper.GetPageTitle(Discussion.Title); } else if (Discussion != null && ProjectSecurity.CanRead(Discussion.Project) && Discussion.Project.ID == Project.ID) { LoadDiscussionDetailsControl(Discussion); IsSubcribed = messageEngine.IsSubscribed(Discussion); EssenceTitle = Discussion.Title; Title = HeaderStringHelper.GetPageTitle(Discussion.Title); } else { RedirectNotFound(string.Format("messages.aspx?prjID={0}", Project.ID)); } } else { if (string.Compare(UrlParameters.ActionType, "add", StringComparison.OrdinalIgnoreCase) == 0) { if (CanCreate) { LoadDiscussionActionControl(null); Title = HeaderStringHelper.GetPageTitle(MessageResource.CreateMessage); } else { Response.Redirect("messages.aspx", true); } } else { contentHolder.Controls.Add(LoadControl(CommonList.Location)); } } }
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); } }
protected override void PageLoad() { var action = UrlParameters.ActionType; CanCreate = RequestContext.CanCreateDiscussion(true); 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); } Title = HeaderStringHelper.GetPageTitle(discussion.Title); } else if (discussion != null && ProjectSecurity.CanRead(discussion.Project) && discussion.Project.ID == Project.ID) { LoadDiscussionDetailsControl(discussion); IsSubcribed = EngineFactory.MessageEngine.IsSubscribed(discussion); EssenceTitle = discussion.Title; Title = HeaderStringHelper.GetPageTitle(discussion.Title); } else { RedirectNotFound(string.Format("messages.aspx?prjID={0}", Project.ID)); } } else { if (action.HasValue && action.Value == UrlAction.Add) { if (CanCreate) { LoadDiscussionActionControl(null); Title = HeaderStringHelper.GetPageTitle(MessageResource.CreateMessage); } else { Response.Redirect("messages.aspx", true); } } else { contentHolder.Controls.Add(LoadControl(CommonList.Location)); loaderHolder.Controls.Add(LoadControl(LoaderPage.Location)); } } }
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); }
protected override void PageLoad() { InitScripts(); var messageEngine = Global.EngineFactory.GetMessageEngine(); if (RequestContext.IsInConcreteProject && !ProjectSecurity.CanReadMessages(Project)) { Response.Redirect("projects.aspx?prjID=" + Project.ID, true); } CanCreate = RequestContext.CanCreateDiscussion(true); int discussionId; if (int.TryParse(UrlParameters.EntityID, out discussionId)) { if (Project == null) { return; } Discussion = messageEngine.GetByID(discussionId); if (string.Compare(UrlParameters.ActionType, "edit", StringComparison.OrdinalIgnoreCase) == 0) { if (ProjectSecurity.CanEdit(Discussion)) { LoadDiscussionActionControl(Project, Discussion); } else { Response.Redirect("messages.aspx", true); } Title = HeaderStringHelper.GetPageTitle(Discussion.Title); } else if (Discussion != null && ProjectSecurity.CanRead(Discussion.Project) && Discussion.Project.ID == Project.ID) { LoadDiscussionDetailsControl(Project, Discussion); Master.EssenceTitle = Discussion.Title; Title = HeaderStringHelper.GetPageTitle(Discussion.Title); Master.IsSubcribed = messageEngine.IsSubscribed(Discussion); } else { LoadElementNotFoundControl(Project.ID); Title = HeaderStringHelper.GetPageTitle(MessageResource.MessageNotFound_Header); } } else { if (string.Compare(UrlParameters.ActionType, "add", StringComparison.OrdinalIgnoreCase) == 0) { if (CanCreate) { LoadDiscussionActionControl(Project, null); Title = HeaderStringHelper.GetPageTitle(MessageResource.CreateMessage); } else { Response.Redirect("messages.aspx", true); } } else { var filter = new TaskFilter(); if (RequestContext.IsInConcreteProject) { filter.ProjectIds.Add(RequestContext.GetCurrentProjectId()); } var allDiscCount = messageEngine.GetByFilterCount(filter); if (allDiscCount > 0) { LoadDiscussionsListControl(Project == null ? -1 : Project.ID, allDiscCount); } var emptyScreenControl = new Studio.Controls.Common.EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("empty_screen_discussions.png", ProductEntryPoint.ID), Header = MessageResource.DiscussionNotFound_Header, Describe = MessageResource.DiscussionNotFound_Describe, ID = "emptyListDiscussion" }; if (CanCreate) { emptyScreenControl.ButtonHTML = RequestContext.IsInConcreteProject ? String.Format("<a href='messages.aspx?prjID={0}&action=add' class='baseLinkAction addFirstElement'>{1}</a>", Project.ID, MessageResource.StartFirstDiscussion) : String.Format("<a href='messages.aspx?action=add' class='baseLinkAction addFirstElement'>{0}</a>", MessageResource.StartFirstDiscussion); } contentHolder.Controls.Add(emptyScreenControl); Title = HeaderStringHelper.GetPageTitle(MessageResource.Messages); } } }