Foren

how to restrict the users who can add maximum 15 communites

Mohamed Faisal, geändert vor 12 Jahren.

how to restrict the users who can add maximum 15 communites

Junior Member Beiträge: 90 Beitrittsdatum: 12.08.09 Neueste Beiträge
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, geändert vor 12 Jahren.

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

Expert Beiträge: 427 Beitrittsdatum: 12.08.09 Neueste Beiträge
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, geändert vor 12 Jahren.

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

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
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, geändert vor 12 Jahren.

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

Junior Member Beiträge: 90 Beitrittsdatum: 12.08.09 Neueste Beiträge
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, geändert vor 12 Jahren.

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

Expert Beiträge: 427 Beitrittsdatum: 12.08.09 Neueste Beiträge
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, geändert vor 12 Jahren.

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

Junior Member Beiträge: 90 Beitrittsdatum: 12.08.09 Neueste Beiträge
Hi Anil,
yes, it is fetching total communities which that particular user added.

Regards,
Faisal
thumbnail
jelmer kuperus, geändert vor 12 Jahren.

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

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
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, geändert vor 12 Jahren.

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

Expert Beiträge: 427 Beitrittsdatum: 12.08.09 Neueste Beiträge
Ohh..sorry for my misunderstanding.Here you are not looking it for specific users instead doing it for all users.