1 dblog.admin.inc dblog_format_message($event, $is_link = FALSE)

Returns HTML for a log message.

Parameters

object $event: An object containing at least the message and variables properties.

bool $is_link: (optional) Format message as link, event->wid is required.

Return value

string: HTML containing a link to the full report.

File

core/modules/dblog/dblog.admin.inc, line 294
Admin page callbacks for the Database Logging module.

Code

function dblog_format_message($event, $is_link = FALSE) {
  $output = '';
  // Check for required properties.
  if (isset($event->message) && isset($event->variables)) {
    $event_variables = @unserialize($event->variables);
    // Messages without variables or user specified text.
    if ($event_variables === NULL) {
      $output = $event->message;
    }
    elseif (!is_array($event_variables)) {
      $output = t('Log data is corrupted and cannot be unserialized: @message', array(
        '@message' => $event->message,
      ));
    }
    // Message to translate with injected variables.
    else {
      $output = t($event->message, $event_variables);
    }
    // If the output is expected to be a link, strip all the tags and
    // special characters by using filter_xss() without any allowed tags.
    // If not, use filter_xss_admin() to allow some tags.
    if ($is_link && isset($event->wid)) {
      // Truncate message after stripping all the tags.
      $output = truncate_utf8(filter_xss($output, array()), config_get('system.core', 'log_max_length'), TRUE, TRUE);
      $output = l($output, 'admin/reports/event/' . $event->wid, array('html' => TRUE));
    }
    else {
      // Prevent XSS in log detail pages.
      $output = filter_xss_admin($output);
    }
  }

  return $output;
}