Ejemplo n.º 1
0
        /// <summary>
        /// Determine visibility of control based on UserType
        /// </summary>
        private void SetButtonVisibility()
        {
            // Determine if page is ProjectMgmt page and read user type
            // to determine visibility
            if (Page is ProjectMgmtBasePage)
            {
                ProjectMgmtBasePage projectPage       = Page as ProjectMgmtBasePage;
                ProjectMgmtContext  activePageContext = projectPage.ProjectContext;
                ProjectMgmtUsers    activeUserType    = projectPage.UserType;

                // Buttons default visibility = false
                bool hasPermission = false;

                foreach (ProjectMgmtUsers type in _userTypes)
                {
                    if (activeUserType == type && (!_customContext || _customContext && _projectContext == activePageContext))
                    {
                        hasPermission = true;
                        break;
                    }
                }

                // Finally set button visibility
                this.Visible = hasPermission;
                this.Enabled = hasPermission;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read paramaters off query string and determine context
        /// </summary>
        private void SetUserPermissions()
        {
            if (PermissionManager.HasPermission(PermissionManager.AdminProjectModule) || PermissionManager.HasPermission(PermissionManager.EditSecurity))
            {
                _userType = ProjectMgmtUsers.ModuleAdmin;
            }
            else if (PermissionManager.HasPermission(PermissionManager.AdminProject))
            {
                SecurityController sc       = new SecurityController();
                string             userName = sc.GetUserName();

                // If working with a Project, determine if user is part of project
                if (!string.IsNullOrEmpty(ProjectId))
                {
                    UserDa userDa = new UserDa();
                    int    userId = userDa.GetUserId(userName);

                    ProjectManagementDa projectDa         = new ProjectManagementDa();
                    DataTable           contactsInProject = projectDa.GetProjectContactsByProjectId(int.Parse(ProjectId));
                    string userInProjectQuery             = Contact.UserId + " IS NOT NULL AND " + Contact.UserId + " = " + userId;

                    // Query contacts in project to see if user is associated with this Project
                    if (contactsInProject.Select(userInProjectQuery).Length > 0)
                    {
                        _userType = ProjectMgmtUsers.ProjectAdmin;
                    }
                    // User permissions for this project defaults to regular user
                    else
                    {
                        _userType = ProjectMgmtUsers.ProjectUser;
                    }
                }
                // If not working in project, user will have normal access to normal
                //ProjectAdmin Administrative functions
                else
                {
                    _userType = ProjectMgmtUsers.ProjectAdmin;
                }
            }
            else if (PermissionManager.HasPermission(PermissionManager.UpdateProject))
            {
                _userType = ProjectMgmtUsers.ProjectUser;
            }
        }
Ejemplo n.º 3
0
 public ProjectMgmtBasePage()
 {
     // Default user type is regular user
     _userType = ProjectMgmtUsers.ProjectUser;
 }