/// <summary>
    /// Returns true iff current user is Global administrator or Community administrator.
    /// </summary>
    private bool CurrentUserIsAdmin()
    {
        CurrentUserInfo ui = CMSContext.CurrentUser;

        if (ui != null)
        {
            SiteInfo si = SiteInfoProvider.GetSiteInfo(this.SiteID);
            if (si != null)
            {
                return(ui.IsInRole("CMSCommunityAdmin", si.SiteName) || ui.IsGlobalAdministrator);
            }
        }
        return(false);
    }
    /// <summary>
    /// Checks whether user is authorized per project access.
    /// </summary>
    public bool IsAuthorizedPerProjectAccess()
    {
        // Keep current user
        CurrentUserInfo cui = CMSContext.CurrentUser;

        // Switch by create project option
        switch (ProjectAccess.ToLowerCSafe())
        {
        // All users
        case "all":
            return(true);

        // Authenticated users
        case "authenticated":
            if (!cui.IsPublic())
            {
                return(true);
            }
            break;

        // Group members
        case "groupmember":
            if (CommunityGroupID > 0)
            {
                return(cui.IsGroupMember(CommunityGroupID));
            }
            break;

        // Authorized roles
        case "authorized":
            // Check whether roles are defined
            if (!String.IsNullOrEmpty(AuthorizedRoles))
            {
                // Check whether user is valid group member if current project is assigned to some group
                if (CommunityGroupID > 0)
                {
                    if (!cui.IsGroupMember(CommunityGroupID))
                    {
                        return(false);
                    }
                }

                // Keep site name
                string siteName = CMSContext.CurrentSiteName;
                // Split roles by semicolon
                string[] roles = AuthorizedRoles.Split(';');

                // Loop thru all roles and check if user is assigned at leat to one role
                foreach (string role in roles)
                {
                    // If user is in role, break current cycle and return true
                    if (cui.IsInRole(role, siteName))
                    {
                        return(true);
                    }
                }
            }
            break;

        // Nobody
        case "nobody":
        default:
            return(false);
        }

        return(false);
    }