You are here

function privatemsg_groups_write_access in Privatemsg 7.2

Write permission check for group recipients.

1 call to privatemsg_groups_write_access()
privatemsg_groups_autocomplete in privatemsg_groups/privatemsg_groups.module
Provides autocomplete suggestions for group.
1 string reference to 'privatemsg_groups_write_access'
privatemsg_groups_privatemsg_recipient_type_info in privatemsg_groups/privatemsg_groups.module
Implements hook_privatemsg_recipient_type_info().

File

privatemsg_groups/privatemsg_groups.module, line 79
Allows to send messages to all members of an organic group

Code

function privatemsg_groups_write_access($recipient) {

  // Check if user has permission to write to all groups.
  if (user_access('write privatemsg to all organic groups')) {
    return TRUE;
  }

  // Check if user has permission to write to own groups.
  if (!user_access('write privatemsg to own organic groups')) {
    return FALSE;
  }
  if ($recipient) {
    $group_type = _privatemsg_groups_get_group_type($recipient->type);
    $gid = $recipient->recipient;
    return og_user_access($group_type, $gid, 'write privatemsg to group');
  }

  // Give access only to users that have group subscriptions.
  $gids = og_get_groups_by_user();
  return !empty($gids);
}