Elgg  Version 4.3
AddToAclHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Friends;
4 
11 
19  public function __invoke(\Elgg\Event $event) {
20  $relationship_object = $event->getObject();
21  if (!$relationship_object instanceof \ElggRelationship) {
22  return;
23  }
24 
25  if ($relationship_object->relationship !== 'friend') {
26  return;
27  }
28 
29  $user = get_user($relationship_object->guid_one);
30  $friend = get_user($relationship_object->guid_two);
31 
32  if (!$user || !$friend) {
33  return;
34  }
35 
36  $acl = $user->getOwnedAccessCollection('friends');
37  if (empty($acl)) {
38  return;
39  }
40 
41  $acl->addMember($friend->guid);
42  }
43 }
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
Modifies ACL membership.
__invoke(\Elgg\Event $event)
Adds the friend to the user friend ACL.
$user
Definition: ban.php:7
Models an event passed to event handlers.
Definition: Event.php:11