You are here

function _login_destination_evaluate_rule in Login Destination 7

A helper function to evaluate destination path.

1 call to _login_destination_evaluate_rule()
login_destination_get_destination in ./login_destination.module
Process all destination rules and return destination path.

File

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

Code

function _login_destination_evaluate_rule($rule, $trigger = '') {
  if ($rule->destination_type == LOGIN_DESTINATION_STATIC) {

    // Take only 1st line.
    if (preg_match("!^(.*?)\$!", $rule->destination, $matches) === 1) {
      $path = $matches[1];
      if (empty($path)) {
        return FALSE;
      }
      elseif ($path == '<current>') {
        return _login_destination_get_current($trigger);
      }
      elseif (strpos($path, '://') !== FALSE) {
        return $path;
      }
      else {
        if (module_exists('token')) {
          $path = token_replace($path);
        }
        $destination = drupal_parse_url($path);
        $options = array();
        $options['query'] = $destination['query'];
        $options['fragment'] = $destination['fragment'];

        // Drupal api, drupal_goto cares about <front>.
        return array(
          $destination['path'],
          $options,
        );
      }
    }
    else {

      // Error - multiple lines.
      return '';
    }
  }
  elseif (module_exists('php')) {

    // We cannot use the php_eval because we expect array here, but for the
    // matter of consistent UI we don't do it with the PHP Filter module off.
    $result = _login_destination_eval($rule->destination);
    if (empty($result)) {
      return FALSE;
    }
    return $result;
  }
  else {

    // PHP code and PHP filter disabled.
    return FALSE;
  }
}