Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here's my use case: I need a list of webforms on the site that the current user hasn't filled out yet (or a list of webforms filled out by the current user). By restricting this information to the current user only, we don't need to worry about access permission issues, users already know what webforms they have submitted.
The patch applies to views/webform.views.inc, and the new handler file has attached separately (thanks CVS for not allowing to diff new files) with a .txt appended (.inc uploads are not allowed).
Credit: I used the views integration of node and flag as examples/references.
Comment | File | Size | Author |
---|---|---|---|
#1 | webform-591902-1.patch | 2.67 KB | djalloway |
webform_handler_filter_current_user_submission.inc_.txt | 698 bytes | floretan | |
webform_user_submissions_filter.patch | 1.67 KB | floretan | |
Comments
Comment #1
djalloway CreditAttribution: djalloway commented@flobruit,
I've tested your code and it seems to work as intended.
If it is alright with you, I've cleaned up some of the wording and names to clarify the filter a bit.
I've also rolled the patch to include the new file via CVS.
Here are the results.
**The trick to getting CVS to add new files when you roll a patch, is to manually modify the hidden CVS folder entries, and add a new line for each of your new files. You can read more about that at here (mid-way down the page under the section "Adding/Deleting Files Using the Diff Command")**
Comment #2
floretan CreditAttribution: floretan commented@djalloway: Thanks for the fixes and the CVS hint!
Is there any chance this could be committed to webform_views as well?
Comment #3
djalloway CreditAttribution: djalloway commentedlooking to add this to the webform_views module.
but... the Left Join is making the view display duplicates (5 submissions on 1 Webform = 5 Results).
Comment #4
floretan CreditAttribution: floretan commentedI only used the negative version of the filter, but the positive does indeed result in duplicate results. The solution would be to use an EXISTS subquery instead, but that's not used anywhere else in Drupal due to the way db_rewrite_sql() works.
Given that this filter only applies to webforms submitted by the current user, I guess it could be ok to bypass db_rewrite_sql() without risking to disclose private information. However, the positive version of the filter doesn't really make that much sense in real use cases, so maybe we need to drop it and simply keep the negative version, which can be very useful especially combined with other filters (pending webforms in your groups for example).
Comment #5
djalloway CreditAttribution: djalloway commentedsure, that is worth a shot.
Comment #6
Dave Sherohman CreditAttribution: Dave Sherohman commentedAre there any changes on this since the October 12 revision of the patch?
I'm going to be looking in the near future to present users with a list of eight webforms (out of nine total existing on the site) with an indicator for each showing whether the user has completed it or not. Display will be a single list with fixed order which may mix positive/negative results (e.g., webforms should be ordered 1, 2, 3, 4, 5, 6, 7, 8 even when user has done #1, 3, 5, and 7, but not #2, 4, 6, or 8). Does that fall within (or at least fairly close to) what this patch does or will I be better off building that functionality from scratch?
Comment #7
quicksketchIf this issue hasn't been marked as "fixed" this hasn't been committed. The Views integration is only included in the 3.x version. This feature does sound like what you want though other than I'm not sure what you mean by "positive/negative" results.
Comment #8
Dave Sherohman CreditAttribution: Dave Sherohman commentedBy "positive/negative" results, I was adopting comment #4's usage of the "positive version" (returns forms the user has submitted) and "negative version" (returns forms the user has not submitted) of the filter.
Is there an expected completion date on 6.x-3.0 or is it on a purely "it'll be ready when it's ready" timeline?
Comment #9
quicksketchI've been hoping to get 3.0 out for some time, I think this latest beta6 will be the last, then we'll move into RCs or possibly directly to a final release. 3.0 is already more stable than 2.x is, since it's moved a lot of areas that caused trouble (such as modifying the node form). That said, a final 3.0 release does NOT mean that the feature in this issue will be included. Most likely it won't be, as I'm really only concentrating on bugs to get the 3.0 version out the door.
Comment #10
Apfel007 CreditAttribution: Apfel007 commentedis this patch already included?
Comment #12
quicksketchNo this patch is not in the 3.x version of the module yet.
Comment #13
YK85 CreditAttribution: YK85 commentedsubscribing
Comment #15
derhasi CreditAttribution: derhasi commentedThis issue can be solved by fixing #1258044: Webform views integration needs to provide relationships for both user and node based views.. Then the user filters can be used to fullfill this need.
quicksketch, shall it be marked as duplicate?
Comment #16
derhasi CreditAttribution: derhasi commentedOk, as this is state of February, I guess it's okay to mark it as duplicate ;)