You are here

function notifications_autosubscribe in Notifications 6.2

Same name and namespace in other branches
  1. 5 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe()
  2. 6.4 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe()
  3. 6 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

$event type: Event type

$field: String, field that subscription depends on. ie 'nid'.

$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 50
Notifications Autosubscribe module.

Code

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

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