留言板

How can I see when a user has joined a particular community?

thumbnail
Prakash Khanchandani,修改在12 年前。

How can I see when a user has joined a particular community?

Expert 帖子: 329 加入日期: 11-2-10 最近的帖子
Hi All,

I have a requirement to develop a portlet, which will show Users ordered by the joining date, i.e. the Date & time when the users joined a certain community.

Currently when I see the USERS_GROUPS table it has only the mapping of the user to the group (in my case community) and does not have any information regarding the date of joining the particular community.

Also in have searched the database and I couldn't find anywhere this joining date information.

I would be very grateful if anybody can give me some idea or direction as to where to look or how to proceed.

Thanks,
Ever grateful to the community. emoticon
thumbnail
Jan Gregor,修改在12 年前。

RE: How can I see when a user has joined a particular community?

Regular Member 帖子: 224 加入日期: 10-10-20 最近的帖子
Hi Prakash,

I am nut sure whether kind of functionality is implemented in Liferay. I would try maybe to have a look on the Social Equity API, maybe there is something useful. Anyways you can implement some model-listener hook, or service hook, or use ext-enviroment for triggering some log-operation after assigning a group object to user object.

Regards,

Jan.
thumbnail
Prakash Khanchandani,修改在12 年前。

RE: How can I see when a user has joined a particular community?

Expert 帖子: 329 加入日期: 11-2-10 最近的帖子
Thanks Jan,

I was also thinking of having a model-listener hook kind-of thing with Spring AOP if it is possible in liferay, and also how would I actually achieve it?

I will take a look at Social Equity, never thought of that.

If I were to create a portlet to show the join date for the members, I would create a different table to have a mapping of the userId, groupId, and a joindate column.

The problem is how to update the table when a user joins, leaves etc, some ideas I had are listed below:
1) Having some sort of point-cut (Spring AOP) or a listener implemented for the methods joinGroup and leaveGroup of LiveUsers class.
2) Or directly create a database trigger to update my mapping table. (The easiest, but I am not fully aware of the pros-cons).

So any feedback will be highly appreciated.

Thanks.

P.S.: By the way wouldn't it be better if Liferay can have this functionality emoticon, as this I think is a normal-basic functionality for a product of this magnitude and quality. Also if it is possible won't it be better to have a createdBy, createdDate, modifiedBy, modifiedDate in almost all the database tables except a few.
thumbnail
Jan Gregor,修改在12 年前。

RE: How can I see when a user has joined a particular community? (答复)

Regular Member 帖子: 224 加入日期: 10-10-20 最近的帖子
Hi Prakash,

I had a quick look at the social api yesterday, and i think the beste way to achieve this will be to use it. I am not 100 % convinced, whether it is already there, but it will definitelly not be difficult to add this action as a social activity. Afterwards, when you have this integration done, you can profit from the whole social equity api, functions and portlets.

Let me know if you have further questions.

Jan.
thumbnail
Prakash Khanchandani,修改在12 年前。

RE: How can I see when a user has joined a particular community?

Expert 帖子: 329 加入日期: 11-2-10 最近的帖子
Thanks Jan

Will look as to how I can add this action as a Social Activity and will definitely ask you if there is some problem.

Also if it works will post the solution, or atleast a description as to what exactly I did.

Thanks for the help emoticon
thumbnail
Jan Gregor,修改在12 年前。

RE: How can I see when a user has joined a particular community?

Regular Member 帖子: 224 加入日期: 10-10-20 最近的帖子
No problem,

Posting a solution on wiki is a very good practice, which helps all community to improve themself and save a lot of time and trial-and-error.

Jan.
thumbnail
Prakash Khanchandani,修改在12 年前。

RE: How can I see when a user has joined a particular community? (答复)

Expert 帖子: 329 加入日期: 11-2-10 最近的帖子
This is how I achieved it (this was the simplest method I could come up with):
1) I created a Portlet to display the members and their join date (order by descending join date).
2) I created a service for the new table with groupid, userid, joindate, having methods to displayUsers, addGroupUsers, deleteGroupUsers.
3) I created a service-hook on com.liferay.portal.service.UserLocalService
4) I customized the methods: addGroupUsers and unsetGroupUsers:

public class MyCustomUserLocalService extends UserLocalServiceWrapper {

	public MyCustomUserLocalService (UserLocalService userLocalService) {
		super(userLocalService);
	}

	// this method associates the user and the community, when the user joins a community
	public void addGroupUsers(long groupId, long[] userIds) throws PortalException, SystemException {

		super.addGroupUsers(groupId, userIds);

        /*
		 * this method inserts the record in my custom user-group table.
		 * And also sets the joinDate as the current server date before adding the record.
		 */
		MyUsersLocalServiceUtil.addGroupUsers(groupId, userIds);
	}

	// this method removes the association of user and community, when the user leaves the community
	public void unsetGroupUsers(long groupId, long[] userIds) throws PortalException, SystemException {

		super.unsetGroupUsers(groupId, userIds);

        /*
		 * this method deletes the record from my custom user-group table.
		 */
		MyUsersLocalServiceUtil.deleteGroupUsers(groupId, userIds);
	}
}


If somebody has achieved this with some other technique and which is more useful. Please find time to post it. emoticon

Thanks for all the help emoticon