Esempio n. 1
0
    /// <summary>
    /// Reminder button OK clicked.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event args</param>
    protected void btnReminderOK_onClick(object sender, EventArgs e)
    {
        string errorMessage = "";

        if (txtReminderText.Text.Length > 0)
        {
            ProjectTaskInfo taskInfo = ProjectTaskInfoProvider.GetProjectTaskInfo(this.ReminderTaskID);
            if (taskInfo != null)
            {
                if (taskInfo.ProjectTaskAssignedToUserID > 0)
                {
                    ProjectTaskInfoProvider.SendNotificationEmail(ProjectTaskEmailNotificationTypeEnum.TaskReminder, taskInfo, CMSContext.CurrentSiteName, txtReminderText.Text);
                    lblInfo.Text = GetString("pm.projecttask.remindersent");
                }
                else
                {
                    errorMessage = GetString("pm.projecttask.remindernoassignee");
                }
            }
        }
        else
        {
            errorMessage = GetString("pm.projecttask.remindermessageerror");
        }

        if (String.IsNullOrEmpty(errorMessage))
        {
            CloseAjaxWindow();
        }
        else
        {
            ShowReminderPopup();
            lblReminderError.Text = errorMessage;
        }
    }
    /// <summary>
    /// Ensures displaying of task detail with dependence on querystring settings.
    /// </summary>
    protected void EnsureForceTask()
    {
        // Check whethe isn't postback
        if (!RequestHelper.IsPostBack())
        {
            // Try get task id from query string
            int taskId = QueryHelper.GetInteger("taskid", 0);
            if (taskId > 0)
            {
                // Try get task info and check whether is assigned to current project
                ProjectTaskInfo pti = ProjectTaskInfoProvider.GetProjectTaskInfo(taskId);
                if ((pti != null) && (pti.ProjectTaskProjectID == ProjectID))
                {
                    // Check whether current user can see required private task
                    if (pti.ProjectTaskIsPrivate)
                    {
                        // Keep current user
                        var cui = MembershipContext.AuthenticatedUser;
                        if (!IsAuthorizedPerProjectEdit() && (pti.ProjectTaskOwnerID != cui.UserID) && (pti.ProjectTaskAssignedToUserID != cui.UserID))
                        {
                            return;
                        }
                    }

                    EditTask(taskId);
                }
            }
        }
    }
Esempio n. 3
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;
            }
        }
    }
Esempio n. 4
0
 /// <summary>
 /// Sets breacrumbs for edit.
 /// </summary>
 private void SetBreadcrumbs(int projectTaskID)
 {
     // If project task is defined display task specific breadcrumbs
     if (projectTaskID != 0)
     {
         // Load project name
         ProjectTaskInfo pi = ProjectTaskInfoProvider.GetProjectTaskInfo(projectTaskID);
         if (pi != null)
         {
             lblEditBack.Text = " <span class=\"TitleBreadCrumbSeparator\">&nbsp;</span>" + HTMLHelper.HTMLEncode(pi.ProjectTaskDisplayName);
         }
     }
     // Dsiplay new task breadcrumb
     else
     {
         lblEditBack.Text = " <span class=\"TitleBreadCrumbSeparator\">&nbsp;</span>" + GetString("pm.projecttask.new");
     }
 }
 /// <summary>
 /// Sets breadcrumbs for edit.
 /// </summary>
 private void SetBreadcrumbs(int projectTaskID)
 {
     // If project task is defined display task specific breadcrumbs
     if (projectTaskID != 0)
     {
         // Load project name
         ProjectTaskInfo pi = ProjectTaskInfoProvider.GetProjectTaskInfo(projectTaskID);
         if (pi != null)
         {
             ucBreadcrumbs.Items[1].Text = HTMLHelper.HTMLEncode(pi.ProjectTaskDisplayName);
         }
     }
     // Display new task breadcrumb
     else
     {
         ucBreadcrumbs.Items[1].Text = GetString("pm.projecttask.new");
     }
 }
    /// <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();
        }
    }
Esempio n. 7
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();
            }
        }
    }
Esempio n. 8
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);
    }