function old_subscriptions_ui_node_view in Subscriptions 2.0.x
Implements hook_node_view().
Inject the node subform or a 'Subscribe' link into node pages (depending on the Display Settings).
Parameters
object $node:
string $view_mode:
string $langcode:
File
- subscriptions_ui/
subscriptions_ui.module, line 48 - Provides a user interface for Subscriptions.
Code
function old_subscriptions_ui_node_view($node, $view_mode, $langcode) {
global $user;
if ($node->nid && $view_mode == 'full' && subscriptions_ui_can_subscribe()) {
$arg2 = subscriptions_arg(2);
$block = variable_get('subscriptions_form_in_block', 0);
$link = variable_get('subscriptions_form_link_only', 0);
if (!$block && (!$link && (empty($arg2) || $arg2 == 'view') || $link && $arg2 == 'subscribe')) {
if ($form = drupal_get_form('subscriptions_ui_node_form', $node, $arg2 == 'subscribe')) {
$node->content['subscriptions_ui'] = [
'subscriptions_ui_form' => $form,
'#weight' => 100,
];
return;
}
}
subscriptions_suspended($user->uid, TRUE);
if (variable_get('subscriptions_form_link_only', 0) && $arg2 != 'subscribe' && (!variable_get('subscriptions_avoid_empty_subscribe_links', 0) || module_invoke_all('subscriptions', 'node_options', $user, $node))) {
/** @var $blocked_types array */
$blocked_types = variable_get('subscriptions_blocked_content_types', []);
if (in_array($node->type, $blocked_types) && !user_access('subscribe to all content types')) {
return;
}
$node->content['links']['node']['#links']['subscriptions-subscribe'] = [
'href' => current_path() . '/subscribe',
'title' => t('Subscribe') . (in_array($node->type, $blocked_types) ? SUBSCRIPTIONS_UNAVAILABLE : ''),
'html' => TRUE,
'fragment' => 'subscribe',
'attributes' => [
'title' => t('Receive notifications about changes and/or comments to this page (and possibly similar pages).'),
],
];
}
}
}