Hi,
I need to be able to select from a list including all the members of a group in the 'assigned' drop down on the project issue add form. (It seemed the choice is only between the current user and 'Unassigned'.) I wrote a small function and was able to list all users within a group in the drop down, but when I select any of them, it defaults to admin or the user that's creating the issue. Here's the code I've been using:
function get_group_members($uid) {
// Function called from project_issue_form(), lines 590 & 605
// TODO: Is this the best way to do this???
// Find out which group user belongs to and get other group members
$nid = db_result(db_query('SELECT nid FROM {og_uid} WHERE uid = %d', $uid));
// Now get all user IDs belonging to the group with user names
$result = db_query('SELECT ou.uid, u.name FROM {og_uid} ou INNER JOIN {users} u ON ou.uid = u.uid WHERE ou.nid = %d', $nid);
while ($user = db_fetch_object($result)) {
$options[$user->uid] = $user->name;
}
return $options;
}
And I am calling it like this:
$assigned = array_merge(array(t('Unassigned')), get_group_members($user->uid));
I need to be able to select any user within the group to assign the issue to - is this possible? I've been trying to sort this out for a while unsuccessfully so I think I need help. The problem I think is that the user ID isn't being saved in the array, so if I have 2 other users listed in the drop down, the value saved in 'assigned' field of project_issues table is either 1 or 2 depending on the user selected (regardless of the user's ID). The uid of the users in the group are 9 & 10 respectively.
dantina.
Comments
Comment #1
hunmonk commentedtroubleshooting this is out of scope for this issue queue, IMO. however, there has been a very long-standing issue created for this as a feature more generally in project_issue.module, which you might want to read over:
http://drupal.org/node/4354
there are several patches posted there which might offer you a starting point, or just flat-out work for your needs.
two more things:
Comment #2
dantina commentedthanks Hunmonk
Comment #3
dantina commentedDecided to post this here just in case it helps anyone ...
After taking a look at the patches suggested here: http://drupal.org/node/4354 (see Hunmonk's post), I discovered why my code wasn't working. The problem I think was the use of array_merge in the line calling the function. So I made some modifications as below:
And to call it, add this to the code populating the 'assigned' field:
$assigned = get_team_members($user->uid);just below these lines:
BTW, I needed the code to be in a separate function because I had another field apart from 'assigned' on my issue form loading the same list. If you are only using the 'assigned' field, you may find it simpler to just replace the calling line with the code lines loading the data.
dantina