You are here

function _subscriptions_taxonomy_node_options in Subscriptions 6

Same name and namespace in other branches
  1. 5.2 subscriptions_taxonomy.module \_subscriptions_taxonomy_node_options()
  2. 7 subscriptions_taxonomy.module \_subscriptions_taxonomy_node_options()
  3. 2.0.x subscriptions_taxonomy/subscriptions_taxonomy.module \_subscriptions_taxonomy_node_options()

Implementation of hook_node_options(), subhook of hook_subscriptions().

This is called by subscriptions_ui_node_form() in subscriptions_ui.module.

See also

subscriptions_ui_node_form()

File

./subscriptions_taxonomy.module, line 78
Subscriptions to taxonomy terms.

Code

function _subscriptions_taxonomy_node_options($account, $node) {
  if (!isset($node->taxonomy) || !is_array($node->taxonomy) || !user_access('subscribe to taxonomy terms')) {
    return;
  }
  $options = array();
  $vids_to_omit = variable_get('subscriptions_omitted_taxa', array());
  foreach ($node->taxonomy as $tid => $term) {

    // Taxonomy term
    if (in_array($term->vid, $vids_to_omit)) {
      continue;
    }
    $options['tid'][] = array(
      'name' => t('To content in %term', array(
        '%term' => $term->name,
      )),
      'params' => array(
        'module' => 'node',
        'field' => 'tid',
        'value' => $tid,
      ),
      'link' => 'taxa/' . $tid,
    );
    $options['tid'][] = array(
      'name' => t('To content in %term by %name', array(
        '%term' => $term->name,
        '%name' => $node->uid ? check_plain($node->name) : variable_get('anonymous', '???'),
      )),
      'params' => array(
        'module' => 'node',
        'field' => 'tid',
        'value' => $tid,
        'author_uid' => $node->uid,
      ),
      'link' => 'taxa/' . $tid . '/' . $node->uid,
    );
    $options['tid']['weight'] = -1;
  }
  return $options;
}