Search in sources :

Example 1 with HomePageConfig

use of org.olat.user.HomePageConfig in project OpenOLAT by OpenOLAT.

the class VideoAdminListController method showUserInfo.

/**
 * Method to open the users visiting card in a new tab. Public to call it also from the parent controller
 * @param ureq
 */
public void showUserInfo(UserRequest ureq, Identity userID) {
    homePageDisplayController = new HomePageDisplayController(ureq, getWindowControl(), userID, new HomePageConfig());
    closeableModalController = new CloseableModalController(getWindowControl(), translate("close"), homePageDisplayController.getInitialComponent(), true, translate("video.contact"));
    listenTo(closeableModalController);
    closeableModalController.activate();
}
Also used : HomePageConfig(org.olat.user.HomePageConfig) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) HomePageDisplayController(org.olat.user.HomePageDisplayController)

Example 2 with HomePageConfig

use of org.olat.user.HomePageConfig in project openolat by klemens.

the class IdentityDocument method createDocument.

/**
 * Factory method to create a new IdentityDocument
 * @param searchResourceContext
 * @param wikiPage
 * @return
 */
public static Document createDocument(SearchResourceContext searchResourceContext, Identity identity) {
    UserManager userMgr = UserManager.getInstance();
    User user = identity.getUser();
    HomePageConfigManager homepageMgr = HomePageConfigManagerImpl.getInstance();
    HomePageConfig publishConfig = homepageMgr.loadConfigFor(identity.getName());
    IdentityDocument identityDocument = new IdentityDocument();
    identityDocument.setTitle(identity.getName());
    identityDocument.setCreatedDate(user.getCreationDate());
    // loop through all user properties and collect the content string and the last modified
    List<UserPropertyHandler> userPropertyHanders = userMgr.getUserPropertyHandlersFor(IdentityDocument.class.getName(), false);
    StringBuilder content = new StringBuilder();
    for (UserPropertyHandler userPropertyHandler : userPropertyHanders) {
        String propertyName = userPropertyHandler.getName();
        // only index fields the user has published!
        if (publishConfig.isEnabled(propertyName)) {
            String value = user.getProperty(propertyName, I18nModule.getDefaultLocale());
            if (value != null) {
                content.append(value).append(" ");
            }
        }
    }
    // user text
    String text = publishConfig.getTextAboutMe();
    if (StringHelper.containsNonWhitespace(text)) {
        text = FilterFactory.getHtmlTagsFilter().filter(text);
        content.append(text).append(' ');
    }
    // finally use the properties as the content for this identity
    if (content.length() > 0) {
        identityDocument.setContent(content.toString());
    }
    identityDocument.setResourceUrl(searchResourceContext.getResourceUrl());
    identityDocument.setDocumentType(searchResourceContext.getParentContextType());
    identityDocument.setCssIcon(CSSHelper.CSS_CLASS_USER);
    if (log.isDebug())
        log.debug(identityDocument.toString());
    return identityDocument.getLuceneDocument();
}
Also used : HomePageConfig(org.olat.user.HomePageConfig) User(org.olat.core.id.User) UserManager(org.olat.user.UserManager) HomePageConfigManager(org.olat.user.HomePageConfigManager) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 3 with HomePageConfig

use of org.olat.user.HomePageConfig in project openolat by klemens.

the class UserVOFactory method get.

public static UserVO get(Identity identity, Locale locale, boolean allProperties, boolean isAdmin, boolean withPortrait) {
    if (locale == null) {
        locale = I18nModule.getDefaultLocale();
    }
    UserVO userVO = new UserVO();
    User user = identity.getUser();
    userVO.setKey(identity.getKey());
    if (identity != null) {
        userVO.setLogin(identity.getName());
    }
    userVO.setExternalId(identity.getExternalId());
    userVO.setFirstName(user.getProperty(UserConstants.FIRSTNAME, null));
    userVO.setLastName(user.getProperty(UserConstants.LASTNAME, null));
    userVO.setEmail(user.getProperty(UserConstants.EMAIL, null));
    if (withPortrait) {
        File portrait = DisplayPortraitManager.getInstance().getSmallPortrait(identity.getName());
        if (portrait != null && portrait.exists()) {
            try {
                InputStream input = new FileInputStream(portrait);
                byte[] datas = IOUtils.toByteArray(input);
                FileUtils.closeSafely(input);
                byte[] data64 = Base64.encodeBase64(datas);
                userVO.setPortrait(new String(data64, "UTF8"));
            } catch (IOException e) {
                log.error("", e);
            }
        }
    }
    if (allProperties) {
        UserManager um = UserManager.getInstance();
        HomePageConfig hpc = isAdmin ? null : HomePageConfigManagerImpl.getInstance().loadConfigFor(identity.getName());
        List<UserPropertyHandler> propertyHandlers = um.getUserPropertyHandlersFor(UserWebService.PROPERTY_HANDLER_IDENTIFIER, false);
        for (UserPropertyHandler propertyHandler : propertyHandlers) {
            String propName = propertyHandler.getName();
            if (hpc != null && !hpc.isEnabled(propName)) {
                continue;
            }
            if (!UserConstants.FIRSTNAME.equals(propName) && !UserConstants.LASTNAME.equals(propName) && !UserConstants.EMAIL.equals(propName)) {
                String value = propertyHandler.getUserProperty(user, locale);
                userVO.putProperty(propName, value);
            }
        }
    }
    return userVO;
}
Also used : HomePageConfig(org.olat.user.HomePageConfig) User(org.olat.core.id.User) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) UserManager(org.olat.user.UserManager) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 4 with HomePageConfig

use of org.olat.user.HomePageConfig in project openolat by klemens.

the class VideoAdminErrorController method showUserInfo.

/**
 * Method to open the users visiting card in a new tab. Public to call it also from the parent controller
 * @param ureq
 */
public void showUserInfo(UserRequest ureq, Identity userID) {
    homePageDisplayController = new HomePageDisplayController(ureq, getWindowControl(), userID, new HomePageConfig());
    closeableModalController = new CloseableModalController(getWindowControl(), translate("close"), homePageDisplayController.getInitialComponent(), true, translate("video.contact"));
    listenTo(closeableModalController);
    closeableModalController.activate();
}
Also used : HomePageConfig(org.olat.user.HomePageConfig) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) HomePageDisplayController(org.olat.user.HomePageDisplayController)

Example 5 with HomePageConfig

use of org.olat.user.HomePageConfig in project openolat by klemens.

the class VideoAdminListController method showUserInfo.

/**
 * Method to open the users visiting card in a new tab. Public to call it also from the parent controller
 * @param ureq
 */
public void showUserInfo(UserRequest ureq, Identity userID) {
    homePageDisplayController = new HomePageDisplayController(ureq, getWindowControl(), userID, new HomePageConfig());
    closeableModalController = new CloseableModalController(getWindowControl(), translate("close"), homePageDisplayController.getInitialComponent(), true, translate("video.contact"));
    listenTo(closeableModalController);
    closeableModalController.activate();
}
Also used : HomePageConfig(org.olat.user.HomePageConfig) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) HomePageDisplayController(org.olat.user.HomePageDisplayController)

Aggregations

HomePageConfig (org.olat.user.HomePageConfig)10 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 HomePageDisplayController (org.olat.user.HomePageDisplayController)6 User (org.olat.core.id.User)4 UserManager (org.olat.user.UserManager)4 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)4 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Identity (org.olat.core.id.Identity)2 HomePageConfigManager (org.olat.user.HomePageConfigManager)2