private static void ConfigureComments(CommentsList commentList, Task taskToUpdate)
        {
            var commentsCount = Global.EngineFactory.GetCommentEngine().Count(taskToUpdate);

            CommonControlsConfigurer.CommentsConfigure(commentList);

            commentList.IsShowAddCommentBtn = ProjectSecurity.CanCreateComment();

            commentList.CommentsCountTitle = commentsCount != 0 ? commentsCount.ToString() : "";

            commentList.ObjectID = taskToUpdate != null?taskToUpdate.ID.ToString() : "";

            commentList.Simple     = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName        = "AjaxPro.TaskDescriptionView.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "AjaxPro.TaskDescriptionView.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName    = "AjaxPro.TaskDescriptionView.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName     = "AjaxPro.TaskDescriptionView.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName     = "AjaxPro.TaskDescriptionView.UpdateComment";
            commentList.FckDomainName      = "projects_comments";
            commentList.OnRemovedCommentJS = "ASC.Projects.TaskDescroptionPage.onDeleteComment";

            commentList.TotalCount = commentsCount;
        }
        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);
        }
示例#3
0
        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));
                    loaderHolder.Controls.Add(LoadControl(LoaderPage.Location));
                }
            }
        }
 protected bool CanReadDiscussion(Guid id)
 {
     return(ProjectSecurity.CanRead(Discussion, id));
 }
 public bool CanCreateTask()
 {
     return(ProjectSecurity.CanCreateTask(Project));
 }
示例#6
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);
        }
示例#7
0
 public CommonSecurityInfo()
 {
     CanCreateProject = ProjectSecurity.CanCreateProject();
 }
        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));
                }
            }
        }
示例#9
0
 private static bool IsAdmin(Guid userId)
 {
     return(ProjectSecurity.IsAdministrator(userId));
 }
示例#10
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);
        }
示例#11
0
 public override bool VisibleFor(Feed feed, object data, Guid userId)
 {
     return(base.VisibleFor(feed, data, userId) &&
            ProjectSecurity.CanGoToFeed(((ParticipantFull)data).Project, userId));
 }
示例#12
0
 public bool CanCreateTask()
 {
     return(ProjectSecurity.CanCreateTask(RequestContext.GetCurrentProject()));
 }
示例#13
0
 public bool CanCreateTimeSpend()
 {
     return(Global.ModuleManager.IsVisible(ModuleType.TimeTracking) &&
            ProjectSecurity.CanCreateTimeSpend(Task.Project));
 }
示例#14
0
        public ReportTemplateWrapper SaveReportTemplate(
            string name,
            string period,
            int periodItem,
            int hour,
            bool autoGenerated,
            ReportType reportType,
            int tag,
            int project,
            TaskStatus?status,
            Guid departament,
            Guid userId,
            ReportTimeInterval reportTimeInterval,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            int viewType,
            bool noResponsible,
            bool isShowAverageTime,
            AverageTime typeOfShowAverageTime,
            bool projectAverageCompletingTasks
            )
        {
            ProjectSecurity.DemandAuthentication();

            if (name == null || name.Trim().Length == 0)
            {
                throw new ArgumentNullException("name");
            }

            var filter = new TaskFilter
            {
                TagId                 = tag,
                DepartmentId          = departament,
                UserId                = userId,
                TimeInterval          = reportTimeInterval,
                FromDate              = fromDate,
                ToDate                = toDate,
                ViewType              = viewType,
                NoResponsible         = noResponsible,
                IsShowAverageTime     = isShowAverageTime,
                TypeOfShowAverageTime = typeOfShowAverageTime
            };

            if (projectAverageCompletingTasks)
            {
                filter.IsShowAverageTime     = true;
                filter.TypeOfShowAverageTime = AverageTime.CompletingTasks;
            }

            if (project != 0)
            {
                filter.ProjectIds.Add(project);
            }

            if (status != null)
            {
                filter.TaskStatuses.Add((TaskStatus)status);
            }

            var template = new ReportTemplate(reportType)
            {
                Filter = filter
            };

            SaveOrUpdateTemplate(template, name, period, periodItem, hour, autoGenerated);
            MessageService.Send(Request, MessageAction.ReportTemplateCreated, MessageTarget.Create(template.Id), template.Name);

            return(new ReportTemplateWrapper(template));
        }
        private static void ConfigureComments(CommentsList commentList, Message messageToUpdate)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);

            var countMessageToUpdate = messageToUpdate != null?Global.EngineFactory.GetCommentEngine().Count(messageToUpdate) : 0;

            commentList.IsShowAddCommentBtn = ((messageToUpdate != null && messageToUpdate.Status == MessageStatus.Open) || messageToUpdate == null) && ProjectSecurity.CanCreateComment();
            commentList.CommentsCountTitle  = countMessageToUpdate != 0 ? countMessageToUpdate.ToString(CultureInfo.InvariantCulture) : "0";
            commentList.ObjectID            = messageToUpdate != null
                                       ? messageToUpdate.ID.ToString(CultureInfo.InvariantCulture) : "";

            commentList.Simple     = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName        = "AjaxPro.DiscussionDetails.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "AjaxPro.DiscussionDetails.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName    = "AjaxPro.DiscussionDetails.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName     = "AjaxPro.DiscussionDetails.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName     = "AjaxPro.DiscussionDetails.UpdateComment";
            commentList.OnRemovedCommentJS = "ASC.Projects.DiscussionDetails.removeComment";
            commentList.FckDomainName      = "projects_comments";
            commentList.TotalCount         = countMessageToUpdate;
        }
示例#16
0
        public TaskWrapper(ProjectApiBase projectApiBase, Task task)
        {
            Id          = task.ID;
            Title       = task.Title;
            Description = task.Description;
            Status      = (int)task.Status;

            if (Status > 2)
            {
                Status = 1;
            }


            Deadline     = (task.Deadline == DateTime.MinValue ? null : new ApiDateTime(task.Deadline, TimeZoneInfo.Local));
            Priority     = task.Priority;
            ProjectOwner = new SimpleProjectWrapper(task.Project);
            MilestoneId  = task.Milestone;
            Created      = (ApiDateTime)task.CreateOn;
            Updated      = (ApiDateTime)task.LastModifiedOn;
            StartDate    = task.StartDate.Equals(DateTime.MinValue) ? null : (ApiDateTime)task.StartDate;

            if (task.SubTasks != null)
            {
                Subtasks = task.SubTasks.Select(x => new SubtaskWrapper(projectApiBase, x, task)).ToList();
            }

            Progress = task.Progress;

            if (task.Milestone != 0 && task.MilestoneDesc != null)
            {
                Milestone = new SimpleMilestoneWrapper(task.MilestoneDesc);
            }

            if (task.Links.Any())
            {
                Links = task.Links.Select(r => new TaskLinkWrapper(r));
            }

            if (task.Security == null)
            {
                ProjectSecurity.GetTaskSecurityInfo(task);
            }

            if (projectApiBase.Context.GetRequestValue("simple") != null)
            {
                CreatedById = task.CreateBy;
                UpdatedById = task.LastModifiedBy;
                if (task.Responsibles != null)
                {
                    ResponsibleIds = task.Responsibles;
                }
            }
            else
            {
                CreatedBy = projectApiBase.GetEmployeeWraper(task.CreateBy);
                if (task.CreateBy != task.LastModifiedBy)
                {
                    UpdatedBy = projectApiBase.GetEmployeeWraper(task.LastModifiedBy);
                }
                if (task.Responsibles != null)
                {
                    Responsibles = task.Responsibles.Select(projectApiBase.GetEmployeeWraper).OrderBy(r => r.DisplayName).ToList();
                }
            }

            CanEdit            = task.Security.CanEdit;
            CanCreateSubtask   = task.Security.CanCreateSubtask;
            CanCreateTimeSpend = task.Security.CanCreateTimeSpend;
            CanDelete          = task.Security.CanDelete;
            CanReadFiles       = task.Security.CanReadFiles;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.RegisterBodyScripts(PathProvider.GetFileStaticRelativePath("projectaction.js"));

            _hintPopupDeleteProject.Options.IsPopup    = true;
            _hintPopupActiveTasks.Options.IsPopup      = true;
            _hintPopupActiveMilestones.Options.IsPopup = true;

            TemplatesCount = Page.EngineFactory.TemplateEngine.GetCount();
            HideChooseTeam = CoreContext.UserManager.GetUsers().All(r => r.ID == SecurityContext.CurrentAccount.ID);

            if (Project != null)
            {
                ProjectManagerName        = CoreContext.UserManager.GetUsers(Project.Responsible).DisplayUserName();
                UrlProject                = "tasks.aspx?prjID=" + Project.ID;
                ActiveTasksCount          = Page.EngineFactory.TaskEngine.GetByProject(Project.ID, TaskStatus.Open, Guid.Empty).Count();
                ActiveMilestonesCount     = Page.EngineFactory.MilestoneEngine.GetByProject(Project.ID).Count(m => m.Status == MilestoneStatus.Open);
                IsEditingProjectAvailable = true;
                PageTitle                         = ProjectResource.EditProject;
                ActiveTasksUrl                    = string.Format("tasks.aspx?prjID={0}#status=open", Project.ID);
                ActiveMilestonesUrl               = string.Format("milestones.aspx?prjID={0}#status=open", Project.ID);
                ProjectActionButtonTitle          = ProjectResource.SaveProject;
                RenderProjectPrivacyCheckboxValue = Project.Private;
                ProjectManagerId                  = Project.Responsible.ToString();

                projectTitle.Text       = Project.Title;
                projectDescription.Text = Project.Description;

                var tags = Page.EngineFactory.TagEngine.GetProjectTags(Project.ID).Select(r => r.Value.HtmlEncode()).ToArray();
                ProjectTags = string.Join(", ", tags);

                ProjectStatusTitle = Project.Status.ToString();
                ProjectStatusList  = string.Join(";",
                                                 string.Join(",", (int)ProjectStatus.Open, ProjectStatus.Open),
                                                 string.Join(",", (int)ProjectStatus.Paused, ProjectStatus.Paused),
                                                 string.Join(",", (int)ProjectStatus.Closed, ProjectStatus.Closed));

                Page.Title = HeaderStringHelper.GetPageTitle(Project.Title);
            }
            else
            {
                if (TemplatesCount > 0)
                {
                    ControlPlaceHolder.Controls.Add(LoadControl("../Common/AddMilestoneContainer.ascx"));
                }

                projectTitle.Attributes.Add("deftext", ProjectTemplatesResource.DefaultProjTitle);

                _hintPopupDeleteProject.Options.IsPopup    = true;
                _hintPopupActiveTasks.Options.IsPopup      = true;
                _hintPopupActiveMilestones.Options.IsPopup = true;

                PageTitle = ProjectResource.CreateNewProject;
                ProjectActionButtonTitle          = ProjectResource.AddNewProject;
                RenderProjectPrivacyCheckboxValue = true;
                ProjectManagerName = ProjectResource.AddProjectManager;

                var users = CoreContext.UserManager.GetUsers().Where(r => ProjectSecurity.IsProjectsEnabled(r.ID)).ToList();
                if (users.Count == 1)
                {
                    var manager = users.First();
                    ProjectManagerId   = manager.ID.ToString();
                    ProjectManagerName = manager.DisplayUserName();
                }

                Page.Title = HeaderStringHelper.GetPageTitle(PageTitle);

                Page.Master.RegisterCRMResources();
            }
        }
示例#18
0
        private void InitEmptyScreens()
        {
            emptyScreenPlaceHolders.Controls.Add(RenderEmptyScreenForFilter(MessageResource.FilterNoDiscussions, MessageResource.DescrEmptyListMilFilter, "discEmptyScreenForFilter"));
            emptyScreenPlaceHolders.Controls.Add(RenderEmptyScreenForFilter(TaskResource.NoTasks, TaskResource.DescrEmptyListTaskFilter, "tasksEmptyScreenForFilter"));
            emptyScreenPlaceHolders.Controls.Add(RenderEmptyScreenForFilter(MilestoneResource.FilterNoMilestones, MilestoneResource.DescrEmptyListMilFilter, "mileEmptyScreenForFilter"));
            emptyScreenPlaceHolders.Controls.Add(RenderEmptyScreenForFilter(ProjectsCommonResource.Filter_NoProjects, ProjectResource.DescrEmptyListProjFilter, "prjEmptyScreenForFilter"));
            emptyScreenPlaceHolders.Controls.Add(RenderEmptyScreenForFilter(TimeTrackingResource.NoTimersFilter, TimeTrackingResource.DescrEmptyListTimersFilter, "timeEmptyScreenForFilter"));

            emptyScreenPlaceHolders.Controls.Add(new EmptyScreenControl
            {
                ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("empty_screen_tasks.png", ProductEntryPoint.ID),
                Header     = TaskResource.NoTasksCreated,
                Describe   = String.Format(TaskResource.TasksHelpTheManage, TaskResource.DescrEmptyListTaskFilter),
                ID         = "emptyListTask",
                ButtonHTML = RequestContext.CanCreateTask(true) ? String.Format("<span class='link dotline addFirstElement'>{0}</span>", TaskResource.AddFirstTask) : string.Empty
            });

            emptyScreenPlaceHolders.Controls.Add(new EmptyScreenControl
            {
                ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("empty_screen_discussions.png", ProductEntryPoint.ID),
                Header     = MessageResource.DiscussionNotFound_Header,
                Describe   = MessageResource.DiscussionNotFound_Describe,
                ID         = "emptyListDiscussion",
                ButtonHTML = RequestContext.CanCreateDiscussion(true) ?
                             (RequestContext.IsInConcreteProject
                                ? String.Format("<a href='messages.aspx?prjID={0}&action=add' class='link dotline addFirstElement'>{1}</a>", RequestContext.GetCurrentProjectId(), MessageResource.StartFirstDiscussion)
                                : String.Format("<a href='messages.aspx?action=add' class='link dotline addFirstElement'>{0}</a>", MessageResource.StartFirstDiscussion))
                            : string.Empty
            });

            emptyScreenPlaceHolders.Controls.Add(new EmptyScreenControl
            {
                ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("empty_screen_milestones.png", ProductEntryPoint.ID),
                Header     = MilestoneResource.MilestoneNotFound_Header,
                Describe   = String.Format(MilestoneResource.MilestonesMarkMajorTimestamps),
                ID         = "emptyListMilestone",
                ButtonHTML = RequestContext.CanCreateMilestone(true) ? String.Format("<a class='link dotline addFirstElement'>{0}</a>", MilestoneResource.PlanFirstMilestone) : string.Empty
            });

            emptyScreenPlaceHolders.Controls.Add(new EmptyScreenControl
            {
                Header     = ProjectResource.EmptyListProjHeader,
                ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("projects_logo.png", ProductEntryPoint.ID),
                Describe   = ProjectResource.EmptyListProjDescribe,
                ID         = "emptyListProjects",
                ButtonHTML = ProjectSecurity.CanCreateProject() ? string.Format("<a href='projects.aspx?action=add' class='projectsEmpty link dotline addFirstElement'>{0}<a>", ProjectResource.CreateFirstProject) : string.Empty
            });

            emptyScreenPlaceHolders.Controls.Add(new EmptyScreenControl
            {
                ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("empty_screen_time_tracking.png", ProductEntryPoint.ID),
                Header     = TimeTrackingResource.NoTtimers,
                Describe   = String.Format(TimeTrackingResource.NoTimersNote),
                ID         = "emptyListTimers",
                ButtonHTML = String.Format("<span class='link dotline addFirstElement {1}'>{0}</span>", TimeTrackingResource.StartTimer, RequestContext.CanCreateTime(true) ? string.Empty : "display-none")
            });

            emptyScreenPlaceHolders.Controls.Add(new EmptyScreenControl
            {
                Header     = ProjectTemplatesResource.EmptyListTemplateHeader,
                ImgSrc     = WebImageSupplier.GetAbsoluteWebPath("project-templates_logo.png", ProductEntryPoint.ID),
                Describe   = ProjectTemplatesResource.EmptyListTemplateDescr,
                ID         = "emptyListTemplates",
                ButtonHTML = string.Format("<a href='projectTemplates.aspx?action=add' class='projectsEmpty link dotline addFirstElement'>{0}<a>", ProjectTemplatesResource.EmptyListTemplateButton)
            });
        }
示例#19
0
        public string GetPreview(string text, string commentID)
        {
            ProjectSecurity.DemandAuthentication();

            return(GetHTMLComment(text, commentID));
        }
 protected bool CanEditProject()
 {
     return(ProjectSecurity.CanEdit(ProjectFat.Project));
 }
 public override bool VisibleFor(Feed feed, object data, Guid userId)
 {
     return(base.VisibleFor(feed, data, userId) && ProjectSecurity.CanGoToFeed((Task)data, userId));
 }
 protected bool CanDeleteProject()
 {
     return(ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID));
 }
 protected void InitView()
 {
     CanEditTeam = ProjectSecurity.CanEditTeam(Project);
 }
示例#24
0
 public bool CanCreateTime()
 {
     return(ProjectFat.GetTasks().Count(t => t.Status == TaskStatus.Open) > 0 && ProjectSecurity.CanCreateTimeSpend(ProjectFat.Project));
 }
示例#25
0
 public override bool CanEdit()
 {
     return(ProjectSecurity.CanEdit(this));
 }
示例#26
0
        public int Create()
        {
            var newProject         = Parser <Project>(Request["project"]);
            var team               = new List <Guid>();
            var listMilestones     = new List <Milestone>();
            var listTasks          = new List <Task>();
            var notifyManager      = Convert.ToBoolean(Request["notifyManager"]);
            var notifyResponsibles = Convert.ToBoolean(Request["notifyResponsibles"]);

            var projectEngine     = Global.EngineFactory.GetProjectEngine();
            var participantEngine = Global.EngineFactory.GetParticipantEngine();
            var taskEngine        = Global.EngineFactory.GetTaskEngine();
            var milestoneEngine   = Global.EngineFactory.GetMilestoneEngine();

            if (Request["team"] != null)
            {
                team = Parser <List <Guid> >(Request["team"]);
            }

            if (Request["milestones"] != null)
            {
                listMilestones = Parser <List <Milestone> >(Request["milestones"]);
            }

            if (Request["noAssignTasks"] != null)
            {
                listTasks = Parser <List <Task> >(Request["noAssignTasks"]);
            }

            if (ProjectSecurity.CanCreateProject())
            {
                if (newProject != null)
                {
                    projectEngine.SaveOrUpdate(newProject, notifyManager);
                    projectEngine.AddToTeam(newProject, participantEngine.GetByID(newProject.Responsible), true);

                    //add team
                    foreach (var participant in team.Where(participant => participant != Guid.Empty))
                    {
                        projectEngine.AddToTeam(newProject, participantEngine.GetByID(participant), true);
                    }

                    foreach (var milestone in listMilestones)
                    {
                        var milestoneTasks = milestone.Tasks;
                        milestone.Description = string.Empty;
                        milestone.Project     = newProject;
                        milestoneEngine.SaveOrUpdate(milestone, notifyResponsibles);

                        foreach (var task in milestoneTasks)
                        {
                            task.Status    = TaskStatus.Open;
                            task.Milestone = milestone.ID;
                            task.Project   = newProject;
                            taskEngine.SaveOrUpdate(task, null, notifyResponsibles);
                        }
                    }

                    //add no assign tasks

                    foreach (var task in listTasks)
                    {
                        task.Project = newProject;
                        task.Status  = TaskStatus.Open;
                        taskEngine.SaveOrUpdate(task, null, notifyResponsibles);
                    }

                    return(newProject.ID);
                }
            }

            return(0);
        }
示例#27
0
        private void RenderContentForTimer()
        {
            var participantId = Guid.Empty;

            if (!WebItemSecurity.IsProductAdministrator(EngineFactory.ProductId, SecurityContext.CurrentAccount.ID))
            {
                participantId = Participant.ID;
            }

            UserProjects = EngineFactory.ProjectEngine.GetByFilter(new TaskFilter
            {
                ProjectStatuses = new List <ProjectStatus> {
                    ProjectStatus.Open
                },
                SortBy    = "title",
                SortOrder = true
            }).Where(r => r.TaskCountTotal > 0).ToList();

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

            var tasks = EngineFactory.TaskEngine.GetByProject(Project.ID, null, Participant.IsVisitor ? participantId : Guid.Empty).Where(r => ProjectSecurity.CanCreateTimeSpend(r)).ToList();

            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 = EngineFactory.ProjectEngine.GetProjectTeamExcluded(Project.ID)
                    .OrderBy(r => DisplayUserSettings.GetFullUserName(r.UserInfo))
                    .Where(r => !r.UserInfo.IsVisitor())
                    .Where(r => !r.IsRemovedFromTeam || tasks.Any(t => t.Responsibles.Contains(r.ID)))
                    .ToList();

            if (!string.IsNullOrEmpty(Request.QueryString["taskId"]))
            {
                Target = int.Parse(Request.QueryString["taskId"]);
            }
        }
 public ReportTemplateWrapper GetReportTemplate(int reportid)
 {
     ProjectSecurity.DemandAuthentication();
     return(new ReportTemplateWrapper(EngineFactory.ReportEngine.GetTemplate(reportid).NotFoundIfNull()));
 }
示例#29
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;
        }
示例#30
0
        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,
            };

            FileEngine.RegisterFileSecurityProvider();
            SearchHandlerManager.Registry(new SearchHandler());

            var securityInterceptor = new SendInterceptorSkeleton(
                "ProjectInterceptorSecurity",
                InterceptorPlace.DirectSend,
                InterceptorLifetime.Global,
                (r, p) =>
            {
                try
                {
                    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.TaskEngine.GetByID(entityId, false);

                        if (task == null && projectId != 0)
                        {
                            var project = Global.EngineFactory.ProjectEngine.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.MessageEngine.GetByID(entityId, false);

                        if (discussion == null && projectId != 0)
                        {
                            var project = Global.EngineFactory.ProjectEngine.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.MilestoneEngine.GetByID(entityId, false);

                        if (milestone == null && projectId != 0)
                        {
                            var project = Global.EngineFactory.ProjectEngine.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);
                }
                return(false);
            });

            NotifyClient.Instance.Client.AddInterceptor(securityInterceptor);
        }