diff --git a/Makefile b/Makefile index 824740ab0a353827ecdd48dd00f4009caf7d4121..86f96acb498ee3e642ae36515b76f09da4f14813 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BASE=acymailing_subscribe_buyer PLUGINTYPE=vmcustom -VERSION=1.3 +VERSION=1.4 PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html diff --git a/acymailing_subscribe_buyer.php b/acymailing_subscribe_buyer.php index 5711a0d5126e9cb46ebb4f67d747920a7586d0e4..f87cf12aead675f2ac3b6e0cae8b4d14271d3099 100644 --- a/acymailing_subscribe_buyer.php +++ b/acymailing_subscribe_buyer.php @@ -16,7 +16,7 @@ defined('_JEXEC') or die( 'Direct Access to ' . basename( __FILE__ ) . ' is not */ if (!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){ - // For some reason, J3.3 does not load the language file otherwice + // For some reason, J3.3 does not load the language file otherwise $language = JFactory::getLanguage(); $language->load('plg_vmcustom_acymailing_subscribe_buyer'); JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_ACYBUYER_ACYMAILING_NEEDED'), 'error'); @@ -34,7 +34,11 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin { 'allow_subscribe_default'=>array(0, 'int'), 'lists'=>array(array(), 'array'), ); - $this->setConfigParameterable((VM_VERSION<3)?'custom_params':'customfield_params',$varsToPush); + if(!defined('VM_VERSION') or VM_VERSION < 3){ + $this->setConfigParameterable ('custom_params', $varsToPush); + } else { + $this->setConfigParameterable ('customfield_params', $varsToPush); + } } function plgVmOnSelfCallFE($type,$name,&$render) { if ($name != $this->_name || $type != 'vmcustom') return false; @@ -103,9 +107,13 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin { */ function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) { if ($field->custom_element != $this->_name) return ''; - $this->parseCustomParams($field); + if(!defined('VM_VERSION') or VM_VERSION < 3){ + $this->parseCustomParams ($field); // Not needed in VM3! + $paramName = 'custom_param'; + } else { + $paramName = 'customfield_params'; + } -// JFactory::getApplication()->enqueueMessage("plgVmCustomAcyMailing_subscribe_Buyer::plgVmOnProductEdit: field=<pre>".print_r($field, 1)."</pre>", 'error'); $html = ''; $html .='<fieldset> <legend>'. JText::_('VMCUSTOM_ACYBUYER') .'</legend> @@ -123,14 +131,14 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin { $lists = $this->getAcyMailinglists(); if ($lists) { - $html .= VmHTML::row ('select','VMCUSTOM_ACYBUYER_LIST', ((VM_VERSION<3)?'custom_param':'customfield_params').'['.$row.'][lists][]', $lists, $field->lists, ' multiple', 'listid', 'name', ''); + $html .= VmHTML::row ('select','VMCUSTOM_ACYBUYER_LIST', $paramName.'['.$row.'][lists][]', $lists, $field->lists, ' multiple', 'listid', 'name', ''); - $html .= VmHTML::row('select', 'VMCUSTOM_ACYBUYER_AUTO_SUBSCRIBE', ((VM_VERSION<3)?'custom_param':'customfield_params').'['.$row.'][subscribe_buyers]', + $html .= VmHTML::row('select', 'VMCUSTOM_ACYBUYER_AUTO_SUBSCRIBE', $paramName.'['.$row.'][subscribe_buyers]', array_merge( array(array('id'=>'-1', 'name'=>JText::sprintf('VMCUSTOM_ACYBUYER_AUTO_DEFAULT', JText::_($autosubscribe_modes[$field->subscribe_buyers_default]['name'])))), $autosubscribe_modes), $field->subscribe_buyers,'','id', 'name', false); - $html .= VmHTML::row('select', 'VMCUSTOM_ACYBUYER_ALLOW_SUBSCRIBE', ((VM_VERSION<3)?'custom_param':'customfield_params').'['.$row.'][allow_subscribe]', + $html .= VmHTML::row('select', 'VMCUSTOM_ACYBUYER_ALLOW_SUBSCRIBE', $paramName.'['.$row.'][allow_subscribe]', array_merge( array(array('id'=>'-1', 'name'=>JText::sprintf('VMCUSTOM_ACYBUYER_ALLOW_DEFAULT', JText::_($subscribe_modes[$field->allow_subscribe_default]['name'])))), $subscribe_modes), @@ -162,7 +170,6 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin { function displayProduct($field) { $html = ''; - $this->parseCustomParams($field); $user = JFactory::getUser(); $uid = $user->get('id'); $allow = ($field->allow_subscribe>=0)?($field->allow_subscribe):($field->allow_subscribe_default); @@ -201,19 +208,14 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin { /** * plgVmOnDisplayProductVariantFE ... Called for product variant custom fields to display on the product details page */ + // Legacy triggers for VM2: function plgVmOnDisplayProductVariantFE($field,&$row,&$group) { - // default return if it's not this plugin - if ($field->custom_element != $this->_name) return ''; - $group->display .= $this->displayProduct($field); - return true; + return plgVmOnDisplayProductFE($field, $row, $group); } - - /** - * plgVmOnDisplayProductFE ... Called for NON-product variant custom fields to display on the product details page - */ function plgVmOnDisplayProductFE( $product, &$idx,&$field){ // default return if it's not this plugin if ($field->custom_element != $this->_name) return ''; + $this->parseCustomParams($field); // <- not needed in VM3 any more, so do it here $field->display .= $this->displayProduct($field); return true; } @@ -227,11 +229,6 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin { } - /** - * We must reimplement this triggers for joomla 1.7 - * vmplugin triggers note by Max Milbers - */ - // TODO: Really required or deprecated? public function plgVmOnStoreInstallPluginTable($psType, $name) { return $this->onStoreInstallPluginTable($psType, $name); } @@ -274,13 +271,11 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin { } $customModel = VmModel::getModel('customfields'); foreach ($order['items'] as $item) { -// JFactory::getApplication()->enqueueMessage("plgVmConfirmedOrder, checking item: <pre>".print_r($item,1)."</pre>", 'error'); if (VM_VERSION<3) { $customs = $customModel->getproductCustomslist ($item->virtuemart_product_id); } else { $customs = $customModel->getCustomEmbeddedProductCustomFields (array($item->virtuemart_product_id)); } -// JFactory::getApplication()->enqueueMessage("plgVmConfirmedOrder, CUSTOMS: <pre>".print_r($customs,1)."</pre>", 'error'); foreach ($customs as $field) { if ($field->custom_element != $this->_name) continue; $subscribe = ($field->subscribe_buyers>=0)?($field->subscribe_buyers):($field->subscribe_buyers_default); diff --git a/acymailing_subscribe_buyer.xml b/acymailing_subscribe_buyer.xml index 5312e3b0c7bc96eb1390b9d44ece7bf4e7c01c85..bee6d6608a81bc6300fc4b5422d17845f7e36c9e 100644 --- a/acymailing_subscribe_buyer.xml +++ b/acymailing_subscribe_buyer.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net/</authorUrl> <copyright>Copyright (C) 2013-2014 Reinhold Kainhofer. All rights reserved.</copyright> <license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license> - <version>1.3.0</version> + <version>1.4</version> <description>VMCUSTOM_ACYBUYER_DESC</description> <files> <filename plugin="acymailing_subscribe_buyer">acymailing_subscribe_buyer.php</filename> @@ -24,6 +24,7 @@ <scriptfile>acymailing_subscribe_buyer.script.php</scriptfile> <vmconfig> <fields name="params"> + <fieldset> <field name="subscribe_buyers_default" type="radio" scope="com_virtuemart" default="1" label="VMCUSTOM_ACYBUYER_AUTO_SUBSCRIBE" description="VMCUSTOM_ACYBUYER_AUTO_SUBSCRIBE_DESC" > <option value="0">COM_VIRTUEMART_NO</option> <option value="1">COM_VIRTUEMART_YES</option> @@ -33,6 +34,7 @@ <option value="1">VMCUSTOM_ACYBUYER_ALLOW_REGISTERED</option> <option value="2">VMCUSTOM_ACYBUYER_ALLOW_ANONYMOUS</option> </field> + </fieldset> </fields> </vmconfig> diff --git a/releases/plg_vmcustom_acymailing_subscribe_buyer_v1.4.zip b/releases/plg_vmcustom_acymailing_subscribe_buyer_v1.4.zip new file mode 100644 index 0000000000000000000000000000000000000000..d40e0f9c73fd74321d2ef13f03b2397b94a656c2 Binary files /dev/null and b/releases/plg_vmcustom_acymailing_subscribe_buyer_v1.4.zip differ