protected function getOptions() { $options = array(); if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $vendor_id = tsmartModelVendor::getLoggedVendor(); // set currency_id to logged vendor if (empty($this->value)) { $currency = tsmartModelVendor::getVendorCurrency($vendor_id); $this->value = $currency->tsmart_currency_id; } // why not logged vendor? shared is missing $db = JFactory::getDBO(); $query = 'SELECT `tsmart_currency_id` AS value, `currency_name` AS text FROM `#__tsmart_currencies` WHERE `tsmart_vendor_id` = "1" AND `published` = "1" ORDER BY `currency_name` ASC '; // default value should be vendor currency $db->setQuery($query); $values = $db->loadObjectList(); foreach ($values as $v) { $options[] = JHtml::_('select.option', $v->value, $v->text); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
function onDisplayEditBECustom($tsmart_custom_id, &$customPlugin) { //if($this->plugin = $this->selectedThisByMethodId($this->_psType,$tsmart_custom_id)){ if ($this->plugin = $this->selectedThisByMethodId($tsmart_custom_id)) { if (empty($this->plugin)) { $this->plugin->custom_jplugin_id = NULL; return $this->plugin; } //Must use here the table to get valid params $this->plugin = $this->getVmPluginMethod($this->plugin->tsmart_custom_id); if (empty($this->plugin->tsmart_vendor_id)) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->plugin->tsmart_vendor_id = tsmartModelVendor::getLoggedVendor(); } $customPlugin = $this->plugin; // return $this->plugin; return TRUE; } }
function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } // get necessary models $model = tmsModel::getModel('manufacturer'); $categoryModel = tmsModel::getModel('manufacturercategories'); $this->SetViewTitle(); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $this->manufacturer = $model->getManufacturer(); $isNew = $this->manufacturer->tsmart_manufacturer_id < 1; $model->addImages($this->manufacturer); /* Process the images */ $mediaModel = tmsModel::getModel('media'); $mediaModel->setId($this->manufacturer->tsmart_media_id); $image = $mediaModel->getFile('manufacturer', 'image'); $this->manufacturerCategories = $categoryModel->getManufacturerCategories(false, true); $this->addStandardEditViewCommands($this->manufacturer->tsmart_manufacturer_id); if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->tsmart_vendor_id = tsmartModelVendor::getLoggedVendor(); } else { $mainframe = JFactory::getApplication(); $categoryFilter = $categoryModel->getCategoryFilter(); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model, 'mf_name'); $this->manufacturers = $model->getManufacturers(); $this->pagination = $model->getPagination(); $tsmart_manufacturercategories_id = $mainframe->getUserStateFromRequest('com_tsmart.tsmart_manufacturercategories_id', 'tsmart_manufacturercategories_id', 0, 'int'); $this->lists['tsmart_manufacturercategories_id'] = JHtml::_('select.genericlist', $categoryFilter, 'tsmart_manufacturercategories_id', 'class="inputbox" onchange="this.form.submit()"', 'value', 'text', $tsmart_manufacturercategories_id); } parent::display($tpl); }
function getVendorAcceptedCurrrenciesList($vendorId = 0) { static $currencies = array(); if ($vendorId === 0) { $multix = tsmConfig::get('multix', 'none'); if (strpos($multix, 'payment') !== FALSE) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $vendorId = tsmartModelVendor::getLoggedVendor(); } else { $vendorId = 1; } } if (!isset($currencies[$vendorId])) { $db = JFactory::getDbo(); $q = 'SELECT `vendor_accepted_currencies`, `vendor_currency` FROM `#__tsmart_vendors` WHERE `tsmart_vendor_id`=' . $vendorId; $db->setQuery($q); $vendor_currency = $db->loadAssoc(); if (!$vendor_currency['vendor_accepted_currencies']) { $vendor_currency['vendor_accepted_currencies'] = $vendor_currency['vendor_currency']; vmWarn('No accepted currencies defined'); if (empty($vendor_currency['vendor_accepted_currencies'])) { $uri = JFactory::getURI(); $link = $uri->root() . 'administrator/index.php?option=com_tsmart&view=user&task=editshop'; vmWarn(tsmText::sprintf('com_tsmart_CONF_WARN_NO_CURRENCY_DEFINED', '<a href="' . $link . '">' . $link . '</a>')); $currencies[$vendorId] = false; return $currencies[$vendorId]; } } $q = 'SELECT `tsmart_currency_id`,CONCAT_WS(" ",`currency_name`,`currency_symbol`) as currency_txt FROM `#__tsmart_currencies` WHERE `tsmart_currency_id` IN (' . $vendor_currency['vendor_accepted_currencies'] . ')'; if ($vendorId != 1) { $q .= ' AND (`tsmart_vendor_id` = "' . $vendorId . '" OR `shared`="1")'; } $q .= ' AND published = "1" ORDER BY `ordering`,`currency_name`'; $db->setQuery($q); $currencies[$vendorId] = $db->loadObjectList(); } return $currencies[$vendorId]; }
public function store(&$data) { if (!vmAccess::manager('custom.edit')) { vmWarn('Insufficient permission to edit custom'); return false; } if (!empty($data['params'])) { foreach ($data['params'] as $k => $v) { $data[$k] = $v; } } //I think this is obsolete, note by Max if (empty($data['tsmart_vendor_id'])) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $data['tsmart_vendor_id'] = tsmartModelVendor::getLoggedVendor(); } else { $data['tsmart_vendor_id'] = (int) $data['tsmart_vendor_id']; } $table = $this->getTable('customs'); if (!empty($data['custom_jplugin_id'])) { $tb = '#__extensions'; $ext_id = 'extension_id'; $db = JFactory::getDBO(); $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['custom_jplugin_id'] . '"'; $db->setQuery($q); $cElement = $db->loadResult(); if (empty($cElement)) { if (!empty($data['tsmart_custom_id'])) { $table->load($data['tsmart_custom_id']); $cElement = $table->custom_element; } else { if (!empty($data['custom_element'])) { $cElement = $data['custom_element']; } } $q = 'SELECT * FROM `' . $tb . '` WHERE `element` = "' . $cElement . '" '; $db->setQuery($q); if ($jids = $db->loadAssocList()) { $newJid = 0; foreach ($jids as $jid) { $newJid = $jid[$ext_id]; if ($jid['enabled'] == 1 and $jid['state'] == 0) { break; } } vmdebug('Available entries ', $newJid, $jids); if (!empty($newJid)) { $q = 'UPDATE `#__tsmart_customs` SET `custom_jplugin_id`="' . $jid . '" WHERE `custom_jplugin_id` = "' . $data['custom_jplugin_id'] . '"'; $db->setQuery($q); $db->execute(); $data['custom_jplugin_id'] = $newJid; vmInfo('Old Plugin id was not available, updated entries with ' . $ext_id . ' = ' . $newJid . ' found for the same element'); } } else { vmWarn('could not load custom_element for plugin, testing if current custom_jplugin_id is still available ' . $q); } } if (!empty($cElement)) { $data['custom_element'] = $cElement; } $q = 'UPDATE `#__extensions` SET `enabled`= 1, `state` = 0 WHERE `extension_id` = "' . $data['custom_jplugin_id'] . '"'; $db->setQuery($q); $db->execute(); } $table->field_type = $data['field_type']; if ($table->field_type == 'C') { //vmInfo(); //$data['is_cart_attribute'] = 1; } $table->custom_element = $data['custom_element']; $table->custom_jplugin_id = $data['custom_jplugin_id']; $table->_xParams = 'custom_params'; if (!empty($data['is_input'])) { if (empty($data['layout_pos'])) { $data['layout_pos'] = 'addtocart'; } } //We are in the custom and so the table contains the field_type, else not!! self::setParameterableByFieldType($table, $table->field_type); if (empty($data['tsmart_custom_id']) and !vmAccess::manager('custom.create')) { vmWarn('Insufficient permission to create custom'); return false; } $table->bindChecknStore($data); JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $error = $dispatcher->trigger('plgVmOnStoreInstallPluginTable', array('custom', $data, $table)); return $table->tsmart_custom_id; }
/** * Bind the post data to the shipment tables and save it * * @author Max Milbers * @return boolean True is the save was successful, false otherwise. */ public function store(&$data) { if ($data) { $data = (array) $data; } if (!vmAccess::manager('shipmentmethod.edit')) { vmWarn('Insufficient permissions to store shipmentmethod'); return false; } else { if (empty($data['tsmart_shipment_id']) and !vmAccess::manager('shipmentmethod.create')) { vmWarn('Insufficient permission to create shipmentmethod'); return false; } } if (!empty($data['params'])) { foreach ($data['params'] as $k => $v) { $data[$k] = $v; } } if (empty($data['tsmart_vendor_id'])) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $data['tsmart_vendor_id'] = tsmartModelVendor::getLoggedVendor(); } else { $data['tsmart_vendor_id'] = (int) $data['tsmart_vendor_id']; } $tb = '#__extensions'; $ext_id = 'extension_id'; $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['shipment_jplugin_id'] . '"'; $db = JFactory::getDBO(); $db->setQuery($q); $data['shipment_element'] = $db->loadResult(); $table = $this->getTable('shipmentmethods'); if (isset($data['shipment_jplugin_id'])) { $q = 'UPDATE `#__extensions` SET `enabled`= 1 WHERE `extension_id` = "' . $data['shipment_jplugin_id'] . '"'; $db->setQuery($q); $db->execute(); JPluginHelper::importPlugin('vmshipment'); $dispatcher = JDispatcher::getInstance(); //bad trigger, we should just give it data, so that the plugins itself can check the data to be stored //so this trigger is now deprecated and will be deleted in vm2.2 $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsShipment', array($data['shipment_element'], $data['shipment_jplugin_id'], &$table)); $retValue = $dispatcher->trigger('plgVmSetOnTablePluginShipment', array(&$data, &$table)); } $table->bindChecknStore($data); $xrefTable = $this->getTable('shipmentmethod_shoppergroups'); $xrefTable->bindChecknStore($data); if (!class_exists('vmPSPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); //Add a hook here for other shipment methods, checking the data of the choosed plugin $dispatcher = JDispatcher::getInstance(); $retValues = $dispatcher->trigger('plgVmOnStoreInstallShipmentPluginTable', array($data['shipment_jplugin_id'])); return $table->tsmart_shipmentmethod_id; }
/** * * @author Max Milbers * */ public function getData($id = 0) { if ($id != 0) { $this->_id = (int) $id; } if (empty($this->_cache[$this->_id])) { $this->_cache[$this->_id] = $this->getTable($this->_maintablename); $this->_cache[$this->_id]->load($this->_id); //just an idea if (isset($this->_cache[$this->_id]->tsmart_vendor_id) && empty($this->_data->tsmart_vendor_id)) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->_cache[$this->_id]->tsmart_vendor_id = tsmartModelVendor::getLoggedVendor(); } } return $this->_cache[$this->_id]; }