示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserDto"/> class.
 /// </summary>
 public UserDto()
 {
     Configuration = new UserConfiguration();
     Policy = new UserPolicy();
 }
示例#2
0
 protected override bool GetBlockUnratedValue(UserPolicy config)
 {
     return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
 }
示例#3
0
        private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent)
        {
            // The xml serializer will output differently if the type is not exact
            if (userPolicy.GetType() != typeof(UserPolicy))
            {
                var json = _jsonSerializer.SerializeToString(userPolicy);
                userPolicy = _jsonSerializer.DeserializeFromString<UserPolicy>(json);
            }

            var path = GetPolifyFilePath(user);

			_fileSystem.CreateDirectory(Path.GetDirectoryName(path));

            lock (_policySyncLock)
            {
                _xmlSerializer.SerializeToFile(userPolicy, path);
                user.Policy = userPolicy;
            }

            await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false);
        }
示例#4
0
        private bool CanAccessDevice(UserPolicy policy, string id)
        {
            if (policy.EnableAllDevices)
            {
                return true;
            }

            if (policy.IsAdministrator)
            {
                return true;
            }

            return ListHelper.ContainsIgnoreCase(policy.EnabledDevices, id);
        }
示例#5
0
 public Task UpdateUserPolicy(string userId, UserPolicy userPolicy)
 {
     var user = GetUserById(userId);
     return UpdateUserPolicy(user, userPolicy, true);
 }
示例#6
0
 protected override bool GetBlockUnratedValue(UserPolicy config)
 {
     return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
 }
示例#7
0
 protected override bool GetBlockUnratedValue(UserPolicy config)
 {
     // Don't block. 
     return false;
 }
示例#8
0
        public bool IsEnabledToSendToUser(string type, string userId, UserPolicy userPolicy)
        {
            NotificationOption opt = GetOptions(type);

            if (opt != null && opt.Enabled)
            {
                if (opt.SendToUserMode == SendToUserType.All)
                {
                    return true;
                }

                if (opt.SendToUserMode == SendToUserType.Admins && userPolicy.IsAdministrator)
                {
                    return true;
                }

                return ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId);
            }

            return false;
        }
示例#9
0
        public async Task UpdateUserPolicy(string userId, UserPolicy userPolicy)
        {
            var user = GetUserById(userId);
            var path = GetPolifyFilePath(user);

            lock (_policySyncLock)
            {
                _xmlSerializer.SerializeToFile(userPolicy, path);
                user.Policy = userPolicy;
            }
        }