function mailhandler_default_type in Mailhandler 6
Same name and namespace in other branches
- 7 mailhandler.module \mailhandler_default_type()
Return a default content type if the user has not chosen a specific type on the settings page In order of priority, return blog, story, page This assumes that one of these basic types is in use on a site (page and story are active by default) A user can choose other content types via the settings page as this exposes all available types
2 calls to mailhandler_default_type()
- mailhandler_admin_settings in ./
mailhandler.admin.inc - Return the settings page for mailhandler
- mailhandler_node_prepare_message in ./
mailhandler.module - Append default commands. Separate commands from body. Strip signature. Return a node object.
3 string references to 'mailhandler_default_type'
- MailhandlerTestCase::assertMailhandlerSettings in ./
mailhandler.test - MailhandlerTestCase::testMailhandlerSettings in ./
mailhandler.test - Verify the functionality of the administrative interface when the user has no privileges to edit filter formats.
- mailhandler_uninstall in ./
mailhandler.install - Implementation of hook_uninstall().
File
- ./
mailhandler.module, line 643 - Mailhandler module code.
Code
function mailhandler_default_type() {
// Get the current default setting, if defined.
$default_type = variable_get('mailhandler_default_type', NULL);
// Find out what types are available.
$available_types = node_get_types('names');
// Check the default type is still available (it could have been deleted).
if ($default_type && array_key_exists($default_type, $available_types)) {
return $default_type;
}
// If we get here then either no default is set, or the default type is no longer available
// Search for the array key (the machine readable name) for blog, story and page basic types
if (array_key_exists('blog', $available_types)) {
$default_type = 'blog';
}
else {
if (array_key_exists('story', $available_types)) {
$default_type = 'story';
}
else {
if (array_key_exists('page', $available_types)) {
$default_type = 'page';
}
else {
// If basic types not found then return the first item from the array as an alternative default
$default_type = key($available_types);
}
}
}
return $default_type;
}