You are here

function login_destination_get_destination in Login Destination 7

Same name and namespace in other branches
  1. 5 login_destination.module \login_destination_get_destination()

Process all destination rules and return destination path.

This function is intended to be used by external modules.

1 call to login_destination_get_destination()
login_destination_perform_redirect in ./login_destination.module
Evaluate rules and perform redirect.

File

./login_destination.module, line 398
Control where users are directed to, once they login

Code

function login_destination_get_destination($trigger = '', $current = NULL) {

  // Get all the login destination rules from the database.
  $result = db_select('login_destination', 'l')
    ->fields('l', array(
    'triggers',
    'roles',
    'pages_type',
    'pages',
    'destination_type',
    'destination',
    'enabled',
  ))
    ->orderBy('weight')
    ->execute()
    ->fetchAll();
  if ($current === NULL) {
    $current = _login_destination_get_current($trigger);
  }

  // Examine path matches.
  foreach ($result as $data) {

    // Try to match the subsequent rule.
    if (_login_destination_match_rule($data, $trigger, $current)) {

      // Note: Matching rule with empty destination will cancel redirect.
      return _login_destination_evaluate_rule($data, $trigger);
    }
  }

  // No rule matched.
  return FALSE;
}