Package org.olat.user

Source Code of org.olat.user.PersonalSettingsController

/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/

package org.olat.user;

import org.olat.basesecurity.Constants;
import org.olat.basesecurity.Manager;
import org.olat.basesecurity.ManagerFactory;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.tabbedpane.TabbedPane;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.ControllerEventListener;
import org.olat.core.gui.control.DefaultController;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.translator.PackageTranslator;
import org.olat.core.id.Identity;
import org.olat.core.logging.OLATSecurityException;
import org.olat.core.logging.Tracing;
import org.olat.core.servlets.WebDAVManager;
import org.olat.core.util.Util;
import org.olat.core.util.resource.OresHelper;
import org.olat.instantMessaging.InstantMessagingModule;
import org.olat.instantMessaging.ui.ChangeIMSettingsController;
import org.olat.registration.DisclaimerController;

/**
* Initial Date:  Jul 29, 2003
*
* @author Sabina Jeger
*
*/
public class PersonalSettingsController extends DefaultController implements ControllerEventListener {
  private static final String PACKAGE = Util.getPackageName(PersonalSettingsController.class);
  private static final String VELOCITY_ROOT = Util.getPackageVelocityRoot(PersonalSettingsController.class);

  private PackageTranslator translator;
  private TabbedPane userConfig;
 
  private Controller ucsc;
  private Controller pwdc;
  private Controller ccsc;
  private Controller hpec;
  private Controller cimsc;
  private Controller pwdav;
  private Controller disclaimerCtr;

  /**
   * @param ureq
   * @param wControl
   */
  public PersonalSettingsController(UserRequest ureq, WindowControl wControl) {
    super(wControl);
      translator = new PackageTranslator(PACKAGE, ureq.getLocale());
      Manager mgr = ManagerFactory.getManager();
      if (!mgr.isIdentityPermittedOnResourceable(
          ureq.getIdentity(),
          Constants.PERMISSION_ACCESS,
          OresHelper.lookupType(this.getClass())))
        throw new OLATSecurityException("Insufficient permissions to access PersonalSettingsController");

      userConfig = new TabbedPane("userConfig", ureq.getLocale());

      hpec = new ProfileAndHomePageEditController(ureq, getWindowControl(), (Identity)DBFactory.getInstance().loadObject(ureq.getIdentity()), false);
      userConfig.addTab(translator.translate("tab.profile"), hpec.getInitialComponent());
     
      ucsc = new ChangePrefsController(ureq, getWindowControl(), (Identity)DBFactory.getInstance().loadObject(ureq.getIdentity()));
      ucsc.addControllerListener(this);
      userConfig.addTab(translator.translate("tab.prefs"), ucsc.getInitialComponent());

      pwdc = new ChangePasswordController(ureq, getWindowControl());
      userConfig.addTab(translator.translate("tab.pwd"), pwdc.getInitialComponent());
     
      if(WebDAVManager.getInstance().isEnabled()) {
        pwdav = new WebDAVPasswordController(ureq, getWindowControl());
        userConfig.addTab(translator.translate("tab.pwdav"), pwdav.getInitialComponent());
      }
     
      if(InstantMessagingModule.isEnabled()){
        cimsc = new ChangeIMSettingsController(ureq, getWindowControl(), (Identity)DBFactory.getInstance().loadObject(ureq.getIdentity()));
        userConfig.addTab(translator.translate("tab.im"), cimsc.getInitialComponent());
      }

      // Show read only display of disclaimer so user sees what he accepted
      disclaimerCtr = new DisclaimerController(ureq, getWindowControl(), true);
      userConfig.addTab(translator.translate("tab.disclaimer"), disclaimerCtr.getInitialComponent());
     
      setInitialComponent(userConfig);
      if (Tracing.isDebugEnabled(PersonalSettingsController.class)){
        Tracing.logDebug("PersonalSettingsController constructed, set velocity page to index.html", PersonalSettingsController.class)
      }
  }

  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(UserRequest ureq, Component source, Event event) {
    // nothing to do here.
  }
 
  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(UserRequest ureq, Controller source, Event event) {
    // nothing to be done
  }
   
  /**
   *
   * @see org.olat.core.gui.control.DefaultController#doDispose(boolean)
   */
  @Override
  protected void doDispose() {
    if (ucsc != null) {
      ucsc.dispose();
      ucsc = null;
    }
    if (pwdc != null) {
      pwdc.dispose();
      pwdc = null;
    }
    if (ccsc != null) {
      ccsc.dispose();
      ccsc = null;
    }
    if (hpec != null) {
        hpec.dispose();
        hpec = null;
    }
    if (cimsc != null) {
        cimsc.dispose();
        cimsc = null;
    }
    if (disclaimerCtr != null) {
      disclaimerCtr.dispose();
      disclaimerCtr = null;
    }
  }

}
TOP

Related Classes of org.olat.user.PersonalSettingsController

TOP
Copyright © 2018 www.massapi.com. 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.