2012-01-30 10 views
8

私はLiferay 6.0を使用しています。複数の組織があり、組織に応じてユーザーのリンク先ページを変更したいと考えています。Liferay:組織に応じてユーザーのランディングページを変更する

Liferayを新しくして、いくつかの提案を見つけようとしましたが、正しい答えが見つかりませんでした。

すぐに使えるツールでも可能ですか?コードを書くことなく?

コードが必要な場合は、最適な解決策は何ですか?

助けてください、 は、Liferayの6で

答えて

7

ありがとうdefault landing pageは、プロパティdefault.landing.page.pathで設定することができますが、それは、ポータルインスタンス内の各ユーザーに影響を与える一般的な設定です。

組織に応じてユーザーのランディングページを変更するには、"post login" portal eventのカスタムアクションが必要です。最終的には、カスタムログインアクションを指すように持っていlogin.events.postプロパティ:フックで

組織のユーザーを土地にするカスタムアクション組織のプライベートページ(上記のリンクから得られたもの):

public class CustomLandingPageAction extends Action { 

    public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException { 
      try { 
        doRun(request, response); 
      } catch (Exception e) { 
        throw new ActionException(e); 
      } 
    } 

    protected void doRun(HttpServletRequest request, HttpServletResponse response) 
      throws Exception { 

     long companyId = PortalUtil.getCompanyId(request); 
     String path = PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH);; 

     if (Validator.isNull(path)) { 
      User user = PortalUtil.getUser(request); 
      String language = user.getLocale().getLanguage(); 
      List<Organization> orgList = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); 

      // Default landing page: go to the path in DefaultLandingPageAction 
      LastPath lastPath = new LastPath(StringPool.BLANK, path, new HashMap<String, String[]>()); 

      // But if the logged user is in some community 
      if (!orgList.isEmpty()){ 
       // and such community has a private page 
       if (orgList.get(0).hasPrivateLayouts()) { 
        // go there instead 
        String orgFriendlyURL = orgList.get(0).getGroup().getFriendlyURL(); 
        String myPath = "/" + language + "/group" + orgFriendlyURL; 

        lastPath = new LastPath(StringPool.BLANK, myPath); 
       } 
      } 

      HttpSession session = request.getSession();       
      session.setAttribute(WebKeys.LAST_PATH, lastPath); 
     } 
    } 
} 
+0

ありがとうございました。 ここに私がしたものがあります: –

関連する問題