Currently, node_submit tries to display a node after creation or editing and completely disregarding it's 'published' or 'unpublished' state. This is especially confusing to an user who, after creating their 'unpublished' node, is immediately taken to the following warning: 'You are not authorized to access this page'. Huh? what does that mean?

This patch displays the newly created/edited node if it is in a published state. If the node is unpublished, a message is returned letting the user know that their node is waiting for approval.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven’s picture

This patch no longer applies because we now do a drupal_goto() after form submission. We could just output a notice and not do a drupal_goto() for this case, but I can imagine people refreshing the 'awaiting approval' message to see if their node was published already: this would submit the node again.

Perhaps we could alter node.module so that when you try to access an unpublished node which you authored (and you're not an admin) that it then displays the "awaiting approval" message?

matt westgate’s picture

FileSize
1.84 KB

Thanks for your feedback Steven :-)

I've come up with a solution that seems quite flexible. Here's the approach:

1. If a node type is unpublished by default, or if an existing node is unpublished, hide a destination URL in the node_form field based on the referrer_uri().

* User clicks submit *

2a. If the node is in a published state or the submitter has 'administrator nodes' privilege, redirect to the standard node view and ignore the hidden destination URL. This is what we do now.

2b. Otherwise, redirect to the destination URL using drupal_goto. If one isn't found, use 'site_front_page'.

===

The advantage of this approach to unpublished nodes is user's with 'administrator nodes' privileges are not affected. They are always able to see nodes in any $node->status state.

Regular user's that don't have publication control are redirected to the originating page where they clicked the edit button or create content link, making this work quite nicely for custom node type overview pages as well as returning them to a sensible location after adding new content.

The last thing I want to see after creating content is an 'Access denied' message. This patch attempts to solve that issue.

Steven’s picture

Comments:
- You should probably use the node_name hook to get a friendly name for a node type, to display in the message.

- How does your referrer-trick work for using multiple tabs? This could be a solution for not redirecting to the appropriate page when submitting a comment as well. Browsers that do not send referrer can still redirect to the regular view page.

matt westgate’s picture

FileSize
1.88 KB

The 'pending approval' status message is now using the node_name hook. Thanks for catching that silly error ;-)

About using the redirect-trick for comments. I think this solution would work, but I don't have time to code it.

As far as tabs go, they are not visible when editing a non-published node.

Steven’s picture

Sorry, with 'tabs' I meant the problem of using multiple browser windows or tabs on a Drupal site. It causes some problem with redirects, and if this doesn't break, then we could use a similar trick elsewhere.

Dries’s picture

I think it will break with tabs. If it doesn't, it is likely to break with caching.

matt westgate’s picture

The scope of this patch is only for nodes that are created with a 'not published' status. It changes the current 'Your node has been created. Access Denied' to 'Your node is pending approval'.

Since I am using drupal_goto after form submission, it allows for modules to offer their own redirection (via hook_load for example) or go with the new default behavior of returning the user to the previous page, which in most cases would be node/add. Currently it tries to display the node which throws the access denied message.

As far as browser tabs go. I have investigated this patch with Safari, Konqueror and FireFox and have not run into a referrer problem. Are there other browsers I should be testing?

Regarding the caching concerns. Whenever a node is submitted the cache is cleared. At least this has been my experience. This seems to even hold true for anonymous users with full access.

matt westgate’s picture

FileSize
1.83 KB

Syncing this patch to CVS HEAD. It should be noted that this patch will only affect nodes that are unpublished or if a module developer defines an alternate destination after node submission.

elias1884’s picture

this was long overdue since unexperienced users tend to get confused by the "access denied message". however, it should go hand in hand with something like mentioned in http://drupal.org/node/1061, in order to give the user a way to verify if his node really, really, really got submitted!

killes@www.drop.org’s picture

Doesn't apply anymore.

moshe weitzman’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)
q8doc’s picture

Version: x.y.z » 5.10

Does this patch work for node.module on drupal 5.10? (it didn't work for me)
I would really appreciate if any body could update it

q8doc’s picture

Status: Closed (fixed) » Needs work
marcingy’s picture

Status: Needs work » Closed (fixed)