Skip to content
Snippets Groups Projects
Commit d517db6f authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Make it work with J3 and VM3; Fix some other smaller bugs

Somehow the product's custom field config fails if the internal value of the selected option (auto-add, allow subscription) is 0. VM then always selects the first entry in the list, even though that has a value of -1...
parent 28c387ee
No related branches found
No related tags found
No related merge requests found
BASE=acymailing_subscribe_buyer
PLUGINTYPE=vmcustom
VERSION=1.2
VERSION=1.3
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
......
......@@ -16,6 +16,9 @@ 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
$language = JFactory::getLanguage();
$language->load('plg_vmcustom_acymailing_subscribe_buyer');
JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_ACYBUYER_ACYMAILING_NEEDED'), 'error');
return;
}
......@@ -31,7 +34,7 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin {
'allow_subscribe_default'=>array(0, 'int'),
'lists'=>array(array(), 'array'),
);
$this->setConfigParameterable('custom_params',$varsToPush);
$this->setConfigParameterable((VM_VERSION<3)?'custom_params':'customfield_params',$varsToPush);
}
function plgVmOnSelfCallFE($type,$name,&$render) {
if ($name != $this->_name || $type != 'vmcustom') return false;
......@@ -101,6 +104,8 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin {
function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) {
if ($field->custom_element != $this->_name) return '';
$this->parseCustomParams($field);
// JFactory::getApplication()->enqueueMessage("plgVmCustomAcyMailing_subscribe_Buyer::plgVmOnProductEdit: field=<pre>".print_r($field, 1)."</pre>", 'error');
$html = '';
$html .='<fieldset>
<legend>'. JText::_('VMCUSTOM_ACYBUYER') .'</legend>
......@@ -118,14 +123,14 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin {
$lists = $this->getAcyMailinglists();
if ($lists) {
$html .= VmHTML::row ('select','VMCUSTOM_ACYBUYER_LIST', 'custom_param['.$row.'][lists][]', $lists, $field->lists, ' multiple', 'listid', 'name', '');
$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_AUTO_SUBSCRIBE', 'custom_param['.$row.'][subscribe_buyers]',
$html .= VmHTML::row('select', 'VMCUSTOM_ACYBUYER_AUTO_SUBSCRIBE', ((VM_VERSION<3)?'custom_param':'customfield_params').'['.$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->allow_subscribe,'','id', 'name', false);
$html .= VmHTML::row('select', 'VMCUSTOM_ACYBUYER_ALLOW_SUBSCRIBE', 'custom_param['.$row.'][allow_subscribe]',
$field->subscribe_buyers,'','id', 'name', false);
$html .= VmHTML::row('select', 'VMCUSTOM_ACYBUYER_ALLOW_SUBSCRIBE', ((VM_VERSION<3)?'custom_param':'customfield_params').'['.$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),
......@@ -184,6 +189,15 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin {
return $html;
}
/**
* plgVmOnDisplayProductFEVM3 ... Called for all custom fields to display on the product details page
*/
function plgVmOnDisplayProductFEVM3(&$product,&$group) {
if ($group->custom_element != $this->_name) return '';
$group->display .= $this->displayProduct($group);
return true;
}
/**
* plgVmOnDisplayProductVariantFE ... Called for product variant custom fields to display on the product details page
*/
......@@ -204,10 +218,20 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin {
return true;
}
function plgVmDeclarePluginParamsCustomVM3(&$data){
return $this->declarePluginParams('custom', $data);
}
// TODO: really required???
function plgVmGetTablePluginParams($psType, $name, $id, &$xParams, &$varsToPush){
return $this->getTablePluginParams($psType, $name, $id, $xParams, $varsToPush);
}
/**
* 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);
}
......@@ -250,7 +274,13 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin {
}
$customModel = VmModel::getModel('customfields');
foreach ($order['items'] as $item) {
$customs = $customModel->getproductCustomslist ($item->virtuemart_product_id);
// 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);
......@@ -263,10 +293,10 @@ class plgVmCustomAcyMailing_subscribe_Buyer extends vmCustomPlugin {
$notsubscribed = array_diff ($field->lists, $allsubscriptions);
$this->subscribeUser($acyuid, $notsubscribed);
// TODO: Shall we display an infor message about the subscription?
// foreach ($notsubscribed as $l) {
// $listname=$this->getAcyListname($l);
// JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_ACYBUYER_ADDED_USER', $name, $email, $listname), 'info');
// }
// foreach ($notsubscribed as $l) {
// $listname=$this->getAcyListname($l);
// JFactory::getApplication()->enqueueMessage(JText::sprintf('VMCUSTOM_ACYBUYER_ADDED_USER', $name, $email, $listname), 'info');
// }
}
}
}
......
......@@ -47,7 +47,7 @@ class plgVmCustomAcyMailing_subscribe_BuyerInstallerScript
{
// enabling plugin
$db =& JFactory::getDBO();
$db->setQuery('update #__extensions set enabled = 1 where type = "plugin" and element = "acy_subscribe_buyer" and folder = "vmcustom"');
$db->setQuery('update #__extensions set enabled = 1 where type = "plugin" and element = "acymailing_subscribe_buyer" and folder = "vmcustom"');
$db->query();
return True;
......
<?xml version="1.0" encoding="UTF-8" ?>
<install version="1.5" type="plugin" group="vmcustom" method="upgrade">
<extension version="2.5" type="plugin" group="vmcustom" method="upgrade">
<name>VMCUSTOM_ACYBUYER</name>
<creationDate>2014-04-27</creationDate>
<author>Reinhold Kainhofer</author>
<authorUrl>http://www.open-tools.net/</authorUrl>
<copyright>Copyright (C) 2013 Reinhold Kainhofer. All rights reserved.</copyright>
<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.2.0</version>
<version>1.3.0</version>
<description>VMCUSTOM_ACYBUYER_DESC</description>
<files>
<filename plugin="acymailing_subscribe_buyer">acymailing_subscribe_buyer.php</filename>
<filename>acymailing_subscribe_buyer.script.php</filename>
<folder>acymailing_subscribe_buyer</folder>
<filename>index.html</filename>
<folder>language</folder>
<folder>language</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_acymailing_subscribe_buyer.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_acymailing_subscribe_buyer.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_acymailing_subscribe_buyer.sys.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_acymailing_subscribe_buyer.sys.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_acymailing_subscribe_buyer.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_acymailing_subscribe_buyer.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_acymailing_subscribe_buyer.sys.ini</language>
<language tag="de-DE">de-DE/de-DE.plg_vmcustom_acymailing_subscribe_buyer.sys.ini</language>
</languages>
<scriptfile>acymailing_subscribe_buyer.script.php</scriptfile>
<vmconfig>
<fields name="params">
<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>
</field>
<field name="allow_subscribe_default" type="list" scope="com_virtuemart" default="0" label="VMCUSTOM_ACYBUYER_ALLOW_SUBSCRIBE" description="VMCUSTOM_ACYBUYER_ALLOW_SUBSCRIBE_DESC" >
<option value="0">VMCUSTOM_ACYBUYER_ALLOW_NONE</option>
<option value="1">VMCUSTOM_ACYBUYER_ALLOW_REGISTERED</option>
<option value="2">VMCUSTOM_ACYBUYER_ALLOW_ANONYMOUS</option>
</field>
</fields>
</vmconfig>
<params addpath="/administrator/components/com_virtuemart/elements">
<param type="vmjpluginwarning" />
<param name="subscribe_buyers_default" type="radio" default="1" label="VMCUSTOM_ACYBUYER_AUTO_SUBSCRIBE" description="VMCUSTOM_ACYBUYER_AUTO_SUBSCRIBE_DESC" >
......@@ -34,4 +48,4 @@
<option value="2">VMCUSTOM_ACYBUYER_ALLOW_ANONYMOUS</option>
</param>
</params>
</install>
</extension>
......@@ -24,6 +24,6 @@ VMCUSTOM_ACYBUYER_NO_LISTS="Es sind keine AcyMailing Listen verfügbar"
VMCUSTOM_ACYBUYER_LIST="AcyMailing Listen:"
VMCUSTOM_ACYBUYER_ADDED_USER="Benutzer '%s' (%s) zur Liste '%s' hinzugefügt."
VMCUSTOM_ACYBUYER_SQL_ERROR="SQL Fehler! Bitte <a href='mailto:reinhold@kainhofer.com'>kontaktieren Sie den Autor</a> und geben Sie folgende Fehlermeldung an:<br/>%s"
VMCUSTOM_ACYBUYER_SQL_ERROR="SQL Fehler! Bitte <a href='mailto:office@open-tools.net'>kontaktieren Sie den Autor</a> und geben Sie folgende Fehlermeldung an:<br/>%s"
VMCUSTOM_ACYBUYER_ACYMAILING_NEEDED="Das Plugin 'VM Käufer zu AcyMailing Listen hinzufügen' benötigt, dass die AcyMailing Komponente installiert ist."
......@@ -24,6 +24,6 @@ VMCUSTOM_ACYBUYER_NO_LISTS="No AcyMailing lists are available"
VMCUSTOM_ACYBUYER_LIST="AcyMailing lists:"
VMCUSTOM_ACYBUYER_ADDED_USER="User '%s' (%s) added to mailing list %s."
VMCUSTOM_ACYBUYER_SQL_ERROR="SQL error, please <a href='mailto:reinhold@kainhofer.com'>contact the author</a> with the following information:<br/>%s"
VMCUSTOM_ACYBUYER_SQL_ERROR="SQL error, please <a href='mailto:office@open-tools.net'>contact the author</a> with the following information:<br/>%s"
VMCUSTOM_ACYBUYER_ACYMAILING_NEEDED="The 'VM Subscribe Buyers to AcyMailing' plugin requires the AcyMailing Component to be installed"
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment