フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Tejas Kanani
How to get user's private page url
2011/09/27 23:32
答え

Tejas Kanani

ランク: Liferay Master

投稿: 653

参加年月日: 2009/01/06

最近の投稿

Hi,

How can we get user's private page url?
Like, if we need user's public home page then we can use user.getDisplayURL(themeDisplay).
Do we have any such method for getting user's private page url ?
Anil Sunkari
RE: How to get user's private page url
2011/09/27 23:56
答え

Anil Sunkari

ランク: Expert

投稿: 412

参加年月日: 2009/08/11

最近の投稿

If you are looking to get the private url only when user is existed on that page.....So,you can achieve it through themeDisplay.getURLCurrent() i hope.Correct me if you thinking of other scenario.
Sandeep Nair
RE: How to get user's private page url
2011/09/28 0:27
答え

Sandeep Nair

ランク: Liferay Legend

投稿: 1693

参加年月日: 2008/11/05

最近の投稿

Tejas Kanani:
Hi,

How can we get user's private page url?
Like, if we need user's public home page then we can use user.getDisplayURL(themeDisplay).
Do we have any such method for getting user's private page url ?



Hi Tejas,

If you see UserImpl where this getDisplayURL is implemented the logic is written for fetching the public page

 1public String getDisplayURL(String portalURL, String mainPath)
 2        throws PortalException, SystemException {
 3
 4        if (isDefaultUser()) {
 5            return StringPool.BLANK;
 6        }
 7
 8        Group group = getGroup();
 9
10        int publicLayoutsPageCount = group.getPublicLayoutsPageCount();
11
12        if (publicLayoutsPageCount > 0) {
13            StringBundler sb = new StringBundler(5);
14
15            sb.append(portalURL);
16            sb.append(mainPath);
17            sb.append("/my_places/view?groupId=");
18            sb.append(group.getGroupId());
19            sb.append("&privateLayout=0");
20
21            return sb.toString();
22        }
23
24        return StringPool.BLANK;
25    }


Just do the same for private ones. by passing privateLayout=1 and checking the condition privateLayoutsPageCount>0

Regards,
Sandeep
Tejas Kanani
RE: How to get user's private page url
2011/10/06 23:12
答え

Tejas Kanani

ランク: Liferay Master

投稿: 653

参加年月日: 2009/01/06

最近の投稿

Thanks Sandeep.

Its exactly same what I am looking for.
Cas Stigter
RE: How to get user's private page url
2012/10/09 7:38
答え

Cas Stigter

ランク: New Member

投稿: 5

参加年月日: 2011/06/28

最近の投稿

Hi,

I know you found a solution, I just wanted to add an example that doesn't use strings concatenation.
 1
 2    public void run(HttpServletRequest request, HttpServletResponse response)
 3            throws ActionException {
 4       
 5        String path = "";
 6        // attempt to get path to User private page
 7        User user = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request));
 8        // check for private layouts
 9        if (LayoutLocalServiceUtil.hasLayouts(user, true)) {
10            List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(user.getGroupId(), true);
11            if (layouts.size()>1){
12                _log.info("More then 1 private layout found for User while max. 1 is assumed. The last layout is returned.");
13            }
14            for (Layout layout : layouts) {               
15                path = PortalUtil.getLayoutActualURL(layout);
16            }                  
17        }
18
19        if (Validator.isNotNull(path)) {
20            LastPath lastPath = new LastPath(StringPool.BLANK, path,new HashMap<String, String[]>());
21            HttpSession session = request.getSession();
22            session.setAttribute(WebKeys.LAST_PATH, lastPath);
23        }       
24    }


I used this in a post login hook where ThemeDisplay isn't available.
Juan Fernández
RE: How to get user's private page url
2012/10/10 11:37
答え

Juan Fernández

LIFERAY STAFF

ランク: Liferay Legend

投稿: 1256

参加年月日: 2008/10/02

最近の投稿

I have created this ticket to avoid this in the future: LPS-30427
Regards,
Juan
sachin maheshwari
RE: How to get user's private page url
2013/09/04 22:30
答え

sachin maheshwari

ランク: Junior Member

投稿: 52

参加年月日: 2010/12/04

最近の投稿

This is the one i am looking for sort and simple.