[plugin] EnhancedPlaceholders: Add more placeholders

3rd party code for phpList

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby drmike » 9:23pm, Thu 16 Jun, 2011

I have just uploaded a version 0.952 which should fix the problems noted. The fixes involved adding
Code: Select all
if (!is_array($this->enhanced_placeholders)) {
   $this->enhanced_placeholders = array();
}

as lines 110 through 112 of enhancedPlaceholders.php and changing line 72 of enhanced_placeholders/enhancedPlaceholdersAdmin.php from
Code: Select all
echo '<p><a href="/admin/?page=main&pi=enhancedPlaceholders&id='.$this->add_new_placeholder.'">add a new placeholder</a><br /><br /><hr/></p>';

to
Code: Select all
echo '<p><a href="'.PageURL2('main&pi=enhancedPlaceholders&id='.$this->add_new_placeholder).'">add a new placeholder</a><br /><br /><hr/></p>';


I also removed the error_reporting(E_ALL | E_STRICT); statements from the construct methods for the classes. It had been there for the testing phase, which I believe may be now concluded. (I have, however, held the version number at less than one to allow for the probability of further bugs being found...)
drmike
PL Nut
 
Posts: 19
Joined: 8:40pm, Sat 14 Aug, 2010
Location: Chesterfield, MO, USA

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby drmike » 9:53pm, Thu 16 Jun, 2011

I found another place where the code
Code: Select all
if (!is_array($this->enhanced_placeholders)) {
   $this->enhanced_placeholders = array();
}

needed to be inserted: just after line 17 of enhanced_placeholders/enhancedPlaceholdersAdmin.php.

I hope that catches all of that particular PHP warning...

I have updated the plugin and uploaded it as EnhancedPlaceholders_0.953.zip.
drmike
PL Nut
 
Posts: 19
Joined: 8:40pm, Sat 14 Aug, 2010
Location: Chesterfield, MO, USA

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby duncanc » 10:02pm, Thu 16 Jun, 2011

drmike wrote:I also removed the error_reporting(E_ALL | E_STRICT); statements from the construct methods for the classes. It had been there for the testing phase, which I believe may be now concluded.


Thanks for the update.
The underlying problem with the mysql error messages being issued is that the constructor for the enhancedPlaceholders class performs some database queries, through sql_query(), without the global database connection having been created.
See file connect.php
line 17 includes pluginlib which creates an instance of each plugin
but the database connection is not created until line 42.

That is why I restructured the classes to avoid those queries being performed in the constructor. They are not actually needed for the admin part of the plugin. Please have a look at the code to see what I have changed.

One further problem that I fixed is the javascript in method showPlaceholderEditForm()

Code: Select all
                     if (placeholder_array[i] == '".$this->placeholder_delimiters[0]."' + placeholder.value + '".$this->placeholder_delimiters[1]."') {

placeholder.value should be placeholder_value, the upper-cased value.

Anyway, thanks for the plugin.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby drmike » 8:15pm, Sat 18 Jun, 2011

Thanks very much! I've looked at your changes, which all seem to me to be quite good, and will meld them with my code as soon as I have time to do so and to run them in the instance of phpList to which I am migrating a customer's mailing lists. That system has an additional extension to my plugin in order to accomplish some stuff which is very specific to the customer's needs. I will have to be sure that things work together alright (which they should) before actually implementing your changes. I hope I can do this next week.
drmike
PL Nut
 
Posts: 19
Joined: 8:40pm, Sat 14 Aug, 2010
Location: Chesterfield, MO, USA

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby boxbreak » 6:41am, Sun 19 Jun, 2011

Thank you all. The two of you have been so helpful! I tried using the new duncanc version.

I am able to see the Enhanced Placeholders page and create Enhanced Placeholders.

However, the Enhanced Placeholders page (phplist/admin/?page=main&pi=enhancedPlaceholders) displays this error at the top of the page (above the Enhanced Placeholders section):
Sorry a software error occurred:
Please report a bug when reporting the bug, please include URL and the entire content of this page.

Notice: unserialize() [function.unserialize]: Error at offset 211 of 263 bytes in /home/ipractic/public_html/phplist/admin/plugins/enhanced_placeholders/enhancedPlaceholdersAdmin.php on line 19
phplist version 2.10.12



Note that this particular error began only after I succesfully sent the first test message using the duncanc version. The first test message did work, as it correctly plugged in an Enhanced Placeholder. However, thereafter the test fails and issues an error about "unserialize".
boxbreak
phpLister
 
Posts: 7
Joined: 3:34pm, Thu 13 Aug, 2009

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby duncanc » 8:18am, Sun 19 Jun, 2011

I think that I saw this type of problem when I first used the plugin, and it is to do with core phplist code, not the plugin code, adding and removing special characters when inserting or querying the database. I think that there is some double removal of back-slashes, and in the end it was too messy to work around it. I'll try to have a closer look though.

If you have used single or double quotes or most likely back-slash in your placeholder name, description or value then that is the cause of the problem so please avoid using them.

If you have knowledge of how to look at your database through control panel, can you view the config table row with item enhanced_placeholders, and copy/paste the value here?
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby boxbreak » 11:21am, Sun 19 Jun, 2011

Sure. Here is the value:
Code: Select all
a:1:{s:19:"{PHPUNSUBSCRIBEURL}";a:5:{s:11:"description";s:0:"";s:19:"nested_placeholders";a:0:{}s:4:"type";s:4:"html";s:5:"value";s:75:"<a href="[UNSUBSCRIBEURL]">??? ?? ???? ?????? ???????";s:10:"value_text";s:66:"??? ?? ???? ?????? ???????: [UNSUBSCRIBEURL]";}}


FYI, here is what I am trying to do:
Create a placeholder {PHPUNSUBSCRIBEURL} that plugs in PHPlist's system placeholder [UNSUBSCRIBEURL], and uses Hebrew Anchor text.
boxbreak
phpLister
 
Posts: 7
Joined: 3:34pm, Thu 13 Aug, 2009

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby boxbreak » 11:59am, Sun 19 Jun, 2011

RESOLVED! Following drmike's tenacious assistance and duncanc's great troubleshooting guidance, we cracked the problem. My Enhanced Placeholder value contained non-English characters; whereas PHPlists's config table defaults to a Collation that did not support non-English characters.

SOLUTION: Using PHPAdmin, I went to the database table 'phplist_conf' and changed the Collation set of the "value" field to utf8_unicode_ci.

Now, I can safely use Hebrew Anchor text within the Enhanced Placeholder value field. For example, I can use this:
Code: Select all
<a href="[UNSUBSCRIBEURL]">Hebrew anchor text here


Tested. Works! Thank you all so much :D
boxbreak
phpLister
 
Posts: 7
Joined: 3:34pm, Thu 13 Aug, 2009

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby shanoviachan » 9:34pm, Tue 05 Jul, 2011

Hi
I am new in phplist and try to get this nice plugin run, but i don´t get a new editor form for my new placeholders. I tried to add two placholders for Upcoming Events and "the most important news"

I open the plugin setup page and create this to placeholders, but the does not appear on the "create new message" page.

I have installed the latest version of phplist and the latest version of this plugin, but i´am a bit confused about all the some recent posts with other instructions than in the opening post with the latest version. I´am also confused about the cron jobs part...

Could someone sum up all relevant steps to get this great plugin running?

Thanks
regards
Thorben
shanoviachan
phpList newbie
 
Posts: 2
Joined: 9:20pm, Tue 05 Jul, 2011

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby drmike » 11:59pm, Tue 05 Jul, 2011

I uploaded a new version (0.96) of the plugin with this post. It incorporated all of the feedback received to date, for which I am very grateful -- especially that of duncanc, culminating in his posting of revised code at 1:50pm, 16 June 2011. The revisions in that posting have been completely incorporated into this version of this plugin. I have now removed this version, since it has been superseded by version 0.97, uploaded with my post of Sat 08 Oct, 2011.

This requires, also, a slightly different set of modifications to admin/sendemaillib.php, than those I put into my original post. I repeat them here from duncanc's post of 1:50pm, 16 June 2011, so that the most recent set of changes is all in one place:

Two changes are required to file admin/sendemaillib.php. Copy and paste the text rather than retyping.

1) add this line after the require statement on line 2

Code: Select all
include_once PLUGIN_ROOTDIR.'/enhanced_placeholders/enhancedPlaceholdersPopulate.php';


2) add these lines immediately before line 240 , ## Parse placeholders

Code: Select all
     
     /*
       *   Addition to process enhanced placeholders
       */
      $obj = enhancedPlaceholdersPopulate::instance();
      $obj->processEnhancedPlaceholders(
       $messageid, $userdata, $user_att_values, $html, $text, $cached[$messageid]['template'],
       $htmlmessage, $textmessage, $cached[$messageid]['subject']
      );


Note that this version incorporates the singleton design pattern (http://php.net/manual/en/language.oop5.patterns.php). This works very well. If your application requires an extension of the enhancedPlaceholdersPopulate class, however, I believe you will need to bypass the singleton design pattern and use a different approach. Since this is not likely to be the case for most of you, I will not belabor the topic further in this posting.
Last edited by drmike on 7:40pm, Sun 09 Oct, 2011, edited 2 times in total.
drmike
PL Nut
 
Posts: 19
Joined: 8:40pm, Sat 14 Aug, 2010
Location: Chesterfield, MO, USA

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby drmike » 12:11am, Wed 06 Jul, 2011

shanoviachan wrote:Hi
I am new in phplist and try to get this nice plugin run, but i don´t get a new editor form for my new placeholders. I tried to add two placholders for Upcoming Events and "the most important news"

I open the plugin setup page and create this to placeholders, but the does not appear on the "create new message" page.

I have installed the latest version of phplist and the latest version of this plugin, but i´am a bit confused about all the some recent posts with other instructions than in the opening post with the latest version. I´am also confused about the cron jobs part...

Could someone sum up all relevant steps to get this great plugin running?

Thanks
regards
Thorben


Could you try again with the post of the latest version (0.96) on Tue 05 Jul, 2011 at 5:59pm? I have tried to incorporate all of what has been posted to date into that version and the instructions in that post. If you are still having difficulty, let us know -- giving as much detail as you can as to what is going on.
drmike
PL Nut
 
Posts: 19
Joined: 8:40pm, Sat 14 Aug, 2010
Location: Chesterfield, MO, USA

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby shanoviachan » 8:05am, Wed 06 Jul, 2011

Hi drmike
thanks for your quick response, it seems the plugin works fine, but not that way i expected... :(

I thought with this plugin i will be able to add a new editor form for newsletter typing. My admins should have the option to "create a new message" with 3 textforms, they fill the first one with major topics, the second on with upcoming events and the third one with the standard body (CONTENT).

This mod viewtopic.php?f=7&t=7967 goes that way, but the def´s of placeholders seems hard, because me admins will get confused about Content 1, Content 2 ... fields.

Just to conclude,your plugin seems to have another aim ;-) Correct me, if iam wrong ;-)
shanoviachan
phpList newbie
 
Posts: 2
Joined: 9:20pm, Tue 05 Jul, 2011

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby carsini » 7:47am, Wed 31 Aug, 2011

Hi drmike,

I've installed the latest version of your plugin (0.96). I can create new placeholders without problems, but if I try to send a message (as test mail or via the real mail processing) I get this error message:
Database error 1064 while doing query You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'arial narrow", arial; font-size: 1.6em; text-transform: uppercase; line-he' at line 1

Do you have an idea what is the reason for that?

Best regards,
carsini

System information
phplist-Version: 2.10.14
PHP-Version: 5.3.6
Webserver: Apache/2.2
MySQL-Version: 5.1.49-3~bpo50+1
carsini
phpList newbie
 
Posts: 1
Joined: 7:33am, Wed 31 Aug, 2011

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby drmike » 7:31pm, Wed 31 Aug, 2011

The thing I notice at first glance is the double quote after the word narrow. It appears that you have some style statement in HTML that is part of the content of whatever test message it is that you are sending and that perhaps there are quotation marks in that style that are confusing the SQL parsing. I suggest you try a test message containing no HTML in either the message or the content of the tags. If that gives no problem, try looking carefully at the HTML in whatever you are sending (and in the tags) to be sure there are no unmatched quotation marks, either double or single. Let us know how it goes. If you cannot find a solution, send me (or post here) the raw HTML of at least the part of the message or tag contents that contains the error reported by MySQL, including a significant portion of the text before and after that error. In the meantime, I will try to take a look at the code to see if there is anything there which could be vulnerable to such a situation.
drmike
PL Nut
 
Posts: 19
Joined: 8:40pm, Sat 14 Aug, 2010
Location: Chesterfield, MO, USA

Re: [plugin:EnhancedPlaceholders] Add more placeholders

Postby drmike » 9:05pm, Wed 31 Aug, 2011

After further consideration, my thought is that the issue might be more likely to be in the HTML for one of the enhanced placeholders.

And I believe I need to review the code further to be sure database interactions are dealing adequately with the issue of escaping characters before strings are inserted in the database and un-escaping when the strings are retrieved from the database. Since any changes I make as a result will need to be tested, I will not be able to complete this work for a few days, due to other obligations.
drmike
PL Nut
 
Posts: 19
Joined: 8:40pm, Sat 14 Aug, 2010
Location: Chesterfield, MO, USA

PreviousNext

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 1 guest