Closed (won't fix)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2008 at 17:02 UTC
Updated:
20 Feb 2019 at 17:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
quicksketchThis currently isn't possible, other than manually updating the values in the database. Let's move it to a feature request.
Comment #2
miro_dietikerWe're working on this.
Comment #3
alawneh86 commentedThe patch attached give permission to change the submission author and date.
Comment #4
quicksketchThanks, this looks pretty good. A few needed changes:
- Format the form so that each element is a defined array like this:
- Use
$form_state['values']instead of$form['#post']. $_POST is spoofable, $form_state is double-checked by Drupal.Comment #5
quicksketchComment #6
miro_dietiker:-) that's what i was just right before submitting: form_state values and permission checks...
quicksketch: when using the ['values'] there's no further permission check needed in the submit function?
Comment #7
quicksketch$form_state['values'] is impossible to spoof from the client-side, so you shouldn't need additional checks. Note that hidden fields are NOT enforced at a particular value, unless you use #value instead of #default_value.
Comment #8
alawneh86 commentedThis is a new patch according the latest changes on the module.
I used array format inside the form alter,
also i used $form_state['values'] rather $form['#post'].
Comment #9
miro_dietikerHere we go some review about current state.
Is there no further global webform admin permission to check and pass?
I suspect this won't lead to display of the right original submission user if you edit a submission of someone else.
Trailing space
Also: what about previous submissions on edit? I suspect this will update the creation time to edit time.
Trailing space
submitted instead of submited (typo) please
Tabs...
Powered by Dreditor.
Comment #10
alawneh86 commentedAll issues are fixed.
now, you can change the submitting author and date if you have 'change submission author' or 'administer users' permissions.
Comment #11
miro_dietikeris it just me or...
what about the $form['#parameters'][3]->xyz
this looks so strange to me...
Is there no official way?
I was additionally looking at the webform code for the current form creation. See the following code from current webform.
I really think $submission should be available and therefore this would be the way to go instead of parameters.
In any other case the interfaces need cleanup.
Comment #12
alawneh86 commentedI used the $submission object to get the submitted author and date rather than $form['#parameters'][3].
and I added the author and date fields inside the 'webform_client_form' rather than 'hook_form_alter'.
Comment #13
alawneh86 commentedproviding validation on the author name.
Comment #14
khaled.zaidan commentedEditing a submission by a user other than the original author, resulted in changing the author to the new submitter.
And editing a submission by a user who has no permission to change the submission date, resulted in changing the date to the current time.
Now it checks, if the user id is already set for an author and the user doesn't have permission to change the author, it keeps the original user id.
And also if the user doesn't have permission to change the submission date, no submission date is sent to the 'webform_submission_update($node, $submission)' call. 'webform_submission_update($node, $submission)' also had to be patched not to update the submission date of it is not specified.
Comment #15
miro_dietikerOK, this now seems to work correctly.
From perspective of clean software code and simplicity:
I don't understand why in webform_client_form_submit() webform is not loading the submission from database using webform_get_submission() instead of building some arbitrary new object. Thus previous author of the submission would be present and no special case needed in webform.submission.inc webform_submission_update()
Not setting it to needs work as this is an architectural decision to be considered by the maintainer.
Comment #16
miro_dietikerthere's a multipage issue. changes don't get persisted, get reverted and only get stored on the last page.
Comment #17
khaled.zaidan commentedNow the admin fieldset has it's own submit button. If editing an existing submission, it will be displayed on all pages, so the user doesn't need to go to the last page to change the author and/or date. If it's a new submission, it is only displayed on the last page.
Edit: of course there will be no separate submit button for new submissions, since the submission doesn't exist yet.
Comment #18
rsacchi commentedVery nice functionality, do you have plan to accomplish that in the version 6.x-3.0 of the webform ???
I'am needing something very similiar, but in the version 3x.
Thank you so much for this peace of code.
Comment #19
miro_dietikerI was sure this was for 3.x ... no?
Comment #20
quicksketchYeah I'm not sure why this is still in 2.x. New features are only being added 3.x.
Comment #21
rsacchi commentedYou are right, my fault.
Thanks
Comment #22
pathaksumit commentedIs it possible to change to multiple user by adding any functionality in this patch??
Comment #23
shawn dearmond commentedThere's still a problem where, when creating a new submission, the submitter sees the "Administration" fieldset on the second page of a multi-page webform. The submitter does have "change submission author" permission, but does not have "edit submissions" access to this webform.
Also, when the form is in "Draft" mode, the "Administration" fieldset appears.
Comment #24
shawn dearmond commentedHere's a re-rolled patch that fixes #23. I also cleaned up the comments a little.
Comment #25
shawn dearmond commentedNeeds Review
Comment #26
flightrisk commentedWas this ever included in webform?
Comment #27
quicksketchNo, if it were it would be marked "fixed" or "closed (fixed)". I'm still interested in the feature but it's not a high priority for me. Reviewing the patch and/or updating it will help move it forward. I marked your other issue #1540396: Can admin submit a form for another user? duplicate, since this is the feature that would be included, rather than a "submit as another user" feature.
Comment #28
flightrisk commentedI just realized this is useless to me. I am using the latest version 7 dev release. This patch is for version 6. The code is very different. Is there any chance I can get this patch for version 7 so I can test? Thanks.
Comment #29
flightrisk commentedIs there any update on this for Drupal 7? Thank you.
Comment #30
miro_dietikerKhaled didn't participate for a long time.
Comment #31
quicksketchThis patch needs a reroll for the 7.x-4.x branch. The current patch also has some code formatting issues that could be addressed (whitespace vs. tabs). I'd appreciate a more polished UI than simply another collapsed fieldset, but I recognize that might not happen in the initial pass.
Comment #32
danchadwick commentedWith the use of views to display the webform submissions and results (7.x-4.2+), I would suggest that you use VBO and and write an action to set the submission user and date. I don't see that this feature would go into webform core, although I would consider adding the actions. If this is an avenue that someone wants to proceed, along with providing some other actions (e.g. delete submission, maybe even download), please open a new issue.
Comment #33
coderintherye commentedDan could you talk more about your reasons for not wanting this in the core of webform?
I could maybe see your logic for D8 since it includes views by default, but it's harder to parse for 7.x. especially with a viable solution at hand and one that is relatively well-contained change with minimal affect on the UI.
I'm attaching a re-rolled patch for 7.x that seemingly works (note it's done against my own repo so probably needs re-roll properly against webform repo) and could use some testing and perhaps further cleanup (might need some fudging as its against 3.x branch vs. 4.x but willing to re-roll against 4.x and add tests if you are open to this possibly making it in).
P.S. Left it as won't fix since you are the maintainer, but if you decide it's worthwhile please flip back to needs work or needs review. Thanks!
Comment #34
danchadwick commentedYour patch seems different from what was discussed above (bulk changing of multiple submissions).
I'm pretty sure you can accomplish this without hacking webform. You can use hook_webform_client_form_alter() to add the admin fieldset, and you can add a submit handler to adjust the author or date(s). Note that submissions now have 3 dates: first saved, first completed, last updated.
If lots of other people jump on this issue and shout with enthusiam, I could consider that an indicator that there is a broader use case than what I see. Absent that, I don't think this belongs in webform core.
Comment #35
mywebmasteruk commented@coderintherye your patch on #33 does not seem to match the current webform.module 7.x 4.13
Can someone help me with an updated patch please?
or has anyone come up with a function from what Dan says in #34?
Comment #36
pixelshrink commentedI'd really like to see the author editable on webform.
Comment #37
robertgarrigos commentedI would love to see this into webform, I'm really enthusiast about it!! :-)
Comment #38
lordzik commentedPatch from #33 is in fact ok (7.x-4.19), only 3rd chunk needs to be applied manually.
What's wrong is that when submission is edited, the following error appear:
Warning: array_flip(): Can only flip STRING and INTEGER values! w DrupalDefaultEntityController->load() (linia 175 z /var/www/html/drupal7/includes/entity.inc).
Please specify a valid author.
Any chance to fix it?
Comment #39
commonpike commented[
deleted] ( I cant delete posts here :-) )