You are here

function subscriptions_user_insert in Subscriptions 2.0.x

Same name in this branch
  1. 2.0.x subscriptions.module \subscriptions_user_insert()
  2. 2.0.x subscriptions.module.old.php \subscriptions_user_insert()
Same name and namespace in other branches
  1. 7 subscriptions.module \subscriptions_user_insert()

Implements hook_user_insert().

Set up the Subscriptions defaults for the new user.

Parameters

array $edit:

object $account:

null $category:

1 call to subscriptions_user_insert()
_subscriptions_get_setting in ./subscriptions.module.old.php
Helper function to retrieve send_self/autosub_on_post/autosub_on_update/autosub_on_comment/ | 1, 0, digest/send_interval/send_updates/send_comments/ | -1 = use default send_interval_visible/send_updates_visible/send_comments_visible/ | 1, 0, -1 = only…

File

./subscriptions.module.old.php, line 323
Subscriptions module.

Code

function subscriptions_user_insert(array $edit, &$account, $category) {
  $new_uid =& drupal_static('subscriptions_user_insert', 0);
  db_insert('subscriptions_user')
    ->fields(array(
    'uid' => $account->uid,
  ))
    ->execute();

  // $account->roles isn't set yet, subscriptions_user_load() below will
  // insert the role-specific initial subscriptions.
  $new_uid = $account->uid;
  $rids = array();
  foreach (array_keys($account->roles) as $rid) {
    $rids[] = -$rid;
  }
  $query = db_select('subscriptions', 's')
    ->fields('s', array(
    'module',
    'field',
    'value',
  ));
  $query
    ->addExpression($new_uid, 'recipient_uid');
  $query
    ->fields('s', array(
    'send_interval',
    'author_uid',
    'send_updates',
    'send_comments',
  ))
    ->condition('s.recipient_uid', $rids, 'IN');
  db_insert('subscriptions', array(
    'return' => Database::RETURN_NULL,
  ))
    ->from($query)
    ->execute();
}