Fórumok
How to get current organization name
Arvind Mishra, módosítva 15 év-val korábban
How to get current organization name
Regular Member Bejegyzések: 226 Csatlakozás dátuma: 2008.02.13. Legújabb bejegyzések
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, módosítva 13 év-val korábban
RE: How to get current organizationId
Junior Member Bejegyzések: 95 Csatlakozás dátuma: 2009.06.18. Legújabb bejegyzések
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, módosítva 13 év-val korábban
RE: How to get current organizationId
Regular Member Bejegyzések: 226 Csatlakozás dátuma: 2008.02.13. Legújabb bejegyzések
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, módosítva 13 év-val korábban
RE: How to get current organizationId
Liferay Master Bejegyzések: 658 Csatlakozás dátuma: 2010.06.15. Legújabb bejegyzések
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, módosítva 13 év-val korábban
RE: How to get current organizationId
Junior Member Bejegyzések: 95 Csatlakozás dátuma: 2009.06.18. Legújabb bejegyzések
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, módosítva 13 év-val korábban
RE: How to get current organizationId
Liferay Master Bejegyzések: 658 Csatlakozás dátuma: 2010.06.15. Legújabb bejegyzésekMallepula NarayanaGoud:
Hi Prakesh,
It is working fine!!!!!!
Thanks alot for Quick Response...
Thanks,
Narayana.
Welcome Narayana...
Arvind Mishra, módosítva 13 év-val korábban
RE: How to get current organizationId
Regular Member Bejegyzések: 226 Csatlakozás dátuma: 2008.02.13. Legújabb bejegyzések
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, módosítva 8 év-val korábban
RE: How to get current organizationId
Regular Member Bejegyzések: 121 Csatlakozás dátuma: 2013.05.14. Legújabb bejegyzésekApoorva 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, módosítva 13 év-val korábban
RE: How to get current organizationId
Junior Member Bejegyzések: 95 Csatlakozás dátuma: 2009.06.18. Legújabb bejegyzések
Hi Arvind,
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
Neha Goyal, módosítva 8 év-val korábban
RE: How to get current organizationId
Regular Member Bejegyzések: 121 Csatlakozás dátuma: 2013.05.14. Legújabb bejegyzésekMallepula 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, módosítva 12 év-val korábban
RE: How to get current organizationId
New Member Bejegyzések: 2 Csatlakozás dátuma: 2011.06.20. Legújabb bejegyzésekArvind 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, módosítva 12 év-val korábban
RE: How to get current organizationId
Regular Member Bejegyzések: 188 Csatlakozás dátuma: 2010.09.01. Legújabb bejegyzésekArvind 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, módosítva 12 év-val korábban
RE: How to get current organizationId
Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
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, módosítva 12 év-val korábban
RE: How to get current organization name
Regular Member Bejegyzések: 188 Csatlakozás dátuma: 2010.09.01. Legújabb bejegyzések
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, módosítva 11 év-val korábban
RE: How to get current organization name
New Member Bejegyzés: 1 Csatlakozás dátuma: 2013.03.07. Legújabb bejegyzések
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());
}
}
}
%>