You are here

function notifications_autosubscribe in Notifications 6.4

Same name and namespace in other branches
  1. 5 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe()
  2. 6 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe()
  3. 6.2 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe()
  4. 6.3 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe()

Subscribes users to content they post, if not already subscribed

Parameters

$account: User account to subscribe

$type: Subscription type

$field: Object or key field

$value: Int, value of $field that triggers subscription.

2 calls to notifications_autosubscribe()
notifications_autosubscribe_comment in notifications_autosubscribe/notifications_autosubscribe.module
Implementation of hook_comment().
notifications_autosubscribe_nodeapi in notifications_autosubscribe/notifications_autosubscribe.module
Implementation of hook_nodeapi()

File

notifications_autosubscribe/notifications_autosubscribe.module, line 48
Notifications Autosubscribe module.

Code

function notifications_autosubscribe($account, $type, $field, $value) {

  // if user has auto subscribe enabled and he's not already subscribed to this object
  if (notifications_user_setting('auto', $account) && !notifications_get_subscriptions(array(
    'type' => $type,
    'uid' => $account->uid,
  ), array(
    $field => $value,
  ))) {
    $subscription = array(
      'uid' => $account->uid,
      'type' => $type,
      'fields' => array(
        $field => $value,
      ),
    );
    notifications_save_subscription($subscription);
  }
}