Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#901 2010-10-27 17:10:00

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: zem_contact_reborn 4.0.3.20

Thanks, Ruud! That works magnificently!

Offline

#902 2010-11-03 13:45:50

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: zem_contact_reborn 4.0.3.20

I’ve seen the example on how to have a user-selectable recipient, with the switch-case processing in another form to match email addresses to recipients. However, what I would like to know is whether I use this approach but pull the email addresses from a database table.

Here is what I have…

Thanks to some trickery with smd_query, I have a separate table which holds positions (President, Secretary, Treasurer, etc) and each position is assigned to a user from the ign_users table.

I would like members on my site to be able to select the position they want to email (not the person’s name) and then for the zem_contact form to send the email to the corresponding email address.

Logically, I can figure out that I need to grab the list of positions, grab the list of corresponding email addresses for those positions and then process the switch-case functionality over the arrays. I just don’t know how to code it in PHP (or whether native TXP codes could do the job).

Offline

#903 2010-11-08 12:59:13

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: zem_contact_reborn 4.0.3.20

Here is what I have so far…

On my zem_contact form, I have the following:

<txp:variable name="addresses"><txp:smd_query query="SELECT GROUP_CONCAT(role ORDER BY type desc, list_order) AS positions FROM as_roles WHERE occupied_by>0">{positions}</txp:smd_query></txp:variable>
<txp:zem_contact_select label="Position" list='<txp:variable name="addresses" />' /><br />

- together with all of the normal tags. This correctly outputs the list of positions in a drop-down box.

In my to_form, I have the following:

<txp:adi_gps post="1" name="Position" quiet="1" />
<txp:variable name="to_address"><txp:smd_query query="SELECT email FROM ign_users,as_roles WHERE as_roles.role='?Position' AND as_roles.occupied_by=ign_users.user_id">{email}</txp:smd_query></txp:variable>
<txp:variable name="to_address" />

This fails to send the email. However, if I change the '?Position' to the name of an actual position, then the form correctly finds the email address of that person and sends the email.

smd_query is happy in every other situation to acceppt a variable using the form ?variable_name. What is different about this situation?

Offline

#904 2010-11-08 18:38:01

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

I’d strongly recommend against using user-input directly in an SQL query without any validation.

Instead, try replacing <txp:adi_gps post="1" name="Position" quiet="1" /> with:

<txp:variable name="Position"><txp:php>
  echo $GLOBALS['zem_contact_form']['Position'];
</txp:php></txp:variable>

PS. the reason your code didn’t work, is because in the zem_contact_select tag you’ve set the label to ‘Position’, but this doesn’t also set the name attribute of the select tag to the same value.

Offline

#905 2010-11-09 00:50:47

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: zem_contact_reborn 4.0.3.20

Thanks for this.

The funny thing was the value of ‘Position’ was coming through from the zem_contact form as I had some tests set up to check for it. But thanks for the tip on getting the value directly into a txp_variable.

On my first try, this still failed but I tried changing the name of the variable to all lower case and that worked!

Finally, I take your point on validation for the SQL query. I was more trying a quick-and-dirty to get this to work, and need to go back now and make it more robust. All of this sits behind a members-only site with ign_password_protect, and the members are all known personally to me ie. this is not like a self-registration system. But I guess it’s always worthwhile putting as many safeguards in place as possible.

Offline

#906 2010-11-10 12:09:29

Tarokun
New Member
Registered: 2010-11-04
Posts: 3

Re: zem_contact_reborn 4.0.3.20

datorhaexa wrote:

Running PHP 5.3.1 on my test server and zem_contact_select throws a Function split() is deprecated on line 538
This might need some fixing.

Hello!

I’ve hit this problem too, using zem_contact_select. I can’t find mention of it anywhere else. Is there a solution to this problem?

Offline

#907 2010-11-10 12:18:14

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

It’ll be fixed in the next version. For now it’s just a warning. It won’t be a problem until PHP 6 is released, so you can ignore the warning for now.

Offline

#908 2010-11-10 12:25:44

Tarokun
New Member
Registered: 2010-11-04
Posts: 3

Re: zem_contact_reborn 4.0.3.20

Ah, okay! Thanks, Ruud!

Offline

#909 2010-12-05 12:23:10

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: zem_contact_reborn 4.0.3.20

Hello Ruud/TXPers,

I have just changed hosting provider and I am finding that email is still being sent as a result of the copysender="1" but no email is arriving with the person named in to=.

After quite a bit of testing I decided on balance to ask here, just in case the is a known characteristic (where the c.c. email works but main does not).

I’ve sort of assumed that the hosters ability to send mail, or not, is OK since the c.c. email arrives OK…

I’ve check the obvious stuff (spam folders).

Tried with two sites so far (both migrated to new hosting), both the same result, one is 4.2.0 the other 4.3.0. Both have
zem_contact_reborn 4.0.3.20
zem_contact_lang 4.0.3.6

Any comments, most appreciated. Cheers, -Alan

PS: In case it’s relevant (I’m almost certain it isn’t), the hosting has:
  • Apache ASP support = Off
  • SSI support = OFF
  • Perl support = OFF
  • Python support = OFF
  • PHP = ON (:-) and it’s not in safe_mode
  • FastCGI = ON

Last edited by alanfluff (2010-12-05 12:27:58)


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#910 2010-12-05 12:28:31

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: zem_contact_reborn 4.0.3.20

The only thing that changed is the hosting provider, so I have to assume that’s where the problem lies. Can you look at the mail server logs to see if the attempt to send email is registered there. If so, there’s a good chance you’ll see why it failed as well.

Offline

#911 2010-12-05 12:31:13

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: zem_contact_reborn 4.0.3.20

Hi Rudd,

Lovely, thanks, I did look, but not expertly, I will go look again — at least I now know it’s not a ‘common’ symptom.

Thanks so much!

Cheers, -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#912 2010-12-05 13:48:12

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: zem_contact_reborn 4.0.3.20

Hi Rudd,TXPers,

If you use a MediaTemple (mt) dv server (very nice) and you are not using email accounts on the server (so it is safe to turn off email for each domain in question), then it seems, turning email off for the domain allows the default mt dv server to send email both to the c.c. address and to the to= address from TXP + zem_contact_reborn.

The mt support agent was very good and asked, specifically if the email was going to a Google Apps email account (it was), and then asked me to turn off the email.

Still not quite sure how the settings at mt allowed c.c. mail from TXP to work (that was going to a plain Gmail) and to= to not work (going to a Google Apps), but I am just delighted to have found the mt setup change to fix it.

Hope this helps someone else.

Thanks again Rudd for your lightening fast response and most-sensible advice.

Cheers, -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

Board footer

Powered by FluxBB