Change addFriend function to allow approval by selected friend
PermalinkI 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;
Or can anyone shed light on the code required to try and achieve the "request / approval" function?
Example is attached.
Please assist.
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?