function privatemsg_user_access

1 privatemsg.module privatemsg_user_access($permission = 'read privatemsg', $account = NULL)
7-1 privatemsg.module privatemsg_user_access($permission = 'read privatemsg', $account = NULL)
7-2 privatemsg.module privatemsg_user_access($permission = 'read privatemsg', $account = NULL)
6-2 privatemsg.module privatemsg_user_access($permission = 'read privatemsg', $account = NULL)

Privatemsg wrapper for user_access.

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

Parameters

$permission: Permission string, defaults to read privatemsg

Return value

TRUE if user has access, FALSE if not

Related topics

26 calls to privatemsg_user_access()
hook_privatemsg_view_alter in ./privatemsg.api.php
Add content to the view thread page.
pm_email_notify_form_user_profile_form_alter in pm_email_notify/pm_email_notify.module
Implements hook_form_FORM_ID_alter().
privatemsg_check_format_access in ./privatemsg.pages.inc
After build callback; Hide format widget if user doesn't have permission.
privatemsg_delete in ./privatemsg.pages.inc
privatemsg_filter_create_tags in privatemsg_filter/privatemsg_filter.module
Function to create a tag

... See full list

3 string references to 'privatemsg_user_access'
pm_block_user_menu in pm_block_user/pm_block_user.module
Implements hook_menu().
privatemsg_filter_menu in privatemsg_filter/privatemsg_filter.module
Implements hook_menu().
privatemsg_menu in ./privatemsg.module
Implements hook_menu().

File

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

Code

function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) {
  static $disabled_displayed = FALSE;
  if ($account === NULL) {
    global $user;
    $account = $user;
  }
  if (!$account->uid) { // Disallow anonymous access, regardless of permissions
    return FALSE;
  }
  if (privatemsg_is_disabled($account) && ($permission == 'write privatemsg')) {
    if (arg(0) == 'messages' && variable_get('privatemsg_display_disabled_message', TRUE) && !$disabled_displayed) {
      $disabled_displayed = TRUE;
      drupal_set_message(t('You have disabled Privatemsg and are not allowed to write messages. Go to your <a href="@settings_url">Account settings</a> to enable it again.', array('@settings_url' => url('user/' . $account->uid . '/edit'))), 'warning');
    }
    return FALSE;
  }
  if (!user_access($permission, $account)) {
    return FALSE;
  }
  return TRUE;
}