use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.
the class LibresonicThemeResolver method doResolveThemeName.
private String doResolveThemeName(HttpServletRequest request) {
String themeId = null;
// Look for user-specific theme.
String username = securityService.getCurrentUsername(request);
if (username != null) {
UserSettings userSettings = settingsService.getUserSettings(username);
if (userSettings != null) {
themeId = userSettings.getThemeId();
}
}
if (themeId != null && themeExists(themeId)) {
return themeId;
}
// Return system theme.
themeId = settingsService.getThemeId();
return themeExists(themeId) ? themeId : "default";
}
use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.
the class UserSettingsController method updateUser.
public void updateUser(UserSettingsCommand command) {
User user = securityService.getUserByName(command.getUsername());
user.setEmail(StringUtils.trimToNull(command.getEmail()));
user.setLdapAuthenticated(command.isLdapAuthenticated());
user.setAdminRole(command.isAdminRole());
user.setDownloadRole(command.isDownloadRole());
user.setUploadRole(command.isUploadRole());
user.setCoverArtRole(command.isCoverArtRole());
user.setCommentRole(command.isCommentRole());
user.setPodcastRole(command.isPodcastRole());
user.setStreamRole(command.isStreamRole());
user.setJukeboxRole(command.isJukeboxRole());
user.setSettingsRole(command.isSettingsRole());
user.setShareRole(command.isShareRole());
if (command.isPasswordChange()) {
user.setPassword(command.getPassword());
}
securityService.updateUser(user);
UserSettings userSettings = settingsService.getUserSettings(command.getUsername());
userSettings.setTranscodeScheme(TranscodeScheme.valueOf(command.getTranscodeSchemeName()));
userSettings.setChanged(new Date());
settingsService.updateUserSettings(userSettings);
List<Integer> allowedMusicFolderIds = Util.toIntegerList(command.getAllowedMusicFolderIds());
settingsService.setMusicFoldersForUser(command.getUsername(), allowedMusicFolderIds);
}
use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.
the class AudioScrobblerService method createRegistrationData.
private RegistrationData createRegistrationData(MediaFile mediaFile, String username, boolean submission, Date time) {
if (mediaFile == null || mediaFile.isVideo()) {
return null;
}
UserSettings userSettings = settingsService.getUserSettings(username);
if (!userSettings.isLastFmEnabled() || userSettings.getLastFmUsername() == null || userSettings.getLastFmPassword() == null) {
return null;
}
RegistrationData reg = new RegistrationData();
reg.username = userSettings.getLastFmUsername();
reg.password = userSettings.getLastFmPassword();
reg.artist = mediaFile.getArtist();
reg.album = mediaFile.getAlbumName();
reg.title = mediaFile.getTitle();
reg.duration = mediaFile.getDurationSeconds() == null ? 0 : mediaFile.getDurationSeconds();
reg.time = time == null ? new Date() : time;
reg.submission = submission;
return reg;
}
use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.
the class LibresonicLocaleResolver method doResolveLocale.
private Locale doResolveLocale(HttpServletRequest request) {
Locale locale = null;
// Look for user-specific locale.
String username = securityService.getCurrentUsername(request);
if (username != null) {
UserSettings userSettings = settingsService.getUserSettings(username);
if (userSettings != null) {
locale = userSettings.getLocale();
}
}
if (locale != null && localeExists(locale)) {
return locale;
}
// Return system locale.
locale = settingsService.getLocale();
return localeExists(locale) ? locale : Locale.ENGLISH;
}
Aggregations