/** * Retrieve the detail record for the current $id if the data has not already been loaded. * * @author RickG */ function getShipment($id = 0) { if (!empty($id)) { $this->_id = (int) $id; } if (empty($this->_cache[$this->_id])) { $this->_cache[$this->_id] = $this->getTable('shipmentmethods'); $this->_cache[$this->_id]->load((int) $this->_id); if (empty($this->_cache[$this->_id]->virtuemart_vendor_id)) { if (!class_exists('VirtueMartModelVendor')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'; } $this->_cache[$this->_id]->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor(); } if ($this->_cache[$this->_id]->shipment_jplugin_id) { JPluginHelper::importPlugin('vmshipment'); $dispatcher = JDispatcher::getInstance(); $blind = 0; $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsShipmentVM3', array(&$this->_cache[$this->_id])); } if (!empty($this->_cache[$this->_id]->_varsToPushParam)) { VmTable::bindParameterable($this->_cache[$this->_id], 'shipment_params', $this->_cache[$this->_id]->_varsToPushParam); } /* Add the shipmentcarreir shoppergroups */ $q = 'SELECT `virtuemart_shoppergroup_id` FROM #__virtuemart_shipmentmethod_shoppergroups WHERE `virtuemart_shipmentmethod_id` = "' . $this->_id . '"'; $this->_db->setQuery($q); $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = $this->_db->loadResultArray(); if (empty($this->_cache[$this->_id]->virtuemart_shoppergroup_ids)) { $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = 0; } } return $this->_cache[$this->_id]; }
function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } $model = VmModel::getModel('custom'); // TODO Make an Icon for custom $this->SetViewTitle('PRODUCT_CUSTOM_FIELD'); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $this->addStandardEditViewCommands(); $customPlugin = ''; $this->custom = $model->getCustom(); $customfields = VmModel::getModel('customfields'); //vmdebug('VirtuemartViewCustom',$this->custom); JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $retValue = $dispatcher->trigger('plgVmOnDisplayEdit', array($this->custom->virtuemart_custom_id, &$customPlugin)); $this->SetViewTitle('PRODUCT_CUSTOM_FIELD', $this->custom->custom_title); $selected = 0; if (!empty($this->custom->custom_jplugin_id)) { VmConfig::loadJLang('plg_vmpsplugin', false); JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields'); $selected = $this->custom->custom_jplugin_id; // Get the payment XML. $formFile = JPath::clean(JPATH_ROOT . DS . 'plugins' . DS . 'vmcustom' . DS . $this->custom->custom_element . DS . $this->custom->custom_element . '.xml'); if (file_exists($formFile)) { $this->custom->form = JForm::getInstance($this->custom->custom_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $this->custom->params = new stdClass(); $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm'); $this->custom->params->custom_params = $this->custom->custom_params; VmTable::bindParameterable($this->custom->params, 'custom_params', $varsToPush); $this->custom->form->bind($this->custom); } else { $this->custom->form = null; } } $this->pluginList = self::renderInstalledCustomPlugins($selected); $this->assignRef('customPlugin', $customPlugin); $this->assignRef('customfields', $customfields); } else { JToolBarHelper::custom('createClone', 'copy', 'copy', vmText::_('COM_VIRTUEMART_CLONE'), true); JToolBarHelper::custom('toggle.admin_only.1', 'publish', '', vmText::_('COM_VIRTUEMART_TOGGLE_ADMIN'), true); JToolBarHelper::custom('toggle.admin_only.0', 'unpublish', '', vmText::_('COM_VIRTUEMART_TOGGLE_ADMIN'), true); JToolBarHelper::custom('toggle.is_hidden.1', 'publish', '', vmText::_('COM_VIRTUEMART_TOGGLE_HIDDEN'), true); JToolBarHelper::custom('toggle.is_hidden.0', 'unpublish', '', vmText::_('COM_VIRTUEMART_TOGGLE_HIDDEN'), true); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model); $customs = $model->getCustoms(vRequest::getInt('custom_parent_id'), vRequest::getCmd('keyword')); $this->assignRef('customs', $customs); $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); } parent::display($tpl); }
function display($tpl = null) { $db = JFactory::getDBO(); if ($field = vRequest::getVar('field')) { if (strpos($field, 'plugin') !== false) { JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields'); $table = '#__extensions'; $field = substr($field, 6); $q = 'SELECT `params`,`element`,`type` FROM `' . $table . '` WHERE `element` = "' . $field . '"'; $db->setQuery($q); $this->userField = $db->loadObject(); //$this->userField->element = substr($this->userField->type, 6); if (!class_exists('vmPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmplugin.php'; } vmPlugin::loadJLang('plg_vmuserfield_' . $this->userField->element, 'vmuserfield', $this->userField->element); $path = JPATH_ROOT . DS . 'plugins' . DS . 'vmuserfield' . DS . $this->userField->element . DS . $this->userField->element . '.xml'; // Get the payment XML. $formFile = JPath::clean($path); if (file_exists($formFile)) { if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } if (!class_exists('VmTable')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php'; } $this->userField->form = JForm::getInstance($this->userField->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $this->userField->params = new stdClass(); $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm'); /* $this->userField->params->userfield_params = $this->userField->params; VmTable::bindParameterable($this->userField->params,'userfield_params',$varsToPush);*/ if (empty($this->userField->userfield_params)) { $this->userField->userfield_params = ''; } $this->userField->params->userfield_params = $this->userField->userfield_params; VmTable::bindParameterable($this->userField->params, 'userfield_params', $varsToPush); $this->userField->form->bind($this->userField); } else { $this->userField->form = false; vmdebug('renderUserfieldPlugin could not find xml for ' . $this->userField->type . ' at ' . $path); } //vmdebug('renderUserfieldPlugin ',$this->userField->form); if ($this->userField->form) { $form = $this->userField->form; ob_start(); include JPATH_VM_ADMINISTRATOR . DS . 'fields' . DS . 'formrenderer.php'; $body = ob_get_contents(); ob_end_clean(); echo $body; } } } jExit(); }
/** * Retrieve the detail record for the current $id if the data has not already been loaded. * * @author Max Milbers */ public function getPayment($id = 0) { if (!empty($id)) { $this->_id = (int) $id; } if (empty($this->_cache[$this->_id])) { $this->_cache[$this->_id] = $this->getTable('paymentmethods'); $this->_cache[$this->_id]->load((int) $this->_id); if (empty($this->_cache->virtuemart_vendor_id)) { if (!class_exists('VirtueMartModelVendor')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'; } $this->_cache[$this->_id]->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor(); } if ($this->_cache[$this->_id]->payment_jplugin_id) { JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsPaymentVM3', array(&$this->_cache[$this->_id])); //$retValue = $dispatcher->trigger('plgVmDeclarePluginParamsPayment',array($this->_cache[$this->_id]->payment_element,$this->_cache[$this->_id]->payment_jplugin_id,&$this->_cache)); } if (!empty($this->_cache[$this->_id]->_varsToPushParam)) { VmTable::bindParameterable($this->_cache[$this->_id], 'payment_params', $this->_cache[$this->_id]->_varsToPushParam); } //todo check if we still need this /*if($this->_data[$this->_id]->getCryptedFields()){ if(!class_exists('vmCrypt')){ require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmcrypt.php'); } if(isset($this->_data[$this->_id]->modified_on)){ $date = JFactory::getDate($this->_data[$this->_id]->modified_on); $date = $date->toUnix(); } else { $date = 0; } foreach($this->_data[$this->_id]->getCryptedFields() as $field){ if(isset($this->_data[$this->_id]->$field)){ $this->_data[$this->_id]->$field = vmCrypt::decrypt($this->_data[$this->_id]->$field,$date); } } }*/ $q = 'SELECT `virtuemart_shoppergroup_id` FROM #__virtuemart_paymentmethod_shoppergroups WHERE `virtuemart_paymentmethod_id` = "' . $this->_id . '"'; $this->_db->setQuery($q); $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = $this->_db->loadResultArray(); if (empty($this->_cache[$this->_id]->virtuemart_shoppergroup_ids)) { $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = 0; } } return $this->_cache[$this->_id]; }
/** * Retrieve the detail record for the current $id if the data has not already been loaded. * * @author RickG */ function getShipment($id = 0) { if (!empty($id)) { $this->_id = (int) $id; } if (empty($this->_cache[$this->_id])) { $this->_cache[$this->_id] = $this->getTable('shipmentmethods'); $this->_cache[$this->_id]->load((int) $this->_id); if (empty($this->_cache[$this->_id]->virtuemart_vendor_id)) { if (!class_exists('VirtueMartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->_cache[$this->_id]->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor(); } if ($this->_cache[$this->_id]->shipment_jplugin_id) { JPluginHelper::importPlugin('vmshipment'); $dispatcher = JDispatcher::getInstance(); $blind = 0; $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsShipmentVM3', array(&$this->_cache[$this->_id])); } if (!empty($this->_cache[$this->_id]->_varsToPushParam)) { VmTable::bindParameterable($this->_cache[$this->_id], 'shipment_params', $this->_cache[$this->_id]->_varsToPushParam); } //We still need this, because the table is already loaded, but the keys are set later if ($this->_cache[$this->_id]->getCryptedFields()) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } if (isset($this->_cache[$this->_id]->modified_on)) { $date = JFactory::getDate($this->_cache[$this->_id]->modified_on); $date = $date->toUnix(); } else { $date = 0; } foreach ($this->_cache[$this->_id]->getCryptedFields() as $field) { if (isset($this->_cache[$this->_id]->{$field})) { $this->_cache[$this->_id]->{$field} = vmCrypt::decrypt($this->_cache[$this->_id]->{$field}, $date); } } } /* Add the shipmentcarreir shoppergroups */ $q = 'SELECT `virtuemart_shoppergroup_id` FROM #__virtuemart_shipmentmethod_shoppergroups WHERE `virtuemart_shipmentmethod_id` = "' . $this->_id . '"'; $this->_db->setQuery($q); $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = $this->_db->loadColumn(); if (empty($this->_cache[$this->_id]->virtuemart_shoppergroup_ids)) { $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = 0; } } return $this->_cache[$this->_id]; }
/** * Gets a single custom by virtuemart_custom_id * . * @param string $type * @param string $mime mime type of custom, use for exampel image * @return customobject */ function getCustom($id = 0) { if (!empty($id)) { $this->_id = (int) $id; } if (empty($this->_cache[$this->_id])) { $this->_cache[$this->_id] = $this->getTable('customs'); $this->_cache[$this->_id]->load($this->_id); $this->_cache[$this->_id]->_varsToPushParam = self::getVarsToPush($this->_cache[$this->_id]->field_type); $this->_cache[$this->_id]->customfield_params = ''; if ($this->_cache[$this->_id]->field_type == 'E') { JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsCustomVM3', array(&$this->_cache[$this->_id])); } //exaample vm2 withParent="0"|parentOrderable="0"| // vm3 withParent="1"|parentOrderable="1"| $this->_cache[$this->_id]->_xParams = 'custom_params'; if (!empty($this->_cache[$this->_id]->_varsToPushParam)) { VmTable::bindParameterable($this->_cache[$this->_id], 'custom_params', $this->_cache[$this->_id]->_varsToPushParam); } } return $this->_cache[$this->_id]; }
/** * Fill the array with all plugins found with this plugin for the current vendor * * @return True when plugins(s) was (were) found for this vendor, false otherwise * @author Oscar van Eijk * @author max Milbers * @author valerie Isaksen */ protected function getPluginMethods($vendorId) { if (!class_exists('VirtueMartModelUser')) { require VMPATH_ADMIN . DS . 'models' . DS . 'user.php'; } $usermodel = VmModel::getModel('user'); $user = $usermodel->getUser(); $user->shopper_groups = (array) $user->shopper_groups; $db = JFactory::getDBO(); $select = 'SELECT l.*, v.*, '; $extPlgTable = '#__extensions'; $extField1 = 'extension_id'; $extField2 = 'element'; $select .= 'j.`' . $extField1 . '`,j.`name`, j.`type`, j.`element`, j.`folder`, j.`client_id`, j.`enabled`, j.`access`, j.`protected`, j.`manifest_cache`, j.`params`, j.`custom_data`, j.`system_data`, j.`checked_out`, j.`checked_out_time`, j.`state`, s.virtuemart_shoppergroup_id '; if (!VmConfig::$vmlang) { VmConfig::setdbLanguageTag(); } $q = $select . ' FROM `#__virtuemart_' . $this->_psType . 'methods_' . VmConfig::$vmlang . '` as l '; $q .= ' JOIN `#__virtuemart_' . $this->_psType . 'methods` AS v USING (`virtuemart_' . $this->_psType . 'method_id`) '; $q .= ' LEFT JOIN `' . $extPlgTable . '` as j ON j.`' . $extField1 . '` = v.`' . $this->_psType . '_jplugin_id` '; $q .= ' LEFT OUTER JOIN `#__virtuemart_' . $this->_psType . 'method_shoppergroups` AS s ON v.`virtuemart_' . $this->_psType . 'method_id` = s.`virtuemart_' . $this->_psType . 'method_id` '; $q .= ' WHERE v.`published` = "1" AND j.`' . $extField2 . '` = "' . $this->_name . '" AND (v.`virtuemart_vendor_id` = "' . $vendorId . '" OR v.`virtuemart_vendor_id` = "0" OR v.`shared` = "1") AND ('; foreach ($user->shopper_groups as $groups) { $q .= ' s.`virtuemart_shoppergroup_id`= "' . (int) $groups . '" OR'; } $q .= ' (s.`virtuemart_shoppergroup_id`) IS NULL ) GROUP BY v.`virtuemart_' . $this->_psType . 'method_id` ORDER BY v.`ordering`'; $db->setQuery($q); $this->methods = $db->loadObjectList(); $err = $db->getErrorMsg(); if (!empty($err)) { vmError('Error reading getPluginMethods ' . $err); } if ($this->methods) { foreach ($this->methods as $method) { VmTable::bindParameterable($method, $this->_xParams, $this->_varsToPushParam); } } return count($this->methods); }
private function getOrderCalc($orderDetails) { $calc = 0; if (!empty($orderDetails['calc_rules'])) { foreach ($orderDetails['calc_rules'] as $rule) { if ($rule->calc_kind == 'taxRulesBill' and $rule->calc_mathop == 'avalara') { $calc = $rule; break; } } } if (empty($calc)) { avadebug('Retrieving calculation rule for avatax failed', $orderDetails->virtuemart_order_id); return false; } if (is_object($calc)) { $calc = get_object_vars($calc); } if (!empty($calc['calc_params'])) { VmTable::bindParameterable($calc, $this->_xParams, $this->_varsToPushParam); return $calc; } else { avadebug('rule had no parameters', $calc); return false; } }
/** * @param $psType * @param $name * @param $id * @param $data * @return bool */ protected function declarePluginParams($psType, $name, $id, &$data) { //vmdebug('declarePluginParams '.$this->_psType.' '.$psType); //Todo I know a test only on seledtThis is wrong here, it works now with extra !empty($this->_psType) if (!empty($this->_psType) and !$this->selectedThis($psType, $name, $id)) { return FALSE; } if (!class_exists('VmTable')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php'; } VmTable::bindParameterable($data, $this->_xParams, $this->_varsToPushParam); return TRUE; // vmdebug('getDeclaredPluginParams return '.$this->_xParams); // return array($this->_xParams,$this->_varsToPushParam); // } else { // return false; // } }
static function bindCustomEmbeddedFieldParams(&$obj, $fieldtype) { //vmdebug('bindCustomEmbeddedFieldParams begin',$obj); if (!class_exists('VirtueMartModelCustom')) { require VMPATH_ADMIN . DS . 'models' . DS . 'custom.php'; } if ($obj->field_type == 'E') { JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsCustomVM3', array(&$obj)); if (!empty($obj->_varsToPushParam)) { if (empty($obj->_varsToPushParamCustom)) { $obj->_varsToPushParamCustom = $obj->_varsToPushParam; } if (empty($obj->_varsToPushParamCustomField)) { $obj->_varsToPushParamCustomField = $obj->_varsToPushParam; } } } else { $obj->_varsToPushParamCustom = VirtueMartModelCustom::getVarsToPush($fieldtype); $obj->_varsToPushParam = $obj->_varsToPushParamCustomField = $obj->_varsToPushParamCustom; //vmdebug('my $obj->_varsToPushParamCustom',$obj->_varsToPushParamCustomField); } if (!empty($obj->_varsToPushParam)) { //$obj ->_xParams = 'custom_params'; VmTable::bindParameterable($obj, 'custom_params', $obj->_varsToPushParamCustom); $obj->_xParams = 'customfield_params'; VmTable::bindParameterable($obj, $obj->_xParams, $obj->_varsToPushParamCustomField); } }
protected function declarePluginParams($psType, $name, $id, &$data) { // if($this->selectedThis($psType,$name,$id)){ if (!class_exists('VmTable')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php'; } VmTable::bindParameterable($data, $this->_xParams, $this->_varsToPushParam); return true; // vmdebug('getDeclaredPluginParams return '.$this->_xParams); // return array($this->_xParams,$this->_varsToPushParam); // } else { // return false; // } }
static function bindParameterableByFieldType(&$table, $type = 0) { if ($type === 0) { $type = $table->field_type; } $varsToPush = self::getVarsToPush($type); if (!empty($varsToPush)) { VmTable::bindParameterable($table, 'custom_param', $varsToPush); } }
public function getVmPluginMethod($int, $cache = true) { $class = $this->myClass(); if (OPCJ3) { $db = JFactory::getDBO(); if (!class_exists($this->_configTableClassName)) { require JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'tables' . DIRECTORY_SEPARATOR . $this->_configTableFileName . '.php'; } $this->_vmpCtable = new $this->_configTableClassName($db); if ($this->_xParams !== 0) { $this->_vmpCtable->setParameterable($this->_configTableFieldName, $this->_varsToPushParam); } if ($this->_cryptedFields) { $this->_vmpCtable->setCryptedFields($this->_cryptedFields); } $ret = $this->_vmpCtable->load($int); if (isset(vmPlugin::$xmlDefaults[$this->_name . 'Form'])) { $defaults = vmPlugin::$xmlDefaults[$this->_name . 'Form']; foreach ($defaults as $key => $name) { $this->{$key} = $name; } } VmTable::bindParameterable($ret, $this->_xParams, $this->_varsToPushParam); return $ret; } $x = vmPlugin::getCache('getVmPluginMethod', $class . $int); $this->_vmpCtable = $x; // vm 2.0.20 if (!empty($x)) { if (!isset($x->tax_id)) { $x->tax_id = -1; } } if (!empty($x)) { return $x; } $x = $this->selectedThisByMethodId($int); if (empty($x)) { $res = false; return vmPlugin::setCache($res, 'getVmPluginMethod', $class . $int); } /* static $lastInt; if (!empty($lastInt)) { if ($int != $lastInt) $refresh = true; else $refresh = false; } else { $refresh = true; $lastInt = $int; } */ if (!class_exists('VmTable')) { require JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'vmtable.php'; } if (empty($this->_vmpCtableAll)) { $this->_vmpCtableAll = array(); } $type = $this->_psType; if (empty($this->_vmpCtableAll[$type . $int])) { $db = JFactory::getDBO(); if (!class_exists($this->_configTableClassName)) { require JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'tables' . DIRECTORY_SEPARATOR . $this->_configTableFileName . '.php'; } $this->_vmpCtableAll[$type . $int] = new $this->_configTableClassName($db); if ($this->_xParams !== 0) { if (method_exists($this->_vmpCtableAll[$type . $int], 'setParameterable')) { $this->_vmpCtableAll[$type . $int]->setParameterable($this->_xParams, $this->_varsToPushParam); } } if ($this->_cryptedFields) { if (method_exists($this->_vmpCtableAll[$type . $int], 'setCryptedFields')) { $this->_vmpCtableAll[$type . $int]->setCryptedFields($this->_cryptedFields); } } } // some plugins are missing some of the params: $this->_vmpCtableAll[$type . $int]->setParameterable($this->_xParams, $this->_varsToPushParam); $x = $this->_vmpCtableAll[$type . $int]->load($int); $this->_vmpCtable = $this->_vmpCtableAll[$type . $int]; if (!empty($x)) { if (!isset($x->payment_logos)) { $x->payment_logos = ''; } if (!isset($x->cost_per_transaction)) { $x->cost_per_transaction = 0; } if (!isset($x->cost_percent_total)) { $x->cost_percent_total = 0; } if (!isset($x->tax_id)) { $x->tax_id = -1; } if (!isset($x->weight_unit)) { $x->weight_unit = 'KG'; } } return vmPlugin::setCache($x, 'getVmPluginMethod', $class . $int); }
public function plgVmGetPluginInternalDataCalc(&$calcData) { $calcData->setParameterable($this->_xParams, $this->_varsToPushParam); if (!class_exists('VmTable')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php'; } VmTable::bindParameterable($calcData, $this->_xParams, $this->_varsToPushParam); return TRUE; }
/** * Fill the array with all plugins found with this plugin for the current vendor * * @return True when plugins(s) was (were) found for this vendor, false otherwise * @author Oscar van Eijk * @author max Milbers * @author valerie Isaksen */ protected function getPluginMethods($vendorId) { if (!class_exists('VirtueMartModelUser')) { require VMPATH_ADMIN . DS . 'models' . DS . 'user.php'; } $usermodel = VmModel::getModel('user'); $user = $usermodel->getUser(); $user->shopper_groups = (array) $user->shopper_groups; $db = JFactory::getDBO(); if (empty($vendorId)) { $vendorId = 1; } $select = 'SELECT i.*, '; $extPlgTable = '#__extensions'; $extField1 = 'extension_id'; $extField2 = 'element'; $select .= 'j.`' . $extField1 . '`,j.`name`, j.`type`, j.`element`, j.`folder`, j.`client_id`, j.`enabled`, j.`access`, j.`protected`, j.`manifest_cache`, j.`params`, j.`custom_data`, j.`system_data`, j.`checked_out`, j.`checked_out_time`, j.`state`, s.virtuemart_shoppergroup_id '; if (!VmConfig::$vmlang) { VmConfig::setdbLanguageTag(); } $joins = array(); if (VmConfig::$defaultLang != VmConfig::$vmlang and Vmconfig::$langCount > 1) { $langFields = array($this->_psType . '_name', $this->_psType . '_desc'); $useJLback = false; if (VmConfig::$defaultLang != VmConfig::$jDefLang) { $joins[] = ' LEFT JOIN `#__virtuemart_' . $this->_psType . '_' . VmConfig::$jDefLang . '` as ljd'; $useJLback = true; } foreach ($langFields as $langField) { $expr2 = 'ld.' . $langField; if ($useJLback) { $expr2 = 'IFNULL(ld.' . $langField . ',ljd.' . $langField . ')'; } $select .= ', IFNULL(l.' . $langField . ',' . $expr2 . ') as ' . $langField . ''; } $joins[] = ' LEFT JOIN `#__virtuemart_' . $this->_psType . 'methods_' . VmConfig::$defaultLang . '` as ld using (`virtuemart_' . $this->_psType . 'method_id`)'; $joins[] = ' LEFT JOIN `#__virtuemart_' . $this->_psType . 'methods_' . VmConfig::$vmlang . '` as l using (`virtuemart_' . $this->_psType . 'method_id`)'; } else { $select .= ', l.* '; $joins[] = ' LEFT JOIN `#__virtuemart_' . $this->_psType . 'methods_' . VmConfig::$vmlang . '` as l using (`virtuemart_' . $this->_psType . 'method_id`)'; } $q = $select . ' FROM `#__virtuemart_' . $this->_psType . 'methods' . '` as i '; //$joins[] = ' JOIN `#__virtuemart_' . $this->_psType . 'methods` AS i USING (`virtuemart_' . $this->_psType . 'method_id`) '; $joins[] = ' LEFT JOIN `' . $extPlgTable . '` as j ON j.`' . $extField1 . '` = i.`' . $this->_psType . '_jplugin_id` '; $joins[] = ' LEFT OUTER JOIN `#__virtuemart_' . $this->_psType . 'method_shoppergroups` AS s ON i.`virtuemart_' . $this->_psType . 'method_id` = s.`virtuemart_' . $this->_psType . 'method_id` '; $q .= implode(' ' . "\n", $joins); $q .= ' WHERE i.`published` = "1" AND j.`' . $extField2 . '` = "' . $this->_name . '" AND (i.`virtuemart_vendor_id` = "' . $vendorId . '" OR i.`virtuemart_vendor_id` = "0" OR i.`shared` = "1") AND ('; foreach ($user->shopper_groups as $groups) { $q .= ' s.`virtuemart_shoppergroup_id`= "' . (int) $groups . '" OR'; } $q .= ' (s.`virtuemart_shoppergroup_id`) IS NULL ) GROUP BY i.`virtuemart_' . $this->_psType . 'method_id` ORDER BY i.`ordering`'; $db->setQuery($q); $this->methods = $db->loadObjectList(); if ($this->methods) { foreach ($this->methods as $method) { VmTable::bindParameterable($method, $this->_xParams, $this->_varsToPushParam); } } else { if ($this->methods === false) { vmError('Error reading getPluginMethods ' . $q); } } return count($this->methods); }
/** * Retrieve the detail record for the current $id if the data has not already been loaded. */ function getUserfield($id = 0,$name = '') { if($id === 0) $id = $this->_id; $hash = $id.$name; if (empty($this->_cache[$hash])) { $this->_cache[$hash] = $this->getTable('userfields'); if($name !==''){ $this->_cache[$hash]->load($id, $name); } else { $this->_cache[$hash]->load($id); } //vmdebug('getUserfield',$id,$name,$this->_cache[$id]); if(strpos($this->_cache[$hash]->type,'plugin')!==false){ JPluginHelper::importPlugin('vmuserfield'); $dispatcher = JDispatcher::getInstance(); $plgName = substr($this->_cache[$hash]->type,6); $type = 'userfield'; $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsUserfieldVM3',array($type,&$this->_cache[$hash])); // vmdebug('pluginGet',$type,$plgName,$id,$this->_cache); } if(!empty($this->_cache[$hash]->_varsToPushParam)){ VmTable::bindParameterable($this->_cache[$hash],'userfield_params',$this->_cache[$hash]->_varsToPushParam); } } return $this->_cache[$hash]; }
function display($tpl = null) { // Load the helper(s) $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers'); if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } $this->user = JFactory::getUser(); $model = VmModel::getModel('paymentmethod'); // TODO logo $this->SetViewTitle(); $layoutName = vRequest::getCmd('layout', 'default'); $vendorModel = VmModel::getModel('vendor'); $vendorModel->setId(1); $vendor = $vendorModel->getVendor(); $currencyModel = VmModel::getModel('currency'); $currencyModel = $currencyModel->getCurrency($vendor->vendor_currency); $this->assignRef('vendor_currency', $currencyModel->currency_symbol); if ($layoutName == 'edit') { // Load the helper(s) if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } VmConfig::loadJLang('plg_vmpsplugin', false); JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields'); $payment = $model->getPayment(); // Get the payment XML. $formFile = JPath::clean(JPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . $payment->payment_element . DS . $payment->payment_element . '.xml'); if (file_exists($formFile)) { $payment->form = JForm::getInstance($payment->payment_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $payment->params = new stdClass(); $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'paymentForm'); $payment->params->payment_params = $payment->payment_params; VmTable::bindParameterable($payment->params, 'payment_params', $varsToPush); $payment->form->bind($payment); } else { $payment->form = null; } $this->assignRef('payment', $payment); $this->assignRef('vmPPaymentList', self::renderInstalledPaymentPlugins($payment->payment_jplugin_id)); $this->assignRef('shopperGroupList', ShopFunctions::renderShopperGroupList($payment->virtuemart_shoppergroup_ids, true)); if (Vmconfig::get('multix', 'none') !== 'none') { $vendorList = ShopFunctions::renderVendorList($payment->virtuemart_vendor_id); $this->assignRef('vendorList', $vendorList); } $this->addStandardEditViewCommands($payment->virtuemart_paymentmethod_id); } else { JToolBarHelper::custom('clonepayment', 'copy', 'copy', vmText::_('COM_VIRTUEMART_PAYMENT_CLONE'), true); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model); $this->payments = $model->getPayments(); foreach ($this->payments as &$data) { // Write the first 5 shoppergroups in the list $data->paymShoppersList = shopfunctions::renderGuiList($data->virtuemart_shoppergroup_ids, 'shoppergroups', 'shopper_group_name', 'payment'); } $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); } parent::display($tpl); }
public function getCustomParams(&$field) { VmTable::bindParameterable($field, 'custom_params', $this->_varsToPushParam); //Why do we have this? if (empty($field->custom_element)) { return 0; } //Why do we have this, when bindParameterable could already doing it //And why we do it here, when we do it later again? foreach ($this->_varsToPushParam as $k => $v) { if (!isset($this->params->{$k})) { $this->params->{$k} = $field->{$k}; } // vmdebug('fields org '.$this->_name,$this->params); } $this->virtuemart_custom_id = $field->virtuemart_custom_id; if (!empty($field->custom_param) && is_string($field->custom_param)) { $this->params = json_decode($field->custom_param); } else { return; } //$field->custom_param = $custom_param; /* vmdebug('$this->_varsToPushParam '.$this->_name,$this->_varsToPushParam ); */ foreach ($this->_varsToPushParam as $k => $v) { if (!isset($this->params->{$k})) { $this->params->{$k} = $field->{$k}; } } }
function renderUserfieldPlugin() { if (!class_exists('vmUserfieldPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmuserfieldtypeplugin.php'; } VmConfig::loadJLang('plg_vmpsplugin', false); JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields'); //$selected = $this->userField->userfield_jplugin_id; //vmdebug('renderUserfieldPlugin $this->userField->element',$this->userField->type,$this->userField->element); $this->userField->element = substr($this->userField->type, 6); $path = JPATH_ROOT . DS . 'plugins' . DS . 'vmuserfield' . DS . $this->userField->element . DS . $this->userField->element . '.xml'; // Get the payment XML. $formFile = JPath::clean($path); if (file_exists($formFile)) { $this->userField->form = JForm::getInstance($this->userField->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $this->userField->params = new stdClass(); $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm'); $this->userField->params->userfield_params = $this->userField->userfield_params; VmTable::bindParameterable($this->userField->params, 'userfield_params', $varsToPush); $this->userField->form->bind($this->userField); } else { $this->userField->form = false; vmdebug('renderUserfieldPlugin could not find xml for ' . $this->userField->type . ' at ' . $path); } //vmdebug('renderUserfieldPlugin ',$this->userField->form); if ($this->userField->form) { $form = $this->userField->form; ob_start(); include JPATH_VM_ADMINISTRATOR . DS . 'fields' . DS . 'formrenderer.php'; $body = ob_get_contents(); ob_end_clean(); return $body; } return; }