views:

19

answers:

2

I'm trying to modify devel generate module to prevent it from generating content by users who don't have the permission to generate this content type.

Problem is I'm fairly new to drupal so I'm not familiar with its hooks. Can someone give me some hints how to approach this.

http://ftp.drupal.org/files/projects/devel-6.x-1.20.tar.gz

+1  A: 

I think there's some disconnect between what you're trying to do and how Devel generate works. To use Devel generate requires the administer nodes permission: this means anyone who can use Devel generate can administer all content types already.

If you're trying to get Devel generate to work without the administer nodes permission, don't. It's a development module to create dummy data: it should never be run as an unprivileged user.

What is it you're trying to accomplish?

Mark Trapp
Devel generates content and attaches an author to that. Randomly. Often it will attach authors that, according to the permissions, cound not create such content at all. Devel should recognise the permissions and only attach authors to generated content who actually can create such content.
berkes
@Mark, the comment by @berkes got it right. That was my point.
cyclo
It's a development module: it's not meant to be used on sites where permissions matter, like a production site.
Mark Trapp
+2  A: 

See

function devel_generate_content_add_node(&$results) {

There is a $users = $results['users']; which contains the "wrong users". You could hack out the users there, or make sure they are not added in the first place.

That happens in

function devel_get_users() {
  $users = array();
  $result = db_query_range("SELECT uid FROM {users}", 0, 50);
  while($user = db_fetch_object($result)){
    $users[] = $user->uid;
  }
  return $users;
}

You would need to modify that method, to make it return only users whith certain permissions. You can omit the incorrect users in the while loop; using node access.

However, this devel_get_users routine is called for other things too, so you probably want to achieve all this in either a new method devel_get_permissioned_users($perm) or by introducing an optional argument.

berkes