function messaging_update_method_replace in Messaging 7
Same name and namespace in other branches
- 6.4 messaging.install \messaging_update_method_replace()
- 6 messaging.install \messaging_update_method_replace()
- 6.2 messaging.install \messaging_update_method_replace()
- 6.3 messaging.install \messaging_update_method_replace()
Find a suitable replacement for a sending method
Parameters
$method: Method key, the one to find a replacement for
$default: Whether to try default remaining method if we cannot find one of the same type
1 call to messaging_update_method_replace()
- Messaging_Method::method_disable in ./
messaging.method.inc - Update messaging method.
File
- ./
messaging.install, line 119
Code
function messaging_update_method_replace($method, $default = TRUE) {
$replace = NULL;
// 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) && $default) {
if ($method == messaging_method_default()) {
$info = messaging_method_info();
unset($info[$method]);
$replace = key($info);
}
else {
$replace = messaging_method_default();
}
}
return $replace;
}