In issue http://drupal.org/node/4354 we've discussed ways to allow selecting from multiple users to assign issues to. We've talked about a new hook, but using form_alter mightmake more sense.

Here's a rough, completely untested (I don't have a cvs.module install with data) idea of how we'd do this. We introduce a new helper function, cvs_is_project_maintainer(), used to determine if a user is a maintainer of a given project. If so, we form_alter the options of the 'assigned' select on project issues.

CommentFileSizeAuthor
#2 cvs-assignees.patch.13.54 KBdww
#1 cvslog-assignees.patch2.23 KBnedjo

Comments

nedjo’s picture

StatusFileSize
new2.23 KB

Attachment.

dww’s picture

Status: Needs review » Needs work
StatusFileSize
new3.54 KB

unfortunately, this doesn't work at all. ;)

  1. on a new issue, $form['#node'] is the *issue* node, not the project node. furthermore, there's no nid yet, since we're in the process of creating the node.
  2. on an issue followup, there's no $form['#node'], since followups aren't nodes
  3. we really want the pid, the project id (nid of the project node) for this. however, i'm not sure what to do about that... since a) you can change the project on the form and b) we don't necessarily have access to the current value of pid in form_alter()
  4. for no apparently good reason, when you followup to an issue, all the issue form stuff is stuffed into a $form['project_issue_form'] array, not the top-level of the form.
  5. the version of cvs_is_project_maintainer() always returns TRUE, since you're just checking the $result from db_query(), not db_num_rows().
  6. cvs_is_project_maintainer() isn't checking if the given uid owns the nid. this is the special case that always has
    cvs access to the project, so we need an additional query in there.

even once you solve these problems, things are still wonky. for example, we always array_merge() the maintainers list, even if one of the maintainers is already assigned the issue. it seems we need to filter out duplicates after that array merge. but you can't just use array_unique() in there since that destroys all the array keys. :(

ugh, this is turning into a huge timesink, and i have no more time. i'll post the current "working" copy i have while i was defeating the numbered points above, but it definitely still needs work. the duplicate values are still unresolved in here. futhermore, my hack solution to #3 is to look directly in $_POST. there might be some crazy way to do this via pre_render() or something, and get the currently selected value out of the form that way, but i don't have time to keep working on this now...

i'd love to get this working, but i don't see that happening before i leave town.

i'm starting to think the hook approach might be more simple, too. this form_alter() stuff is kind of a mess, once you really have to start getting it working. ;) if it was just a hook, project could do a single pass to filter out dups, sort the final list, etc, instead of having everyone trying to do that in their own form_alter()... just a thought.

dww’s picture

dww’s picture

Assigned: nedjo » dww
Category: feature » bug
Issue tags: +drupal.org upgrade

This used to work via code in drupalorg.module (added at #253825: Allow project co-maintainers to assign issues to each other). However, something during the d.o upgrade to D6 broke that code. Instead of fixing it there, we should just move it directly into cvs.module so cvs.module will be the one to implement hook_project_issue_assignees().

pasqualle’s picture

subscribe

dww’s picture

Status: Needs work » Fixed

Fixed, tested, committed (and removed from drupalorg.module) and deployed on d.o.

Status: Fixed » Closed (fixed)
Issue tags: -drupal.org upgrade

Automatically closed -- issue fixed for 2 weeks with no activity.