/// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        gridMatrix.OnItemChanged       += gridMatrix_OnItemChanged;
        gridMatrix.StopProcessing       = true;
        gridMatrix.ColumnsPreferedOrder = string.Join(",", mAllowedPermissions);

        if (ProjectID > 0)
        {
            mProject = ProjectInfoProvider.GetProjectInfo(ProjectID);

            // Check whether the project still exists
            EditedObject = mProject;
        }

        // Handle page chnaged event
        gridMatrix.OnPageChanged += gridMatrix_OnPageChanged;

        // Disable permission matrix if user has no MANAGE rights
        if (!ProjectInfoProvider.IsAuthorizedPerProject(ProjectID, PERMISSION_MANAGE, MembershipContext.AuthenticatedUser))
        {
            Enable             = false;
            gridMatrix.Enabled = false;
            lblError.Text      = String.Format(GetString("general.accessdeniedonpermissionname"), "Manage");
            lblError.Visible   = true;
        }
    }
Exemple #2
0
    /// <summary>
    /// Gets the sorting arrows visibility according to the settings of the project or other circumstances.
    /// </summary>
    private bool GetSortingArrowsVisibility()
    {
        bool arrowsVisible = false;

        // Hide/show sorting arrows  with dependence on project ordering
        if (ProjectID > 0)
        {
            if (ProjectInfoProvider.IsAuthorizedPerProject(ProjectID, ProjectManagementPermissionType.MODIFY, CMSContext.CurrentUser) ||
                CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ProjectManagement", CMSAdminControl.PERMISSION_MANAGE))
            {
                arrowsVisible = true;
                if (OrderByType == ProjectTaskOrderByEnum.ProjectOrder)
                {
                    ProjectInfo projectObj = ProjectInfoProvider.GetProjectInfo(ProjectID);
                    if (projectObj != null)
                    {
                        arrowsVisible = projectObj.ProjectAllowOrdering;
                    }
                }
            }
        }
        // Tasks list only
        else
        {
            // Show sorting only for all site tasks
            if (String.IsNullOrEmpty(SiteName))
            {
                arrowsVisible = true;
            }
        }

        return(arrowsVisible);
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        gridMatrix.OnItemChanged       += new UniMatrix.ItemChangedEventHandler(gridMatrix_OnItemChanged);
        gridMatrix.StopProcessing       = true;
        gridMatrix.ColumnsPreferedOrder = string.Join(",", allowedPermissions);


        if (ProjectID > 0)
        {
            project = ProjectInfoProvider.GetProjectInfo(ProjectID);

            // Check whether the project still exists
            EditedObject = project;
        }

        // Handle page chnaged event
        gridMatrix.OnPageChanged += new EventHandler <EventArgs>(gridMatrix_OnPageChanged);

        // Disable permission matrix if user has no MANAGE rights
        if (!ProjectInfoProvider.IsAuthorizedPerProject(ProjectID, PERMISSION_MANAGE, CMSContext.CurrentUser))
        {
            Enable             = false;
            gridMatrix.Enabled = false;
            lblError.Text      = String.Format(GetString("CMSSiteManager.AccessDeniedOnPermissionName"), "Manage");
            lblError.Visible   = true;
        }
    }
Exemple #4
0
    /// <summary>
    /// Checks whether current user can delete task.
    /// </summary>
    /// <param name="permissionType">Permission type</param>
    /// <param name="modulePermissionType">Module permission type</param>
    /// <param name="sender">Sender object</param>
    void ucTaskList_OnCheckPermissionsExtended(string permissionType, string modulePermissionType, CMSAdminControl sender)
    {
        int itemID = ucTaskEdit.ItemID;

        // If edit task ItemID is 0, try get from list
        if (itemID == 0)
        {
            itemID = ucTaskList.SelectedItemID;
        }

        // Get task info for currently deleted task
        ProjectTaskInfo pti = ProjectTaskInfoProvider.GetProjectTaskInfo(itemID);

        // Check permission only for existing tasks and tasks assigned to some project
        if ((pti != null) && (pti.ProjectTaskProjectID > 0))
        {
            // Check whether user is allowed to modify or delete task
            if (!ProjectInfoProvider.IsAuthorizedPerProject(pti.ProjectTaskProjectID, permissionType, CMSContext.CurrentUser))
            {
                lblError.Visible      = true;
                lblError.Text         = GetString("pm.project.permission");
                sender.StopProcessing = true;
            }
        }
    }
 /// <summary>
 /// Checks delete and modify permissions (delete and up/down actions)
 /// </summary>
 /// <param name="permissionType">Permission type</param>
 /// <param name="modulePermissionType">Module permission type</param>
 /// <param name="sender">Sender object</param>
 private void ucTaskList_OnCheckPermissionsExtended(string permissionType, string modulePermissionType, CMSAdminControl sender)
 {
     // Check whether user is allowed to modify or delete task
     if (!ProjectInfoProvider.IsAuthorizedPerProject(ProjectID, permissionType, MembershipContext.AuthenticatedUser) && !IsAuthorizedPerProjectAccess())
     {
         lblError.Visible      = true;
         lblError.Text         = GetString("pm.project.permission");
         sender.StopProcessing = true;
     }
 }
    /// <summary>
    /// Checks whether user can create new task.
    /// </summary>
    protected bool IsAuthorizedPerCreateTask()
    {
        // Keep current user info object
        var cui = MembershipContext.AuthenticatedUser;

        // If user can edit project => can create task
        if (IsAuthorizedPerProjectEdit())
        {
            return(true);
        }

        // Check create permission
        return(ProjectInfoProvider.IsAuthorizedPerProject(ProjectID, ProjectManagementPermissionType.CREATE, cui));
    }
Exemple #7
0
    /// <summary>
    /// Checks whether user can create new task.
    /// </summary>
    protected bool IsAuthorizedPerCreateTask()
    {
        // Keep current user info object
        CurrentUserInfo cui = CMSContext.CurrentUser;

        // If user can edit project => can create task
        if (IsAuthorizedPerProjectEdit())
        {
            return(true);
        }

        // Check create permission
        return(ProjectInfoProvider.IsAuthorizedPerProject(this.ProjectID, ProjectManagementPermissionType.CREATE, cui));
    }
Exemple #8
0
    protected override void OnInit(EventArgs e)
    {
        // Get project id from query string
        projectId = QueryHelper.GetInteger("projectid", 0);

        // Check whether user can see required project
        if (!ProjectInfoProvider.IsAuthorizedPerProject(projectId, ProjectManagementPermissionType.READ, CMSContext.CurrentUser))
        {
            RedirectToAccessDenied("CMS.ProjectManagement", "Manage");
        }

        editElem.ProjectID = QueryHelper.GetInteger("projectid", 0);

        base.OnInit(e);
    }
    /// <summary>
    /// Checks modify permission on task edit.
    /// </summary>
    /// <param name="permissionType">Permission type</param>
    /// <param name="modulePermissionType">Module permission type</param>
    /// <param name="sender">Sender object</param>
    private void ucTaskEdit_OnCheckPermissionsExtended(string permissionType, string modulePermissionType, CMSAdminControl sender)
    {
        // Indicates whether user is owner or assignee
        bool isInvolved = false;

        // Check whether taks is in edit mode
        if (ucTaskEdit.ItemID > 0)
        {
            // Get task info
            ProjectTaskInfo pti = ProjectTaskInfoProvider.GetProjectTaskInfo(ucTaskEdit.ItemID);
            // Check whether task exists
            if (pti != null)
            {
                // Keep current user
                var cui = MembershipContext.AuthenticatedUser;
                // If user is assignee or owenr set flag
                if ((pti.ProjectTaskAssignedToUserID == cui.UserID) || (pti.ProjectTaskOwnerID == cui.UserID))
                {
                    isInvolved = true;
                }
            }
        }


        // Check whether user is allowed to modify task
        if (!isInvolved && !ProjectInfoProvider.IsAuthorizedPerProject(ProjectID, permissionType, MembershipContext.AuthenticatedUser) && !IsAuthorizedPerProjectAccess())
        {
            // Set error message to the dialog
            ucTaskEdit.SetError(GetString("pm.project.permission"));
            // Stop edit control processing
            sender.StopProcessing = true;
            // Display dialog with HTML editor
            ucPopupDialogTask.Visible = true;
            // Set current project ID
            ucTaskEdit.ProjectID = ProjectID;
            // Show popup dialog for possibility of error on task edit form
            ucPopupDialogTask.Show();
            // Updade modal dialog update panel
            pnlUpdateModalTask.Update();
        }
    }
Exemple #10
0
    /// <summary>
    /// Checks whether current user can modify task.
    /// </summary>
    /// <param name="permissionType">Permission type</param>
    /// <param name="modulePermissionType">Module permission type</param>
    /// <param name="sender">Sender object</param>
    void ucTaskEdit_OnCheckPermissionsExtended(string permissionType, string modulePermissionType, CMSAdminControl sender)
    {
        // Get task info for currently deleted task
        ProjectTaskInfo pti = ProjectTaskInfoProvider.GetProjectTaskInfo(ucTaskEdit.ItemID);

        // Check permission only for existing tasks and tasks assigned to some project
        if ((pti != null) && (pti.ProjectTaskProjectID > 0))
        {
            // Keep current user
            CurrentUserInfo cui = CMSContext.CurrentUser;

            // Check access to project permission for modify action
            if ((String.Compare(permissionType, ProjectManagementPermissionType.MODIFY, true) == 0) && ProjectInfoProvider.IsAuthorizedPerProject(pti.ProjectTaskProjectID, ProjectManagementPermissionType.READ, cui))
            {
                // If user is owner or assignee => allow taks edit
                if ((pti.ProjectTaskOwnerID == cui.UserID) || (pti.ProjectTaskAssignedToUserID == cui.UserID))
                {
                    return;
                }
            }

            // Check whether user is allowed to modify task
            if (!ProjectInfoProvider.IsAuthorizedPerProject(pti.ProjectTaskProjectID, permissionType, cui))
            {
                // Set error message to the dialog
                ucTaskEdit.SetError(GetString("pm.project.permission"));
                // Stop edit control processing
                sender.StopProcessing = true;

                // Render dialog
                this.ucPopupDialog.Visible = true;
                // Show dialog
                ucPopupDialog.Show();
                // Update dialog panel
                pnlUpdateList.Update();
            }
        }
    }
Exemple #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Keep current user object
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Title element settings
        titleElem.TitleImage = GetImageUrl("Objects/PM_ProjectTask/object.png");
        titleElem.TitleText  = GetString("pm.projecttask.edit");

        #region "Header actions"

        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            // New task link
            string[,] actions = new string[1, 7];
            actions[0, 0]     = HeaderActions.TYPE_LINKBUTTON;
            actions[0, 1]     = GetString("pm.projecttask.newpersonal");
            actions[0, 2]     = null;
            actions[0, 4]     = null;
            actions[0, 5]     = GetImageUrl("Objects/PM_Project/add.png");
            actions[0, 6]     = "new_task";

            HeaderActions.Actions          = actions;
            HeaderActions.ActionPerformed += new CommandEventHandler(actionsElem_ActionPerformed);
            HeaderActions.ReloadData();
        }
        #endregion

        // Switch by display type and set correct list grid name
        switch (this.TasksDisplayType)
        {
        // Project tasks
        case TasksDisplayTypeEnum.ProjectTasks:
            ucTaskList.OrderByType   = ProjectTaskOrderByEnum.NotSpecified;
            ucTaskList.Grid.OrderBy  = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC";
            ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/ProjectTasks.xml";
            pnlListActions.Visible   = false;
            break;

        // Tasks owned by me
        case TasksDisplayTypeEnum.TasksOwnedByMe:
            ucTaskList.OrderByType   = ProjectTaskOrderByEnum.NotSpecified;
            ucTaskList.Grid.OrderBy  = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC";
            ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/TasksOwnedByMe.xml";
            break;

        // Tasks assigned to me
        case TasksDisplayTypeEnum.TasksAssignedToMe:
            // Set not specified order by default
            ucTaskList.OrderByType = ProjectTaskOrderByEnum.NotSpecified;
            // If sitename is not defined => display task from all sites => use user order
            if (String.IsNullOrEmpty(this.SiteName))
            {
                ucTaskList.OrderByType = ProjectTaskOrderByEnum.UserOrder;
            }
            ucTaskList.Grid.OrderBy  = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC";
            ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/TasksAssignedToMe.xml";
            break;
        }

        #region "Force edit by TaskID in querystring"

        // Check whether is not postback
        if (!RequestHelper.IsPostBack())
        {
            // Try get value from request stroage which indicates whether force dialog is displayed
            bool isDisplayed = ValidationHelper.GetBoolean(RequestStockHelper.GetItem("cmspmforceitemdisplayed", true), false);

            // Try get task id from querystring
            int forceTaskId = QueryHelper.GetInteger("taskid", 0);
            if ((forceTaskId > 0) && (!isDisplayed))
            {
                ProjectTaskInfo pti = ProjectTaskInfoProvider.GetProjectTaskInfo(forceTaskId);
                ProjectInfo     pi  = ProjectInfoProvider.GetProjectInfo(pti.ProjectTaskProjectID);

                // Check whether task is defined
                // and if is assigned to some project, this project is assigned to current site
                if ((pti != null) && ((pi == null) || (pi.ProjectSiteID == CMSContext.CurrentSiteID)))
                {
                    bool taskIdValid = false;

                    // Switch by display type
                    switch (this.TasksDisplayType)
                    {
                    // Tasks created by me
                    case TasksDisplayTypeEnum.TasksOwnedByMe:
                        if (pti.ProjectTaskOwnerID == currentUser.UserID)
                        {
                            taskIdValid = true;
                        }
                        break;

                    // Tasks assigned to me
                    case TasksDisplayTypeEnum.TasksAssignedToMe:
                        if (pti.ProjectTaskAssignedToUserID == currentUser.UserID)
                        {
                            taskIdValid = true;
                        }
                        break;

                    // Project task
                    case TasksDisplayTypeEnum.ProjectTasks:
                        if (!String.IsNullOrEmpty(ProjectNames) && (pi != null))
                        {
                            string projectNames = ";" + ProjectNames.ToLower() + ";";
                            if (projectNames.Contains(";" + pi.ProjectName.ToLower() + ";"))
                            {
                                // Check whether user can see private task
                                if (!pti.ProjectTaskIsPrivate ||
                                    ((pti.ProjectTaskOwnerID == currentUser.UserID) || (pti.ProjectTaskAssignedToUserID == currentUser.UserID)) ||
                                    ((pi.ProjectGroupID > 0) && currentUser.IsGroupAdministrator(pi.ProjectGroupID)) ||
                                    ((pi.ProjectGroupID == 0) && (currentUser.IsAuthorizedPerResource("CMS.ProjectManagement", CMSAdminControl.PERMISSION_MANAGE))))
                                {
                                    taskIdValid = true;
                                }
                            }
                        }
                        break;
                    }

                    bool displayValid = true;

                    // Check whether do not display finished tasks is required
                    if (!this.ShowFinishedTasks)
                    {
                        ProjectTaskStatusInfo ptsi = ProjectTaskStatusInfoProvider.GetProjectTaskStatusInfo(pti.ProjectTaskStatusID);
                        if ((ptsi != null) && (ptsi.TaskStatusIsFinished))
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether private task should be edited
                    if (!this.ShowPrivateTasks)
                    {
                        if (pti.ProjectTaskProjectID == 0)
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether ontime task should be edited
                    if (!this.ShowOnTimeTasks)
                    {
                        if ((pti.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) && (pti.ProjectTaskDeadline < DateTime.Now))
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether overdue task should be edited
                    if (!this.ShowOverdueTasks)
                    {
                        if ((pti.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) && (pti.ProjectTaskDeadline > DateTime.Now))
                        {
                            displayValid = false;
                        }
                    }

                    // Check whether user is allowed to see project
                    if ((pi != null) && (ProjectInfoProvider.IsAuthorizedPerProject(pi.ProjectID, ProjectManagementPermissionType.READ, CMSContext.CurrentUser)))
                    {
                        displayValid = false;
                    }

                    // If task is valid and user has permissions to see this task display edit task dialog
                    if (displayValid && taskIdValid && ProjectTaskInfoProvider.IsAuthorizedPerTask(forceTaskId, ProjectManagementPermissionType.READ, CMSContext.CurrentUser, CMSContext.CurrentSiteID))
                    {
                        this.ucTaskEdit.ItemID = forceTaskId;
                        this.ucTaskEdit.ReloadData();
                        // Render dialog
                        this.ucPopupDialog.Visible = true;
                        this.ucPopupDialog.Show();
                        // Set "force dialog displayed" flag
                        RequestStockHelper.Add("cmspmforceitemdisplayed", true, true);
                    }
                }
            }
        }

        #endregion


        #region "Event handlers registration"

        // Register list action handler
        ucTaskList.OnAction += new CommandEventHandler(ucTaskList_OnAction);

        #endregion


        #region "Pager settings"

        // Paging
        if (!EnablePaging)
        {
            ucTaskList.Grid.PageSize = "##ALL##";
            ucTaskList.Grid.Pager.DefaultPageSize = -1;
        }
        else
        {
            ucTaskList.Grid.Pager.DefaultPageSize = PageSize;
            ucTaskList.Grid.PageSize    = this.PageSize.ToString();
            ucTaskList.Grid.FilterLimit = PageSize;
        }

        #endregion


        // Use postbacks on list actions
        ucTaskList.UsePostbackOnEdit = true;
        // Check delete permission
        ucTaskList.OnCheckPermissionsExtended += new CheckPermissionsExtendedEventHandler(ucTaskList_OnCheckPermissionsExtended);
        // Dont register JS edit script
        ucTaskList.RegisterEditScript = false;

        // Hide default ok button on edit
        ucTaskEdit.ShowOKButton = false;
        // Disable on site validators
        ucTaskEdit.DisableOnSiteValidators = true;
        // Check modify permission
        ucTaskEdit.OnCheckPermissionsExtended += new CheckPermissionsExtendedEventHandler(ucTaskEdit_OnCheckPermissionsExtended);
        // Build condition event
        ucTaskList.BuildCondition += new CMSModules_ProjectManagement_Controls_UI_ProjectTask_List.BuildConditionEvent(ucTaskList_BuildCondition);
    }