Would it be possible to add substitution values for any of the other user profile fields? I am thinking in particular first name and surname and possibly for the custom fields as well or even integration with the Token module?

There are very few modules that offer bulk emailing users with the use of filters. Although I have looked at using the newsletter module, Advanced User is much simpler and straightforward to use and being able to use other substitution values for the email would be, in my view, a good and helpful extension.

Comments

Anonymous’s picture

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

Integration with Token module would probably be best. Feel free to provide a patch for 6.x-3.x-dev for the maintainers to look at.

Anonymous’s picture

Title: Additional email substitution values for other user profile fields » Integrate with the Token module for email token substitution.
Anonymous’s picture

rsevero’s picture

Status: Active » Needs review
StatusFileSize
new12.92 KB

Here is a patch that changes the variable substitution used in the Advanced User module from the current method to Token module.

Almost all substitution variables had their names changed because the names used by Advanced User where different from the ones used in the Token module.

There were a few variables used by Advanced User that didn't exist in the Tokens module so I created them inside Advanced User through the Tokens module API.

I changed the default subject and email definitions to match the new variable names, i.e., I changed the definitions so the default subject and emails would remain the same.

I also changed the prefix and suffix used by Advanced User to match the ones recommended by the Token module. Previously Advanced User used % as prefix and nothing as suffix. Token module mentions that it's safer to use a prefix AND a suffix to eliminate the possibility of variables starting with the same letters being substituted wrongly. I adopted [ as the prefix and ] as the suffix.

Please review the patch and let me know if there are any modifications necessary.

Anonymous’s picture

Oh, joy, I don't have to do it! :D

Do we really have to code it like this?

+    User: !prefixuser!suffix
+    Mail: !prefixmail!suffix

That's just ugly. I knew using Token would require this level of alteration. Is the !prefixuser!suffix what the user will put in the settings form?

rsevero’s picture

Oh, joy, I don't have to do it! :D

You are welcome.

Do we really have to code it like this?

No. Not really. I did it this way only because I was uncertain that the delimiters change would be well received by you (from "% before" to "surronded by []") and this way it would be easier to roll back the delimiters change.

Is the !prefixuser!suffix what the user will put in the settings form?

No not all. The user will use [user]

As the users won't have to deal with this ultra-ugly !prefixuser!suffix syntax I believe the way I coded is ok but if you prefer it can be made prettier. Please let me know.

Anonymous’s picture

Status: Needs review » Needs work

Yes, please make it prettier. It is too difficult to tell where the !prefix ends and the variable begins. I had planned to use the [] format which seems to be standard.

Should I host a profile_tokens module? Drupal 6 will be around for a while longer so it wouldn't hurt. We can make it optionally dependent on the profile module being active and raise warnings to the administrator if it is missing when profile module is active.

rsevero’s picture

Here is a patch that beautifies the default subject and mail definitions. It should be applied after applying my previous patch.

There are already some discussions on the subject of hosting the Profile Tokens module (or including it in the Token module itself). You can track these discussions at #125640-73: Profile tokens.

I think your idea of the optional dependency is a good one. I believe we should just see what is settled with the Token module maintainers about the Profile Token module before doing anything.

rsevero’s picture

Status: Needs work » Needs review

Forgot to change the status.

Anonymous’s picture

Status: Needs review » Needs work

The second patch is empty. Can you please use ``cvs diff -up'' to create the patch? Easier for me to apply.

rsevero’s picture

Status: Needs work » Needs review
StatusFileSize
new9.89 KB

How many mistakes one can make when trying to provide a patch?...

Let's see if I managed to provide a working patch this time.

This is a complete patch made with all up to the last modifications you asked for created against DRUPAL-6--3 version from a few hours back with the command you mentioned. (I'm still unsure if DRUPAL-6--3 is a branch or a tag).

Anonymous’s picture

Status: Needs review » Needs work

The only thing I question is the use of the word _DEFAULT_ in ADVUSER_DEFAULT_TOKEN_PREFIX, ADVUSER_DEFAULT_TOKEN_SUFFIX . We don't provide a settings option for the user to change it so we should just use ADVUSER_TOKEN_PREFIX, ADVUSER_TOKEN_SUFFIX instead.

BTW, DRUPAL-6.x-3.x is both a branch and a tag. Branch is a type of tag and release is a type of tag. You work from the branch tag and the release tag is a static repository of the released code.

rsevero’s picture

Status: Needs work » Needs review
StatusFileSize
new9.81 KB

This patch has the DEFAULT_ removed from the prefix and suffix constant names.

Just to further clarify the branch X tag X release cvs definitions: you say the release tag is static. So is it correct to infer that the branch tag isn't static?

Anonymous’s picture

Should we add a hook_requirements to alert the users who update without reading on the new dependency for the Token module? Is there some method to tell the Update status module about this dependency?

rsevero’s picture

I think it's a good idea.

Here is a patch.

Edit: I'm not sure about the name and path of the Profile Tokens 6 module as the page where fizk said he put it isn't showing it yet. He said it would show sometime today.

Anonymous’s picture

Status: Needs review » Needs work

Always provide a full patch without specifying the file so that all changes are incorporated in one patch.

The requirement you've given in the install file is for profile_token which is not mentioned in the info file. My question in #14 was related to the Token module required in the info file.

rsevero’s picture

AFAIU there are two dependency issues at hand:

  1. The mandatory dependency on the Token module. This is dealt with with the "dependencies[]" entry on the .info file. As per the hook_requirements API manual page "Module dependencies do not belong to these installation requirements, but should be defined in the module's .info file."
  2. The optional dependency on the Token Profile module. This is the one I'm trying to deal with on hook_requirements.

Do you envision something different?

On other matter: what do you think about creating a constants file for the module?

Anonymous’s picture

Well, ``optional'' functionality isn't a requirement so profile_token doesn't belong in hook_requirements. I'm wanting to give the users of advuser a status message that Token module isn't available when they have advuser active and then simply drop in an updated version and they don't even have the Token module installed in the modules directory. I was just thinking that hook_requirements would be the better place but if there is something else I'm listening. I'm just trying to avoid the RTFM issues.

rsevero’s picture

Ok, I will include the mandatory dependency on the Token module in the 'runtime' requirements. In case of failure it will return with an error.

About the optional dependency on the Token Profile module: I believe that it would be helpful for users to get an warning on the lack of the Token Profile module in the same spirit the Upload module does in a similar situation. Here is an example of the warning the Upload module provides:

Upload progress Disabled
Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library (preferred) or to install APC.

What you think about it?

Any ideas on the one below?

On other matter: what do you think about creating a constants file for the module?

Anonymous’s picture

The thing I would dislike about that is the fact that if I don't care I really don't care and don't want to see a message on the admin form. If you use a drupal_set_message on the admin/build/modules page when the profile module is in use then I'm all for it. Use 'advuser_warning' as the type of message.

As for the constants, assuming that you're talking about the define('ADVUSER_...', ...) ones, they belong in the .module file. No need to include another file. If you find one that is only associated to the settings form, then you could move it to forms/advuser_settings.inc but then you run the risk of some future maintenance needing to move it back to the .module file.

rsevero’s picture

Status: Needs work » Needs review
StatusFileSize
new12.07 KB

Ok. Your module, your rules. ;)

Here is the patch without 'requirements' testing for Token Profile module.

Anonymous’s picture

Great and thanks. I'll give it a try this weekend.

jghyde’s picture

rsevero--

Can you re-apply your patch and post it based upon the latest DEV version? Thanks.

Joe

rsevero’s picture

StatusFileSize
new11.77 KB

Here is a patch against DRUPAL--6-3 version I checked out a few minutes ago.

jghyde’s picture

rsevero --

Applied the patch to DRUPAL--6-3 and it appears to work through a series of tests, including simpletest. We need someone else to test this patch to make sure there are no bugs before committing to the next version.

Thanks for your quick reply!

Joe

5t4rdu5t’s picture

Hi there,

I've just tested the patch on #24 and although found no major errors or issues, here's a list of what I've detected so far:

1. User profile tokens don't show on the Substitution variables list
2. "Administor" typo on Mail body default text
3. Couldn't get notifications logged in watchdog or account activity emailed to admin either for new user or updated profile info even when selecting these options in settings. (guess maybe I'm missing something here, I'll try again later)

This is my testing setup:

Drupal-6.17
Advanced User Management 6.x-3.x-dev
Profile Tokens 6.x-1.x-dev
Token 6.x-1.12
Core profile module enabled

jghyde’s picture

Thanks Libriana!

I have reviewed your bugs and I think fixed them. Here is the next patch that I need reviewed by two people before we can commit it to the next version. This is to add Tokens module dependency and features to the Advanced User module (advuser).

I split the patches up into five files, one for each file to be patched. I am also submitting a tarball with the entire module to make it easier for someone to download and test. The tarball is 6.x-3.x-dev with all five patches to provide Tokens support applied.

The sooner we get some testing, the faster we can commit this feature! Thanks everyone for helping out.

My testing environment:
Drupal-6.17
advuser 6.x-1.x-dev
Token 6.x-1.12
(core) Profile module enabled

(I did not test this against Profile Tokens 6.x-1.x-dev)

All tokens appeared.
Email notifications happened.
Everything was showing up in Watchdog.

Anonymous’s picture

The patch in #24 needs to have an hook_update_N to change the previous substitution tokens to the changed tokens in the variables for the mail if they exist in the variable table.

@joe: You need to use ``cvs diff -up'' in the top level directory. Do not include differences of each file nor the entire changed module in a tar.gz.

rsevero’s picture

StatusFileSize
new13.46 KB

Updated version of #24 patch with requested hook_update_N.

rsevero’s picture

Updated #29 patch with fix for #26 item 2 (which wasn't introduced by this patch BTW).

Item 1: user tokens are listed in http://example.org/admin/settings/advuser "Registration notification controls" and "Account update notification controls". Is there anywhere else to check? Or are there other tokens to be presented? Please provide more detailed information if you believe there is still a problem.

Item 3: I didn't test it. If this problem is really present, I bet it has nothing to do with this patch so I suggest a specific issue is opened for it.

rsevero’s picture

Ok, this gotta be the last version of this patch.

Fixed the account-url passed as user administration page.

Anonymous’s picture

Thanks rsevero, I'll give it a look later this week.

bmango’s picture

I'm happy to help with testing. I have never tested before is it fairly straightforward?

Anonymous’s picture

@bmango: Thanks for the offer but I don't have time to train you in how to test modules with patches applied. If you can find a book or online document that you can read and figure it out that would be great.

bmango’s picture

I tried uploading the tarball in #27. Everything worked fine until I tried to submit a "send email" action. I then got a fatal error:

Fatal error: Call to undefined function _advuser_get_tokens_list() in /homepages/0/d309344694/htdocs/ben/sites/all/modules/advuser/forms/advuser_multiple_email_confirm.inc on line 66

This is my testing setup:

Drupal-6.16
Advanced User Management 6.x-3.x-dev
Token Profile 6.x-1.x-dev
Token 6.x-1.12
Core profile module enabled

rsevero’s picture

@bmango: the more up to date patch is the one from #31. Could you test it and report?

Thanks.

bmango’s picture

@rsevero: I have just applied the patch from #31 to Advanced User Management 6.x-3.x-dev. I got the following message:

Hunk #1 FAILED at 2.
1 out of 1 hunk FAILED

Everything else seemed to be ok. I tried the module, and had the same problem as in #35 when trying to "email selected users". I got the fatal error:

Fatal error: Call to undefined function _advuser_get_tokens_list() in /homepages/0/d309344694/htdocs/ben/sites/all/modules/advuser/forms/advuser_multiple_email_confirm.inc on line 66

rsevero’s picture

StatusFileSize
new13.72 KB

@bmango: could you please test this patch?

bmango’s picture

StatusFileSize
new99.65 KB

@rsevero:

Just tested the patch in #38. I am getting the error: Hunk #1 FAILED at 2. 1 out of 1 hunk FAILED, but apart from that it seemed to apply the patch fine.

I then tested the "email selected users" action and this is now working without errors. I am attaching a screen-shot.

However, I had added a profile field for users to add their first name (as a test) but this field wasn't appearing on the list for token replacements in the email. I thought that it would?

The only other thing was the alignment for the bullet point of the list of people being emailed was appearing slightly outside the box (see top of attached image).

Hope this helps.

rsevero’s picture

@bmango: if you are getting a Hunk #1 FAILED at 2 error you don't have the newest DRUPAL-6--3 code as the above patch applies cleanly in it.

This patch makes Advanced User use the Token module for token substitution and creates a few specific Advanced User tokens. To get profile field tokens you need the Token Profile module from http://drupal.org/project/token_profile.

The bullet point alignment issue isn't related to this patch. I bet it has something to do with the select theme.

bmango’s picture

@rsevero

Ok, thanks.

akalata’s picture

I also applied the patch in #38 to 6.x-3.x-dev from 2010-Jul-11. Same error as bmango in #39 (since I didn't get from CVS), but otherwise appears to be working fine.

Now to figure out how to get this token applied to the registration email (#257200: Custom profile fields in registration mail)...

raulmuroc’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Assigned: jghyde » raulmuroc
Status: Needs review » Patch (to be ported)
StatusFileSize
new13.72 KB

Patch #38: Tested & reviewed. It works correctly. It has some Warnings and mistakes, I think they can be solved through Drupal 7 port.

Re-attaching patch and working on it (to be ported).

Anonymous’s picture

RaulMuroc: The patches are approved. Go ahead with the commit. Please release a 6.x-3.x alpha2 release.

Anonymous’s picture

Patch in #38 has been pushed to the repository at http://drupalcode.org/project/advuser.git/commit/c48f7f1 for 6.x-3.x. I will do the same for 7.x-3.x soon.

Anonymous’s picture

StatusFileSize
new12.65 KB

I manually applied the patch to 7.x-3.x-dev, the attached is the result.

Anonymous’s picture

Assigned: raulmuroc »
Anonymous’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.