/**
  * 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]->tsmart_vendor_id)) {
             if (!class_exists('tsmartModelVendor')) {
                 require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
             }
             $this->_cache[$this->_id]->tsmart_vendor_id = tsmartModelVendor::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)) {
             tsmTable::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('tsmCrypt')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'tsmcrypt.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} = tsmCrypt::decrypt($this->_cache[$this->_id]->{$field}, $date);
                 }
             }
         }
         /* Add the shipmentcarreir shoppergroups */
         $q = 'SELECT `tsmart_shoppergroup_id` FROM #__tsmart_shipmentmethod_shoppergroups WHERE `tsmart_shipmentmethod_id` = "' . $this->_id . '"';
         $this->_db->setQuery($q);
         $this->_cache[$this->_id]->tsmart_shoppergroup_ids = $this->_db->loadColumn();
         if (empty($this->_cache[$this->_id]->tsmart_shoppergroup_ids)) {
             $this->_cache[$this->_id]->tsmart_shoppergroup_ids = 0;
         }
     }
     return $this->_cache[$this->_id];
 }
Beispiel #2
0
 /**
  * Gets a single custom by tsmart_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)) {
             tsmTable::bindParameterable($this->_cache[$this->_id], 'custom_params', $this->_cache[$this->_id]->_varsToPushParam);
         }
     }
     return $this->_cache[$this->_id];
 }
 static function bindCustomEmbeddedFieldParams(&$obj, $fieldtype)
 {
     //vmdebug('bindCustomEmbeddedFieldParams begin',$obj);
     if (!class_exists('tsmartModelCustom')) {
         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 = tsmartModelCustom::getVarsToPush($fieldtype);
         $obj->_varsToPushParam = $obj->_varsToPushParamCustomField = $obj->_varsToPushParamCustom;
         //vmdebug('my $obj->_varsToPushParamCustom',$obj->_varsToPushParamCustomField);
     }
     if (!empty($obj->_varsToPushParam)) {
         //$obj ->_xParams = 'custom_params';
         tsmTable::bindParameterable($obj, 'custom_params', $obj->_varsToPushParamCustom);
         $obj->_xParams = 'customfield_params';
         tsmTable::bindParameterable($obj, $obj->_xParams, $obj->_varsToPushParamCustomField);
     }
 }
 public function getCustomParams(&$field)
 {
     tsmTable::bindParameterable($field, 'customfield_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->tsmart_custom_id = $field->tsmart_custom_id;
     if (!empty($field->custom_params) && is_string($field->custom_params)) {
         $this->params = json_decode($field->custom_params);
     } else {
         return;
     }
     //$field->custom_params = $custom_params;
     //vmdebug('$this->_varsToPushParam '.$this->_name,$this->_varsToPushParam );
     foreach ($this->_varsToPushParam as $k => $v) {
         if (!isset($this->params->{$k})) {
             $this->params->{$k} = $field->{$k};
         }
     }
 }
Beispiel #5
0
 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'])) {
         tsmTable::bindParameterable($calc, $this->_xParams, $this->_varsToPushParam);
         return $calc;
     } else {
         avadebug('rule had no parameters', $calc);
         return false;
     }
 }
Beispiel #6
0
    /**
     * 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('tsmartModelUser')) {
            require VMPATH_ADMIN . DS . 'models' . DS . 'user.php';
        }
        $usermodel = tmsModel::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.tsmart_shoppergroup_id ';
        if (!tsmConfig::$vmlang) {
            tsmConfig::setdbLanguageTag();
        }
        $joins = array();
        if (tsmConfig::$defaultLang != tsmConfig::$vmlang and tsmConfig::$langCount > 1) {
            $langFields = array($this->_psType . '_name', $this->_psType . '_desc');
            $useJLback = false;
            if (tsmConfig::$defaultLang != tsmConfig::$jDefLang) {
                $joins[] = ' LEFT JOIN `#__tsmart_' . $this->_psType . '_' . tsmConfig::$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 `#__tsmart_' . $this->_psType . 'methods_' . tsmConfig::$defaultLang . '` as ld using (`tsmart_' . $this->_psType . 'method_id`)';
            $joins[] = ' LEFT JOIN `#__tsmart_' . $this->_psType . 'methods_' . tsmConfig::$vmlang . '` as l using (`tsmart_' . $this->_psType . 'method_id`)';
        } else {
            $select .= ', l.* ';
            $joins[] = ' LEFT JOIN `#__tsmart_' . $this->_psType . 'methods_' . tsmConfig::$vmlang . '` as l using (`tsmart_' . $this->_psType . 'method_id`)';
        }
        $q = $select . ' FROM   `#__tsmart_' . $this->_psType . 'methods' . '` as i ';
        //$joins[] = ' JOIN `#__tsmart_' . $this->_psType . 'methods` AS i USING (`tsmart_' . $this->_psType . 'method_id`) ';
        $joins[] = ' LEFT JOIN `' . $extPlgTable . '` as j ON j.`' . $extField1 . '` =  i.`' . $this->_psType . '_jplugin_id` ';
        $joins[] = ' LEFT OUTER JOIN `#__tsmart_' . $this->_psType . 'method_shoppergroups` AS s ON i.`tsmart_' . $this->_psType . 'method_id` = s.`tsmart_' . $this->_psType . 'method_id` ';
        $q .= implode(' ' . "\n", $joins);
        $q .= ' WHERE i.`published` = "1" AND j.`' . $extField2 . '` = "' . $this->_name . '"
	    						AND  (i.`tsmart_vendor_id` = "' . $vendorId . '" OR i.`tsmart_vendor_id` = "0" OR i.`shared` = "1")
	    						AND  (';
        foreach ($user->shopper_groups as $groups) {
            $q .= ' s.`tsmart_shoppergroup_id`= "' . (int) $groups . '" OR';
        }
        $q .= ' (s.`tsmart_shoppergroup_id`) IS NULL ) GROUP BY i.`tsmart_' . $this->_psType . 'method_id` ORDER BY i.`ordering`';
        $db->setQuery($q);
        $this->methods = $db->loadObjectList();
        if ($this->methods) {
            foreach ($this->methods as $method) {
                tsmTable::bindParameterable($method, $this->_xParams, $this->_varsToPushParam);
            }
        } else {
            if ($this->methods === false) {
                vmError('Error reading getPluginMethods ' . $q);
            }
        }
        return count($this->methods);
    }
Beispiel #7
0
 /**
  * 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();
             $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsUserfieldVM3', array(&$this->_cache[$hash]));
         }
         if (!empty($this->_cache[$hash]->_varsToPushParam)) {
             tsmTable::bindParameterable($this->_cache[$hash], 'userfield_params', $this->_cache[$hash]->_varsToPushParam);
         }
     }
     return $this->_cache[$hash];
 }