--- /Users/oli/Desktop/service_links/service_links.module +++ service_links.module @@ -41,6 +41,12 @@ '#default_value' => variable_get('service_links_node_types', array()), '#options' => node_get_types('names'), ); + $form['where_to_show_the_links']['service_links_hide4author'] = array( + '#type' => 'checkbox', + '#title' => t("Hide service links if the actual user is the author of the node."), + '#return_value' => 1, + '#default_value' => variable_get('service_links_hide4author', 1), + ); if (module_exists('taxonomy')) { $form['where_to_show_the_links']['service_links_category_types'] = array( '#type' => 'select', @@ -213,7 +219,7 @@ function service_links_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { case 'view': - $links_show = _service_links_show($node->type, $node->nid); + $links_show = _service_links_show($node, $node->nid); if ($links_show && user_access('use service links')) { switch (variable_get('service_links_in_node', 0)) { case 1: @@ -275,7 +281,7 @@ $show_links = FALSE; } - $links_show = _service_links_show($node->type, $node->nid); + $links_show = _service_links_show($node, $node->nid); if ($type == 'node' && $links_show && $show_links && user_access('use service links')) { $links = service_links_render($node, TRUE); @@ -295,7 +301,7 @@ else if ($op == 'view') { if (user_access('use service links') && arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); - $links_show = _service_links_show($node->type, $node->nid); + $links_show = _service_links_show($node, $node->nid); if ($links_show) { $block['subject'] = t('Bookmark/Search this post'); $block['content'] = theme('service_links_block_format', service_links_render($node)); @@ -449,9 +455,9 @@ /** * Check if the service links should be displayed for the node type/category. */ -function _service_links_show($type, $nid) { +function _service_links_show($node, $nid) { $links_show = FALSE; - $node_type = in_array($type, variable_get('service_links_node_types', array()), TRUE); + $node_type = in_array($node->type, variable_get('service_links_node_types', array()), TRUE); if (module_exists('taxonomy')) { $terms = taxonomy_node_get_terms($nid); foreach ($terms as $term) { @@ -460,7 +466,12 @@ } if ($node_type || $category_type) { $links_show = TRUE; + if(variable_get('service_links_hide4author', 0)){ + global $user; + $links_show = ($user->uid == $node->uid) ? FALSE : TRUE; + } } + return $links_show; }