You are here

function subscriptions_autosubscribe in Subscriptions 5

Same name and namespace in other branches
  1. 5.2 subscriptions.module \subscriptions_autosubscribe()
  2. 6 subscriptions.module \subscriptions_autosubscribe()
  3. 7 subscriptions.module \subscriptions_autosubscribe()
  4. 2.0.x subscriptions.module.old.php \subscriptions_autosubscribe()

Subscribes users to nodes in which they post, if not already subscribed

2 calls to subscriptions_autosubscribe()
subscriptions_comment in ./subscriptions.module
Implementation of hook_comment().
subscriptions_nodeapi in ./subscriptions.module
Implementation of hook_nodeapi().

File

./subscriptions.module, line 619

Code

function subscriptions_autosubscribe($uid, $nid) {
  global $user;

  // if user has auto subscribe enabled
  if ($user->subscriptions_auto) {

    // check to see if already subscribed
    $result = db_query('SELECT sid FROM {subscriptions} WHERE sid = %d AND stype = \'node\' AND uid = %d', $nid, $uid);
    if (!db_num_rows($result)) {

      // if not, subscribe
      subscriptions_add($nid, $user->uid, 'node');
    }
  }
}