PDA

View Full Version : PHPList for OsCommerce



michael_s
04-26-2007, 10:00 AM
The 'Newsletter' field in the customers list in admin/Customers.php still reads from the old database.

In admin/customers.php Find:

while ($customers = tep_db_fetch_array($customers_query)) {

And add directly below it:

// PHPlist PHPlist Newsletter add-on
require(DIR_WS_INCLUDES . '/phplist_define.php'); //get the phplist specifics


$existing_email_query = tep_db_query("select id, email, foreignkey from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "user_user where email = '" . $customers['customers_email_address'] . "'"); //check for existing by email address
$existing_user_query = tep_db_query("select id, foreignkey, email from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "user_user where foreignkey = " . $customers['customers_id'] . ""); //check for existing by phplist userid in case they subscribed using another method.

$existing_email = tep_db_fetch_array($existing_email_query);
$existing_user = tep_db_fetch_array($existing_user_query);

if (tep_db_num_rows($existing_user_query) > 0) //check for user subscription
$newsletter_query = tep_db_query("select userid from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "listuser where listid = " . PHPLIST_LISTNO . " and userid = " . $existing_user['id'] . "");
else
$newsletter_query = tep_db_query("select userid from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "listuser," . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "user_user where listid = " . PHPLIST_LISTNO . " and userid = id and email = '" . $customers['customers_email_address'] . "'");
$customers['customers_newsletter'] = ((tep_db_num_rows($newsletter_query) < 1) ? '0' : '1');
// End PHPlist Newsletter add-on

Attached is the latest version with this fix added.

Known bugs:
if you don't have a surname attribute in PHPList, the included config file says just to leave the field blank. The script doesn't seem to check for this and caused me errors. I had to comment out lines in create_account.php which used the surname value when accessing the database.
This has not been done in the attached version, it's up to you...

More... (http://www.oscommerce.com/community/contributions,3976)