/** * Return current user locale. * * @return user's Locale object */ private Locale getCurrentUserLocale() { Locale loc = null; try { // check if locale is requested for specific user String userId = M_sm.getCurrentSessionUserId(); if (userId != null) { Preferences prefs = M_ps.getPreferences(userId); ResourceProperties locProps = prefs.getProperties(ResourceLoader.APPLICATION_ID); String localeString = locProps.getProperty(ResourceLoader.LOCALE_KEY); // Parse user locale preference if set if (localeString != null) { String[] locValues = localeString.split("_"); if (locValues.length > 1) // language, country loc = new Locale(locValues[0], locValues[1]); else if (locValues.length == 1) // language loc = new Locale(locValues[0]); } if (loc == null) loc = Locale.getDefault(); } else { loc = (Locale) M_sm.getCurrentSession() .getAttribute(ResourceLoader.LOCALE_KEY + M_sm.getCurrentSessionUserId()); } } catch (NullPointerException e) { loc = Locale.getDefault(); } return loc; }
@Override public String getDefaultPrivacyState(String userId) { String privacy = null; if (userId != null) { Preferences prefs = preferencesService.getPreferences(userId); ResourceProperties props = prefs.getProperties(PRIVACY_PREFS); privacy = props.getProperty(PrivacyManager.DEFAULT_PRIVACY_KEY); } if (privacy == null) { // default privacy is visible privacy = PrivacyManagerImpl.VISIBLE; } return privacy; }
/** * Get the current user preference list value. First attempt Preferences, then defaults from * sakai.properties. * * @param name The property name. * @return The preference list value or null if not set. */ private static List getPreferenceList(String name) { Preferences prefs = M_ps.getPreferences(M_sm.getCurrentSessionUserId()); ResourceProperties rp = prefs.getProperties(PREFS_KEY); List l = rp.getPropertyList(name); return l; }
/** * Get the current user preference value. First attempt Preferences, then defaults from * sakai.properties. * * @param name The property name. * @return The preference value or null if not set. */ private static String getPreferenceString(String name) { Preferences prefs = M_ps.getPreferences(M_sm.getCurrentSessionUserId()); ResourceProperties rp = prefs.getProperties(PREFS_KEY); String value = rp.getProperty(name); return value; }