function tripal_add_notification

3.x tripal.entities.api.inc tripal_add_notification($title, $details, $type, $actions, $submitter_id)

Allows a module to write to the admin notification table during the cron run.

Parameters

$title: A generic phrase indicating what the notification is for.

$details: A human-readable sentence or two describing the issue.

$type: A one word type indicating the type of notification. Tripal types include: Jobs, Fields. If no type is required please pass NULL.

$actions: A serialized PHP associative array containing the link and URL for each action. If not type is required please pass NULL.

$submitter_id: A unique ID provided by the submitter for checking to make sure that the notification is not added more than once.

Related topics

1 call to tripal_add_notification()
tripal_tripal_cron_notification in tripal/api/tripal.entities.api.inc
Refreshes the bundle such that new fields added by modules will be found during cron.

File

tripal/api/tripal.entities.api.inc, line 382
Provides an application programming interface (API) for working with TripalEntity content types (bundles) and their entities.

Code

function tripal_add_notification($title, $details, $type, $actions, $submitter_id) {
  $transaction = db_transaction();

  // Check the notification isn't already in the admin notification table.
  $dedup = db_select('tripal_admin_notfications', 'tan')
    ->fields('tan')
    ->condition('submitter_id', $submitter_id, '=')
    ->execute()->fetchAll();

  if (empty($dedup)) {
    try {
      $record = new stdClass;
      $record->details = $details;
      $record->title = $title;
      $record->submitter_id = $submitter_id;
      $record->actions = serialize($actions);
      $record->enabled = 1;
      $record->type = $type;
      $success = drupal_write_record('tripal_admin_notfications', $record);
    }
    catch (Exception $e) {
      $transaction->rollback();
      watchdog('tripal_cron', 'Could not write notification to database.');
    }
  }
}