You are here

function messaging_update_method_replace in Messaging 6.3

Same name and namespace in other branches
  1. 6.4 messaging.install \messaging_update_method_replace()
  2. 6 messaging.install \messaging_update_method_replace()
  3. 6.2 messaging.install \messaging_update_method_replace()
  4. 7 messaging.install \messaging_update_method_replace()

Find a suitable replacement for a sending method

1 call to messaging_update_method_replace()
messaging_method_disable in ./messaging.module
Update messaging method.

File

./messaging.install, line 184

Code

function messaging_update_method_replace($method) {

  // Find an alternative one within the same group, i.e. 'mail'
  if ($method_group = messaging_method_info($method, 'group')) {
    foreach (messaging_method_info(NULL, 'group') as $index => $group) {
      if ($group == $method_group && $method != $index) {
        $replace = $index;
        break;
      }
    }
  }

  // If still not replacement, go for the default
  if (empty($replace)) {
    if ($method == messaging_method_default()) {
      $info = messaging_method_info();
      unset($info[$method]);
      $replace = key($info);
    }
    else {
      $replace = messaging_method_default();
    }
  }
  return $replace;
}