You are here

function insight_alert_save in Insight 7

1 call to insight_alert_save()
insight_report_alerts_save in ./insight.module

File

./insight.module, line 306

Code

function insight_alert_save($alert) {

  // check if report already exists
  $alert0 = insight_alert_load_by_params(NULL, $alert['report'], $alert['name'], $alert['nid'], $alert['path']);
  $alert += array(
    'created' => REQUEST_TIME,
    'active' => 1,
  );
  if (isset($alert0['iaid'])) {
    $alert['iaid'] = $alert0['iaid'];
    drupal_write_record('insight_alert', $alert, array(
      'iaid',
    ));
  }
  else {
    drupal_write_record('insight_alert', $alert);
  }

  // Let other modules update as necessary on save.
  module_invoke_all('insight_alert_save', $alert);
  return $alert;
}