0

I'm trying to implement an issue tracking application with Drupal.

I have 4 clients and I want that each one of them will be able to access the site and add an issue. I filter the project ID so any client see only his project issues.

The only thing I don't get how to do is to assign an issue.

In the "Issue" content type I created a "user Reference" filed called "Assign To" (which cause to Rules to send an email to the assigned user).

I want to be able to assign an issue to any client, but I want a client to be able to assign an issue only to me.

How can I do that? If I can't exclude some users from the list (say-by role) - do you have any idea about different way to achieve the "Assign To" functionality?

0

Since your needs are so specific, I think the easiest (and maybe most logical) way to do this is not to restrict the users on the list. Instead, hide the field for all users of a certain role and have the value default to you. And for you, just don't hide it.

You can achieve this in a few ways. It would be very simple to write a custom module to do this. Use hook_form_alter() to access your issue form. In that function, use the global $user object to check the role of the current user, and if it's your clients' role, set the '#access' property to FALSE and the '#value' to your user id. That's all.

You can probably do this without custom code also. Every field already has a default value in Drupal core. Set the default value for that field to you. Then use a module like Field Permissions to hide the field from your clients.

This achieves what you want without actually messing with the user reference list. That is also an option, but seems like a worse option to me. To do that, you would need a custom hook_form_alter() that, depending on the current user's role, would loop through the #options for that field and remove any users that aren't you.

4
  • That is a good idea. thank you. I wanted the client to understand that he/she are rolling the issue to my side and that it is my responsibility now, but it seems like I can't do that.
    – Tibo
    May 22 '12 at 4:30
  • Well, you could. Like I mention in the last part of the answer, it is totally possible to do what you're thinking. Note though that even If you go with my first suggestion (hiding the field), it would only be hidden on the edit form. As soon as your client would create the issue, It would be listed as assigned to you, and they would see that on the node view page, just not the create or edit page.
    – goron
    May 22 '12 at 4:41
  • you are right. that is the solution I'm going to implement. BTW - I created a view that will show issues for a specific project. example: /issues/11. how can I prevent the client to guess that there are other projects and load issues from other project? (in other words: how can I define that a specific role is allowed to see content with a specific field value?)
    – Tibo
    May 22 '12 at 8:26
  • well - seems like this would do what I want: drupal.org/node/31601
    – Tibo
    May 22 '12 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.