function tripal_set_message

2.x tripal_core.tripal.api.inc tripal_set_message($message, $importance = TRIPAL_INFO, $options = array())
3.x tripal.notice.api.inc tripal_set_message($message, $importance = TRIPAL_INFO, $options = array())

Display messages to tripal administrators.

This can be used instead of drupal_set_message when you want to target tripal administrators.

Parameters

$message: The message to be displayed to the tripal administrators

$importance: The level of importance for this message. In the future this will be used to allow administrators to filter some of these messages. It can be one of the following:

$options: Any options to apply to the current message. Supported options include:

  • return_html: return HTML instead of setting a drupal message. This can be used to place a tripal message in a particular place in the page. The default is FALSE.
19 calls to tripal_set_message()
chado_add_node_form_dbxrefs in tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc
Provides a form for adding to BASE_dbxref and dbxref tables
chado_add_node_form_properties in tripal_core/api/tripal_core.chado_nodes.properties.api.inc
chado_add_node_form_relationships in tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
Provides a form for adding to BASE_relationship and relationship tables
chado_library_form in tripal_library/includes/tripal_library.chado_node.inc
Implements hook_form().
chado_stock_form in tripal_stock/includes/tripal_stock.chado_node.inc
Implements hook_form(). Creates the main Add/Edit/Delete Form for chado stocks

... See full list

File

tripal_core/api/tripal_core.tripal.api.inc, line 170
Provides an application programming interface (API) for Tripal

Code

function tripal_set_message($message, $importance = TRIPAL_INFO, $options = array()) {
  global $user;

  // Only show the message to the users with 'view dev helps' permission.
  if (!user_access('view dev helps')) {
    return '';
  }

  // set defaults
  $options['return_html'] = (isset($options['return_html'])) ? $options['return_html'] : FALSE;

  // Get human-readable severity string
  $importance_string = '';
  switch ($importance) {
    case TRIPAL_CRITICAL:
      $importance_string = 'CRITICAL';
      break;
    case TRIPAL_ERROR:
      $importance_string = 'ERROR';
      break;
    case TRIPAL_WARNING:
      $importance_string = 'WARNING';
      break;
    case TRIPAL_NOTICE:
      $importance_string = 'NOTICE';
      break;
    case TRIPAL_INFO:
      $importance_string = 'INFO';
      break;
    case TRIPAL_DEBUG:
      $importance_string = 'DEBUG';
      break;
  }

  // Mark-up the Message
  $full_message =
    '<div class="tripal-site-admin-message">'
    . '<span class="tripal-severity-string ' . strtolower($importance_string) . '">' . $importance_string . ': </span>'
    . $message
    . '</div>';

  // Handle whether to return the HTML & let the caller deal with it
  // or to use drupal_set_message to put it near the top of the page  & let the theme deal with it
  if ($options['return_html']) {
    return '<div class="messages tripal-site-admin-only">' . $full_message . '</div>';
  }
  else {
    drupal_set_message($full_message, 'tripal-site-admin-only');
  }
}