Elgg  Version master
Friends.php
Go to the documentation of this file.
1 <?php
2 
4 
10 trait Friends {
11 
20  public function addFriend(int $friend_guid, bool $create_river_item = false) {
21  if (!get_user($friend_guid)) {
22  return false;
23  }
24 
25  if (!$this->addRelationship($friend_guid, 'friend')) {
26  return false;
27  }
28 
29  if ($create_river_item) {
31  'view' => 'river/relationship/friend/create',
32  'action_type' => 'friend',
33  'subject_guid' => $this->guid,
34  'object_guid' => $friend_guid,
35  ]);
36  }
37 
38  return true;
39  }
40 
48  public function removeFriend(int $friend_guid): bool {
49  return $this->removeRelationship($friend_guid, 'friend');
50  }
51 
59  public function isFriendsWith(int $user_guid): bool {
60  return $this->hasRelationship($user_guid, 'friend');
61  }
62 
70  public function isFriendOf(int $user_guid): bool {
71  return (bool) _elgg_services()->relationshipsTable->check($user_guid, 'friend', $this->guid);
72  }
73 }
$user_guid
Definition: login_as.php:10
elgg_create_river_item(array $options=[])
Elgg river.
Definition: river.php:28
$friend_guid
Assembles and outputs the registration page.
Definition: register.php:12
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346