Change addFriend function to allow approval by selected friend

Permalink
I want to change the way the "Add Friend" function works in the "Members/profiles" views. Once you search for a friend's name, you have the choice to add them as a friend.

I would rather it be a request to add a friend where the friend has to approve the request before the friend appears in the requestor's friend list to limit unwanted associations among members.

In the Profile/view/x, the public viewable attributes would be limited until the profiled person is an approved friend.

In the code below "addFriend function in \users_friends.php, $status field value of null is added to the SQL UsersFriends table with every added friend. Can this column be used for "Approval" Status?


static function addFriend( $friendUID, $uID=0, $status=''){
if( !intval($friendUID) ) return false;
if( !intval($uID) ){$u = new User();
if(!$u || !intval($u->uID)) return false;
$uID=$u->uID;}
$db = Loader::db();         
if( UsersFriends::isFriend( $friendUID, $uID ) ){
$vals = array( $status, $friendUID, $uID );
$sql = 'UPDATE UsersFriends SET status=? WHERE friendUID=? AND uID=?'; 
}else{ 
$vals = array( $friendUID, $uID, $status, date("Y-m-d H:i:s")); 
$sql = 'INSERT INTO UsersFriends ( friendUID, uID, status, uDateAdded ) values (?, ?, ?, ?)'; 
}         
$db->query($sql,$vals); 
return true;

merill00
 
synlag replied on at Permalink Reply
synlag
Interesting point, adding friends without an approval isn't good if you want to build a community page.
It would be useful, if friend request are send via mail and approvals like at fb ;)
I guess the status can be used for that, opinions?
htarlov replied on at Permalink Reply
htarlov
Hi, did you find out some kind of solution?
mibookscom replied on at Permalink Reply
Did anybody get anywhere with this?
Or can anyone shed light on the code required to try and achieve the "request / approval" function?
ranxem replied on at Permalink Reply 1 Attachment
ranxem
My friend request function is not working at all. 'Member Search' window in Profile doesn't give any results at all.

Example is attached.

Please assist.