You are here

function privatemsg_user_access in Privatemsg 6.2

Same name and namespace in other branches
  1. 6 privatemsg.module \privatemsg_user_access()
  2. 7.2 privatemsg.module \privatemsg_user_access()
  3. 7 privatemsg.module \privatemsg_user_access()

Privatemsg wrapper for user_access.

Never allows anonymous user access as that doesn't makes sense.

Parameters

$permission: Permission string, defaults to read privatemsg

$account: User account to check permissions. If null, default to current user.

Return value

TRUE if user has access, FALSE if not.

Related topics

26 calls to privatemsg_user_access()
hook_privatemsg_view_messages_alter in ./privatemsg.api.php
Add content to the view thread page.
pm_email_notify_user in pm_email_notify/pm_email_notify.module
Implements hook_user().
privatemsg_delete in ./privatemsg.pages.inc
privatemsg_filter_create_tags in privatemsg_filter/privatemsg_filter.module
Function to create a tag
privatemsg_filter_dropdown in privatemsg_filter/privatemsg_filter.module

... See full list

1 string reference to 'privatemsg_user_access'
pm_block_user_menu in pm_block_user/pm_block_user.module
Implements hook_menu().

File

./privatemsg.module, line 275
Allows users to send private messages to other users.

Code

function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) {
  if ($account === NULL) {
    global $user;
    $account = $user;
  }

  // Disallow anonymous access, regardless of permissions.
  if (!$account->uid) {
    return FALSE;
  }

  // Deny write access if the user has privatemsg disabled.
  if (privatemsg_is_disabled($account) && $permission == 'write privatemsg') {
    return FALSE;
  }
  if (!user_access($permission, $account)) {
    return FALSE;
  }
  return TRUE;
}