functions.php 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * All helper functions are bundled here
  4. */
  5. /**
  6. * Create river events when a friend is added
  7. *
  8. * @param int $user_guid the user who is accepting
  9. * @param int $friend_guid the friend who he accepted
  10. *
  11. * @return bool
  12. */
  13. function friend_request_create_river_events($user_guid, $friend_guid) {
  14. $user_guid = sanitise_int($user_guid, false);
  15. $friend_guid = sanitise_int($friend_guid, false);
  16. if (empty($user_guid) || empty($friend_guid)) {
  17. return false;
  18. }
  19. // check plugin setting
  20. if (elgg_get_plugin_setting('add_river', 'friend_request') === 'no') {
  21. // no event are to be created
  22. return true;
  23. }
  24. // add to river
  25. elgg_create_river_item([
  26. 'view' => 'river/relationship/friend/create',
  27. 'action_type' => 'friend',
  28. 'subject_guid' => $user_guid,
  29. 'object_guid' => $friend_guid,
  30. ]);
  31. elgg_create_river_item([
  32. 'view' => 'river/relationship/friend/create',
  33. 'action_type' => 'friend',
  34. 'subject_guid' => $friend_guid,
  35. 'object_guid' => $user_guid,
  36. ]);
  37. return true;
  38. }