You are here

function popup_message_init in Popup message 6

Same name and namespace in other branches
  1. 7 popup_message.module \popup_message_init()

Implements hook_init().

File

./popup_message.module, line 56
Main module file.

Code

function popup_message_init() {

  // Check permissions to display message.
  $permission = user_access('display popup message');

  // Get status: enabled/disabled.
  $status = variable_get('popup_message_enable', 1);

  // Allow other modules to modiffy permissions.
  drupal_alter('popup_message_permission', $permission);
  if ($permission && $status) {
    $message_title = filter_xss(variable_get('popup_message_title', ''));
    $message_body = check_markup(variable_get('popup_message_body_text', ''), variable_get('popup_message_body_format', variable_get('filter_default_format', 1)), FALSE);
    $popup_message_parameters = array(
      'title' => $message_title,
      'body' => $message_body,
      'check_cookie' => variable_get('popup_message_check_cookie', 1),
      'width' => variable_get('popup_message_width', 300),
      'height' => variable_get('popup_message_height', 300),
    );

    // Allow other modules to modiffy message parameters.
    drupal_alter('popup_message_perameters', $popup_message_parameters);
    if ($message_title && $message_body) {
      popup_message_show_message($popup_message_parameters);
    }
  }
}