You are here

public function EntityLegalMethodRedirect::execute in Entity Legal 7.2

Same name and namespace in other branches
  1. 7 methods/entity_legal.redirect.inc \EntityLegalMethodRedirect::execute()

Execution method for redirect method.

File

methods/entity_legal.redirect.inc, line 14
Method include file for 'redirect'.

Class

EntityLegalMethodRedirect
Method class for redirecting existing users to accept a legal document.

Code

public function execute($method = 'redirect') {
  $documents = $this
    ->getDocumentsForMethod($method, ENTITY_LEGAL_USER_EXISTING);
  foreach ($documents as $document) {
    $entity_uri = $document
      ->uri();

    // Only redirect if the legal document isn't currently being viewed.
    if (current_path() == $entity_uri['path']) {
      return;
    }

    // Do not redirect user logout.
    if (current_path() == 'user/logout') {
      return;
    }
    drupal_set_message(t('You must accept this agreement before continuing.'), 'warning');
    drupal_goto($entity_uri['path'], array(
      'query' => drupal_get_destination(),
    ));
  }
}