You are here

function user_relationships_api_privatemsg_restrict in User Relationships 6

2 calls to user_relationships_api_privatemsg_restrict()
user_relationships_api_privatemsg_block_message in user_relationships_api/user_relationships_api.privatemsg.inc
Blocks messages to users that are not in relationships with sender.
user_relationships_api_privatemsg_sql_autocomplete_alter in user_relationships_api/user_relationships_api.privatemsg.inc
Fills new Privatemsg autocomplete To: field with friends only.

File

user_relationships_api/user_relationships_api.privatemsg.inc, line 52
Integration with Privatemsg module @author mansspams http://drupal.org/user/293179 @author alex.k http://drupal.org/user/183217

Code

function user_relationships_api_privatemsg_restrict($author) {

  //#522078 admin killswitch, always ignore this for user 1.
  if (variable_get('user_relationships_restrict_privatemsg', 'all') == 'all' || $author->uid == 1) {
    return FALSE;
  }
  $exlude_roles = array_filter(variable_get('user_relationships_privatemsg_role_exclusions', array()));

  // First, make sure that we have a user object with roles, and then check if
  // the users does have any of the exluded roles.
  if (!empty($author->roles) || ($author = user_load($author->uid))) {
    $is_excluded = array_intersect(array_keys($author->roles), $exlude_roles);
    if (!empty($is_excluded)) {
      return FALSE;
    }
  }
  return TRUE;
}