Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#8 | node_unpublish_dsp_2.patch | 1.83 KB | matt westgate |
#4 | node_unpublish_dsp_1.patch | 1.88 KB | matt westgate |
#2 | node_unpublish_dsp_0.patch | 1.84 KB | matt westgate |
node_unpublish_dsp.patch | 686 bytes | matt westgate | |
Comments
Comment #1
Steven CreditAttribution: Steven commentedThis 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?
Comment #2
matt westgate CreditAttribution: matt westgate commentedThanks 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.
Comment #3
Steven CreditAttribution: Steven commentedComments:
- 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.
Comment #4
matt westgate CreditAttribution: matt westgate commentedThe '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.
Comment #5
Steven CreditAttribution: Steven commentedSorry, 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.
Comment #6
Dries CreditAttribution: Dries commentedI think it will break with tabs. If it doesn't, it is likely to break with caching.
Comment #7
matt westgate CreditAttribution: matt westgate commentedThe 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.
Comment #8
matt westgate CreditAttribution: matt westgate commentedSyncing 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.
Comment #9
elias1884 CreditAttribution: elias1884 commentedthis 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!
Comment #10
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedDoesn't apply anymore.
Comment #11
moshe weitzman CreditAttribution: moshe weitzman commentedComment #12
(not verified) CreditAttribution: commentedComment #13
q8doc CreditAttribution: q8doc commentedDoes 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
Comment #14
q8doc CreditAttribution: q8doc commentedComment #15
marcingy CreditAttribution: marcingy commented