civicrm/civicrm-core — pull request #2188 by kirkatcaat (2013-12-10 12:56:13+00:00)
Title: Allow Participant roles to be specified as an array

The commit in this pull request is a duplicate of the commit in pull request 2130. PR 2130 was merged into master but the fix was intended for 4.4. Eileen McNaughton asked me to submit a second PR to allow the fix to be merged into 4.4 (see comment on CRM-13884) so that is what I have done.

This patch allows the Participant BAO to accept role IDs in an array. This fixes the problem of the Participant API not being able to accept multiple roles (CRM-13884).

When multiple roles are supplied to the Participant API as a delimiter-separated string of role IDs, the API automatically explodes that string into an array (in civicrmapi3_api_match_pseudoconstant). This is then supplied to the Participant BAO (CRM_Event_BAO_Participant) which causes errors because the BAO is expecting a delimiter-separated string of role IDs, not an array.

With this patch, the Participant BAO accepts an array of role IDs in the same way that the Contact BAO accepts an array of contact sub-types: by checking if the parameter is supplied as an array, and if so, imploding it into a delimiter-separated string.

This solution is in keeping with the comment in civicrmapi3_api_match_pseudoconstant (the function which, for better or worse, explodes the string of role IDs into an array) which states: "Better yet would be to... ensure that every dao/bao can handle array input".