Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#229 2012-06-30 17:02:15

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

I took a look at this page ,
where you can find the full old list of the fields can be output using the bab_pm_data tag,
and there is no mention for the unsubscribeID.
So I guess Michael didn’t added it during developing the new versions.
If I’m right, then do you know how can we add the option to output unsubscribeID please?

Offline

#230 2012-06-30 17:20:48

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,777
Website GitHub Twitter

Re: mem_postmaster - Postmaster Revamp

Hi Gil, Unfortunately I have no idea as I never used the particular feature, neither on the original release nor when Michael took over. I think that it can be done with phplist. Some years ago I wrote a tutorial on how it could be integrated with txp.

With Ben’s departure from txp and Michael’s absence from the forum makes it harder to use this plugin. I am also worried what is going to happen with its compatibility with the next txp release.


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#231 2012-06-30 19:42:06

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

colak wrote:

Hi Gil, Unfortunately I have no idea as I never used the particular feature, neither on the original release nor when Michael took over. I think that it can be done with phplist. Some years ago I wrote a tutorial on how it could be integrated with txp.

Thanks and I will check and try it, but it will not work for the project I’m currently working on, maybe for others it will.

colak wrote:

With Ben’s departure from txp and Michael’s absence from the forum makes it harder to use this plugin. I am also worried what is going to happen with its compatibility with the next txp release.

Yep a big problema!

I’m trying to play with the code, being do that for hours now, and I found that the function bab_pm_unsubscribeLink($atts, $thing='') in the library doesn’t really do anything maybe it’s totally not in use and nothing is calling that function.
that’s the function of the <txp:bab_pm_unsubscribeLink /> tag.
I’m still playing with it now maybe I will make it and then share how to here (I hope).
Really don’t want to get into day #4.

Last edited by THE BLUE DRAGON (2012-06-30 19:43:00)

Offline

#232 2012-06-30 19:59:02

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

Also the next code in the plugin doesn’t seems to do anything:

				$url = $unsubscribe_url;
				if (!empty($url)) {
					$bab_pm_unsubscribeLink = $url . (strrchr($url, '?') ? '&' : '?') . 'uid=' . urlencode($unsubscribeID);
				}
				else {
					$bab_pm_unsubscribeLink = '';
				}

you can comment it out, and instead use:

$url = 'bla bla';
$bab_pm_unsubscribeLink = 'bla bla 2';

and you will get nothing! LOL

Offline

#233 2012-06-30 21:21:49

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

Finally made it to output the unsubscribeID and use if for the direct unsubscribe link :)

Now it’s not so pretty but it does works,
I changed the subscriberName to output the unsubscribeID instead of the full name.

So if you use the full name tag in your form
<txp:bab_pm_data display="subscriberName" />

then you will need to start using the two others first&last name tags instead.
<txp:bab_pm_data display="subscriberFirstName" />
<txp:bab_pm_data display="subscriberLastName" />

(it’s better then nothing!)

Now go to the plugin code and change:

			if ($i <= $email_batch) {
				@extract($subscriber);

				if (empty($subscriberLastName) && empty($subscriberFirstName))
				{
					$subscriberName = "Subscriber";
				} else {
					$subscriberName = @$subscriberFirstName . ' ' . @$subscriberLastName;
				}

into this:

			if ($i <= $email_batch) {
				@extract($subscriber);
/*
				if (empty($subscriberLastName) && empty($subscriberFirstName))
				{
					$subscriberName = "Subscriber";
				} else {
					$subscriberName = @$subscriberFirstName . ' ' . @$subscriberLastName;
				}
*/
				$subscriberName = @$unsubscribeID;

done!
Now you can create your direct unsubscribe link like this:
http://example.com/unsubscribe?uid=<txp:bab_pm_data display="subscriberName" />

Remember to include the <txp:bab_pm_unsubscribe /> inside your “unsubscribe” page, for example click here

Tomorrow mission (day #4 !!!) is to deal or find a workaround for the errors when adding a new subscriber manually in the postmaster tab, as I mentioned here

Offline

#234 2012-07-01 07:38:28

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,777
Website GitHub Twitter

Re: mem_postmaster - Postmaster Revamp

Hi Gil, thanks for all your work on this. Can you also tell me if there can be a solution for this issue?


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#235 2012-07-01 10:20:11

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

colak wrote:

Hi Gil, thanks for all your work on this. Can you also tell me if there can be a solution for this issue?

colak wrote:

In the postmaster manual it says that we can enter <txp:bab_pm_zemTime custom_field="zemSubscriberCustom2" /> should we want the subscription date.

I have tried numerous variations of that including <txp:zem_contact_zemTime custom_field="zemSubscriberCustom2" /> but nothing works. Can anybody shed some light?

Mmm…when I look in the database inside “bab_pm_subscribers” table, there is no subscription date for each subscriber,
so I believe the tag -
<txp:bab_pm_zemTime custom_field="zemSubscriberCustom1" />
Is just the same as a regular data tag –
<txp:bab_pm_data display="subscriberCustom1" />

You can use PHP to get the date and just send it regular using
<txp:zem_contact_secret name="zemSubscriberCustom1" value="the date goes here" />
and then output it using
<txp:bab_pm_data display="subscriberCustom1" />

example:

<txp:zem_contact_secret name="zemSubscriberCustom1" value='<txp:php>echo date("d.m.Y");</txp:php>' />

Just tried it and it works fine.

Offline

#236 2012-07-01 10:47:58

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

Another small “fix”
After editing a subscriber information, it output a long SQL query like this:

update bab_pm_subscribers set `subscriberFirstName` = 'Gil', `subscriberLastName` = 'test', `subscriberEmail` = 'test@example.com', `subscriberCustom1` = '', `subscriberCustom2` = '', `subscriberCustom3` = '', `subscriberCustom4` = '', `subscriberCustom5` = '', `subscriberCustom6` = '', `subscriberCustom7` = '', `subscriberCustom8` = '', `subscriberCustom9` = '', `subscriberCustom10` = '', `subscriberCustom11` = '', `subscriberCustom12` = '', `subscriberCustom13` = '', `subscriberCustom14` = '', `subscriberCustom15` = '', `subscriberCustom16` = '', `subscriberCustom17` = '', `subscriberCustom18` = '', `subscriberCustom19` = '', `subscriberCustom20` = '' where `subscriberID` = 7

If you want you can just hide it using CSS/JS, it’s shown inside a <pre> tag.

Using JS:
search in the plugin code for:

<script type="text/javascript">
$(document).ready(function(){
$("a.show").toggle(
function(){
$(".stuff").show('fast');
}, function(){
$(".stuff").hide('slow');
});
});
</script>

and add this line to it:
$('#bab_pm_content pre').hide();

Like this:

<script type="text/javascript">
$(document).ready(function(){
$("a.show").toggle(
function(){
$(".stuff").show('fast');
}, function(){
$(".stuff").hide('slow');
});

$('#bab_pm_content pre').hide();

});
</script>

we are not fixing anything here, we are just hiding our “shame” from the clients LOL ;)

Last edited by THE BLUE DRAGON (2012-07-01 10:49:05)

Offline

#237 2012-07-01 13:24:08

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

And another workaround solution,
this is for what I mentioned 2 days ago
about that we can’t manually add a new subscriber in the postmaster tab because it’s output bunch of errors and not working.

The workaround:
Hiding the not working form, and instead insert an iframe that contains a page with a signup form.
you can use a section+page, or just use rah_external_output plugin.

1.
Go and create a page with a signup form, regular just like the signup form you already got.
example:

<txp:zem_contact to="example@example.com" label="" subject="A new subscriber added" from="Your site name <info@example.com>">

	<txp:zem_contact_secret name="zemSubscriberLists" value="default" />

	<txp:zem_contact_text name="zemSubscriberFirstName" label="First Name" />
	<txp:zem_contact_text name="zemSubscriberLastName" label="Last Name" />
	<txp:zem_contact_email name="zemSubscriberEmail" label="Email" />
	<txp:zem_contact_text name="zemSubscriberCustom1" label="Your custom field 1 title" />
	<txp:zem_contact_text name="zemSubscriberCustom2" label="Your custom field 2 title" />

	<txp:zem_contact_submit label="Send" />

</txp:zem_contact>

I personally also added a “thanks” attribute to the <txp:zem_contact> tag with a link to refresh the page after the form successfully submitted

<txp:zem_contact to="example@example.com" label="" thanks='Thanks, the new subscriber have been successfully added<br/><a href="textpattern/index.php?event=postmaster&step=subscribers" target="_top">Click here to refresh the page!</a>' subject="A new subscriber added" from="Your site name <info@example.com>">

And of course add or delete custom fields as your need.
And yes you will need to style the page and the form how you want to.
.

2.
After you got this done, go to the plugin code and search for:

<script type="text/javascript">
$(document).ready(function(){
$("a.show").toggle(
function(){
$(".stuff").show('fast');
}, function(){
$(".stuff").hide('slow');
});
});
</script>

This can be a little bit different if you also did my previous tip

Now we will add a code to hide the broken signup form, and insert our working one in an iframe.

Place the code just before the last }); closing, that close the $(document).ready() function.

The code to add:

var iframe_src = '../postmaster_signup';
var iframe_height = '500px';

if($('.bab_pm_underhed:contains("Add a Subscriber")').length > 0){
	$('#subscriber_edit_form').hide().before('<iframe src="'+iframe_src+'" scrolling="no" frameborder="0" style="border:none; width:100%; height:'+iframe_height+';" allowTransparency="true"></iframe>');
}

Now as you can see I set 2 variables:

iframe_height – is for setting the height of the iframe,
500px may be too big, but remember that you need space for the form errors and thanks (zemError, zemThanks)

iframe_src – to set the iframe source,
in the source just link to the page you created that contains the signup form.
If you are using “rah_external_output” then it will be like this:
var iframe_src = '../?rah_external_output=postmaster_signup';

Save it, and you are all set!
you may need to refresh the postmaster tab by clicking ctrl+F5 on your keyboard to see the changes.

Hope that’s helps you, and I’m not just spamming this topic non-stop LOL ;)

Edit:
3.
I forgot to mention that if you want to protect the signup page from regular visitors, then you can easily do that using the rvm_privileged plugin.
Just install the plugin and drop this tag inside your signup page:
<txp:rvm_privileged />

Last edited by THE BLUE DRAGON (2012-07-01 13:37:54)

Offline

#238 2012-07-02 18:54:57

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: mem_postmaster - Postmaster Revamp

A Tip,
Sending a subscriber from the newsletter back to your site with all that subscriber’s information.

This can be useful for forms, discounts and so on.
(for example in the project I’m currently working on, I need to let the subscribers to register to workshops from the newsletter by just clicking on a link)

Starting with that I’m using the unsubscribeID of the subscriber to have a unique link like this:

http://example.com/section/article?uid=29e1f1263f0f42f46f631373c9c46290

without showing any other information, as if we was just using the email like this:

http://example.com/section/?email=example@example.com

that is not good for security cause if someone got your email address then that someone can get all your other information.
so that’s why I’m using the unsubscribeID

Now before we start,
to be able to use the unsubscribeID, you will need to read my previous tip here
you don’t have to use the unsubscribeID for creating a direct unsubscribe link,
you just need to be able to output it as <txp:bab_pm_data display="subscriberName" />

Here’s the PHP code, place it where you want to get the subscriber information
(In the same place to where you are sending your subscribers from the newsletter back to your site,
of course not in your unsubscribe page)

THE CODE WAS UNSECURED, AS MENTIONED BY Gocom, so I removed it for now and will post it back when it will be safe to use.

After that you can create TXP variables with the subscriber information, as in the code above I created these 5 variables:

	$variable["sFirstName"] = $row['subscriberFirstName'];
	$variable["sLastName"] = $row['subscriberLastName'];
	$variable["sEmail"] = $row['subscriberEmail'];
	$variable["sCustom1"] = $row['subscriberCustom1'];
	$variable["sCustom2"] = $row['subscriberCustom2'];

You can also output any of the others fields from the bab_pm_subscribers table in the database, as for example to output the subscriber ID# add this:

	$variable["sID"] = $row['subscriberID'];

Name your TXP variables as you want
(sFirstName, sLastName, sEmail, sCustom1, sCustom2, sID …)

Now you can output the TXP variables anywhere in your page, after and outside the PHP code.

example:

<txp:if_variable name="uid">
	<h3>Welcome back <txp:variable name="sFirstName" /> <txp:variable name="sLastName" /></h3>
	<p>Your coupon code is: blablabla<txp:variable name="uid" />blablalba
</txp:if_variable></p>

In your newsletter form, you can now create links this:

http://example.com/section/article?uid=<txp:bab_pm_data display="subscriberName" />
http://example.com/section/?uid=<txp:bab_pm_data display="subscriberName" />
http://example.com/?uid=<txp:bab_pm_data display="subscriberName" />

That’s all.

As I mentioned before I personally currently using this to register subscribers to workshops,
so I’m using jQuery $.post() to post the information to a Google document (a spreadsheet)

example:

<txp:if_variable name="uid">
	<script>
		$(document).ready(function(){
			var first_name = '<txp:variable name="sFirstName" />';
			var last_name = '<txp:variable name="sLastName" />';
			var email_address = '<txp:variable name="sEmail" />';
			var phone = '<txp:variable name="sCustom1" />';

			var formKey = 'dDE3423cnfjWG6tWE2ghRWluWhgfxE6u3Q';

			$.post('https://docs.google.com/spreadsheet/formResponse?formkey='+formKey+'',{ 'entry.0.single': first_name, 'entry.1.single': last_name, 'entry.2.single': email_address, 'entry.3.single': phone });
		});
	</script>

	<p>Thanks, you have been successfully registered to this workshop.</p>
</txp:if_variable>

Hope you like it, and please share any improvements you think that can be done to the code, as from security or performance view.

Last edited by THE BLUE DRAGON (2012-07-03 21:12:34)

Offline

#239 2012-07-03 04:48:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,777
Website GitHub Twitter

Re: mem_postmaster - Postmaster Revamp

Hey Gil

this is wonderful work you are doing. I am checking it out…


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#240 2012-07-03 10:06:23

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: mem_postmaster - Postmaster Revamp

Nice tip, Gil.

Two comments:

1) I don’t think you need to connect again to the DB, so I think you could get rid of this:

		$con = mysql_connect("database_server","database_user","database_password");
		if(!$con){
			die('Could not connect: ' . mysql_error());
		}

		mysql_select_db("database_name", $con);

2) I wouldn’t want to trigger any kind of panic, but I think there may be a security issue with the way you use the variable ‘uid’ directly in the SQL statement, without any kind of sanitizing. Maybe you could drag Gocom’s (the de-facto security expert on TXP forums) attention and he could confirm if the snippet has some security drawbacks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB