function references_dialog_entityreference_link_helper in References dialog 7
1 call to references_dialog_entityreference_link_helper()
- references_dialog_entityreference_add_link in ./
references_dialog.dialog_widgets.inc - Add link callback for entity references.
File
- ./
references_dialog.dialog_widgets.inc, line 286 - Implements dialogs for node reference and user reference fields.
Code
function references_dialog_entityreference_link_helper($entity_type, $bundle = NULL) {
$wrapper = entity_metadata_wrapper($entity_type, NULL, array(
'bundle' => $bundle,
));
$info = $wrapper
->entityInfo();
if (isset($bundle)) {
$label = $info['bundles'][$bundle]['label'];
}
else {
$label = $info['label'];
}
// entity_access() doesn't provide a generic bundle create op access check.
switch ($entity_type) {
case 'node':
$access = node_access('create', $bundle);
break;
case 'taxonomy_term':
if (module_exists('taxonomy_access_fix')) {
$vocabulary = taxonomy_vocabulary_machine_name_load($bundle);
$access = taxonomy_access_fix_access('add terms', $vocabulary);
}
else {
$access = entity_access('create', $entity_type);
}
break;
default:
$access = entity_access('create', $entity_type);
break;
}
$path = references_dialog_get_admin_path($entity_type, 'add', $bundle);
if ($access && $path) {
$link = array(
'title' => t('Create @type', array(
'@type' => $label,
)),
'href' => $path,
);
return $link;
}
return FALSE;
}