Beispiel #1
0
        public IndexGridSpec(FirmaSession currentFirmaSession)
        {
            var hasDeletePermission = new UserEditFeature().HasPermissionByFirmaSession(currentFirmaSession);

            if (hasDeletePermission)
            {
                Add(string.Empty,
                    x => DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteUrl(), true, true),
                    30, DhtmlxGridColumnFilterType.None);
            }

            // Impersonate link
            bool impersonationIsAllowed     = FirmaWebConfiguration.ImpersonationAllowedInEnvironment;
            bool hasImpersonationPermission = new FirmaImpersonateUserFeature().HasPermissionByFirmaSession(currentFirmaSession);

            if (impersonationIsAllowed && hasImpersonationPermission)
            {
                Add("Imper. User", a => ImpersonateUserButton.MakeImpersonateSinglePageHtmlLink(a), 45, DhtmlxGridColumnFilterType.Html);
            }

            Add("Last Name", a => UrlTemplate.MakeHrefString(a.GetDetailUrl(), a.LastName), 100, DhtmlxGridColumnFilterType.Html);
            Add("First Name", a => UrlTemplate.MakeHrefString(a.GetDetailUrl(), a.FirstName), 100, DhtmlxGridColumnFilterType.Html);
            Add("Email", a => a.Email, 200);
            Add($"{FieldDefinitionEnum.Organization.ToType().GetFieldDefinitionLabelPluralized()}", a => a.Organization.GetShortNameAsUrl(), 200);
            Add("Phone", a => a.Phone.ToPhoneNumberString(), 100);
            Add("Username", a => a.LoginName.ToString(), 200);
            Add("Last Activity", a => a.LastActivityDate, 120);
            Add("Role", a => a.Role.GetDisplayNameAsUrl(), 100, DhtmlxGridColumnFilterType.SelectFilterHtmlStrict);
            Add("Active?", a => a.IsActive.ToYesNo(), 75, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add("Receives Support Emails?", a => a.ReceiveSupportEmails.ToYesNo(), 100, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add($"{FieldDefinitionEnum.OrganizationPrimaryContact.ToType().GetFieldDefinitionLabel()} for Organizations", a => a.GetPrimaryContactOrganizations().Count, 120);
        }
Beispiel #2
0
        public DetailViewData(FirmaSession currentFirmaSession,
                              Person personToView,
                              Project.UserProjectGridSpec userProjectGridSpec,
                              string basicProjectInfoGridName,
                              string basicProjectInfoGridDataUrl,
                              UserNotificationGridSpec userNotificationGridSpec,
                              string userNotificationGridName,
                              string userNotificationGridDataUrl,
                              string activateInactivateUrl,
                              ActionItemsUserGridSpec actionItemsUserGridSpec,
                              string actionItemsGridName,
                              string actionItemsGridDataUrl)
            : base(currentFirmaSession)
        {
            Person     = personToView;
            PageTitle  = personToView.GetFullNameFirstLast() + (!personToView.IsActive ? " (inactive)" : string.Empty);
            EntityName = "User";

            EditPersonOrganizationPrimaryContactUrl = SitkaRoute <PersonOrganizationController> .BuildUrlFromExpression(c => c.EditPersonOrganizationPrimaryContacts(personToView));

            IndexUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.Index());

            if (FirmaWebConfiguration.AuthenticationType == AuthenticationType.LocalAuth)
            {
                EditDetailBasicsUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.EditUser(personToView.PrimaryKey));

                ChangePasswordUrl = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.ChangePassword(personToView.PrimaryKey));
            }

            // And again, here we should take Current FirmaSession, not the person. -- SLG & SG
            UserHasPersonViewPermissions   = new UserViewFeature().HasPermission(currentFirmaSession, personToView).HasPermission;
            UserHasPersonManagePermissions = new UserEditFeature().HasPermissionByFirmaSession(currentFirmaSession);
            UserHasAdminPermissions        = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession);

            CurrentPersonCanBeImpersonatedByCurrentUser = new FirmaImpersonateUserFeature().HasPermission(currentFirmaSession, personToView).HasPermission;

            IsViewingSelf = !currentFirmaSession.IsAnonymousUser() && currentFirmaSession.PersonID == personToView.PersonID;
            EditRolesLink = UserHasAdminPermissions
                ? ModalDialogFormHelper.MakeEditIconLink(SitkaRoute <UserController> .BuildUrlFromExpression(c => c.EditRoles(personToView)),
                                                         $"Edit Roles for User - {personToView.GetFullNameFirstLast()}",
                                                         true)
                : new HtmlString(string.Empty);

            UserProjectGridSpec         = userProjectGridSpec;
            BasicProjectInfoGridName    = basicProjectInfoGridName;
            BasicProjectInfoGridDataUrl = basicProjectInfoGridDataUrl;

            UserNotificationGridSpec    = userNotificationGridSpec;
            UserNotificationGridName    = userNotificationGridName;
            UserNotificationGridDataUrl = userNotificationGridDataUrl;
            ActivateInactivateUrl       = activateInactivateUrl;

            TenantHasStewardshipAreas = MultiTenantHelpers.GetProjectStewardshipAreaType() != null;

            ActionItemsUserGridSpec = actionItemsUserGridSpec;
            ActionItemsGridName     = actionItemsGridName;
            ActionItemsGridDataUrl  = actionItemsGridDataUrl;
        }
Beispiel #3
0
        public static void AssertFirmaSessionCanImpersonate(FirmaSession firmaSession)
        {
            bool currentFirmaSessionCanImpersonate = new FirmaImpersonateUserFeature().HasPermissionByFirmaSession(firmaSession);

            Check.RequireThrowNotAuthorized(currentFirmaSessionCanImpersonate, $"User {firmaSession.UserDisplayName} is not allowed to impersonate anyone else.");
        }