The purpose of Add This is to share content with the world, in other words anonymous users. It does not make sense to share unpublished content (unless of course your site allows anonymous users to access unpublished content).

Could this module do one or more of the following?

  1. Hide AddThis links on unpublished nodes unless the user has access to view it
  2. As above, but change the link to a message "you cannot share this page because it is unpublished"
  3. As above, but change the message to "This page is unpublished, are you sure you want to share it?"
  4. All of the above, with configuration text and checkboxes

Comments

vesapalmu’s picture

Priority: Normal » Minor
Status: Active » Needs work

While I agree that this is a bug in some cases it's also a feature in some cases where you might want to preview the page before publishing it. Of course if you don't have permission to see a node you will not be able to see the Addthis button on it. This is only a problem if you have views (or something else) displaying unpublished nodes.

Options 2 and 3 are a bit difficult to implement in generic way because you can theme the button in many different ways. To make things even more difficult you can create Addthis block and context of the button is not always perfectly clear. I would go with adding a checkbox to hide the button on unpublished nodes and leave it off by default. Implementing this is trivial when using node links, block and using Addthis directly in your theme are a bit more difficult cases.

I will accept a patch for 2.x branch for this if somebody creates one. However since this is in my opinion sort of a edge case I'm changing priority to minor.

mstrelan’s picture

Hide AddThis links on unpublished nodes unless the user has access to view it

This should read
"... unless anonymous users have access to view it"

Nonetheless I think the other options are better options. I agree, this is an edge case.

mstrelan’s picture

I don't anticipate writing a patch for any of the above options, but if anyone wants to implement Option 1 in their own custom module here is what I have done.

<?php
/**
 * Implementation of hook_link_alter().
 */
function MYMODULE_link_alter(&$links, $node) {
  // Remove AddThis link on content not accessible to anonymous users
  if (isset($links['addthis']) && !node_access('view', $node, user_load(0))) {
    unset($links['addthis']);
  }
}
?>
gisle’s picture

Version: 6.x-2.x-dev » 7.x-4.x-dev
Issue summary: View changes

This problem still exists in 7.x-4.x. Changing version.

The elaborate scheme outlined in the issue summary will not be implemented (at least not by me).

This will be implemented: The buttons will be hidden on unpublished nodes, so that unpublished contents is not shared through carelessness.

matglas86’s picture

Category: Bug report » Feature request
Status: Needs work » Active

As @vesapalmu said this is a edge case. In the 4.x branch it is possible to use alters to display only if you want that. Please consider that first. I am going to put this in Feature request and active status. Any patches are welcome and we can review the suggestions for that.

Personally I am not a real proponent of this since the unpublished content is many times not accessible to people outside certain people. Besides that. Creating this will create a bload of extra edge cases that will be added as 'bugs' while not really bugs.

I would like to hear any comments.