You are here

function Notifications_Subscription::check_destination in Notifications 6.4

Same name and namespace in other branches
  1. 7 notifications.subscription.inc \Notifications_Subscription::check_destination()

Check destination or create it if new

File

includes/notifications_subscription.class.inc, line 347
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription
Message destination class

Code

function check_destination() {
  if (empty($this->mdid)) {
    return $this
      ->create_destination();
  }
  elseif ($destination = $this
    ->get_destination()) {

    // We may need to create a new destination if this address is not valid for method has changed
    if (!empty($this->send_method) && messaging_method_info($this->send_method, 'address_type') != $destination->type) {
      return $this
        ->create_destination();
    }
    else {
      return $destination;
    }
  }
  else {

    // Last try, figure out a destination
    return $this
      ->create_destination();
  }
}