Foros de discusión
How to get user's private page url
Tejas Kanani, modificado hace 12 años.
How to get user's private page url
Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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 ?
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, modificado hace 12 años.
RE: How to get user's private page url
Expert Mensajes: 427 Fecha de incorporación: 12/08/09 Mensajes recientes
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, modificado hace 12 años.
RE: How to get user's private page url
Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientesTejas 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
public String getDisplayURL(String portalURL, String mainPath)
throws PortalException, SystemException {
if (isDefaultUser()) {
return StringPool.BLANK;
}
Group group = getGroup();
int publicLayoutsPageCount = group.getPublicLayoutsPageCount();
if (publicLayoutsPageCount > 0) {
StringBundler sb = new StringBundler(5);
sb.append(portalURL);
sb.append(mainPath);
sb.append("/my_places/view?groupId=");
sb.append(group.getGroupId());
sb.append("&privateLayout=0");
return sb.toString();
}
return StringPool.BLANK;
}
Just do the same for private ones. by passing privateLayout=1 and checking the condition privateLayoutsPageCount>0
Regards,
Sandeep
Tejas Kanani, modificado hace 12 años.
RE: How to get user's private page url
Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
Thanks Sandeep.
Its exactly same what I am looking for.
Its exactly same what I am looking for.
Cas Stigter, modificado hace 11 años.
RE: How to get user's private page url
New Member Mensajes: 5 Fecha de incorporación: 28/06/11 Mensajes recientes
Hi,
I know you found a solution, I just wanted to add an example that doesn't use strings concatenation.
I used this in a post login hook where ThemeDisplay isn't available.
I know you found a solution, I just wanted to add an example that doesn't use strings concatenation.
public void run(HttpServletRequest request, HttpServletResponse response)
throws ActionException {
String path = "";
// attempt to get path to User private page
User user = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request));
// check for private layouts
if (LayoutLocalServiceUtil.hasLayouts(user, true)) {
List<layout> layouts = LayoutLocalServiceUtil.getLayouts(user.getGroupId(), true);
if (layouts.size()>1){
_log.info("More then 1 private layout found for User while max. 1 is assumed. The last layout is returned.");
}
for (Layout layout : layouts) {
path = PortalUtil.getLayoutActualURL(layout);
}
}
if (Validator.isNotNull(path)) {
LastPath lastPath = new LastPath(StringPool.BLANK, path,new HashMap<string, string[]>());
HttpSession session = request.getSession();
session.setAttribute(WebKeys.LAST_PATH, lastPath);
}
}
</string,></layout>
I used this in a post login hook where ThemeDisplay isn't available.
Juan Fernández, modificado hace 11 años.
RE: How to get user's private page url
Liferay Legend Mensajes: 1261 Fecha de incorporación: 2/10/08 Mensajes recientes
sachin maheshwari, modificado hace 10 años.
RE: How to get user's private page url
Junior Member Mensajes: 52 Fecha de incorporación: 4/12/10 Mensajes recientes
This is the one i am looking for sort and simple.