Fórum
How to get current organization name
Arvind Mishra, modificado 15 Anos atrás.
How to get current organization name
Regular Member Postagens: 226 Data de Entrada: 13/02/08 Postagens Recentes
Hi
How can i get the current organization name .. in which i am right now .
Actually i want to sent to user the login page of the current orgnazation when he logs out of this organization
I have written this piece of code in LogoutPostAction.java
but it prints
user group - user id :10134
Why its taking this organization as private user community .
thanks
arvind
How can i get the current organization name .. in which i am right now .
Actually i want to sent to user the login page of the current orgnazation when he logs out of this organization
I have written this piece of code in LogoutPostAction.java
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
com.liferay.portal.model.Group currentGroup = themeDisplay.getLayout().getGroup();
if (currentGroup.isUser()) {
// the group is a private user community
// getting the userId of the group's owner is
long userId = currentGroup.getClassPK();
System.out.println("user group - user id :" + userId );
}
else if (currentGroup.isOrganization()) {
// the group is an Organization
long organizationId = currentGroup.getClassPK();
System.out.println("Organization group - organizationId :" + organizationId );
}
else {
// its a normal community
System.out.println("its a normal community");
}
but it prints
user group - user id :10134
Why its taking this organization as private user community .
thanks
arvind
Mallepula NarayanaGoud, modificado 13 Anos atrás.
RE: How to get current organizationId
Junior Member Postagens: 95 Data de Entrada: 18/06/09 Postagens Recentes
Hi Arvind,
How can i get the current organizationId.. in which i am right now .
Actually i trying to build menu for individual organization, when user login to an organization menu is build.
But when an user is assign to multiple organizations, I want current organizationId of an organization were user is trying to login so that i can build menu.
Thanks in Advance.....
Thanks,
Narayana.
How can i get the current organizationId.. in which i am right now .
Actually i trying to build menu for individual organization, when user login to an organization menu is build.
But when an user is assign to multiple organizations, I want current organizationId of an organization were user is trying to login so that i can build menu.
Thanks in Advance.....
Thanks,
Narayana.
Arvind Mishra, modificado 13 Anos atrás.
RE: How to get current organizationId
Regular Member Postagens: 226 Data de Entrada: 13/02/08 Postagens Recentes
Above mentioned code should work
Otherwise u can get group id from themeDisplay.getScopeGroupId(). if group is organization then scope group id is your organizationid
Otherwise u can get group id from themeDisplay.getScopeGroupId(). if group is organization then scope group id is your organizationid
Apoorva Prakash, modificado 13 Anos atrás.
RE: How to get current organizationId
Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens Recentes
Hello Arvind,
you are right... But please consider the following code snippet too...
Thanks and regards...
you are right... But please consider the following code snippet too...
ThemeDisplay td = (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
User u=td.getUser();
System.out.println(u.getOrganizationIds());
Thanks and regards...
Mallepula NarayanaGoud, modificado 13 Anos atrás.
RE: How to get current organizationId
Junior Member Postagens: 95 Data de Entrada: 18/06/09 Postagens Recentes
Hi Prakesh,
It is working fine!!!!!!
Thanks alot for Quick Response...
Thanks,
Narayana.
It is working fine!!!!!!
Thanks alot for Quick Response...
Thanks,
Narayana.
Apoorva Prakash, modificado 13 Anos atrás.
RE: How to get current organizationId
Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens RecentesMallepula NarayanaGoud:
Hi Prakesh,
It is working fine!!!!!!
Thanks alot for Quick Response...
Thanks,
Narayana.
Welcome Narayana...
Arvind Mishra, modificado 13 Anos atrás.
RE: How to get current organizationId
Regular Member Postagens: 226 Data de Entrada: 13/02/08 Postagens Recentes
If you need to get the User , you can get it from HttpServletRequest itself.
User u = PortalUtil.getUser(request);
User u = PortalUtil.getUser(request);
Neha Goyal, modificado 8 Anos atrás.
RE: How to get current organizationId
Regular Member Postagens: 121 Data de Entrada: 14/05/13 Postagens RecentesApoorva Prakash:
Hello Arvind,
you are right... But please consider the following code snippet too...ThemeDisplay td = (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY); User u=td.getUser(); System.out.println(u.getOrganizationIds());
Thanks and regards...
Hi Apoorva,
What will happen when a user is a part of multiple organization.I think question was how to get current organization where he is right now.But with the help of above code we would get to which organization a logged in user belogs.
I think we should use group id and then get organization id as follow:
long groupId = com.liferay.portal.kernel.util.ParamUtil.getLong(request, "groupId");
long orgId = com.liferay.portal.service.GroupLocalServiceUtil.getGroup(groupId).getOrganizationId();
com.liferay.portal.model.Organization org = com.liferay.portal.service.OrganizationLocalServiceUtil.getOrganization(orgId);
Correct me if i am wrong.
Regards:
Neha
Mallepula NarayanaGoud, modificado 13 Anos atrás.
RE: How to get current organizationId
Junior Member Postagens: 95 Data de Entrada: 18/06/09 Postagens Recentes
Hi Arvind,
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
Neha Goyal, modificado 8 Anos atrás.
RE: How to get current organizationId
Regular Member Postagens: 121 Data de Entrada: 14/05/13 Postagens RecentesMallepula NarayanaGoud:
Hi Arvind,
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
Did you check which organization you will get if a user belogs to multiple organizations??
Gregg Archer, modificado 12 Anos atrás.
RE: How to get current organizationId
New Member Postagens: 2 Data de Entrada: 20/06/11 Postagens RecentesArvind Mishra:
Otherwise u can get group id from themeDisplay.getScopeGroupId(). if group is organization then scope group id is your organizationid
Thanks to Arvind's tip about getScopeGroupId(), I found that #theme_display.getScopeGroupName() was exactly what I needed to put the current org's name into a page title.
Hiran Chaudhuri, modificado 12 Anos atrás.
RE: How to get current organizationId
Regular Member Postagens: 188 Data de Entrada: 01/09/10 Postagens RecentesArvind Mishra:
Above mentioned code should work
Otherwise u can get group id from themeDisplay.getScopeGroupId(). if group is organization then scope group id is your organizationid
Hello, Arvind.
I do have the same problem, and your response sounds promising.
The scope group in my page looke like this (toString called):
{groupId=18, companyId=1, creatorUserId=5, classNameId=9, classPK=18, parentGroupId=0, liveGroupId=0, name=Guest, description=, type=1, typeSettings=, friendlyURL=/guest, active=true}
Now how would I detect from that whether I have an organization, a community or a private user page?
Sandeep Nair, modificado 12 Anos atrás.
RE: How to get current organizationId
Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
Use GroupLocalServiceUtil for example
GroupLocalServiceUtil.getGroup(groupId).isOrganization() --> tells whether its Organization
GroupLocalServiceUtil.getGroup(groupId).isCommunity() --> tells whether its Community
GroupLocalServiceUtil.getGroup(groupId).isUser() --> tells whether its Usr
Regards,
Sandeep
GroupLocalServiceUtil.getGroup(groupId).isOrganization() --> tells whether its Organization
GroupLocalServiceUtil.getGroup(groupId).isCommunity() --> tells whether its Community
GroupLocalServiceUtil.getGroup(groupId).isUser() --> tells whether its Usr
Regards,
Sandeep
Hiran Chaudhuri, modificado 12 Anos atrás.
RE: How to get current organization name
Regular Member Postagens: 188 Data de Entrada: 01/09/10 Postagens Recentes
Thank you for that quick help, Sandeep.
At the same time I also found http://www.liferay.com/community/forums/-/message_boards/message/10790380, in which they say you can simply use
Group currentGroup = themeDisplay.getLayout().getGroup();
currentGroup.isCommunity(), .isOrganization(), .isUser()
At the same time I also found http://www.liferay.com/community/forums/-/message_boards/message/10790380, in which they say you can simply use
Group currentGroup = themeDisplay.getLayout().getGroup();
currentGroup.isCommunity(), .isOrganization(), .isUser()
Juan Camilo Carrillo Casas, modificado 11 Anos atrás.
RE: How to get current organization name
New Member Mensagem: 1 Data de Entrada: 07/03/13 Postagens Recentes
To get the Site/Group Name always and not "Guest" use this:
group.getDescriptiveName()
I found the use of this method in the source code of Liferay, in dockbar view.jsp code you can see the use of them:
/portal-web/docroot/html/portlet/dockbar/view.jsp
Look at this fragment of code in line 22.
group.getDescriptiveName()
I found the use of this method in the source code of Liferay, in dockbar view.jsp code you can see the use of them:
/portal-web/docroot/html/portlet/dockbar/view.jsp
Look at this fragment of code in line 22.
<%
String refererGroupDescriptiveName = null;
String backURL = null;
if (themeDisplay.getRefererPlid() > 0) {
Layout refererLayout = LayoutLocalServiceUtil.fetchLayout(themeDisplay.getRefererPlid());
if (refererLayout != null) {
Group refererGroup = refererLayout.getGroup();
if (refererGroup.isUserGroup()) {
Group scopeGroup = themeDisplay.getScopeGroup();
if (scopeGroup.isUser()) {
refererGroup = scopeGroup;
refererLayout = new VirtualLayout(refererLayout, refererGroup);
}
}
refererGroupDescriptiveName = refererGroup.getDescriptiveName(locale);
if (refererGroup.isUser() && (refererGroup.getClassPK() == user.getUserId())) {
if (refererLayout.isPublicLayout()) {
refererGroupDescriptiveName = LanguageUtil.get(pageContext, "my-public-pages");
}
else {
refererGroupDescriptiveName = LanguageUtil.get(pageContext, "my-private-pages");
}
}
backURL = PortalUtil.getLayoutURL(refererLayout, themeDisplay);
if (!CookieKeys.hasSessionId(request)) {
backURL = PortalUtil.getURLWithSessionId(backURL, session.getId());
}
}
}
%>