留言板
How to get current organization name
Arvind Mishra,修改在15 年前。
How to get current organization name
Regular Member 帖子: 226 加入日期: 08-2-13 最近的帖子
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,修改在13 年前。
RE: How to get current organizationId
Junior Member 帖子: 95 加入日期: 09-6-18 最近的帖子
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,修改在13 年前。
RE: How to get current organizationId
Regular Member 帖子: 226 加入日期: 08-2-13 最近的帖子
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,修改在13 年前。
RE: How to get current organizationId
Liferay Master 帖子: 658 加入日期: 10-6-15 最近的帖子
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,修改在13 年前。
RE: How to get current organizationId
Junior Member 帖子: 95 加入日期: 09-6-18 最近的帖子
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,修改在13 年前。
RE: How to get current organizationId
Liferay Master 帖子: 658 加入日期: 10-6-15 最近的帖子Mallepula NarayanaGoud:
Hi Prakesh,
It is working fine!!!!!!
Thanks alot for Quick Response...
Thanks,
Narayana.
Welcome Narayana...
Arvind Mishra,修改在13 年前。
RE: How to get current organizationId
Regular Member 帖子: 226 加入日期: 08-2-13 最近的帖子
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,修改在8 年前。
RE: How to get current organizationId
Regular Member 帖子: 121 加入日期: 13-5-14 最近的帖子Apoorva 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,修改在13 年前。
RE: How to get current organizationId
Junior Member 帖子: 95 加入日期: 09-6-18 最近的帖子
Hi Arvind,
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
It is working fine!!!!!!
Thanks alot...
Thanks,
Narayana.
Neha Goyal,修改在8 年前。
RE: How to get current organizationId
Regular Member 帖子: 121 加入日期: 13-5-14 最近的帖子Mallepula 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??
Arvind 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,修改在12 年前。
RE: How to get current organizationId
Regular Member 帖子: 188 加入日期: 10-9-1 最近的帖子Arvind 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,修改在12 年前。
RE: How to get current organizationId
Liferay Legend 帖子: 1744 加入日期: 08-11-6 最近的帖子
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,修改在12 年前。
RE: How to get current organization name
Regular Member 帖子: 188 加入日期: 10-9-1 最近的帖子
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,修改在11 年前。
RE: How to get current organization name
New Member 发布: 1 加入日期: 13-3-7 最近的帖子
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());
}
}
}
%>