| Project: | Node Reference Create |
| Version: | 6.x-1.0 |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
I've got this module installed and working well except for one issue. I have two content types: event and venue. I use this module along with the rules tutorial from the docs (redirecting to venue edit after event creation) to allow users to add new venues while adding new events. It works great except that it ignores my default workflow and comment settings.
My workflow settings for the venue content type (the one automatically being created) are:
Not published
Not promoted to front page
Not sticky at top of lists
Not create new revision
In moderation queue
The comment settings is set to Read/Write.
When I create an event with a new venue, this module creates the venue, but the workflow settings become:
Published
...
NOT In moderation queue
... and the comment settings changes to disabled.
What is going on with this module that it doesn't respect these defaults?
Thanks
Comments
#1
OK ... I fixed it. I apologize I don't have much (or any) familiarity with generating actual patch files, but here is my fix ...
In the file 'noderefcreate.module' replace the following lines:
$newnode->uid = $user->uid;$newnode->title = $value;
node_save($newnode);
... with these:
$newnode->uid = $user->uid;
$newnode->title = $value;
// if the comment module is installed, try to set the new node's comments according to this type's defaults
if(module_exists('comment')){
$newnode->comment = variable_get("comment_venue", COMMENT_NODE_DISABLED);
}
// init the main node options to false (0)
$newnode->status = 0;
$newnode->promote = 0;
$newnode->sticky = 0;
$newnode->revision = 0;
// get the array of node options for this type
$node_options = variable_get('node_options_' . $newnode->type, array('status'));
// loop through node options setting the type's defaults
foreach($node_options as $key=>$value){
$newnode->$value = 1;
}
node_save($newnode);
NOTE: I used the loop toward the end to allow for setting an indeterminate number of options. For example, I was using modr8 and it added an option for the moderation queue.
#2
Encountered same. This code fixed. Should be added to patch. Without it, anonymous users without proper permissions were allowed to enter and PUBLISH erroneous data even when the parent form was not submitted. This is a security issue.
Subscribing
#3
Needs patch, and as pointed out in #2, is a security issue.
#4
Took the code from #1 and rolled a patch against the 7.x-dev branch. Tested and working for me.
#5
Code from #1 for a D6 patch. Tested and working for me.
#6
Change:
$newnode->comment = variable_get("comment_venue, COMMENT_NODE_DISABLED);
To:
$newnode->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);