This widget is an extention of the existing search and invite widget developed by Neel Haldar.The enhancement allows you to suggest a friend to some of your existing friends..It also allows you to approve friend suggestion requests, in addition to friend requests..
A simple friend request is where user A sends a friend request to user B.When user B sees this friend request and approves it, then user A and B become friends..This has been possible using search and Invite friends widget.
With friend suggestion request, user A can suggest some of his own friends(say user C) to user B..When user B logs in, he sees that user A has suggested him a friend,user C..Once user B approves this suggestion, a friend request is sent to user C, asking user C to add user B as his friend..After user C approves it user B and C become friends..
Lets take a concrete example to see how this suggest a friend feature works..We'll consider a use case where Bruno wants to suggest a friend ,Sarah to John..
Login as Bruno.Select "SuggestFriends" tab and click on "Search Friends" to view all Bruno's friends.
Bruno searches for all his friends and picks up John as the friend to whom he has to suggest some friends(Sarah)
Click on "suggest a friend" link besides John's name,to open a popup of all existing friends of Bruno.From this list select a friend(Sarah) whom Bruno would like to suggest to John
Click on "Suggest"..The result of "Suggest" action is updated immediatedly.
Incase John and Sarah are already friends then an suitable message(John and Sarah are already friends) is displayed..
When John logs in, he sees a friend suggestion request in "MyPendingRequests" tab. "MyPendingRequests" tab essentially performs the same function as the "Requests" portlet does.You can also use the "Requests" portlet to approve requests.
After John confirms the friend suggestion ,a friend request is automatically sent to Sarah..Now login as Sarah to see the friend request.
When Sarah confirms the friend request, Sarah and John become friends.
Sarah can use the "Myfriends" tab to view all her current friends.
Implementation Details
The widget uses Expando to store the 3rd users info i.e(Sarah in this case) by adding a column to SocialRequest table..Since 3 users are involved in a Suggestion Request as opposed to 2 in Friend Request, extending SocialRequest table was necessary.
table = ExpandoTableLocalServiceUtil.addDefaultTable(
"com.liferay.portlet.social.model.SocialRequest");
ExpandoColumnLocalServiceUtil.addColumn(table.getTableId(),"selectedfriendId",
ExpandoColumnConstants.LONG);
ExpandoValueLocalServiceUtil.addValue(
"com.liferay.portlet.social.model.SocialRequest",table.getName(),
"selectedfriendId", sr.getPrimaryKey(),Long.parseLong(selFriendId));
Also the widget extends FriendsRequestInterpreter of WOL portlet to interpret Friend Suggestion Request.
In the first image the search container shows the user portrait .It can be configured to show only username by setting a preference.
Click here for source.
Steps to generate war
1)Unzip search-suggest-invite-portlet.zip into Liferay plugin portlets directory (..\liferay\plugins\branches\5.2.x\portlets\)
2)cd ..\liferay\plugins\branches\5.2.x\portlets\search-suggest-invite-portlet
3)Run ant


