public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig)
        {
            NotificationOption opt = GetOptions(type);

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

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

                return(opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase));
            }

            return(false);
        }
 public UserConfig(UserConfiguration data)
 {
     this._data = data;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserDto"/> class.
 /// </summary>
 public UserDto()
 {
     Configuration = new UserConfiguration();
     Policy = new UserPolicy();
 }
Example #4
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     // Don't block. Let either the entire series rating or episode rating determine it
     return false;
 }
Example #5
0
        private async Task UpdateConfiguration(User user, UserConfiguration config, bool fireEvent)
        {
            var path = GetConfigurationFilePath(user);

            // The xml serializer will output differently if the type is not exact
            if (config.GetType() != typeof(UserConfiguration))
            {
                var json = _jsonSerializer.SerializeToString(config);
                config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
            }

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

            lock (_configSyncLock)
            {
                _xmlSerializer.SerializeToFile(config, path);
                user.Configuration = config;
            }

            if (fireEvent)
            {
                EventHelper.FireEventIfNotNull(UserConfigurationUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
            }
        }
Example #6
0
 public Task UpdateConfiguration(string userId, UserConfiguration config)
 {
     var user = GetUserById(userId);
     return UpdateConfiguration(user, config, true);
 }
Example #7
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
 }
Example #8
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     return config.BlockUnratedMusic;
 }
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     // Don't block. 
     return false;
 }
Example #10
0
        public void UpdateConfiguration(User user, UserConfiguration newConfiguration)
        {
            var xmlPath = user.ConfigurationFilePath;
            Directory.CreateDirectory(Path.GetDirectoryName(xmlPath));
            _xmlSerializer.SerializeToFile(newConfiguration, xmlPath);

            EventHelper.FireEventIfNotNull(UserConfigurationUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
        }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserDto"/> class.
 /// </summary>
 public UserDto()
 {
     Configuration = new UserConfiguration();
 }
Example #12
0
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <param name="serializer">The serializer.</param>
        /// <exception cref="System.ArgumentNullException">config</exception>
        public void UpdateConfiguration(UserConfiguration config, IXmlSerializer serializer)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            var customLibraryChanged = config.UseCustomLibrary != Configuration.UseCustomLibrary;

            Configuration = config;
            SaveConfiguration(serializer);

            // Force these to be lazy loaded again
            if (customLibraryChanged)
            {
                RootFolder = null;
            }
        }
Example #13
0
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <exception cref="System.ArgumentNullException">config</exception>
        public void UpdateConfiguration(UserConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            Configuration = config;
            UserManager.UpdateConfiguration(this, Configuration);
        }
Example #14
0
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="config">The config.</param>
        /// <param name="serializer">The serializer.</param>
        /// <exception cref="System.ArgumentNullException">config</exception>
        public void UpdateConfiguration(UserConfiguration config, IXmlSerializer serializer)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            Configuration = config;
            SaveConfiguration();
        }
Example #15
0
 protected override bool GetBlockUnratedValue(UserConfiguration config)
 {
     return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
 }
        public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig)
        {
            NotificationOption opt = GetOptions(type);

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

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

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

            return false;
        }