You are here

public static function Messaging_Destination::validate_type in Messaging 7

Same name and namespace in other branches
  1. 6.4 includes/messaging_destination.class.inc \Messaging_Destination::validate_type()

Validate values to create a destination

Parameters

$type: Address type

$address: Address value

$account: Optional user id or account object

1 call to Messaging_Destination::validate_type()
Messaging_Destination::validate_method in ./messaging.destination.inc
Validate values to create a destination

File

./messaging.destination.inc, line 205
Drupal Messaging Framework - Default class file

Class

Messaging_Destination
Message destination class

Code

public static function validate_type($type, $address, $account = NULL) {

  // First try validate callback for this address type
  if (!self::validate_address($type, $address)) {
    return FALSE;
  }
  elseif (isset($account)) {
    $uid = messaging_user_uid($account);
    if ($existing = self::get_by_address($type, $address)) {

      // There's already a destination with these parameters, check user
      // It will be ok if users match or it was anonymous before
      return !isset($account) || !$existing->uid || $existing->uid == $uid;
    }
    elseif ($address_uid = self::address2uid($type, $address)) {

      // Ok if this address belongs to the same user or to no user
      return !$address_uid || $address_uid == $uid;
    }
  }
  return TRUE;
}