Example #1
0
        private void GetApiData()
        {
            var apiServer     = new Api.ApiServer();
            var currentUserId = SecurityContext.CurrentAccount.ID;

            if (RequestContext.IsInConcreteProject())
            {
                var projectParticipants = apiServer.GetApiResponse(string.Format("api/1.0/project/{0}/team.json?fields={1}",
                                                                                 RequestContext.GetCurrentProjectId(), "id,displayName"), "GET");
                JsonPublisher(projectParticipants, "projectTeam");

                var milestones = apiServer.GetApiResponse(string.Format("api/1.0/project/milestone/filter.json?sortBy=deadline&sortOrder=descending&status=open&projectId={0}&fields={1}",
                                                                        RequestContext.GetCurrentProjectId(), "id,title,deadline"), "GET");
                JsonPublisher(milestones, "milestones");
            }
            else
            {
                var milestones = apiServer.GetApiResponse(ProjectSecurity.IsAdministrator(currentUserId)
                    ? string.Format("api/1.0/project/milestone/filter.json?sortBy=deadline&sortOrder=descending&status=open&fields={0}", "id,title,deadline")
                    : string.Format("api/1.0/project/milestone/filter.json?sortBy=deadline&sortOrder=descending&status=open&participant={0}&fields={1}", currentUserId, "id,title,deadline"),
                                                          "GET");
                JsonPublisher(milestones, "milestones");

                var tags = apiServer.GetApiResponse(string.Format("api/1.0/project/tag.json"), "GET");
                JsonPublisher(tags, "tags");

                var projects = apiServer.GetApiResponse(ProjectSecurity.IsAdministrator(currentUserId)
                    ? string.Format("api/1.0/project/filter.json?status=open&sortBy=title&sortOrder=ascending&fields={0}", "id,title,security,isPrivate")
                    : string.Format("api/1.0/project/filter.json?participant={0}&status=open&sortBy=title&sortOrder=ascending&fields={1}", currentUserId, "id,title,security,isPrivate"),
                                                        "GET");
                JsonPublisher(projects, "projects");
            }
        }
Example #2
0
        protected override void PageLoad()
        {
            if (RequestContext.IsInConcreteProject)
            {
                if (string.Compare(UrlParameters.ActionType, "edit", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    _content.Controls.Add(LoadControl(PathProvider.GetControlVirtualPath("ProjectAction.ascx")));
                    Master.DisabledPrjNavPanel = true;
                    return;
                }

                Response.Redirect(String.Concat(PathProvider.BaseAbsolutePath, "tasks.aspx?prjID=" + RequestContext.GetCurrentProjectId()));
            }
            else
            {
                if (string.Compare(UrlParameters.ActionType, "add", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (ProjectSecurity.IsAdministrator(Participant.ID))
                    {
                        _content.Controls.Add(LoadControl(PathProvider.GetControlVirtualPath("ProjectAction.ascx")));
                        return;
                    }
                    Response.Redirect("projects.aspx");
                }
            }

            RenderControls();

            Title = HeaderStringHelper.GetPageTitle(ProjectResource.Projects);
        }
        public string GetOnClickEvent(Guid userID, ProjectTeamSecurity security)
        {
            if (ProjectSecurity.CanEditTeam(Project) &&
                userID != TeamLeader.ID &&
                !ProjectSecurity.IsAdministrator(userID) &&
                Project.Private)
            {
                switch (security)
                {
                case ProjectTeamSecurity.Messages:
                    return(string.Format("onclick=\"javascript:changePermission(this,'{0}', 0);\" title='{1}'",
                                         userID.ToString(), ProjectResource.ClosedProjectTeamMessageButtonTooltip));

                case ProjectTeamSecurity.Files:
                    return(string.Format("onclick=\"javascript:changePermission(this,'{0}', 1);\" title='{1}'",
                                         userID.ToString(), ProjectResource.ClosedProjectTeamDocumentButtonTooltip));

                case ProjectTeamSecurity.Tasks:
                    return(string.Format("onclick=\"javascript:changePermission(this,'{0}', 2);\" title='{1}'",
                                         userID.ToString(), ProjectResource.ClosedProjectTeamTaskButtonTooltip));

                case ProjectTeamSecurity.Milestone:
                    return(string.Format("onclick=\"javascript:changePermission(this,'{0}', 3);\" title='{1}'",
                                         userID.ToString(), ProjectResource.ClosedProjectTeamMilestoneButtonTooltip));
                }
            }
            return(string.Empty);
        }
Example #4
0
        private bool Can(FileEntry fileEntry, Guid userId, SecurityAction action)
        {
            if (fileEntry == null || project == null)
            {
                return(false);
            }

            if (!ProjectSecurity.CanReadFiles(project, userId))
            {
                return(false);
            }

            if (project.Status == ProjectStatus.Closed &&
                action != SecurityAction.Read)
            {
                return(false);
            }

            if (ProjectSecurity.IsAdministrator(userId))
            {
                return(true);
            }

            using (var scope = DIHelper.Resolve())
            {
                var projectEngine = scope.Resolve <EngineFactory>().ProjectEngine;

                var folder = fileEntry as Folder;
                if (folder != null && folder.FolderType == FolderType.DEFAULT && folder.CreateBy == userId)
                {
                    return(true);
                }

                var file = fileEntry as File;
                if (file != null && file.CreateBy == userId)
                {
                    return(true);
                }

                switch (action)
                {
                case SecurityAction.Read:
                    return(!project.Private || projectEngine.IsInTeam(project.ID, userId));

                case SecurityAction.Create:
                case SecurityAction.Edit:
                    return(projectEngine.IsInTeam(project.ID, userId) &&
                           (!ProjectSecurity.IsVisitor(userId) ||
                            folder != null && folder.FolderType == FolderType.BUNCH));

                case SecurityAction.Delete:
                    return(!ProjectSecurity.IsVisitor(userId) && project.Responsible == userId);

                default:
                    return(false);
                }
            }
        }
 public ParticipantWrapper(Participant participant) : base(participant.UserInfo)
 {
     CanReadFiles      = participant.CanReadFiles;
     CanReadMilestones = participant.CanReadMilestones;
     CanReadMessages   = participant.CanReadMessages;
     CanReadTasks      = participant.CanReadTasks;
     CanReadContacts   = participant.CanReadContacts;
     IsAdministrator   = ProjectSecurity.IsAdministrator(participant.ID);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            EssenceTitle  = Page.Master.EssenceTitle;
            EssenceStatus = Page.Master.EssenceStatus;

            _hintPopup.Options.IsPopup = true;
            _projectDescriptionPopup.Options.IsPopup = true;

            CanEditProject          = ProjectSecurity.CanEdit(Project);
            CanDeleteProject        = ProjectSecurity.IsAdministrator(Page.Participant.ID);
            ProjectLeaderName       = Global.EngineFactory.GetParticipantEngine().GetByID(Project.Responsible).UserInfo.DisplayUserName();
            IsFollowed              = Global.EngineFactory.GetProjectEngine().IsFollow(Project.ID, Page.Participant.ID);
            IsInTeam                = Global.EngineFactory.GetProjectEngine().IsInTeam(Project.ID, Page.Participant.ID);
            InConcreteProjectModule = RequestContext.IsInConcreteProjectModule;
            InitScripts();

            SetShowGanttChartFlag();

            if (string.IsNullOrEmpty(EssenceTitle))
            {
                EssenceTitle  = Project.Title;
                EssenceStatus = Project.Status != ProjectStatus.Open ? LocalizedEnumConverter.ConvertToString(Project.Status).ToLower() : "";
            }

            if (!InConcreteProjectModule)
            {
                Tabs.TabItems.AddRange(ModuleManager.GetModules(Project).Select(r => r.ConvertToNavigatorItem(CurrentPage)));
            }

            if (HttpContext.Current.Request.UrlReferrer != null)
            {
                var urlReferrer = HttpContext.Current.Request.UrlReferrer.ToString().ToLower();

                if (CurrentPage == "tasks")
                {
                    UpLink = "tasks.aspx";
                }

                if (CurrentPage == "messages")
                {
                    UpLink = "messages.aspx";
                }

                if (!string.IsNullOrEmpty(UpLink))
                {
                    if (urlReferrer.IndexOf("add", StringComparison.OrdinalIgnoreCase) > 0 || urlReferrer.IndexOf("edit", StringComparison.OrdinalIgnoreCase) > 0)
                    {
                        UpLink = string.Format("{0}?prjID={1}", UpLink, Project.ID);
                    }

                    if ((urlReferrer.IndexOf("messages", StringComparison.OrdinalIgnoreCase) > 0 || urlReferrer.IndexOf("tasks", StringComparison.OrdinalIgnoreCase) > 0) && urlReferrer.IndexOf("prjid", StringComparison.OrdinalIgnoreCase) > 0)
                    {
                        UpLink = string.Format("{0}?prjID={1}", UpLink, Project.ID);
                    }
                }
            }
        }
        private bool Can(FileEntry fileEntry, Guid userId, SecurityAction action)
        {
            if (fileEntry == null || Project == null)
            {
                return(false);
            }

            if (!ProjectSecurity.CanReadFiles(Project, userId))
            {
                return(false);
            }

            if (Project.Status != ProjectStatus.Open &&
                action != SecurityAction.Read)
            {
                return(false);
            }

            if (ProjectSecurity.IsAdministrator(userId))
            {
                return(true);
            }

            var folder = fileEntry as Folder;

            if (folder != null && folder.FolderType == FolderType.DEFAULT && folder.CreateBy == userId)
            {
                return(true);
            }

            var file = fileEntry as File;

            if (file != null && file.CreateBy == userId)
            {
                return(true);
            }

            switch (action)
            {
            case SecurityAction.Read:
                return(!Project.Private || Global.EngineFactory.ProjectEngine.IsInTeam(Project.ID, userId));

            case SecurityAction.Create:
            case SecurityAction.Edit:
                return(Global.EngineFactory.ProjectEngine.IsInTeam(Project.ID, userId) &&
                       (!ProjectSecurity.IsVisitor(userId) || folder != null && folder.FolderType == FolderType.BUNCH));

            case SecurityAction.Delete:
                return(!ProjectSecurity.IsVisitor(userId) && Project.Responsible == userId);

            default:
                return(false);
            }
        }
Example #8
0
        public bool CanCreateMilestone()
        {
            if (RequestContext.IsInConcreteProject())
            {
                return(ProjectSecurity.CanCreateMilestone(RequestContext.GetCurrentProject()));
            }

            return(ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID)
                ? RequestContext.HasAnyProjects()
                : Global.EngineFactory.GetProjectEngine().GetByParticipant(SecurityContext.CurrentAccount.ID).Where(ProjectSecurity.CanCreateMilestone).Any());
        }
Example #9
0
        protected override void PageLoad()
        {
            IsAdmin = ProjectSecurity.IsAdministrator(Participant.ID);

            Bootstrap();

            LoadControls();

            Page.RegisterInlineScript(@"
                    if (location.href.indexOf('milestones.aspx') > 0) {
                        ASC.Projects.AllMilestones.init(" + EntryCountOnPage + ",'" + CookieKeyForPagination + "', " + Global.VisiblePageCount + ");}", true);
        }
        private void GetApiData()
        {
            var          apiServer = new Api.ApiServer();
            const string fields    = "id,title,security";

            var projects = apiServer.GetApiResponse(ProjectSecurity.IsAdministrator(CurrentUserId) ?
                                                    string.Format("api/1.0/project/filter.json?status=open&sortBy=title&sortOrder=ascending&fields={0}", fields) :
                                                    string.Format("api/1.0/project/filter.json?participant={0}&status=open&sortBy=title&sortOrder=ascending&fields={1}", CurrentUserId, fields),
                                                    "GET");

            Page.JsonPublisher(projects, "projects");
        }
Example #11
0
        protected override void PageLoad()
        {
            ((IStudioMaster)Master).DisabledSidePanel = true;

            if (!ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID))
            {
                HttpContext.Current.Response.Redirect(ProjectsCommonResource.StartURL, true);
            }

            AjaxPro.Utility.RegisterTypeForAjax(typeof(Settings));

            InitPage();
        }
Example #12
0
        private static bool CanCreate(Func <Project, bool> canCreate, bool checkConreteProject)
        {
            if (checkConreteProject && IsInConcreteProject)
            {
                var project = GetCurrentProject();
                return(project.Status != ProjectStatus.Closed && canCreate(project));
            }

            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            return(isAdmin
                       ? HasAnyProjects()
                       : GetCurrentUserProjects().Where(canCreate).Any());
        }
Example #13
0
        protected override void PageLoad()
        {
            if (!ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID))
            {
                HttpContext.Current.Response.Redirect(ProjectsCommonResource.StartURL, true);
            }

            Utility.RegisterTypeForAjax(typeof(EditProjectTemplate));
            ((IStudioMaster)Master).DisabledSidePanel = true;

            if (Int32.TryParse(UrlParameters.EntityID, out _projectTmplId))
            {
                Templ = Global.EngineFactory.GetTemplateEngine().GetTemplate(_projectTmplId);
                JsonPublisher(Templ, "template");
            }

            InitBreadCrumbs();
        }
        private bool Can(FileEntry fileEntry, Guid userId, SecurityAction action)
        {
            if (!ProjectSecurity.CanReadFiles(Project, userId))
            {
                return(false);
            }

            if (ProjectSecurity.IsAdministrator(userId))
            {
                return(true);
            }
            if (fileEntry == null || Project == null)
            {
                return(false);
            }
            if (fileEntry is Folder && ((Folder)fileEntry).FolderType == FolderType.DEFAULT && fileEntry.CreateBy == userId)
            {
                return(true);
            }
            if (fileEntry is File && fileEntry.CreateBy == userId)
            {
                return(true);
            }

            switch (action)
            {
            case SecurityAction.Read:
                return(!Project.Private || dao.IsInTeam(Project.ID, userId));

            case SecurityAction.Create:
            case SecurityAction.Edit:
                return(dao.IsInTeam(Project.ID, userId) &&
                       (!ProjectSecurity.IsVisitor(userId) || fileEntry is Folder && ((Folder)fileEntry).FolderType == FolderType.BUNCH));

            case SecurityAction.Delete:
                return(!ProjectSecurity.IsVisitor(userId) && Project.Responsible == userId);

            default:
                return(false);
            }
        }
Example #15
0
        protected override void PageLoad()
        {
            if (!ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID))
            {
                HttpContext.Current.Response.Redirect(ProjectsCommonResource.StartURL, true);
            }

            Utility.RegisterTypeForAjax(GetType(), Page);
            ((IStudioMaster)Master).DisabledSidePanel = true;

            ListTemplates = Global.EngineFactory.GetTemplateEngine().GetTemplates();
            if (ListTemplates.Count != 0)
            {
                EmptyListTemplates = false;
                JsonPublisher(ListTemplates, "templates");
                _hintPopup.Options.IsPopup = true;
            }
            else
            {
                EmptyListTemplates = true;
            }

            var escNoTmpl = new Studio.Controls.Common.EmptyScreenControl
            {
                Header     = ProjectTemplatesResource.EmptyListTemplateHeader,
                ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("project-templates_logo.png", ProductEntryPoint.ID),
                Describe   = ProjectTemplatesResource.EmptyListTemplateDescr,
                ID         = "escNoTmpl",
                ButtonHTML = string.Format("<a href='editprojecttemplate.aspx' class='projectsEmpty baseLinkAction'>{0}<a>", ProjectTemplatesResource.EmptyListTemplateButton)
            };

            _escNoTmpl.Controls.Add(escNoTmpl);

            Master.BreadCrumbs.Add(new BreadCrumb
            {
                Caption = ProjectTemplatesResource.AllProjectTmpl
            });

            Title = HeaderStringHelper.GetPageTitle(ProjectTemplatesResource.AllProjectTmpl, Master.BreadCrumbs);
        }
Example #16
0
        private void GetApiData()
        {
            var apiServer = new Api.ApiServer();

            if (RequestContext.IsInConcreteProject())
            {
                var projectParticipants = apiServer.GetApiResponse(string.Format("api/1.0/project/{0}/team.json?fields={1}", RequestContext.GetCurrentProjectId(), "id,displayName"), "GET");
                JsonPublisher(projectParticipants, "projectParticipants");
                return;
            }

            var tags = apiServer.GetApiResponse(string.Format("api/1.0/project/tag.json"), "GET");

            JsonPublisher(tags, "tags");

            var projects = apiServer.GetApiResponse(ProjectSecurity.IsAdministrator(CurrentUserId) ?
                                                    string.Format("api/1.0/project/filter.json?status=open&sortBy=title&sortOrder=ascending&fields={0}", "id,title") :
                                                    string.Format("api/1.0/project/filter.json?status=open&sortBy=title&sortOrder=ascending&participant={0}&fields={1}", CurrentUserId, "id,title,responsible,status"),
                                                    "GET");

            JsonPublisher(projects, "projects");
        }
        public string GetCssClass(Guid userID, ProjectTeamSecurity security)
        {
            var participant    = Global.EngineFactory.GetParticipantEngine().GetByID(userID);
            var havePermission = Global.EngineFactory.GetProjectEngine().GetTeamSecurity(Project, participant, security);

            if (ProjectSecurity.CanEditTeam(Project) && userID != TeamLeader.ID && !ProjectSecurity.IsAdministrator(userID) && Project.Private)
            {
                if (havePermission)
                {
                    return("pm-projectTeam-modulePermissionOn");
                }
                return("pm-projectTeam-modulePermissionOff");
            }
            else
            {
                if (havePermission)
                {
                    return("pm-projectTeam-modulePermissionOn-disable");
                }
                return("pm-projectTeam-modulePermissionOff-disable");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentUser = SecurityContext.CurrentAccount.ID;

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

            if (!ProjectSecurity.IsAdministrator(CurrentUser))
            {
                filter.ParticipantId = CurrentUser;
            }

            UserProjects = Global.EngineFactory.GetProjectEngine().GetByFilter(filter);

            if (UserProjects.Any() && (Project == null || !UserProjects.Contains(Project)))
            {
                Project = UserProjects[0];
            }

            var tasks = Global.EngineFactory.GetTaskEngine().GetByProject(Project.ID, null, Guid.Empty);

            OpenUserTasks   = tasks.Where(r => r.Status == TaskStatus.Open).OrderBy(r => r.Title);
            ClosedUserTasks = tasks.Where(r => r.Status == TaskStatus.Closed).OrderBy(r => r.Title);

            Users = Global.EngineFactory.GetProjectEngine().GetTeam(Project.ID).OrderBy(r => DisplayUserSettings.GetFullUserName(r.UserInfo)).ToList();

            if (!string.IsNullOrEmpty(Request.QueryString["taskId"]))
            {
                Target = int.Parse(Request.QueryString["taskId"]);
            }
        }
Example #19
0
        protected override void PageLoad()
        {
            if (!Global.ModuleManager.IsVisible(ModuleType.TMDocs))
            {
                Response.Redirect(ProjectsCommonResource.StartURL);
            }

            int projectID;

            int.TryParse(UrlParameters.ProjectID, out projectID);
            var project = Global.EngineFactory.GetProjectEngine().GetByID(projectID);

            if (project == null || !ProjectSecurity.CanReadFiles(project))
            {
                Response.Redirect(ProjectsCommonResource.StartURL.ToLower());
            }

            var mainMenu = (MainMenu)LoadControl(MainMenu.Location);

            mainMenu.EnableImport     = false;
            mainMenu.EnableThirdParty = false;
            CommonContainerHolder.Controls.Add(mainMenu);

            var mainContent = (MainContent)LoadControl(MainContent.Location);

            mainContent.FolderIDCurrentRoot = FileEngine2.GetRoot(projectID);
            mainContent.TitlePage           = ProjectsCommonResource.ModuleName;
            mainContent.CurrentUserAdmin    = project.Responsible == SecurityContext.CurrentAccount.ID || ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);
            CommonContainerHolder.Controls.Add(mainContent);

            Title = HeaderStringHelper.GetPageTitle(ProjectsFileResource.Files, Master.BreadCrumbs);

            Master.DisabledSidePanel = true;
        }
Example #20
0
 public bool IsAdmin()
 {
     return(ProjectSecurity.IsAdministrator(Page.Participant.ID));
 }
Example #21
0
        protected override void PageLoad()
        {
            if (RequestContext.IsInConcreteProject())
            {
                Server.Transfer(String.Concat(PathProvider.BaseAbsolutePath, "ProjectOverview.aspx"));
            }
            else
            {
                if (String.Compare(UrlParameters.ActionType, "add", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID))
                    {
                        Server.Transfer(String.Concat(PathProvider.BaseAbsolutePath, "ProjectAction.aspx"));
                    }
                    else
                    {
                        Response.Redirect("projects.aspx");
                    }
                }
            }

            ((IStudioMaster)Master).DisabledSidePanel = true;

            Master.BreadCrumbs.Add(new BreadCrumb
            {
                Caption       = ProjectResource.Projects,
                NavigationUrl = "projects.aspx"
            });

            Title = HeaderStringHelper.GetPageTitle(ProjectResource.Projects, Master.BreadCrumbs);

            IsEmptyListProjects = !RequestContext.HasAnyProjects();
            if (IsEmptyListProjects)
            {
                var button = "";
                if (ProjectSecurity.CanCreateProject())
                {
                    button = string.Format("<a href='projects.aspx?action=add' class='projectsEmpty baseLinkAction'>{0}<a>",
                                           ProjectResource.CreateFirstProject);
                }
                var escNoProj = new Studio.Controls.Common.EmptyScreenControl
                {
                    Header     = ProjectResource.EmptyListProjHeader,
                    ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("projects_logo.png", ProductEntryPoint.ID),
                    Describe   = ProjectResource.EmptyListProjDescribe,
                    ID         = "escNoProj",
                    ButtonHTML = button
                };
                _escNoProj.Controls.Add(escNoProj);
            }
            else
            {
                var list = (Controls.Projects.ProjectsList)LoadControl(PathProvider.GetControlVirtualPath("ProjectsList.ascx"));
                __listProjects.Controls.Add(list);

                var advansedFilter = new Studio.Controls.Common.AdvansedFilter {
                    BlockID = "AdvansedFilter"
                };
                _content.Controls.Add(advansedFilter);

                var emptyScreenControlFilter = new Studio.Controls.Common.EmptyScreenControl
                {
                    ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("empty-filter.png", ProductEntryPoint.ID),
                    Header     = ProjectsCommonResource.Filter_NoProjects,
                    Describe   = ProjectResource.DescrEmptyListProjFilter,
                    ID         = "emptyFilter",
                    ButtonHTML = String.Format("<a href='javascript:void(0)' class='baseLinkAction'>{0}</a>",
                                               ProjectsFilterResource.ClearFilter)
                };
                projectListEmptyScreen.Controls.Add(emptyScreenControlFilter);
            }
        }
        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);
        }
Example #23
0
 private static bool IsAdmin(Guid userId)
 {
     return(ProjectSecurity.IsAdministrator(userId));
 }
 protected bool CanDeleteProject()
 {
     return(ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID));
 }