You are here

function oa_notifications_add in Open Atrium Notifications 7.2

Add a new notification to a node

Parameters

$nid:

$type:

$id:

File

./oa_notifications.module, line 392

Code

function oa_notifications_add($nid, $type, $id) {

  // See if record already exists
  $query = db_select('oa_notifications', 'n')
    ->fields('n', array(
    'notification_id',
  ))
    ->condition('n.source_id', $nid)
    ->condition('n.source_type', 'node')
    ->condition('n.target_type', $type)
    ->condition('n.target_id', $id);
  $results = $query
    ->execute()
    ->fetchCol(0);
  if (empty($results)) {

    // Add new notification record
    $n = oa_notifications_make($type, $id, 'node', $nid);
    drupal_write_record('oa_notifications', $n);
  }
}