You are here

function _user_relationships_set_notifications in User Relationships 5

Same name and namespace in other branches
  1. 5.2 user_relationships.module \_user_relationships_set_notifications()
1 call to _user_relationships_set_notifications()
user_relationships_user in ./user_relationships_hooks.inc
User

File

./user_relationships.module, line 47

Code

function _user_relationships_set_notifications(&$account) {
  global $user;

  //only do this for the active user
  if ($account->uid != $user->uid) {
    return;
  }
  $notifications = drupal_get_messages('status', FALSE);
  $notifications = $notifications['status'] ? $notifications['status'] : array();
  $account_relationships = user_relationships_load_all_for_user($account->uid);
  foreach ($account_relationships as $relationship) {
    if (!$relationship->approved && $account->uid != $relationship->requester_id) {
      $msg = user_relationships_get_message('pending', array(
        '!requester' => theme('username', user_load(array(
          'uid' => $relationship->requester_id,
        ))),
        '%relationship_name' => $relationship->name,
        '%relationship_plural_name' => $relationship->plural_name,
        '!pending_relationship_requests' => l(t('pending relationship requests'), 'relationships/' . $account->uid . '/requests'),
      ));
      if (!in_array($msg, $notifications)) {
        drupal_set_message($msg);
      }
    }
  }
}