function _node_embed_user_feedback in Node Embed 7
Helper function for returning feedback to the user.
1 call to _node_embed_user_feedback()
- _node_embed_replacements in ./
node_embed.module - Provides the replacement html to be rendered in place of the embed code.
File
- ./
node_embed.module, line 110 - This module defines an input filter for taking an embed code syntax ([[nid: ###]]) and removing the embed code and replacing with a rendered node view at that position in the text field.
Code
function _node_embed_user_feedback($parent_node, $matches, $type) {
if (is_object($parent_node)) {
// There is no point to show the embed code if the user can't edit the node.
if (!node_access('update', $parent_node)) {
return '';
}
$parent_node_url = l($parent_node->title, 'node/' . $parent_node->nid);
}
else {
// There is no point to show the embed code if the user can't edit any node.
if (!user_access('administer nodes')) {
return '';
}
// There is no Parent.
$type = null;
}
switch ($type) {
case 'access':
drupal_set_message(t('You don\'t have the permission to view embedded node ID %nid in !node.', array(
'%nid' => $matches[1],
'!node' => $parent_node_url,
)), 'warning');
break;
case 'unpublished':
drupal_set_message(t('The embedded node !node is unpublished.', array(
'%nid' => $matches[1],
'!node' => $parent_node_url,
)), 'warning');
break;
case 'loop':
drupal_set_message(t('Loop detected while embedding code %code in !node', array(
'%code' => $matches[0],
'!node' => $parent_node_url,
)), 'error');
break;
case 'invalid':
drupal_set_message(t('The embedded node ID %nid in !node does not exist (anymore).', array(
'%nid' => $matches[1],
'!node' => $parent_node_url,
)), 'warning');
break;
default:
drupal_set_message(t('There is a node with embedded node ID %nid that does not exist (anymore).', array(
'%nid' => $matches[1],
)), 'warning');
}
// Return a simple inline message for content editors to identify the problem.
return t('-- Failed to embed node %nid. --', array(
'%nid' => $matches[1],
));
}