When a ContentDM wrapper node it created, the author is always set to uid 0, the anonymous user. On our site it's important that wrapper nodes be owned by the user that created them, like other Drupal nodes, so contentdm_create_wrapper() should at least have that ability.

Comments

laken’s picture

Status: Active » Needs review
StatusFileSize
new1.33 KB

Here's a simple patch that sets the wrapper node's author to the currently logged-in user. This should probably be expanded a bit to let the calling function pass in an $account parameter (which would default to $user->uid) for flexibility.

markj’s picture

Thanks for the patch Andy, looks good. I'll test and push to -dev tomorrow some time.

laken’s picture

StatusFileSize
new1.45 KB

Actually this patch was only working intermittently for me. If you look at node_submit() you'll see that, if the current user had 'administer nodes' permission, it checks $node->name and then sets $node->uid. Since we aren't setting $node->name in contentdm_create_wrapper(), this fails and $node->uid is set to 0 regardless of how we set it in contentdm_create_wrapper(). This also introduces different uid handling depending on whether it's an admin user or normal user, so it's kind of a mess.

A very experienced developer tells me the call to node_submit() is usually unnecessary, so I just removed it and everything seems to work, though I haven't tested with ContentDM Harvester yet. But here's a new patch.

markj’s picture

Andy, I'd rather populate $node->name in contentdm_create_wrapper() than omit node_submit(). With all respect to the developer who advised dropping node_submit(), I've learned that programatically creating nodes without calling that function leads to frustration. Would populating $node->name in contentdm_create_wrapper() solve the problem?

markj’s picture

Status: Needs review » Closed (fixed)

Admin option added to assign node ownership to user who first views the CONTENTdm item; pushed to -dev in commit d15c20f.