Package org.olat.core.id

Examples of org.olat.core.id.Preferences


  protected void formOK(UserRequest ureq) {
    UserManager um = UserManager.getInstance();
    Manager secMgr = ManagerFactory.getManager();
    // Refresh user from DB to prevent stale object issues
    tobeChangedIdentity = secMgr.loadIdentityByKey(tobeChangedIdentity.getKey());
    Preferences prefs = tobeChangedIdentity.getUser().getPreferences();
    prefs.setLanguage(language.getSelectedKey());
    prefs.setFontsize(fontsize.getSelectedKey());
    if (notificationInterval != null) {
      // only read notification interval if available, could be disabled by configuration
      prefs.setNotificationInterval(notificationInterval.getSelectedKey());     
    }

    // Maybe the user changed the font size
    if (ureq.getIdentity().equalsByPersistableKey(tobeChangedIdentity)) {
      int fontSize = Integer.parseInt(fontsize.getSelectedKey());
View Full Code Here


  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("title.prefs");
    setFormContextHelp(this.getClass().getPackage().getName(), "home-prefs.html", "help.hover.prefs");
   
    // load preferences
    Preferences prefs = tobeChangedIdentity.getUser().getPreferences();

    // Username
    StaticTextElement username = uifactory.addStaticTextElement("form.username", tobeChangedIdentity.getName(), formLayout);
    username.setEnabled(false);

    // Language
    Map<String, String> languages = I18nManager.getInstance().getEnabledLanguagesTranslated();
    String[] langKeys = StringHelper.getMapKeysAsStringArray(languages);
    String[] langValues = StringHelper.getMapValuesAsStringArray(languages);
    ArrayHelper.sort(langKeys, langValues, false, true, false);
    language = uifactory.addDropdownSingleselect("form.language", formLayout, langKeys, langValues, null);
    String langKey = prefs.getLanguage();
    // Preselect the users language if available. Maye not anymore enabled on
    // this server
    if (prefs.getLanguage() != null && I18nModule.getEnabledLanguageKeys().contains(langKey)) {
      language.select(prefs.getLanguage(), true);
    } else {
      language.select(I18nModule.getDefaultLocale().toString(), true);
    }

    // Font size
    String[] cssFontsizeValues = new String[] { translate("form.fontsize.xsmall"), translate("form.fontsize.small"),
        translate("form.fontsize.normal"), translate("form.fontsize.large"), translate("form.fontsize.xlarge"),
        translate("form.fontsize.presentation") };
    fontsize = uifactory.addDropdownSingleselect("form.fontsize", formLayout, cssFontsizeKeys, cssFontsizeValues, null);
    fontsize.select(prefs.getFontsize(), true);

    // Email notification interval
    NotificationsManager nMgr = NotificationsManager.getInstance();
    List<String> intervals = nMgr.getNotificationIntervals();
    if (intervals.size() > 0) {
      String[] intervalKeys = new String[intervals.size()];
      intervals.toArray(intervalKeys);
      String[] intervalValues = new String[intervalKeys.length];
      String i18nPrefix = "interval.";
      for (int i = 0; i < intervalKeys.length; i++) {
        intervalValues[i] = translate(i18nPrefix + intervalKeys[i]);
      }
      notificationInterval = uifactory.addDropdownSingleselect("form.notification", formLayout, intervalKeys, intervalValues, null);
      notificationInterval.select(prefs.getNotificationInterval(), true);     
    }

    // Text encoding
    Map<String, Charset> charsets = Charset.availableCharsets();
    String currentCharset = UserManager.getInstance().getUserCharset(tobeChangedIdentity);
View Full Code Here

  /**
   * @see org.olat.user.UserManager#createUser(java.lang.String, java.lang.String, java.lang.String)
   */
  public User createUser(String firstName, String lastName, String eMail) {
    User newUser = new UserImpl(firstName, lastName, eMail);
    Preferences prefs = newUser.getPreferences();
   
    Locale loc;
    // for junit test case: use German Locale
    if (Settings.isJUnitTest()) {
      loc = Locale.GERMAN;
    } else {
      loc = I18nModule.getDefaultLocale();
    }
    //Locale loc
    prefs.setLanguage(loc.toString());
    prefs.setFontsize("normal");
    prefs.setPresenceMessagesPublic(false);
    prefs.setInformSessionTimeout(false);
    return newUser;
  }
View Full Code Here

   
    setProperty(UserConstants.FIRSTNAME, firstname);
    setProperty(UserConstants.LASTNAME, lastname);
    setProperty(UserConstants.EMAIL, email);
   
    setPreferences(new Preferences() {
      public String getFontsize() {
        return null;
      }

      public String getNotificationInterval() {
View Full Code Here

          Authentication auth = ManagerFactory.getManager().findAuthentication(identity, OLATAuthenticationController.PROVIDER_OLAT);
          if (auth == null) {
            getWindowControl().setWarning(translate("password.cantchange"));
            return;
          }
          Preferences prefs = identity.getUser().getPreferences();
          Locale locale = I18nManager.getInstance().getLocaleOrDefault(prefs.getLanguage());
          ureq.getUserSession().setLocale(locale);
          myContent.contextPut("locale", locale);
          Translator userTrans = Util.createPackageTranslator(PwChangeController.class, locale) ;
          String emailAdress = identity.getUser().getProperty(UserConstants.EMAIL, locale);
          TemporaryKey tk = rm.loadTemporaryKeyByEmail(emailAdress);
View Full Code Here

      // set language
      String userLanguage = user.getPreferences().getLanguage();
      if (attributeChangeMap.containsKey(LANG_IDENTIFYER)) {
        String inputLanguage = attributeChangeMap.get(LANG_IDENTIFYER);
        if (!userLanguage.equals(inputLanguage)) {
          Preferences preferences = user.getPreferences();
          preferences.setLanguage(inputLanguage);
          user.setPreferences(preferences);
        }
      }

      Context vcContext = new VelocityContext();
View Full Code Here

        //FIXME
        UserManager um = UserManager.getInstance();
        User volatileUser = um.createUser(rf2.getTextElement(UserConstants.FIRSTNAME).getValue(),
            rf2.getTextElement(UserConstants.LASTNAME).getValue(), tempKey.getEmailAddress());
        // set user configured language
        Preferences preferences = volatileUser.getPreferences();
        preferences.setLanguage(rf2.getSingleSelectionElement("lang").getSelectedKey());
        volatileUser.setPreferences(preferences);
        // create an identity with the given username / pwd and the user object
        String login = rf2.getTextElement("usr_login").getValue();
        String pwd = rf2.getTextElement("pwd1").getValue();
        Identity persistedIdentity = rm.createNewUserAndIdentityFromTemporaryKey(login, pwd, volatileUser, tempKey);
View Full Code Here

TOP

Related Classes of org.olat.core.id.Preferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.