Because there is no permission control for content push, the "Distribute" field form displays for ALL user from anonymous to admin on my sites. I handled it via a form-alter workaround, but strongly suggest adding permission control to the module.

Comments

joachim’s picture

Category: feature » bug
Priority: Normal » Major

Yikes.

Could you make that form change in the module itself and post a patch?

wolv3rin3’s picture

Unfortunately I'm a hack developer, Joachim, so I have no idea how to integrate with Drupal's permissions. But here's the snippets of what I did:

The form in question is $form['content_push'] which I found around line 46 in the content_push.module

In a Misc module specific to this site, I used form alter to only display the form for specific user roles, which is why it's just a workaround and not a true permission setting. My logic looked like:
if($user->uid==1 || in_array('nameofuserrole1', $user->roles) || in_array('nameofuserrole2', $user->roles))
(make sure you call global $user prior to this)

---

Sorry I can't help more.

joachim’s picture

> Unfortunately I'm a hack developer

Hehe, that's how most of us started :)

I won't be able to get to this till later in the week at the earliest, so if you wanted to dig in, what you need is two things:

- hook_perm() to define a permission name, say, 'push content to remote sites'.
- the user_access() function. This checks whether the current user has the given permission. (And no need to say global $user first!)

Happy hacking :)

wolv3rin3’s picture

Thanks for the boost in the right direction. Might not be able to get to it before you do, but you've given me enough pieces to get going.

OT: The integration with Features is saving me hours and hours of installation time. Thanks so much for adding that functionality.

joachim’s picture

> OT: The integration with Features is saving me hours and hours of installation time. Thanks so much for adding that functionality.

Cool. Same here! :D

greta_drupal’s picture

And, please, don't keep that patch to yourself! :-) ...I am awaiting that functionality as well.

[not a php coder or drupal mod developer]

Ed Sawyer’s picture

Did this ever get rolled into the latest codebase? E.g. a permissions control? I could have a go at it if need be. It should be pretty straightforward.