Skip to content

Commit

Permalink
Update to V4.0.36.ZC (#31)
Browse files Browse the repository at this point in the history
* Correct usage of bindVars

In three locations the use of bindVars was not correctly implemented. In each case the sql statement had a variable formatted like ':var:' but in the substitution performed by bindVars the variable was identified as only ':var' this causes an extra : to remain behind in the sql. This method of substitution has been chosen to prevent incorrect substitution from occurring because of sequencing of the bindVars functions when more than one variable begins with the same text as one that is fully defined by that beginning text. Ie. :value substituted into :value_me will cause an issue if :value_me isn't listed before :value in the bindVars sequencing.

* Additional bindVars mistype found

Corrected one more found mistype for using bindVars.

* Update working version of EP4

Modifications have been made here in the master. In order to minimize cross version issues, establishing this as an "Alpha" version so that when it is made effective on the ZC site without the alpha designator, users will receive notification of such an update/final version.

* Missing value to which to compare on import

if the function mb_strlen does not exist on the operating system then EP4 reverts to string length comparison by strlen; however, when this feature was added in, the comparison for $categories_name_max_len was not included and therefore all categories reported as being too long.

* Capture database id for insert before zen_record_admin_activity

When EP4 incorporated the zen_record_admin_activity function
to align with data capture requested/expected for ZC database
change tracking, the function was incorporated before the
insert_id was captured.  As a result, the database insertion
record location was "overwritten" by the logging function
and therefore caused tracked records to be incorrect during
import.  This has recently been pointed out as related to
the four issues identified in this commit.

Added the German installation instructions from the translated
version of this program.
Thanks to webchills of the german ZC forum for providing
instructions in German on how to install EP4.
These instructions were copied over from
easy-populate-4.028-beta-zencart-153-deutsch.zip

* Split out import files.

Removed code from within the easypopulate_4_import.php file to
accomplish a few things: reduce the amount of code that is
loaded on each cycle of processing, simplify understanding when
reviewing the import file, and continue streamlining the code.

Created new module files:
easypopulate_4_attrib_detailed_ep.php
easypopulate_4_default_these.php
easypopulate_4_featured_ep.php
easypopulate_4_import_categorymeta_ep.php
easypopulate_4_initiate.php
easypopulate_4_sba_detailed_ep.php
easypopulate_4_sba_stock_ep.php

* Use of alternate primary key

Primary key is now exported with full product export if not set
to the default of products_model; however, does not prevent the
primary key from being one of the other existing $filelayout
options (ie. exported twice).  While hasn't been identified
as a problem in the past, perhaps a "sanitizer" for export
should be used to ensure that a field is exported only once
and thus not complicate the import process.

Associated with issue #26

* Split out the Insert Queries for ZC 1.5.x to make future
 implementation of an update button process instead of remove
and reinstall for database affected records.

* Resequence code to improve readability.

* Remove unnecessary php ending tag.

* Clean up doc tag(s)

* Improve error reporting based on primary key.

* Correct import datatypes.

* Remove excess variables and manually clear memory.

* Correct typoes.

* Apply applicable ZC function (zen_db_input) instead of
the "generic" PHP function addslashes.

* Update for PHP/ZC versions.

* Improve Dropdown Understanding.

* Code formatting cleanup.

* Improve upload/import notification and handling.

* Improve Documentation.

* Use of alternate primary key

Primary key is now exported with full product export if not set
to the default of products_model; however, does not prevent the
primary key from being one of the other existing $filelayout
options (ie. exported twice).  While hasn't been identified
as a problem in the past, perhaps a "sanitizer" for export
should be used to ensure that a field is exported only once
and thus not complicate the import process.

Associated with issue #26

* Resequence code to improve readability.

* Remove duplicate code.

* Version Stamping/Update

* Update changelog.
  • Loading branch information
mc12345678 authored Nov 3, 2016
1 parent e9fbf06 commit 7ba1380
Show file tree
Hide file tree
Showing 24 changed files with 1,551 additions and 841 deletions.
10 changes: 7 additions & 3 deletions INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and can be downloaded from here:

http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=81

Also note that EasyPopulate 4.0 Beta will install and run independently of all other
Also note that EasyPopulate 4.0 will install and run independently of all other
versions of easypopulate. Names 1.2.5.4 (and flavors) and EP Advance 3.0.3.

INSTALLATION (Upgrade from any prior version of EP4) is suggested as follows:
Expand Down Expand Up @@ -39,8 +39,12 @@ INSTALLATION:
a) If you are using zencart 1.3.8/1.3.9, you need to also upload the additional
files in the "zencart 1.3 extra files" folder.

b) If you are using zencart 1.5.x, no additional files need to be uploaded as the file necessary
to support ZenCart 1.5.x has been placed within the above "admin" directory.
b) If you are using zencart 1.5.x, the files necessary to support ZenCart 1.5.x are already within the plugins "admin" directory, and should be placed onto your server.

c) Create a directory where EP4 related datafiles will be uploaded/exported. If this
directory will be in your admin area, then be sure to either merge the contents/changes
of the folder htaccess4AdminTempFolder with your new folder, or place the file(s) there.
This directory is *not* auto-created.

3. Login to your store's admin. Under Tools you will see a new entry "Easy Populate 4".
(If you do not see this entry, you did not upload your files correctly.)
Expand Down
183 changes: 123 additions & 60 deletions README.txt

Large diffs are not rendered by default.

27 changes: 15 additions & 12 deletions admin/easypopulate_4.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// $Id: easypopulate_4.php, v4.0.35.ZC 04-29-2016 mc12345678 $
// $Id: easypopulate_4.php, v4.0.35.ZC.2 10-03-2016 mc12345678 $

// CSV VARIABLES - need to make this configurable in the ADMIN
// $csv_delimiter = "\t"; // "\t" = tab AND "," = COMMA
Expand Down Expand Up @@ -78,7 +78,7 @@
//$sql_fail_test == true; // used to cause an sql error on new product upload - tests error handling & logs
/* Test area end */

$curver = '4.0.35.ZC';
$curver = '4.0.36.ZC';
$message = '';
if (IS_ADMIN_FLAG) {
$new_version_details = plugin_version_check_for_updates(2069, $curver);
Expand All @@ -88,7 +88,7 @@
}

// Current EP Version - Modded by mc12345678 after Chadd had done so much
$curver = $curver . ' - 04-29-2016' . $message;
$curver = $curver . ' - 07-05-2016' . $message;
$display_output = ''; // results of import displayed after script run
$ep_dltype = NULL;
$ep_stack_sql_error = false; // function returns true on any 1 error, and notifies user of an error
Expand Down Expand Up @@ -252,7 +252,7 @@
// default langauage should not be important since all installed languages are used $langcode[]
// and we should iterate through that array (even if only 1 stored value)
// $epdlanguage_id is used only in categories generation code since the products import code doesn't support multi-language categories
/* @var $epdlanguage_query type array */
/* @var $epdlanguage_query array */
//$epdlanguage_query = $db->Execute("SELECT languages_id, name FROM ".TABLE_LANGUAGES." WHERE code = '".DEFAULT_LANGUAGE."'");
if (!defined(DEFAULT_LANGUAGE)) {
$epdlanguage_query = ep_4_query("SELECT languages_id, code FROM " . TABLE_LANGUAGES . " ORDER BY languages_id LIMIT 1");
Expand Down Expand Up @@ -305,7 +305,7 @@
if (is_uploaded_file($file['tmp_name'])) {
ep_4_copy_uploaded_file($file, (EP4_ADMIN_TEMP_DIRECTORY !== 'true' ? /* Storeside */ DIR_FS_CATALOG : /* Admin side */ DIR_FS_ADMIN) . $tempdir);
}
$messageStack->add(sprintf("File uploaded successfully: " . $file['name']), 'success');
$messageStack->add(sprintf(EASYPOPULATE_4_DISPLAY_RESULT_UPLOAD_COMPLETE, $file['name'], /*"<td align=center>" .*/ (strtolower(end(explode('.', $file['name']))) == 'csv' ? zen_draw_form('import_form', basename($_SERVER['SCRIPT_NAME']), '', 'post', '', $request_type == 'SSL') . zen_draw_hidden_field('import', urlencode($file['name']), '') . zen_draw_input_field('import_button', EASYPOPULATE_4_DISPLAY_EXPORT_FILE_IMPORT, '', false, 'submit') . EASYPOPULATE_4_DISPLAY_RESULT_UPLOAD_IMPORT . "</form>\n" /*</td>\n"*/ : EASYPOPULATE_4_DISPLAY_RESULT_UPLOAD_NO_CSV), 'success'));
}
// Handle file deletion (delete only in the current directory for security reasons)
Expand Down Expand Up @@ -463,6 +463,15 @@ function init()

<div align = "left">
<?php
$export_type_array = array();
$export_type_array = array(array("id" => '0', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_DEFAULT),
array("id" => '0', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_COMPLETE),
array("id" => '1', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_QUANTITY),
array("id" => '2', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_BREAKS));

$category_filter_array = array();
$category_filter_array = array_merge(array(0 => array("id" => '', 'text' => EASYPOPULATE_4_DD_FILTER_CATEGORIES)), zen_get_category_tree());

$manufacturers_array = array();
$manufacturers_array[] = array("id" => '', 'text' => EASYPOPULATE_4_DISPLAY_MANUFACTURERS);
if ($ep_uses_mysqli) {
Expand All @@ -478,15 +487,11 @@ function init()
}
}
$status_array = array(array("id" => '1', 'text' => EASYPOPULATE_4_DD_STATUS_DEFAULT ), array("id" => '1', 'text' => EASYPOPULATE_4_DD_STATUS_ACTIVE), array("id" => '0', 'text' => EASYPOPULATE_4_DD_STATUS_INACTIVE), array("id" => '3', 'text' => EASYPOPULATE_4_DD_STATUS_ALL));
$export_type_array = array(array("id" => '0', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_DEFAULT),
array("id" => '0', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_COMPLETE),
array("id" => '1', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_QUANTITY),
array("id" => '2', 'text' => EASYPOPULATE_4_DD_DOWNLOAD_BREAKS));

echo "<b>" . EASYPOPULATE_4_DISPLAY_FILTERABLE_EXPORTS . "</b><br />";

echo zen_draw_pull_down_menu('ep_export_type', $export_type_array) . ' ';
echo ' ' . zen_draw_pull_down_menu('ep_category_filter', array_merge(array(0 => array("id" => '', 'text' => EASYPOPULATE_4_DD_FILTER_CATEGORIES)), zen_get_category_tree())) . ' ';
echo ' ' . zen_draw_pull_down_menu('ep_category_filter', $category_filter_array) . ' ';
echo ' ' . zen_draw_pull_down_menu('ep_manufacturer_filter', $manufacturers_array) . ' ';
echo ' ' . zen_draw_pull_down_menu('ep_status_filter', $status_array) . ' ';
echo zen_draw_input_field('export', EASYPOPULATE_4_DD_FILTER_EXPORT, ' style="padding: 0px"', false, 'submit');
Expand Down Expand Up @@ -541,12 +546,10 @@ function init()
<?php } /* End SBA1 Addition */
$zco_notifier->notify('EP4_LINK_SELECTION_END');
?>

<br><?php echo EASYPOPULATE_4_DISPLAY_TITLE_EXPORT_ONLY; ?><br />
<a href="<?php echo zen_href_link(FILENAME_EASYPOPULATE_4, 'export=options', $request_type); ?>"><?php echo EASYPOPULATE_4_DISPLAY_EXPORT_OPTION_NAMES; ?></a><br />
<a href="<?php echo zen_href_link(FILENAME_EASYPOPULATE_4, 'export=values', $request_type); ?>"><?php echo EASYPOPULATE_4_DISPLAY_EXPORT_OPTION_VALUES; ?></a><br />
<a href="<?php echo zen_href_link(FILENAME_EASYPOPULATE_4, 'export=optionvalues', $request_type); ?>"><?php echo EASYPOPULATE_4_DISPLAY_EXPORT_OPTION_NAMES_TO_VALUES; ?></a><br />

<?php
// List uploaded files in multifile mode
// Table header
Expand Down
14 changes: 7 additions & 7 deletions admin/easypopulate_4_attrib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// $Id: easypopulate_4_attrib.php, v4.0.35 04-21-2016 mc12345678 $
// $Id: easypopulate_4_attrib.php, v4.0.35.ZC.2 10-03-2016 mc12345678 $

if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
Expand All @@ -22,7 +22,7 @@
// READ products_id and products_model from TABLE_PRODUCTS
// Since products_model must be unique (for EP4 at least), this query can be LIMIT 1
$query ="SELECT * FROM ".TABLE_PRODUCTS." WHERE (products_model = :v_products_model:) LIMIT 1";
$query = $db->bindVars($query, ':v_products_model', $v_products_model, 'string');
$query = $db->bindVars($query, ':v_products_model:', $v_products_model, 'string');
$result = ep_4_query($query);

if (($ep_uses_mysqli ? mysqli_num_rows($result) : mysql_num_rows($result)) == 0) { // products_model is not in TABLE_PRODUCTS
Expand Down Expand Up @@ -94,8 +94,8 @@
(:v_products_options_id:, :language_id:, :v_products_options_name:, :v_products_options_type:)";
$sql = $db->bindVars($sql, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql = $db->bindVars($sql, ':language_id:', $l_id, 'integer');
$sql = $db->bindVars($sql, ':v_products_options_name', $v_products_options_name[$l_id], 'string');
$sql = $db->bindVars($sql, ':v_products_options_type', $v_products_options_type, 'integer');
$sql = $db->bindVars($sql, ':v_products_options_name:', $v_products_options_name[$l_id], 'string');
$sql = $db->bindVars($sql, ':v_products_options_type:', $v_products_options_type, 'integer');
$errorcheck = ep_4_query($sql);
}
$new_options_name++;
Expand Down Expand Up @@ -218,7 +218,7 @@
a.products_options_id = :v_products_options_id: AND
a.products_options_values_id = b.products_options_values_id AND
b.products_options_values_name = :values_name:";
$sql5 = $db->bindVars($sql5, ':v_products_options_id', $v_products_options_id, 'integer');
$sql5 = $db->bindVars($sql5, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql5 = $db->bindVars($sql5, ':values_name:', $values_names_array[$l_id][$values_names_index], 'string');
$result5 = ep_4_query($sql5);

Expand Down Expand Up @@ -288,7 +288,7 @@
$sql7 = $db->bindVars($sql7, ':values_names_index:', $values_names_index, 'integer');
$sql7 = $db->bindVars($sql7, ':v_products_id:', $v_products_id, 'integer');
$sql7 = $db->bindVars($sql7, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql7 = $db->bindVars($sql7, ':a_products_options_values_id:', $a_productsion_options_values_id, 'integer');
$sql7 = $db->bindVars($sql7, ':a_products_options_values_id:', $a_products_options_values_id, 'integer');
$errorcheck = ep_4_query($sql7);
$table_products_attributes_update = 1;
}
Expand Down Expand Up @@ -325,4 +325,4 @@
} // END: if
} // END: while #2
} // END: while #1
?>

9 changes: 6 additions & 3 deletions admin/easypopulate_4_export.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// $Id: easypopulate_4_export.php, v4.0.33 02-29-2016 mc12345678 $
// $Id: easypopulate_4_export.php, v4.0.35.ZC.2 10-03-2016 mc12345678 $

if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
Expand Down Expand Up @@ -36,7 +36,7 @@
$ep_dltype = 'priceqty'; // Model/Price/Qty
} elseif ($_POST['ep_export_type'] == '2') {
$ep_dltype = 'pricebreaks'; // Model/Price/Breaks
}
}
}

// override for $ep_dltype
Expand Down Expand Up @@ -247,6 +247,9 @@
$active_language_id = $row['v_language_id'];

$active_row['v_products_model'] = $row['v_products_model'];
if ($chosen_key != 'v_products_model' && zen_not_null($chosen_key)) {
$active_row[$chosen_key] = $row[$chosen_key];
}
$active_row['v_products_options_type'] = $row['v_products_options_type'];

$l_id = $row['v_language_id'];
Expand Down Expand Up @@ -788,7 +791,7 @@

if ($ep_dltype == 'attrib_basic') { // must write last record
// Clean the texts that could break CSV file formatting
$datarow = ep_4_rmv_chars($filelayout, $active_row, $csv_delimiter);
$dataRow = ep_4_rmv_chars($filelayout, $active_row, $csv_delimiter);

fwrite($fp, $dataRow); // write 1 line of csv data (this can be slow...)
$ep_export_count++;
Expand Down
Loading

0 comments on commit 7ba1380

Please sign in to comment.