You are here

function privatemsg_is_disabled in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg.module \privatemsg_is_disabled()
  2. 7.2 privatemsg.module \privatemsg_is_disabled()

Checks the status of private messaging for provided user.

Parameters

user object to check:

Return value

TRUE if user has disabled private messaging, FALSE otherwise

4 calls to privatemsg_is_disabled()
privatemsg_form_alter in ./privatemsg.module
Implements hook_form_alter().
privatemsg_privatemsg_block_message in ./privatemsg.module
Implements hook_privatemsg_block_message().
privatemsg_user_access in ./privatemsg.module
Privatemsg wrapper for user_access.
privatemsg_user_update in ./privatemsg.module
Implements hook_user_update().

File

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

Code

function privatemsg_is_disabled($account) {
  if (!$account || !isset($account->uid) || !$account->uid) {
    return FALSE;
  }
  if (!isset($account->privatemsg_disabled)) {

    // Make sure we have a fully loaded user object and try to load it if not.
    if ((!empty($account->roles) || ($account = user_load($account->uid))) && user_access('allow disabling privatemsg', $account)) {
      $account->privatemsg_disabled = (bool) db_query('SELECT 1 FROM {pm_disable} WHERE uid = :uid ', array(
        ':uid' => $account->uid,
      ))
        ->fetchField();
    }
    else {
      $account->privatemsg_disabled = FALSE;
    }
  }
  return $account->privatemsg_disabled;
}