You are here

function sharethis_nodeapi in ShareThis 6

Same name and namespace in other branches
  1. 5 sharethis.module \sharethis_nodeapi()

Implementation of hook_nodeapi().

File

./sharethis.module, line 49
Provides the ShareThis service.

Code

function sharethis_nodeapi(&$node, $op, $teaser, $page) {
  switch ($op) {
    case 'view':
      if (user_access('use share this')) {
        if (!$teaser || variable_get('sharethis_teaser', 1)) {
          if (variable_get('sharethis_sharethis_this_where', 'links') == 'nodes') {
            if (in_array($node->type, variable_get('sharethis_sharethis_this_node_types', array()), TRUE)) {

              // Create the ShareThis element.
              $sharethis = theme('sharethis', $node->title, url('node/' . $node->nid, array(
                'absolute' => TRUE,
              )));
              $node->content['sharethis_sharethis_this'] = array(
                '#value' => $sharethis,
                '#weight' => variable_get('sharethis_sharethis_weight', 0),
              );
            }
          }
        }
      }
      break;
  }
}