/**
  * @author Max Milbers
  * @param JDataBase $db
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_rating_reviews', 'virtuemart_rating_review_id', $db);
     $this->setPrimaryKey('virtuemart_rating_review_id');
     $this->setObligatoryKeys('comment');
     $this->setLoggable();
 }
Example #2
0
 function check()
 {
     if (empty($this->shopper_group_name)) {
         vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME'));
         return false;
     } else {
         if (function_exists('mb_strlen')) {
             if (mb_strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         } else {
             if (strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         }
     }
     /* commented by PATRICK This set always shoppergroup to 1 if you do a new shoppergroup
     		if(empty($this->virtuemart_shoppergroup_id)){
     			$q = 'SELECT `virtuemart_shoppergroup_id` FROM `#__virtuemart_shoppergroups` WHERE `default`="1" AND `virtuemart_vendor_id`="1" ';
     			$this->_db->setQuery($q);
     			$this->virtuemart_shoppergroup_id=$this->_db->loadResult();
     		}
     */
     return parent::check();
 }
Example #3
0
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_calcs', 'virtuemart_calc_id', $db);
     $this->setObligatoryKeys('calc_name');
     $this->setObligatoryKeys('calc_kind');
     $this->setLoggable();
 }
Example #4
0
 function check()
 {
     if (empty($this->shopper_group_name)) {
         vmError('COM_VIRTUEMART_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME');
         return false;
     } else {
         if (function_exists('mb_strlen')) {
             $length = mb_strlen($this->shopper_group_name);
         } else {
             $length = strlen($this->shopper_group_name);
         }
         if ($length > 128) {
             vmError('COM_VIRTUEMART_SHOPPERGROUP_NAME_128');
         }
     }
     if ($this->virtuemart_shoppergroup_id == 1) {
         $this->default = 2;
         $this->sgrp_additional = 0;
     }
     if ($this->virtuemart_shoppergroup_id == 2) {
         $this->default = 1;
         $this->sgrp_additional = 0;
     }
     return parent::check();
 }
Example #5
0
 /**
  * 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 __construct(&$db)
 {
     parent::__construct('#__virtuemart_shoppergroups', 'virtuemart_shoppergroup_id', $db);
     $this->setUniqueName('shopper_group_name');
     $this->setLoggable();
     $this->setTableShortCut('sg');
 }
Example #7
0
 /**
  *
  * @author Max Milbers
  * @param $db Class constructor; connect to the database
  *
  */
 function __construct($db)
 {
     parent::__construct('#__virtuemart_invoices', 'virtuemart_invoice_id', $db);
     $this->setUniqueName('invoice_number');
     $this->setLoggable();
     $this->setTableShortCut('inv');
 }
Example #8
0
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->addHelperPath(VMPATH_ADMIN . DS . 'helpers');
     if (!class_exists('vmPSPlugin')) {
         require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php';
     }
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $model = VmModel::getModel();
     $layoutName = vRequest::getCmd('layout', 'default');
     $this->SetViewTitle();
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         VmConfig::loadJLang('plg_vmpsplugin', false);
         JForm::addFieldPath(VMPATH_ADMIN . DS . 'fields');
         $shipment = $model->getShipment();
         // Get the payment XML.
         $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmshipment' . DS . $shipment->shipment_element . DS . $shipment->shipment_element . '.xml');
         if (file_exists($formFile)) {
             $shipment->form = JForm::getInstance($shipment->shipment_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
             $shipment->params = new stdClass();
             $varsToPush = vmPlugin::getVarsToPushFromForm($shipment->form);
             VmTable::bindParameterableToSubField($shipment, $varsToPush);
             $shipment->form->bind($shipment->getProperties());
         } else {
             $shipment->form = null;
         }
         if (!class_exists('VmImage')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
         }
         if (!class_exists('VirtueMartModelVendor')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
         }
         $vendor_id = 1;
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $this->assignRef('vendor_currency', $currency->currency_symbol);
         if ($this->showVendors()) {
             $vendorList = ShopFunctions::renderVendorList($shipment->virtuemart_vendor_id);
             $this->assignRef('vendorList', $vendorList);
         }
         $this->pluginList = self::renderInstalledShipmentPlugins($shipment->shipment_jplugin_id);
         $this->assignRef('shipment', $shipment);
         $this->shopperGroupList = ShopFunctions::renderShopperGroupList($shipment->virtuemart_shoppergroup_ids, true);
         $this->addStandardEditViewCommands($shipment->virtuemart_shipmentmethod_id);
     } else {
         JToolBarHelper::custom('cloneshipment', 'copy', 'copy', vmText::_('COM_VIRTUEMART_SHIPMENT_CLONE'), true);
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $this->shipments = $model->getShipments();
         VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
         foreach ($this->shipments as &$data) {
             // Write the first 5 shoppergroups in the list
             $data->shipmentShoppersList = shopfunctions::renderGuiList($data->virtuemart_shoppergroup_ids, 'shoppergroups', 'shopper_group_name', 'shopper');
         }
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
 }
Example #9
0
 /**
  * @author Max Milbers
  * @param $db A database connector object
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_rating_votes', 'virtuemart_rating_vote_id', $db);
     $this->setPrimaryKey('virtuemart_product_id');
     //		$this->setObligatoryKeys('vote');
     $this->setLoggable();
 }
Example #10
0
 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);
 }
 /**
  * @author  Patrick Kohl
  * @param JDataBase $db
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_customs', 'virtuemart_custom_id', $db);
     $this->setUniqueName('custom_title');
     $this->setObligatoryKeys('field_type');
     $this->setLoggable();
     $this->setOrderable('ordering', false);
 }
Example #12
0
 /**
  * Validates the userfields record fields.
  *
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check($nrOfValues)
 {
     if (preg_match('/[^a-z0-9\\._\\-]/i', $this->group_name) > 0) {
         vmError(JText::_('COM_VIRTUEMART_PERMISSION_GROUP_NAME_INVALID_CHARACTERS'));
         return false;
     }
     return parent::check();
 }
 /**
  * @author Max Milbers
  * @param $db A database connector object
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_product_customfields', 'virtuemart_customfield_id', $db);
     $this->setPrimaryKey('virtuemart_product_id');
     // $this->setSecondaryKey('virtuemart_customfield_id');
     $this->setLoggable();
     $this->setOrderable();
 }
 function check()
 {
     if (empty($this->notify_email) || !filter_var($this->notify_email, FILTER_VALIDATE_EMAIL)) {
         vmError(JText::_('COM_VIRTUEMART_ENTER_A_VALID_EMAIL_ADDRESS'), JText::_('COM_VIRTUEMART_ENTER_A_VALID_EMAIL_ADDRESS'));
         return false;
     }
     return parent::check();
 }
 /**
  * @author Max Milbers
  * @param JDataBase $db
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_manufacturercategories', 'virtuemart_manufacturercategories_id', $db);
     $this->setUniqueName('mf_category_name');
     $this->setLoggable();
     $this->setTranslatable(array('mf_category_name', 'mf_category_desc'));
     $this->setSlug('mf_category_name');
 }
 /**
  * @author RickG
  * @author Max Milbers
  * @param JDataBase $db
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_states', 'virtuemart_state_id', $db);
     $this->setUniqueName('state_name');
     $this->setObligatoryKeys('state_2_code');
     $this->setObligatoryKeys('state_3_code');
     $this->setLoggable();
 }
Example #17
0
 /**
  * @author Max Milbers
  * @param $db A database connector object
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_countries', 'virtuemart_country_id', $db);
     $this->setUniqueName('country_name');
     $this->setObligatoryKeys('country_2_code');
     $this->setObligatoryKeys('country_3_code');
     $this->setLoggable();
     $this->setOrderable('ordering', false);
 }
 function check()
 {
     if (!empty($this->customfield_price)) {
         $this->customfield_price = str_replace(array(',', ' '), array('.', ''), $this->customfield_price);
     } else {
         $this->customfield_price = null;
     }
     return parent::check();
 }
Example #19
0
 /**
  * @author Max Milbers
  * @param JDataBase $db
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_ratings', 'virtuemart_rating_id', $db);
     //In a VmTable the primary key is the same as the _tbl_key and therefore not needed
     $this->setPrimaryKey('virtuemart_rating_id');
     //		$this->setObligatoryKeys('virtuemart_product_id');
     $this->setLoggable();
     $this->setTableShortCut('r');
 }
 /**
  * @author Max Milbers
  * @param JDataBase $db
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_manufacturers', 'virtuemart_manufacturer_id', $db);
     $this->setUniqueName('mf_name');
     $this->setLoggable();
     $this->setTranslatable(array('mf_name', 'mf_email', 'mf_desc', 'mf_url'));
     $this->setSlug('mf_name');
     $this->setTableShortCut('m');
 }
 /**
  * @author Max Milbers
  * @param JDataBase $db
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_paymentmethods', 'virtuemart_paymentmethod_id', $db);
     $this->setObligatoryKeys('payment_jplugin_id');
     $this->setObligatoryKeys('payment_name');
     $this->setLoggable();
     $this->setTranslatable(array('payment_name', 'payment_desc'));
     $this->setSlug('payment_name');
     // 	$this->setUniqueName('ordering');
 }
Example #22
0
 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();
 }
Example #23
0
 /**
  * Class contructor
  *
  * @author Max Milbers
  * @param $db A database connector object
  */
 public function __construct($db)
 {
     parent::__construct('#__virtuemart_categories', 'virtuemart_category_id', $db);
     //In a VmTable the primary key is the same as the _tbl_key and therefore not needed
     // 		$this->setPrimaryKey('virtuemart_category_id');
     $this->setObligatoryKeys('category_name');
     $this->setLoggable();
     $this->setTranslatable(array('category_name', 'category_description', 'metadesc', 'metakey', 'customtitle'));
     $this->setSlug('category_name');
     $this->setTableShortCut('c');
 }
Example #24
0
 /**
  * @author Max Milbers
  * @param $db A database connector object
  */
 function __construct(&$db)
 {
     parent::__construct('#__virtuemart_shipmentmethods', 'virtuemart_shipmentmethod_id', $db);
     // we can have several time the same shipment name. It is the vendor problem to set up correctly his shipment rate.
     // $this->setUniqueName('shipment_name');
     $this->setObligatoryKeys('shipment_jplugin_id');
     $this->setObligatoryKeys('shipment_name');
     $this->setLoggable();
     $this->setTranslatable(array('shipment_name', 'shipment_desc'));
     $this->setSlug('shipment_name');
 }
 /**
  * method must be called after preflight
  * Sets the paths and loads VMFramework config
  */
 public function loadVm()
 {
     // 			$this->path = JInstaller::getInstance()->getPath('extension_administrator');
     if (empty($this->path)) {
         $this->path = VMPATH_ADMIN;
     }
     if (!class_exists('VmConfig')) {
         require_once $this->path . '/helpers/config.php';
     }
     VmConfig::loadConfig(false, true);
     VmTable::addIncludePath($this->path . DS . 'tables');
     VmModel::addIncludePath($this->path . DS . 'models');
 }
Example #26
0
 /**
  * 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];
 }
Example #27
0
 /**
  * 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];
 }
 /**
  * Validates the order status record fields.
  *
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 function check()
 {
     $db = JFactory::getDBO();
     $q = 'SELECT count(*),virtuemart_orderstate_id FROM `#__virtuemart_orderstates` ';
     $q .= 'WHERE `order_status_code`="' . $this->order_status_code . '"';
     $db->setQuery($q);
     $row = $db->loadRow();
     if (is_array($row)) {
         if ($row[0] > 0) {
             if ($row[1] != $this->virtuemart_orderstate_id) {
                 vmError(vmText::_('COM_VIRTUEMART_ORDER_STATUS_CODE_EXISTS'));
                 return false;
             }
         }
     }
     return parent::check();
 }
 function check()
 {
     if (empty($this->shopper_group_name)) {
         vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME'));
         return false;
     } else {
         if (function_exists('mb_strlen')) {
             if (mb_strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         } else {
             if (strlen($this->shopper_group_name) > 32) {
                 vmError(JText::_('COM_VIRTUEMART_SHOPPERGROUP_NAME_LESS_THAN_32_CHARACTERS'));
                 return false;
             }
         }
     }
     return parent::check();
 }
Example #30
0
 /**
  * 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];
 }