留言板

how to restrict the users who can add maximum 15 communites

Mohamed Faisal,修改在12 年前。

how to restrict the users who can add maximum 15 communites

Junior Member 帖子: 90 加入日期: 09-8-12 最近的帖子
Hi,

we have developed a social network site like facebook.

here, registered user can add groups. For this i have customized "My communities" portlet and kept in user's private page, its working fine.

now i would like to restrict the user can add maximum 15 groups.

Please help me to do this task.

Thanks,
Faisal
thumbnail
Anil Sunkari,修改在12 年前。

RE: how to restrict the users who can add maximum 15 communites

Expert 帖子: 427 加入日期: 09-8-12 最近的帖子
My idea is create one custom_field.You already customized My Communities.So, while user adds a community you have to update the custom_field value mapping with userId.Later while populating communites check the count which you want to restrict and make Add_Community option as hide & make an property entry of your count.This is Only my idea! You can think better than this!.

Regards,
Anil Sunkari
thumbnail
jelmer kuperus,修改在12 年前。

RE: how to restrict the users who can add maximum 15 communites

Liferay Legend 帖子: 1191 加入日期: 10-3-10 最近的帖子
Probably create a service hook, that intercepts calls to addGroup. Create a dynamic query to count the number of communities the user has already createed and throw an exception if the number of communities this user created exceeds the threshold. Then handle that exception in the view
Mohamed Faisal,修改在12 年前。

RE: how to restrict the users who can add maximum 15 communites

Junior Member 帖子: 90 加入日期: 09-8-12 最近的帖子
I have got the solution by using

List results = GroupLocalServiceUtil.search(company.getCompanyId(), null, null, groupParams, -1, -1, null);

here, we can get total communties user added. Then we can check result.size

<c:if test="<%= showAddButton && PortalPermissionUtil.contains(permissionChecker, ActionKeys.ADD_COMMUNITY) && results.size() <= 14%>">
<aui:button onClick='<%= renderResponse.getNamespace() + "addGroup();" %>' value="add-community" />
</c:if>

it is working fine.

Regards,
Faisal
thumbnail
Anil Sunkari,修改在12 年前。

RE: how to restrict the users who can add maximum 15 communites

Expert 帖子: 427 加入日期: 09-8-12 最近的帖子
Hi Faisal,

Appreciate for your work done.Here i have a query(results.size()).Is these results are fetching based on user???

Thanks,
Anil Sunkari
Mohamed Faisal,修改在12 年前。

RE: how to restrict the users who can add maximum 15 communites

Junior Member 帖子: 90 加入日期: 09-8-12 最近的帖子
Hi Anil,
yes, it is fetching total communities which that particular user added.

Regards,
Faisal
thumbnail
jelmer kuperus,修改在12 年前。

RE: how to restrict the users who can add maximum 15 communites

Liferay Legend 帖子: 1191 加入日期: 10-3-10 最近的帖子
That will work. But I do hope you realize that this offers no security what so ever. Because you are only removing the button from the interface a moderately clever person could still add a comunity if he knew what url to invoke. Also there is always the possibility that there are multiple entry points to adding a community. So you may end up playing whack-a-mole trying to hide buttons everytime some user discovers a new backdoor
thumbnail
Anil Sunkari,修改在12 年前。

RE: how to restrict the users who can add maximum 15 communites

Expert 帖子: 427 加入日期: 09-8-12 最近的帖子
Ohh..sorry for my misunderstanding.Here you are not looking it for specific users instead doing it for all users.