You are here

function privatemsg_user_update in Privatemsg 7

Same name and namespace in other branches
  1. 7.2 privatemsg.module \privatemsg_user_update()

Implements hook_user_update().

1 call to privatemsg_user_update()
privatemsg_user_insert in ./privatemsg.module
Implements hook_user_insert().

File

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

Code

function privatemsg_user_update(&$edit, $account, $category) {
  if (isset($edit['pm_enable']) && (user_access('write privatemsg') || user_access('read privatemsg')) && user_access('allow disabling privatemsg')) {
    $current = privatemsg_is_disabled($account);
    $disabled = !$edit['pm_enable'];
    $edit['pm_enable'] = NULL;
    $account->privatemsg_disabled = $disabled;

    // only perform the save if the value has changed
    if ($current != $disabled) {
      if ($disabled) {
        db_insert('pm_disable')
          ->fields(array(
          'uid' => $account->uid,
        ))
          ->execute();
      }
      else {
        db_delete('pm_disable')
          ->condition('uid', $account->uid)
          ->execute();
      }
    }
  }
}