First off kudos to the maintainers for the great module and for keeping the issue queue in such great shape.

Our client uses a very large number of webforms, the submissions of which are emailed to one or more employees within the organization. They have a requirement for a report which shows the email addresses that each webform is sending to, with filtering and sorting. One example use of this would be when an employee retires, this report will allow the admins to easily locate the forms that employee was a recipient on and remove them.

I was able to get them what they wanted by exposing the webform_emails table to views.

CommentFileSizeAuthor
#2 expose_emails_to_views-2580517-1.patch2.83 KBjoshf

Comments

joshf created an issue. See original summary.

joshf’s picture

Assigned: joshf » Unassigned
Status: Active » Needs review
StatusFileSize
new2.83 KB

The attached patch got me as far as I needed to go. "Webform Email" is added as a views field group, and a single field "Email Addresses" is added to that group. During pre_render(), any integer values are assumed to be component IDs and an additional query to the webform_component table is fired off for each to get the component name, which is then rendered as '"Email" (form component)' (or whatever the component name is).

Although this solution works for me, it may be unsuitable for inclusion without additional work:

  1. I didn't add custom filter, sorting or argument handlers. Email records that use components instead of literal email addresses will still sort and filter based on the component ID, not the component name.
  2. I didn't add webform_emails as a base table in webform_views_data(). To do so would require adding a unique primary key to the table, which would't be hard but seemed unnecessary for this narrow case.
  3. The only column from this table that I added to webform_views_data() is "emails". There's probably a case to be made for adding other fields.
  4. There's probably a better way to join into the components table without doing N additional queries during pre_render().
danchadwick’s picture

Status: Needs review » Closed (won't fix)

It's good to have this work here for posterity. If someone is interested in pushing this over the goal line, addressing the issues raised in #2, I'm open to committing this to webform core. Otherwise let's close this and "won't fix" since it isn't complete.