示例#1
0
        public static List <ProjectCommonModule> GetModules(Project project)
        {
            var modules = new List <ProjectCommonModule>
            {
                new MilestonesModule(project),
                new TasksModule(project),
                new ProjectTeamModule(project)
            };

            if (ProjectSecurity.CanReadFiles(project))
            {
                modules.Add(new DocumentsModule(project));
            }

            if (ProjectSecurity.CanReadMessages(project))
            {
                modules.Add(new MessagesModule(project));
            }

            if (ProjectSecurity.CanCreateTimeSpend(project))
            {
                modules.Add(new TimeTrackingModule(project));
            }


            var crmEnabled = WebItemManager.Instance[new Guid("6743007C-6F95-4d20-8C88-A8601CE5E76D")];

            if (crmEnabled != null && !crmEnabled.IsDisabled() && ProjectSecurity.CanReadContacts(project))
            {
                modules.Add(new ContactsModule(project));
            }

            return(modules.OrderBy(r => r.Context.DefaultSortOrder).ToList());
        }
示例#2
0
        public IEnumerable <MessageWrapper> GetProjectMessages(int projectid)
        {
            var project = EngineFactory.ProjectEngine.GetByID(projectid).NotFoundIfNull();

            if (!ProjectSecurity.CanReadMessages(project))
            {
                throw ProjectSecurity.CreateSecurityException();
            }

            return(EngineFactory.MessageEngine.GetByProject(projectid).Select(x => new MessageWrapper(x)));
        }
示例#3
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);
 }
示例#4
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);
 }
示例#5
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);
        }
示例#6
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);
        }
        protected void RenderHeader()
        {
            var topNavigationPanel = (TopNavigationPanel)LoadControl(TopNavigationPanel.Location);

            topNavigationPanel.SingleSearchHandlerType = typeof(SearchHandler);

            var absolutePathWithoutQuery = Request.Url.AbsolutePath.Substring(0, Request.Url.AbsolutePath.IndexOf(".aspx"));
            var sysName   = absolutePathWithoutQuery.Substring(absolutePathWithoutQuery.LastIndexOf('/') + 1);
            var project   = RequestContext.GetCurrentProject(false);
            var projectID = -1;

            if (RequestContext.IsInConcreteProject())
            {
                projectID = project.ID;

                var rigthItems = new List <NavigationItem>();
                foreach (var webitem in WebItemManager.Instance.GetSubItems(ProductEntryPoint.ID))
                {
                    var module = webitem as IModule;

                    var navigationItem = new NavigationItem()
                    {
                        URL         = String.Format(webitem.StartURL, projectID),
                        Name        = webitem.Name,
                        Description = webitem.Description,
                        Selected    = String.Compare(sysName, module.ModuleSysName, true) == 0
                    };

                    var added = false;
                    if (String.Compare(module.ModuleSysName, "History", true) == 0 ||
                        String.Compare(module.ModuleSysName, "ProjectAction", true) == 0 ||
                        String.Compare(module.ModuleSysName, "ProjectTeam", true) == 0)
                    {
                        navigationItem.RightAlign = true;
                        rigthItems.Add(navigationItem);
                        added = true;
                    }

                    //hide in private projects
                    if (String.Compare(module.ModuleSysName, "Messages", true) == 0 && !ProjectSecurity.CanReadMessages(RequestContext.GetCurrentProject()))
                    {
                        continue;
                    }
                    if (String.Compare(module.ModuleSysName, "TMDocs", true) == 0 && !ProjectSecurity.CanReadFiles(RequestContext.GetCurrentProject()))
                    {
                        continue;
                    }

                    if (String.Compare(module.ModuleSysName, "TMDocs", true) == 0)
                    {
                        navigationItem.Selected = String.Compare(sysName, "tmdocs", true) == 0;
                        navigationItem.Name     = ProjectsFileResource.Documents;
                        navigationItem.URL      = PathProvider.BaseAbsolutePath + "tmdocs.aspx?prjID=" + projectID;
                    }

                    if (!added)
                    {
                        topNavigationPanel.NavigationItems.Add(navigationItem);
                    }
                }

                rigthItems.Reverse();
                topNavigationPanel.NavigationItems.AddRange(rigthItems);
            }
            else
            {
                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = String.Concat(PathProvider.BaseAbsolutePath, "default.aspx"),
                    Name        = ProjectsCommonResource.Dashboard,
                    Description = "",
                    Selected    = String.Compare(sysName, "Default", true) == 0
                });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = String.Concat(PathProvider.BaseAbsolutePath, "projects.aspx"),
                    Name        = ProjectResource.Projects,
                    Description = "",
                    Selected    = String.Compare(sysName, "Projects", true) == 0 || String.Compare(sysName, "ProjectAction", true) == 0
                });


                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = String.Concat(PathProvider.BaseAbsolutePath, "milestones.aspx"),
                    Name        = MilestoneResource.Milestones,
                    Description = "",
                    Selected    = String.Compare(sysName, "milestones", true) == 0
                });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = String.Concat(PathProvider.BaseAbsolutePath, "tasks.aspx"),
                    Name        = TaskResource.Tasks,
                    Description = "",
                    Selected    = String.Compare(sysName, "tasks", true) == 0
                });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = String.Concat(PathProvider.BaseAbsolutePath, "messages.aspx"),
                    Name        = MessageResource.Messages,
                    Description = "",
                    Selected    = String.Compare(sysName, "messages", true) == 0
                });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = String.Concat(PathProvider.BaseAbsolutePath, "reports.aspx"),
                    Name        = ReportResource.Reports,
                    Description = "",
                    Selected    = String.Compare(sysName, "Reports", true) == 0 || String.Compare(sysName, "Templates", true) == 0
                });

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = String.Concat(PathProvider.BaseAbsolutePath, "history.aspx"),
                    Name        = ProjectsCommonResource.History,
                    Description = "",
                    Selected    = String.Compare(sysName, "History", true) == 0
                });


                if (ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID))
                {
                    topNavigationPanel.NavigationItems.Add(new NavigationItem
                    {
                        URL         = String.Concat(PathProvider.BaseAbsolutePath, "projectTemplates.aspx"),
                        Name        = ProjectResource.ProjectTemplates,
                        Description = "",
                        Selected    = String.Compare(sysName, "ProjectTemplates", true) == 0,
                        RightAlign  = true
                    });
                }

                topNavigationPanel.NavigationItems.Add(new NavigationItem
                {
                    URL         = CommonLinkUtility.GetEmployees(ProductEntryPoint.ID),
                    Name        = CustomNamingPeople.Substitute <ProjectsCommonResource>("Employees"),
                    Description = "",
                    Selected    = UserOnlineManager.Instance.IsEmployeesPage() || UserOnlineManager.Instance.IsUserProfilePage(),
                    RightAlign  = true
                });
            }
            if (RequestContext.HasAnyProjects())
            {
                var pageName = "default";
                switch (sysName)
                {
                case "userprofile":
                case "default":
                case "reports":
                case "projectTemplates":
                case "createprojectfromtemplate":
                case "editprojecttemplate":
                    pageName = "projects";
                    break;

                case "settings":
                    pageName = "projectAction";
                    break;

                case "employee":
                    pageName = "projectTeam";
                    break;

                default:
                    pageName = sysName;
                    break;
                }
                topNavigationPanel.CustomInfoHTML = RenderAllProjectsBlock(projectID, pageName);
            }
            _topNavigationPanelPlaceHolder.Controls.Add(topNavigationPanel);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
                }
            }
        }