function subscriptions_link in Subscriptions 5
Implementation of hook_link().
File
- ./
subscriptions.module, line 937
Code
function subscriptions_link($type, $node = NULL, $teaser = NULL) {
$omittypes = variable_get('subscriptions_omitted_content_types', array());
$omittaxa = variable_get('subscriptions_omitted_taxa', array());
$taxaclear = TRUE;
$links = array();
if ($type != 'node' || $node->comment != 2 || !user_access('maintain own subscriptions') || $teaser && !variable_get('subscriptions_link_teaser', 1)) {
return $links;
}
// loop through possibly muliple taxa to determine if any are on omit list
if (!isset($node->taxonomy)) {
$node->taxonomy = array();
}
foreach ($node->taxonomy as $taxa) {
if (in_array($taxa->vid, $omittaxa)) {
$taxaclear = FALSE;
break;
}
}
if ($taxaclear && !in_array($node->type, $omittypes)) {
$subscriptions = subscriptions_get_user();
$name = node_get_types('name', $node);
if ($node->type == 'blog') {
if (isset($subscriptions['blog'][$node->uid])) {
$links['subscriptions_del_blog'] = array(
'title' => t('Unsubscribe blog'),
'href' => 'subscriptions/del/blog/' . $node->uid,
'attributes' => array(
'title' => t("Stop receiving an e-mail whenever a new entry is made to this person's blog."),
),
);
}
else {
$links['subscriptions_add_blog'] = array(
'title' => t('Subscribe blog'),
'href' => 'subscriptions/add/blog/' . $node->uid,
'attributes' => array(
'title' => t("Receive an e-mail whenever a new entry is made to this person's blog."),
),
);
}
}
if (isset($subscriptions['node'][$node->nid])) {
$links['subscriptions_del_node'] = array(
'title' => t('Unsubscribe post'),
'href' => 'subscriptions/del/node/' . $node->nid,
'attributes' => array(
'title' => t('Stop receiving an e-mail whenever a new comment is posted to this @type.', array(
'@type' => $name,
)),
),
);
}
else {
$links['subscriptions_add_node'] = array(
'title' => t('Subscribe post'),
'href' => 'subscriptions/add/node/' . $node->nid,
'attributes' => array(
'title' => t('Receive an e-mail whenever a comment is posted to this @type.', array(
'@type' => $name,
)),
),
);
}
}
return $links;
}