I needed this for a project. Before I port it to Drupal 6 I need to know if this is going to be accepted.

Thanks
Robert

Comments

rmiddle’s picture

Title: Add the option for a form to use the submitter username and password. » Add the option for a form to use the submitter username and password as the from address.
quicksketch’s picture

Ooo, interesting. If I understand correctly, this patch make the username and e-mail address the "from address"? I'm not sure where passwords come into play.

This looks like a good approach, but it's worth mentioning that you can do this anyway with two hidden fields with the default values of %username and %usermail, then use those component as the From name and e-mail. Regardless, this might be a nice shortcut. What happens when the user is not logged in?

rmiddle’s picture

Title: Add the option for a form to use the submitter username and password as the from address. » Add the option for a form to use the submitter username and email address as the from address.

quicksketch,

The title made since when I wrote it? I ment email address not password.

%usermail doesn't work because the validation function doesn't allow it. We could update the Validation function to allow support for that variable but it would still be a lot harder for a user to find. I think I did try using %username at one point but it didn't work although I am pretty certain that was a typo on my part not something that doesn't work as it works when I tried it after create this patch.

When the user isn't logged in or in the off change there is no email address defined. I my case it happens sometimes because someones AD account doesn't have one set. Then it will fall back to webform's system wide defaults.

Thanks
Robert

PS. I noticed I left 1 line of debuging code in there. If you think the idea has merit I will update the 5.x patch when I submit a 6.x patch.

quicksketch’s picture

Yep, I think this would be a good enhancement. If you can tidy up the enhancement and port it to 6 I'd be happy to commit it.

rmiddle’s picture

StatusFileSize
new5.84 KB
new6.13 KB

Here is the lastest D5 & D6 patch against CVS.

rmiddle’s picture

This patch has been used on my live site for over a month now with no visible problems.

rmiddle’s picture

Bumping to the top of the list to see if quicksketch will have a change to add the update.

Thanks
Robert

quicksketch’s picture

Status: Needs review » Reviewed & tested by the community

Thanks rmiddle, this code all looks fine to me. Sorry I've been completely swamped trying to get stable versions of FileField and ImageField released. Next time I'm working on Webform patches I'll add this in.

hass’s picture

Status: Reviewed & tested by the community » Needs work

There is one small bug inside a translatable string. t('Use submitter\'s information if anonymous users use default.') need to be changed to t("Use submitter's information if anonymous users use default.")

quicksketch’s picture

Version: 5.x-2.x-dev »

Well now this has taken so long we're not working on 2.x anymore. Moving to the 3.x queue. Thinking of an alternative, we could just run _webform_filter_values() on the e-mail values, meaning you could just set the e-mail to %useremail and from to %username, then we wouldn't need to add another radio button at all.

strider72’s picture

Version: » 6.x-2.9

I would very much like to see this working when the submitter is not logged in. I use web forms on a public site -- the only "Users" on the site are the admins, so forms are always submitted by people not logged in.

I would like to have an "email" field, and if (!) it is filled in, that is the return address on the email.

(As a side note-- I'm a bit confused. Why do so many Drupal updates linger for so long? This apparently had a working patch for **over a year** ready to be committed, and then "Whups -- too late!" Does Drupal just not have enough committers to go around?)

quicksketch’s picture

@strider72: Webform is pretty much maintained just by myself, and I also maintain a dozen other modules and make regular contributions to core. Since I don't actually use Webform on a regular basis, the features that get reviewed and go into Webform are frequently added based on the time I have available. So yes, there is a dearth of reliable committers that are able and willing to contribute their time, especially since it's done in free time and rarely paid for.

quicksketch’s picture

Version: 6.x-2.9 » 6.x-3.x-dev

Also, still not going into 2.x, this is a 3.x only feature since 2.x is nearly at the end of its rope.

strider72’s picture

@quicksketch: As a contributor to WordPress (and several plugins for it), I appreciate the nature of free open source coding. ;-)

I guess I'm just surprised that this particular one only has one person maintaining it, as web forms are such a *basic* thing I would think there was a huge demand for this module.

Either way, thanks for plugging away at this (so to speak). Perhaps when I have a better understanding of the Drupal plugin API I'll contribute to this plugin.

Grayside’s picture

To clarify, the current intent is to use Webform's Token system for From: email configuration? I will roll a patch to that effect.

As an aside, is there a reason this does not use the Token module?

quicksketch’s picture

Hi Grayside, yes I believe the current direction is my suggestion in #10:

Thinking of an alternative, we could just run _webform_filter_values() on the e-mail values, meaning you could just set the e-mail to %useremail and from to %username, then we wouldn't need to add another radio button at all.

Regarding token.module, see #428982: New hooks for additional token replacements.

Grayside’s picture

Assigned: Unassigned » Grayside

Okay.

I see that the email subject is using a %title token by default. This does not appear in theme_webform_token_help(). Does that mean it is not part of the webform token system?

quicksketch’s picture

The help is not based on the actual tokens available (though it tries to include all of them). The best thing is to check _webform_filter_values() and see what tokens are available there. %title should be added to the list of tokens in the help.

Grayside’s picture

Looking at this, I see there are global email settings at admin/settings/webform, and also email settings at node/#/webform/emails. However, the settings of the latter do not seem to be pulling global defaults.

What do you want here?

quicksketch’s picture

The global settings are just the defaults, they're never used directly they just set the defaults for new e-mails.

Grayside’s picture

Right, but the webform-specific email settings are not pulling the global defaults in as defaults, they are using the same sitename/siteemail used in a vanilla install. So either there is a bug, or I have no idea what the Email From: settings do in the main settings form.

quicksketch’s picture

StatusFileSize
new158.83 KB

Maybe this screenshot will help.

The improper ordering of subject, from, and email should probably be fixed at some point. :-)

Grayside’s picture

Thanks. So that confirms that what I see looks like a bug. When I save those settings to admin/settings/webform, they are not used as defaults on the specific webform's email configuration.

I will confirm that and create a separate issue as needed.

Grayside’s picture

Okay, what I'm seeing is a UI issue with filtering the tokens to build the email address/etc in building the UI. Back on forward momentum.

webform_format_email_address() in webform.module applies filters the email addresses. This creates confusing UI where the webform administrator sees the processed tokens, such as their own email address. Since there are already so many arguments going into this function, I wanted to ask: is a preference on how to conditionally skip token filtering?

quicksketch’s picture

Ah interesting. It sounds like webform_format_email_address() shouldn't be getting called at all then if you're wanting to show the original tokens and not the final e-mail address? If you can make a generic attempt at fixing the problem I'll see if it makes sense, it'd also help me understand the problem fully.

Grayside’s picture

Hm, I never thought about not calling it. I assumed if there were no tokens the rest of that function did desirable things. I think it's important in the node/#/webform/emails page that if the form creator used %useremail, he's not confused by seeing his own email address.

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new10.19 KB

Okay, now accepting tokens for email address configuration.

This did not require touching the actual email submission system, as that already checks for tokens.

Summary of Changes:

  1. webform_format_email_address() and webform_format_email_subject() now have a $filter_tokens argument. If false, the _webform_filter_tokens() function is *skipped*.
  2. The per-webform email configuration UI now displays the configured email without token filtration, meaning the form administrator can see the tokens. I could not decide if there should be further documentation around the UI explaining this.
  3. Custom email address per form puts the user input through the filtration process to double check correct use of tokens. This means the currently logged in user needs to be valid if things like %useremail are to be used. [see webform_email_address_validate()]
YK85’s picture

subscribing

quicksketch’s picture

So I'm reviewing old patches now and finally took another look at this issue. I don't like all the new parameters added by the patch in #27. We've already got 5-7 parameters on these functions and adding more just makes our code more difficult to follow. The overall effect of the patch doesn't seem to make things easier to understand, though it would provide a shortcut for advanced users. Overall I'm not sure there's a net-gain for this patch.

quicksketch’s picture

Status: Needs review » Needs work

Moving this to needs work pending any feedback. Right now I'm leaning towards won't fixing this issue.

danchadwick’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

There won't be further feature development in the X.x-3.x branches.