You are here

function _subscriptions_content_node_options in Subscriptions 5.2

Same name and namespace in other branches
  1. 6 subscriptions_content.module \_subscriptions_content_node_options()
  2. 7 subscriptions_content.module \_subscriptions_content_node_options()
  3. 2.0.x subscriptions_content/subscriptions_content.module \_subscriptions_content_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_content.module, line 85
Subscriptions to content events

Code

function _subscriptions_content_node_options($account, $node) {

  // Default node, field are the first three indexes, but they can be overridden in params
  // Thread
  $options = array();
  $statics = variable_get('subscriptions_static_content_types', array());
  if (!in_array($node->type, $statics)) {
    $options['nid'][] = array(
      'name' => t('Subscribe to this page'),
      'params' => array(
        'module' => 'node',
        'field' => 'nid',
        'value' => $node->nid,
      ),
      'link' => 'node/' . $node->nid,
    );
    $options['nid']['weight'] = -4;
  }
  $unlisteds = variable_get('subscriptions_unlisted_content_types', array());
  if (user_access('subscribe to content types', $account)) {
    $unlisted_tag = '';
    if (in_array($node->type, $unlisteds)) {
      if (user_access('subscribe to all content types', $account)) {
        $unlisted_tag = ' ' . SUBSCRIPTIONS_UNAVAILABLE;
      }
      else {
        return $options;
      }
    }

    // Content type
    $type_name = node_get_types('name', $node->type);
    if ($type_name) {
      $options['type'][] = array(
        'name' => t('To %type content', array(
          '%type' => $type_name,
        )) . $unlisted_tag,
        'params' => array(
          'module' => 'node',
          'field' => 'type',
          'value' => $node->type,
        ),
        'link' => 'type/' . $node->type,
      );

      // Content type and author
      $options['type'][] = array(
        'name' => t('To %type content by %name', array(
          '%type' => $type_name,
          '%name' => $node->uid ? $node->name : variable_get('anonymous', '???'),
        )) . $unlisted_tag,
        'params' => array(
          'module' => 'node',
          'field' => 'type',
          'value' => $node->type,
          'author_uid' => $node->uid,
        ),
        'link' => 'type/' . $node->type . '/' . $node->uid,
      );
      $options['type']['weight'] = -2;
    }
  }
  return $options;
}