civicrm/civicrm-core — pull request #2130 by kirkatcaat (2013-12-02 16:31:25+00:00)
Title: Participant BAO can accept role IDs in an array

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 _civicrm_api3_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 _civicrm_api3_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".