when a user with administer nodes perm submits a node, the status and promote and similar attributes are taken from the $_POST. Other users have those values set for them according to the content type settings. Thats all fine, but sometimes nodes get created outside of the node form such as via email into mailhandler. Mailhandler submits the node using the API provided by node.module (i.e. call node_submit() then node_save()). This works poorly when the submitter hasd the admin nodes perm because no status, sticky, promote values are supplied and node_submit() assumes they are all false. Instead, it should assume the content type defaults. this can be achieved by always treating the incomimg post as if it were authored by a usual user and then overriding any values supplied by an 'administer nodes' user.

CommentFileSizeAuthor
#3 node_robust.patch1.19 KBchx
#1 mailhandler_0.module_defaultsPatch509 bytes3B
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

3B’s picture

it seems that this patch could solve the issue.

please verify

many thanks
alberto

126a127,134
> // handle defaults for node creation (e.g. comment | promote | moderate | sticky fields)
> $node_blog_default = variable_get('node_options_blog', array('status', 'promote'));
> $node->status = in_array('status', $node_blog_default);
> $node->promote = in_array('promote', $node_blog_default);
> $node->moderate = in_array('moderate', $node_blog_default);
> $node->revision = in_array('revision', $node_blog_default);
> $node->comment = variable_get('comment_blog', 2);
>

moshe weitzman’s picture

please supply uniffied diff as per http://drupal.org/diffandpatch. please try to solve the problem in the cleanest way possible. that will likely mean applying defaults and then overriding them if user is ana admin.

chx’s picture

Priority: Minor » Normal
Status: Active » Needs review
FileSize
1.19 KB

This is very easy.

Robin Monks’s picture

Status: Needs review » Reviewed & tested by the community

Tested on WAMP with PHP4 and 5, I was able to create nodes fine with and without the perm.

+1, ready to commit.

Robin
I ♥ Bugz

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Fixed

applied

Anonymous’s picture

Status: Fixed » Closed (fixed)