From 4ac82bc3f39862bd39ac6c69ff1764311f9f0e6b Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Mon, 13 Oct 2014 20:32:11 +0200 Subject: [PATCH] First steps with upgrading to VM3 --- Makefile | 5 +++-- buyer_assign_group.php | 30 +++++++++++++++++++++++------- buyer_assign_group.xml | 18 +++++++++++++----- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index b31f700..f1ee0e3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BASE=buyer_assign_group PLUGINTYPE=vmcustom ZIPBASE=opentools_vm2 -VERSION=1.1 +VERSION=1.2 PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html @@ -9,6 +9,7 @@ TRANSLATIONS=$(call wildcard,language/*/*.plg_$(PLUGINTYPE)_$(BASE).*ini) langua # INDEXFILES=$(BASE)/index.html INDEXFILES=$(call wildcard,language/**/index.html) $(call wildcard,elements/*.html) ELEMENTS=$(call wildcard,elements/*) +FIELDS=$(call wildcard,fields/*) # TMPLFILES=$(call wildcard,$(BASE)/tmpl/*.php) $(BASE)/index.html $(BASE)/tmpl/index.html # ASSETS=$(call wildcard,$(BASE)/assets/*.png) $(call wildcard,$(BASE)/assets/*.css) ZIPFILE=plg_$(ZIPBASE)_$(BASE)_v$(VERSION).zip @@ -16,7 +17,7 @@ ZIPFILE=plg_$(ZIPBASE)_$(BASE)_v$(VERSION).zip zip: $(PLUGINFILES) $(TRANSLATIONS) $(ELEMENTS) $(TMPLFILES) @echo "Packing all files into distribution file $(ZIPFILE):" - @zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(ELEMENTS) $(INDEXFILES) $(TMPLFILES) $(ASSETS) + @zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(ELEMENTS) $(FIELDS) $(INDEXFILES) $(TMPLFILES) $(ASSETS) clean: rm -f $(ZIPFILE) diff --git a/buyer_assign_group.php b/buyer_assign_group.php index 73d900c..14e54a0 100644 --- a/buyer_assign_group.php +++ b/buyer_assign_group.php @@ -25,8 +25,12 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin { 'shopper_groups_remove'=>array(array(), 'array'), 'purchased_status' => array(array(), 'array'), ); - $this->setConfigParameterable('custom_params',$varsToPush); - $this->onStoreInstallPluginTable($this->_psType); + if(!defined('VM_VERSION') or VM_VERSION < 3){ + $this->setConfigParameterable ('custom_params', $varsToPush); + } else { + $this->setConfigParameterable ('customfield_params', $varsToPush); + } +// $this->onStoreInstallPluginTable($this->_psType); } /** @@ -36,14 +40,19 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin { function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) { if ($field->custom_element != $this->_name) return ''; $html = ''; - $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'; + } $html .= '<table class="admintable">'; - $html .= VmHTML::row (array('JHTML', '_'),'VMCUSTOM_BUYER_GROUP_JOOMLA', 'access.usergroup', 'custom_param['.$row.'][joomla_groups][]', $field->joomla_groups, ' multiple data-placeholder=" "', false); - $html .= VmHTML::row (array('JHTML', '_'),'VMCUSTOM_BUYER_GROUP_JOOMLA_REMOVE', 'access.usergroup', 'custom_param['.$row.'][joomla_groups_remove][]', $field->joomla_groups_remove, ' multiple data-placeholder=" "', true); + $html .= VmHTML::row (array('JHTML', '_'),'VMCUSTOM_BUYER_GROUP_JOOMLA', 'access.usergroup', $paramName.'['.$row.'][joomla_groups][]', $field->joomla_groups, ' multiple data-placeholder=" "', false); + $html .= VmHTML::row (array('JHTML', '_'),'VMCUSTOM_BUYER_GROUP_JOOMLA_REMOVE', 'access.usergroup', $paramName.'['.$row.'][joomla_groups_remove][]', $field->joomla_groups_remove, ' multiple data-placeholder=" "', true); - $html .= VmHTML::row (array('ShopFunctions', 'renderShopperGroupList'), 'VMCUSTOM_BUYER_GROUP_SHOPPER', $field->shopper_groups, TRUE, 'custom_param['.$row.'][shopper_groups][]', ' '); - $html .= VmHTML::row (array('ShopFunctions', 'renderShopperGroupList'), 'VMCUSTOM_BUYER_GROUP_SHOPPER_REMOVE', $field->shopper_groups_remove, TRUE, 'custom_param['.$row.'][shopper_groups_remove][]', ' '); + $html .= VmHTML::row (array('ShopFunctions', 'renderShopperGroupList'), 'VMCUSTOM_BUYER_GROUP_SHOPPER', $field->shopper_groups, TRUE, $paramName.'['.$row.'][shopper_groups][]', ' '); + $html .= VmHTML::row (array('ShopFunctions', 'renderShopperGroupList'), 'VMCUSTOM_BUYER_GROUP_SHOPPER_REMOVE', $field->shopper_groups_remove, TRUE, $paramName.'['.$row.'][shopper_groups_remove][]', ' '); $html .= '</table></fieldset>'; $retValue .= $html; @@ -59,9 +68,16 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin { return $this->onStoreInstallPluginTable($psType, $name); } + // VM2 Compat: function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){ return $this->declarePluginParams('custom', $name, $id, $data); } + function plgVmDeclarePluginParamsCustomVM3(&$data){ + return $this->declarePluginParams('custom', $data); + } + function plgVmGetTablePluginParams($psType, $name, $id, &$xParams, &$varsToPush){ + return $this->getTablePluginParams($psType, $name, $id, $xParams, $varsToPush); + } function plgVmSetOnTablePluginParamsCustom($name, $id, &$table){ return $this->setOnTablePluginParams($name, $id, $table); diff --git a/buyer_assign_group.xml b/buyer_assign_group.xml index ca588a9..61d9f09 100644 --- a/buyer_assign_group.xml +++ b/buyer_assign_group.xml @@ -1,12 +1,12 @@ <?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_BUYER_GROUP</name> <creationDate>2014-04-07</creationDate> <author>Reinhold Kainhofer</author> <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.1</version> + <version>1.2</version> <description>VMCUSTOM_BUYER_GROUP_DESC</description> <files> <filename plugin="buyer_assign_group">buyer_assign_group.php</filename> @@ -14,17 +14,25 @@ <filename>index.html</filename> <folder>language</folder> <folder>elements</folder> + <folder>fields</folder> </files> <languages folder="language"> <language tag="en-GB">en-GB/en-GB.plg_vmcustom_buyer_assign_group.ini</language> <language tag="en-GB">en-GB/en-GB.plg_vmcustom_buyer_assign_group.sys.ini</language> </languages> <scriptfile>buyer_assign_group.script.php</scriptfile> + + <vmconfig> + <fields name="params" addfieldpath="/administrator/components/com_virtuemart/fields/"> + <fieldset name="order_status" addfieldpath="/plugins/vmcustom/buyer_assign_group/fields/"> + <field name="purchased_status" type="orderstatus" default="C,S" multiple="multiple" label="VMCUSTOM_BUYER_GROUP_STATUS" description="VMCUSTOM_BUYER_GROUP_STATUS_DESC"/> + </fieldset> + </fields> + </vmconfig> + <params addpath="/plugins/vmcustom/buyer_assign_group/elements/" /> <params addpath="/administrator/components/com_virtuemart/elements/"> <param type="vmjpluginwarning" /> <param name="purchased_status" type="vmorderstates" default="C,S" multiple="multiple" label="VMCUSTOM_BUYER_GROUP_STATUS" description="VMCUSTOM_BUYER_GROUP_STATUS_DESC"/> </params> -</install> - - +</extension> -- GitLab