Пример #1
0
        public virtual bool IsSettingSupported(ConfigSetting setting)
        {
            if (setting == null)
            {
                return(false);
            }
            IUserManagement userManagement = ServiceRegistration.Get <IUserManagement>();

            return(userManagement.CheckUserAccess(setting));
        }
Пример #2
0
        private bool CheckRestrictedToOwn()
        {
            IUserManagement userManagement = ServiceRegistration.Get <IUserManagement>();

            if (userManagement == null || userManagement.UserProfileDataManagement == null)
            {
                return(true);
            }

            var hasSettings = userManagement.CheckUserAccess(new AccessCheck {
                RestrictionGroup = "Settings.UserProfile"
            });
            var hasOwn = userManagement.CheckUserAccess(new AccessCheck {
                RestrictionGroup = "Settings.UserProfile.ManageOwn"
            });

            // The restriction to own profile is only valid if the global user management is prohibited.
            return(!hasSettings && hasOwn);
        }
Пример #3
0
        /// <summary>
        /// Applies a filter to channel groups. This will be used to remove "All Channels" group if needed or to apply user restrictions.
        /// </summary>
        /// <param name="channelGroups">Groups</param>
        /// <returns>Filtered groups</returns>
        private static IList <IChannelGroup> FilterGroups(IList <IChannelGroup> channelGroups)
        {
            IList <IChannelGroup> filteredGroups = new List <IChannelGroup>();
            IUserManagement       userManagement = ServiceRegistration.Get <IUserManagement>();
            bool hideAllChannelsGroup            = ServiceRegistration.Get <ISettingsManager>().Load <SlimTvClientSettings>().HideAllChannelsGroup;

            foreach (IChannelGroup channelGroup in channelGroups.Where(g => !hideAllChannelsGroup || g.Name != "All Channels"))
            {
                IUserRestriction restriction = channelGroup as IUserRestriction;
                if (restriction != null && !userManagement.CheckUserAccess(restriction))
                {
                    continue;
                }
                filteredGroups.Add(channelGroup);
            }
            return(filteredGroups);
        }