You are here

function avatar_selection_user_update in Avatar Selection 7

Implements hook_user_update().

File

./avatar_selection.module, line 420
The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user, and to the administrator to disable uploading other avatar files by the user.

Code

function avatar_selection_user_update(&$edit, $account, $category) {
  if (!empty($edit['select_avatar'])) {
    $usage = new stdClass();
    $usage->uid = $account->uid;
    $usage->fid = $edit['select_avatar'];
    $has_rows = (bool) db_query_range('SELECT 1 FROM {avatar_selection_usage} WHERE uid = :uid', 0, 1, array(
      ':uid' => $account->uid,
    ))
      ->fetchField();
    if ($has_rows) {
      drupal_write_record('avatar_selection_usage', $usage, 'uid');
    }
    else {
      drupal_write_record('avatar_selection_usage', $usage);
    }
  }
}