You are here

function overlay_user_dismiss_message in Drupal 7

Page callback: Dismisses the overlay accessibility message for this user.

Return value

A render array for a page containing a list of content.

1 string reference to 'overlay_user_dismiss_message'
overlay_menu in modules/overlay/overlay.module
Implements hook_menu().

File

modules/overlay/overlay.module, line 328
Displays the Drupal administration interface in an overlay.

Code

function overlay_user_dismiss_message() {
  global $user;

  // It's unlikely, but possible that "access overlay" permission is granted to
  // the anonymous role. In this case, we do not display the message to disable
  // the overlay, so there is nothing to dismiss. Also, protect against
  // cross-site request forgeries by validating a token.
  if (empty($user->uid) || !isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'overlay')) {
    return MENU_ACCESS_DENIED;
  }
  else {
    user_save(user_load($user->uid), array(
      'data' => array(
        'overlay_message_dismissed' => 1,
      ),
    ));
    drupal_set_message(t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.'));

    // Destination is normally given. Go to the user profile as a fallback.
    drupal_goto('user/' . $user->uid . '/edit');
  }
}