function bean_add_page in Bean (for Drupal 7) 7
Menu Callback to list available bean types to add
1 string reference to 'bean_add_page'
- bean_menu in ./
bean.module - Implements hook_menu().
File
- includes/
bean.pages.inc, line 42 - Bean Functions
Code
function bean_add_page() {
$bean_types = bean_get_types();
$types = array();
foreach ($bean_types as $key => $bean_type) {
if (entity_access('create', 'bean', $bean_type->type)) {
$types[$key] = $bean_type;
}
}
// If there are block types, but the user doesn't have access, return 403.
if (count($types) == 0 && count($bean_types) > 0) {
return drupal_access_denied();
}
// Bypass the block/add listing if only one block type is available.
if (count($types) == 1) {
$bean_type = array_shift($types);
drupal_goto('block/add/' . $bean_type
->buildURL());
}
return theme('bean_add_list', array(
'content' => $types,
));
}