Exemplo n.º 1
0
        private void ShowAuthenticatedProperties(SiteUser siteUser)
        {
            mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

            if (profileConfig != null)
            {
                foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
#if !MONO
                    // we are using the new TimeZoneInfo list but it doesn't work under Mono
                    // this makes us skip the TimeOffsetHours setting from mojoProfile.config which is not used under windows
                    if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeOffsetHoursKey)
                    {
                        continue;
                    }
#endif

                    // we allow this to be configured as a profile property so it can be required for registration
                    // but we don't need to load it here because we have a dedicated control for the property already
                    if (propertyDefinition.Name == mojoProfilePropertyDefinition.TimeZoneIdKey)
                    {
                        continue;
                    }

                    if (
                        (propertyDefinition.VisibleToAuthenticated) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        ) &&
                        (
                            (propertyDefinition.OnlyVisibleForRoles.Length == 0) ||
                            (WebUser.IsInRoles(propertyDefinition.OnlyVisibleForRoles))
                        )

                        )
                    {
                        object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad);
                        if (propValue != null)
                        {
                            mojoProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propValue.ToString(),
                                timeOffset,
                                timeZone);
                        }
                        else
                        {
                            mojoProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propertyDefinition.DefaultValue,
                                timeOffset,
                                timeZone);
                        }
                    }
                }
            }
        }
        private void ShowAnonymousProperties(SiteUser siteUser)
        {
            bool wouldSeeMoreIfAuthenticated = false;

            CProfileConfiguration profileConfig = CProfileConfiguration.GetConfig();

            if (profileConfig != null)
            {
                foreach (CProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
                    if (
                        (propertyDefinition.VisibleToAnonymous) &&
                        (propertyDefinition.OnlyVisibleForRoles.Length == 0) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        )
                        )
                    {
                        object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad);
                        if (propValue != null)
                        {
                            CProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propValue.ToString(),
                                timeOffset);
                        }
                        else
                        {
                            CProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propertyDefinition.DefaultValue,
                                timeOffset);
                        }
                    }
                    else
                    {
                        if (
                            (propertyDefinition.VisibleToAuthenticated) &&
                            (propertyDefinition.OnlyVisibleForRoles.Length == 0) &&
                            (
                                (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                                (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                            )
                            )
                        {
                            wouldSeeMoreIfAuthenticated = true;
                        }
                    }
                }
            }

            if (wouldSeeMoreIfAuthenticated)
            {
                lblMessage.Text = ProfileResource.WouldSeeMoreIfAuthenticatedMessage;
            }
        }
Exemplo n.º 3
0
        private void PopulateProfileControls()
        {
            if (siteUser == null)
            {
                return;
            }
            if (!isAdmin)
            {
                return;
            }

            CProfileConfiguration profileConfig = CProfileConfiguration.GetConfig();

            if (profileConfig != null)
            {
                foreach (CProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
                    if (
                        (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                        (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        )
                    {
                        object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad);
                        if (propValue != null)
                        {
                            CProfilePropertyDefinition.SetupPropertyControl(
                                this,
                                pnlProfileProperties,
                                propertyDefinition,
                                propValue.ToString(),
                                TimeOffset,
                                SiteRoot);
                        }
                        else
                        {
                            CProfilePropertyDefinition.SetupPropertyControl(
                                this,
                                pnlProfileProperties,
                                propertyDefinition,
                                propertyDefinition.DefaultValue,
                                TimeOffset,
                                SiteRoot);
                        }
                    }
                }
            }
        }
        private void ShowAuthenticatedProperties(SiteUser siteUser)
        {
            CProfileConfiguration profileConfig = CProfileConfiguration.GetConfig();

            if (profileConfig != null)
            {
                foreach (CProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
                    if (
                        (propertyDefinition.VisibleToAuthenticated) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        ) &&
                        (
                            (propertyDefinition.OnlyVisibleForRoles.Length == 0) ||
                            (WebUser.IsInRoles(propertyDefinition.OnlyVisibleForRoles))
                        )

                        )
                    {
                        object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad);
                        if (propValue != null)
                        {
                            CProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propValue.ToString(),
                                timeOffset);
                        }
                        else
                        {
                            CProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                pnlProfileProperties,
                                propertyDefinition,
                                propertyDefinition.DefaultValue,
                                timeOffset);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void PopulateProfileControls()
        {
            if (siteUser == null)
            {
                return;
            }

            gbProfileConfiguration profileConfig = gbProfileConfiguration.GetConfig();

            if (profileConfig != null)
            {
                foreach (gbProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
#if !MONO
                    if (propertyDefinition.Name == gbProfilePropertyDefinition.TimeOffsetHoursKey)
                    {
                        continue;
                    }
#endif
                    if (propertyDefinition.Name == gbProfilePropertyDefinition.TimeZoneIdKey)
                    {
                        continue;
                    }

                    if (
                        (propertyDefinition.VisibleToUser) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        )
                        )
                    {
                        object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad);
                        if (propValue != null)
                        {
                            if (propertyDefinition.EditableByUser)
                            {
                                gbProfilePropertyDefinition.SetupPropertyControl(
                                    this,
                                    pnlProfileProperties,
                                    propertyDefinition,
                                    propValue.ToString(),
                                    timeOffset,
                                    timeZone,
                                    SiteRoot);
                            }
                            else
                            {
                                gbProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                    pnlProfileProperties,
                                    propertyDefinition,
                                    propValue.ToString(),
                                    timeOffset,
                                    timeZone);
                            }
                        }
                        else
                        {
                            if (propertyDefinition.EditableByUser)
                            {
                                gbProfilePropertyDefinition.SetupPropertyControl(
                                    this,
                                    pnlProfileProperties,
                                    propertyDefinition,
                                    propertyDefinition.DefaultValue,
                                    timeOffset,
                                    timeZone,
                                    SiteRoot);
                            }
                            else
                            {
                                gbProfilePropertyDefinition.SetupReadOnlyPropertyControl(
                                    pnlProfileProperties,
                                    propertyDefinition,
                                    propertyDefinition.DefaultValue,
                                    timeOffset,
                                    timeZone);
                            }
                        }
                    }
                }
            }
        }