Foren
How to get current organization name
Arvind Mishra, geändert vor 15 Jahren.
How to get current organization name
Regular Member Beiträge: 226 Beitrittsdatum: 13.02.08 Neueste Beiträge
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, geändert vor 13 Jahren.
RE: How to get current organizationId
Junior Member Beiträge: 95 Beitrittsdatum: 18.06.09 Neueste Beiträge
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, geändert vor 13 Jahren.
RE: How to get current organizationId
Regular Member Beiträge: 226 Beitrittsdatum: 13.02.08 Neueste Beiträge
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, geändert vor 13 Jahren.
RE: How to get current organizationId
Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträge
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, geändert vor 13 Jahren.
RE: How to get current organizationId
Junior Member Beiträge: 95 Beitrittsdatum: 18.06.09 Neueste Beiträge
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, geändert vor 13 Jahren.
RE: How to get current organizationId
Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste BeiträgeMallepula NarayanaGoud:
Hi Prakesh,
It is working fine!!!!!!
Thanks alot for Quick Response...
Thanks,
Narayana.
Welcome Narayana...
Arvind Mishra, geändert vor 13 Jahren.
RE: How to get current organizationId
Regular Member Beiträge: 226 Beitrittsdatum: 13.02.08 Neueste Beiträge
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, geändert vor 8 Jahren.
RE: How to get current organizationId
Regular Member Beiträge: 121 Beitrittsdatum: 14.05.13 Neueste BeiträgeApoorva 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, geändert vor 13 Jahren.
RE: How to get current organizationId
Junior Member Beiträge: 95 Beitrittsdatum: 18.06.09 Neueste Beiträge
Hi Arvind,
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
Neha Goyal, geändert vor 8 Jahren.
RE: How to get current organizationId
Regular Member Beiträge: 121 Beitrittsdatum: 14.05.13 Neueste BeiträgeMallepula 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, geändert vor 12 Jahren.
RE: How to get current organizationId
New Member Beiträge: 2 Beitrittsdatum: 20.06.11 Neueste BeiträgeArvind 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, geändert vor 12 Jahren.
RE: How to get current organizationId
Regular Member Beiträge: 188 Beitrittsdatum: 01.09.10 Neueste BeiträgeArvind 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, geändert vor 12 Jahren.
RE: How to get current organizationId
Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
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, geändert vor 12 Jahren.
RE: How to get current organization name
Regular Member Beiträge: 188 Beitrittsdatum: 01.09.10 Neueste Beiträge
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, geändert vor 11 Jahren.
RE: How to get current organization name
New Member Beitrag: 1 Beitrittsdatum: 07.03.13 Neueste Beiträge
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());
}
}
}
%>