Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

CS-Cart 4.0.1 installation bug add-on in the "mail" directories Rate Topic   * * * * * 2 votes

 

Posted 27 July 2013 - 01:26 PM #1

Dear friends,

While developing on the add-on for the version CS-Cart 4.0.1 we found standard bug. The error consists in the fact that at installation add-on the files from the directories "mail" aren't copied":
"var/themes_repository/basic/mail/templates/addons/";
"var/themes_repository/basic/mail/css/addons/";
"var/themes_repository/basic/mail/media/images/addons/".

The code in the file "app/functions/fn.addons.php" was studied. It turns out that CS-Cart's architects just forgot about the folder "mail" :)
The mistake's fix consists in that that the code was added to the "fn_install_addon_templates" function.
The code containing the mistake's fix is given below:
/**
* Copies addon templates from repository
*
* @param string $addon_name Addons name to copy templates for
* @return bool Always true
*/
function fn_install_addon_templates($addon_name)
{
	$repo_dir = fn_get_theme_path('[repo]/basic/');

	if (fn_allowed_for('ULTIMATE')) {
		foreach (fn_get_all_companies_ids() as $company) {
			$installed_themes = fn_get_installed_themes($company);
			$design_dir = fn_get_theme_path('[themes]/', 'C', $company);
			foreach ($installed_themes as $theme_name) {
				if (is_dir($repo_dir . 'templates/addons/' . $addon_name)) {
					fn_copy($repo_dir . 'templates/addons/' . $addon_name, $design_dir . $theme_name . '/templates/addons/' . $addon_name);
				}
				if (is_dir($repo_dir . 'css/addons/' . $addon_name)) {
					fn_copy($repo_dir . 'css/addons/' . $addon_name, $design_dir . $theme_name . '/css/addons/' . $addon_name);
				}
				if (is_dir($repo_dir . 'media/images/addons/' . $addon_name)) {
					fn_copy($repo_dir . 'media/images/addons/' . $addon_name, $design_dir . $theme_name . '/media/images/addons/' . $addon_name);
				}
				// [WSA-team] fixed standard bug 2013/07/27
				if (is_dir($repo_dir . 'mail/templates/addons/' . $addon_name)) {
					fn_copy($repo_dir . 'mail/templates/addons/' . $addon_name, $design_dir . $theme_name . '/mail/templates/addons/' . $addon_name);
				}
				if (is_dir($repo_dir . 'mail/css/addons/' . $addon_name)) {
					fn_copy($repo_dir . 'mail/css/addons/' . $addon_name, $design_dir . $theme_name . '/mail/css/addons/' . $addon_name);
				}
				if (is_dir($repo_dir . 'mail/media/images/addons/' . $addon_name)) {
					fn_copy($repo_dir . 'mail/media/images/addons/' . $addon_name, $design_dir . $theme_name . '/mail/media/images/addons/' . $addon_name);
				}
				// [/WSA-team]

			}

		}
	} else {
		$installed_themes = fn_get_installed_themes();
		$design_dir = fn_get_theme_path('[themes]/', 'C');
		foreach ($installed_themes as $theme_name) {
			if (is_dir($repo_dir . 'templates/addons/' . $addon_name)) {
				fn_copy($repo_dir . 'templates/addons/' . $addon_name, $design_dir . $theme_name . '/templates/addons/' . $addon_name);
			}
			if (is_dir($repo_dir . 'css/addons/' . $addon_name)) {
				fn_copy($repo_dir . 'css/addons/' . $addon_name, $design_dir . $theme_name . '/css/addons/' . $addon_name);
			}
			if (is_dir($repo_dir . 'media/images/addons/' . $addon_name)) {
				fn_copy($repo_dir . 'media/images/addons/' . $addon_name, $design_dir . $theme_name . '/media/images/addons/' . $addon_name);
			}
			// [WSA-team] fixed standard bug 2013/07/27
			if (is_dir($repo_dir . 'mail/templates/addons/' . $addon_name)) {
				fn_copy($repo_dir . 'mail/templates/addons/' . $addon_name, $design_dir . $theme_name . '/mail/templates/addons/' . $addon_name);
			}
			if (is_dir($repo_dir . 'mail/css/addons/' . $addon_name)) {
				fn_copy($repo_dir . 'mail/css/addons/' . $addon_name, $design_dir . $theme_name . '/mail/css/addons/' . $addon_name);
			}
			if (is_dir($repo_dir . 'mail/media/images/addons/' . $addon_name)) {
				fn_copy($repo_dir . 'mail/media/images/addons/' . $addon_name, $design_dir . $theme_name . '/mail/media/images/addons/' . $addon_name);
			}
			// [/WSA-team]

		}
	}

	return true;
}

Also I attached the file with a fix of the described mistake in attachments.
I hope the given information will be useful to somebody.

Thank you.

Attached Files



 
  • ThomH
  • Senior Member
  • Members
  • Join Date: 20-Nov 07
  • 1,340 posts

Posted 08 August 2013 - 10:57 AM #2

The same fix is required for the fn_uninstall_addon_templates
Posted in the bug tracker.

WebGraphiq offers a wide range of professionally developed, ready to use CS-Cart add-ons to provide additional functionality and boost your sales. The oldest active CS-Cart add-on development team. -- Since 2006 --


CS-CART ADD-ONS | FREE QUOTE | CS-CART DEVELOPMENT | @webgraphiq