function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('group_size.*')->from('#__tsmart_group_size AS group_size'); $user = JFactory::getUser(); $shared = ''; if (vmAccess::manager()) { //$query->where('transferaddon.shared=1','OR'); } $search = vRequest::getCmd('search', false); if (empty($search)) { $search = vRequest::getString('search', false); } // add filters if ($search) { $db = JFactory::getDBO(); $search = '"%' . $db->escape($search, true) . '%"'; $query->where('group_size.group_name LIKE ' . $search); } if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } $query->order('group_size.' . $this->_selectedOrdering . ' ' . $this->_selectedOrderingDir); //echo $query->dump(); return $query; }
function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*')->from('#__tsmart_coupons AS coupons'); if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } $query->order($this->_selectedOrdering . ' ' . $this->_selectedOrderingDir); return $query; }
/** * There are too many functions doing almost the same for my taste * the results are sometimes slighty different and makes it hard to work with it, therefore here the function for future proxy use * */ public static function displayProductCustomfieldSelected($product, $html, $trigger) { if (isset($product->param)) { vmTrace('param found, seek and destroy'); return false; } $row = 0; if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $variantmods = isset($product->customProductData) ? $product->customProductData : $product->product_attribute; if (empty($variantmods)) { $productDB = VmModel::getModel('product')->getProduct($product->virtuemart_product_id); if ($productDB) { $product->customfields = $productDB->customfields; } } if (!is_array($variantmods)) { $variantmods = json_decode($variantmods, true); } $productCustoms = array(); foreach ((array) $product->customfields as $prodcustom) { //We just add the customfields to be shown in the cart to the variantmods if (is_object($prodcustom)) { if ($prodcustom->is_cart_attribute and !$prodcustom->is_input) { if (!is_array($variantmods[$prodcustom->virtuemart_custom_id])) { $variantmods[$prodcustom->virtuemart_custom_id] = array(); } $variantmods[$prodcustom->virtuemart_custom_id][$prodcustom->virtuemart_customfield_id] = false; } else { if (!empty($variantmods) and !empty($variantmods[$prodcustom->virtuemart_custom_id])) { } } $productCustoms[$prodcustom->virtuemart_customfield_id] = $prodcustom; } } foreach ((array) $variantmods as $custom_id => $customfield_ids) { if (!is_array($customfield_ids)) { $customfield_ids = array($customfield_ids => false); } foreach ($customfield_ids as $customfield_id => $params) { if (empty($productCustoms) or !isset($productCustoms[$customfield_id])) { continue; } $productCustom = $productCustoms[$customfield_id]; //The stored result in vm2.0.14 looks like this {"48":{"textinput":{"comment":"test"}}} //and now {"32":[{"invala":"100"}]} if (!empty($productCustom)) { $otag = ' <span class="product-field-type-' . $productCustom->field_type . '">'; if ($productCustom->field_type == "E") { $tmp = ''; if (!class_exists('vmCustomPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmcustomplugin.php'; } JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger($trigger . 'VM3', array(&$product, &$productCustom, &$tmp)); if (!empty($tmp)) { $html .= $otag . $tmp; } } else { $value = ''; if ($productCustom->field_type == 'G') { $db = JFactory::getDBO(); $db->setQuery('SELECT `product_name` FROM `#__virtuemart_products_' . VmConfig::$vmlang . '` WHERE virtuemart_product_id=' . (int) $productCustom->customfield_value); $child = $db->loadObject(); $value = $child->product_name; } elseif ($productCustom->field_type == 'M') { $customFieldModel = VmModel::getModel('customfields'); $value = $customFieldModel->displayCustomMedia($productCustom->customfield_value, 'product', $productCustom->width, $productCustom->height, self::$useAbsUrls); } elseif ($productCustom->field_type == 'S') { if ($productCustom->is_list and $productCustom->is_input) { $value = vmText::_($params); } else { $value = vmText::_($productCustom->customfield_value); } } elseif ($productCustom->field_type == 'A') { $value = vmText::_($product->{$productCustom->customfield_value}); //vmdebug('Customfield A',$productCustom,$productCustom->customfield_value); } elseif ($productCustom->field_type == 'C') { //vmdebug('displayProductCustomfieldSelected C',$productCustom,$productCustom->selectoptions); foreach ($productCustom->options->{$product->virtuemart_product_id} as $k => $option) { $value .= '<span> '; if (!empty($productCustom->selectoptions[$k]->clabel) and in_array($productCustom->selectoptions[$k]->voption, self::$dimensions)) { $value .= vmText::_('COM_VIRTUEMART_' . $productCustom->selectoptions[$k]->voption); $rd = $productCustom->selectoptions[$k]->clabel; if (is_numeric($rd) and is_numeric($option)) { $value .= ' ' . number_format(round((double) $option, (int) $rd), $rd); } } else { if (!empty($productCustom->selectoptions[$k]->clabel)) { $value .= vmText::_($productCustom->selectoptions[$k]->clabel); } $value .= ' ' . vmText::_($option) . ' '; } $value .= '</span><br>'; } $value = trim($value); if (!empty($value)) { $html .= $otag . $value . '</span><br />'; } continue; } else { $value = vmText::_($productCustom->customfield_value); } $trTitle = vmText::_($productCustom->custom_title); $tmp = ''; if ($productCustom->custom_title != $trTitle and strpos($trTitle, '%1') !== false) { $tmp .= vmText::sprintf($productCustom->custom_title, $value); } else { $tmp .= $trTitle . ' ' . $value; } if (!empty($tmp)) { $html .= $otag . $tmp . '</span><br />'; } } } else { foreach ((array) $customfield_id as $key => $value) { $html .= '<br/ >Couldnt find customfield' . ($key ? '<span>' . $key . ' </span>' : '') . $value; } vmdebug('customFieldDisplay, $productCustom is EMPTY ' . $customfield_id); } } } return $html . '</div>'; }
/** * This function creates a product with the attributes of the parent. * * @param int $virtuemart_product_id * @param boolean $front for frontend use * @param boolean $withCalc calculate prices? * @param boolean published * @param int quantity * @param boolean load customfields */ public function getProduct($virtuemart_product_id = NULL, $front = TRUE, $withCalc = TRUE, $onlyPublished = TRUE, $quantity = 1, $virtuemart_shoppergroup_ids = 0) { //vmSetStartTime('getProduct'); if (isset($virtuemart_product_id)) { $virtuemart_product_id = $this->setId($virtuemart_product_id); } else { if (empty($this->_id)) { vmdebug('Can not return product with empty id'); return FALSE; } else { $virtuemart_product_id = $this->_id; } } $checkedProductKey = $this->checkIfCached($virtuemart_product_id, $front, $withCalc, $onlyPublished, $quantity, $virtuemart_shoppergroup_ids); if ($checkedProductKey[0]) { if (self::$_products[$checkedProductKey[1]] === false) { return false; } else { //vmTime('getProduct return cached clone','getProduct'); return clone self::$_products[$checkedProductKey[1]]; } } $productKey = $checkedProductKey[1]; if ($this->memory_limit < ($mem = round(memory_get_usage(FALSE) / (1024 * 1024), 2))) { vmdebug('Memory limit reached in model product getProduct(' . $virtuemart_product_id . '), consumed: ' . $mem . 'M'); vmError('Memory limit reached in model product getProduct() ' . $virtuemart_product_id); return false; } $child = $this->getProductSingle($virtuemart_product_id, $front, $quantity, true, $virtuemart_shoppergroup_ids); if (!$child->published && $onlyPublished) { self::$_products[$productKey] = false; vmTime('getProduct return false, not published', 'getProduct'); return FALSE; } if (!isset($child->orderable)) { $child->orderable = TRUE; } //store the original parent id $pId = $child->virtuemart_product_id; $ppId = $child->product_parent_id; $published = $child->published; if (!empty($pId)) { $child->allIds[] = $pId; } $i = 0; $runtime = microtime(TRUE) - $this->starttime; //Check for all attributes to inherited by parent products while (!empty($child->product_parent_id)) { $runtime = microtime(TRUE) - $this->starttime; if ($runtime >= $this->maxScriptTime) { vmdebug('Max execution time reached in model product getProduct() ', $child); vmError('Max execution time reached in model product getProduct() ' . $child->product_parent_id); break; } else { if ($i > 10) { vmdebug('Time: ' . $runtime . ' Too many child products in getProduct() ', $child); vmError('Time: ' . $runtime . ' Too many child products in getProduct() ' . $child->product_parent_id); break; } } //$child->allIds[] = $child->product_parent_id; if (!empty($child->product_parent_id)) { $child->allIds[] = $child->product_parent_id; } $parentProduct = $this->getProductSingle($child->product_parent_id, $front, $quantity); if ($child->product_parent_id === $parentProduct->product_parent_id) { vmError('Error, parent product with virtuemart_product_id = ' . $parentProduct->virtuemart_product_id . ' has same parent id like the child with virtuemart_product_id ' . $child->virtuemart_product_id); vmTrace('Error, parent product with virtuemart_product_id = ' . $parentProduct->virtuemart_product_id . ' has same parent id like the child with virtuemart_product_id ' . $child->virtuemart_product_id); break; } $attribs = get_object_vars($parentProduct); foreach ($attribs as $k => $v) { if ('product_in_stock' != $k and 'product_ordered' != $k) { // Do not copy parent stock into child if (strpos($k, '_') !== 0 and empty($child->{$k})) { $child->{$k} = $v; // vmdebug($child->product_parent_id.' $child->$k',$child->$k); } } } $i++; if ($child->product_parent_id != $parentProduct->product_parent_id) { $child->product_parent_id = $parentProduct->product_parent_id; } else { $child->product_parent_id = 0; } } //vmdebug('getProduct Time: '.$runtime); $child->published = $published; $child->virtuemart_product_id = $pId; $child->product_parent_id = $ppId; if ($withCalc) { $child->allPrices[$child->selectedPrice] = $this->getPrice($child, 1); $child->prices = $child->allPrices[$child->selectedPrice]; } if (empty($child->product_template)) { $child->product_template = VmConfig::get('producttemplate'); } if (!empty($child->canonCatId)) { // Add the product link for canonical $child->canonical = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id . '&virtuemart_category_id=' . $child->canonCatId; } else { $child->canonical = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id; } if (!empty($child->virtuemart_category_id)) { $child->link = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id . '&virtuemart_category_id=' . $child->virtuemart_category_id; } else { $child->link = $child->canonical; } $child->quantity = $quantity; $child->addToCartButton = false; if (empty($child->categories)) { $child->categories = array(); } if ($this->withRating) { if (!isset($child->rating)) { $ratings = $this->getTable('ratings'); $ratings->load($virtuemart_product_id, 'virtuemart_product_id'); if ($ratings->published) { $child->rating = $ratings->rating; } } } $stockhandle = VmConfig::get('stockhandle', 'none'); $app = JFactory::getApplication(); if ($app->isSite() and $stockhandle == 'disableit' and $child->product_in_stock - $child->product_ordered <= 0) { vmdebug('STOCK 0', VmConfig::get('use_as_catalog', 0), VmConfig::get('stockhandle', 'none'), $child->product_in_stock); self::$_products[$productKey] = false; } else { $product_available_date = substr($child->product_available_date, 0, 10); $current_date = date("Y-m-d"); if ($child->product_in_stock - $child->product_ordered < 1) { if ($product_available_date != '0000-00-00' and $current_date < $product_available_date) { $child->availability = vmText::_('COM_VIRTUEMART_PRODUCT_AVAILABLE_DATE') . ': ' . JHtml::_('date', $child->product_available_date, vmText::_('DATE_FORMAT_LC4')); } else { if ($stockhandle == 'risetime' and VmConfig::get('rised_availability') and empty($child->product_availability)) { $child->availability = file_exists(VMPATH_ROOT . DS . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability')) ? JHtml::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . VmConfig::get('rised_availability', '7d.gif'), VmConfig::get('rised_availability', '7d.gif'), array('class' => 'availability')) : vmText::_(VmConfig::get('rised_availability')); } else { if (!empty($child->product_availability)) { $child->availability = file_exists(VMPATH_ROOT . DS . VmConfig::get('assets_general_path') . 'images/availability/' . $child->product_availability) ? JHtml::image(JURI::root() . VmConfig::get('assets_general_path') . 'images/availability/' . $child->product_availability, $child->product_availability, array('class' => 'availability')) : vmText::_($child->product_availability); } } } } else { if ($product_available_date != '0000-00-00' and $current_date < $product_available_date) { $child->availability = vmText::_('COM_VIRTUEMART_PRODUCT_AVAILABLE_DATE') . ': ' . JHtml::_('date', $child->product_available_date, vmText::_('DATE_FORMAT_LC4')); } } self::$_products[$productKey] = $child; } if (!self::$_products[$productKey]) { return false; } else { //vmTime('getProduct loaded ','getProduct'); return clone self::$_products[$productKey]; } }
/** * Main filter function, called by the others with set Parameters * The standard filter is non restrictiv. * * @author Max Milbers * @param $name * @param null $default * @param int $filter * @param int $flags * @return mixed|null */ public static function get($name, $default = null, $filter = FILTER_UNSAFE_RAW, $flags = FILTER_FLAG_NO_ENCODE,$source = 0){ //vmSetStartTime(); if(!empty($name)){ if($source===0){ $source = $_REQUEST; } else if($source=='GET'){ $source = $_GET; if(JVM_VERSION>2){ $router = JFactory::getApplication()->getRouter(); $vars = $router->getVars(); if($router->getMode() and !empty($vars)){ $source = array_merge($_GET,$vars); } } } else if($source=='POST'){ $source = $_POST; } if(!isset($source[$name])){ return $default; } //if(strpos($name,'[]'!==FALSE)){ return self::filter($source[$name],$filter,$flags); } else { vmTrace('empty name in vRequest::get'); return $default; } }
function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('faq.*,categoryfaq.categoryfaq_name')->from('#__tsmart_faq AS faq')->leftJoin('#__tsmart_categoryfaq AS categoryfaq ON categoryfaq.tsmart_categoryfaq_id=faq.tsmart_categoryfaq_id'); $user = JFactory::getUser(); $shared = ''; if (vmAccess::manager()) { //$query->where('transferaddon.shared=1','OR'); } $search = vRequest::getCmd('search', false); if (empty($search)) { $search = vRequest::getString('search', false); } // add filters if ($search) { $db = JFactory::getDBO(); $search = '"%' . $db->escape($search, true) . '%"'; $query->where('faq.title LIKE ' . $search); } if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } $query->order($this->_selectedOrdering . ' ' . $this->_selectedOrderingDir); return $query; }
/** * There are too many functions doing almost the same for my taste * the results are sometimes slighty different and makes it hard to work with it, therefore here the function for future proxy use * */ public static function displayProductCustomfieldSelected($product, $html, $trigger) { if (isset($product->param)) { vmTrace('param found, seek and destroy'); return false; } $row = 0; if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $variantmods = isset($product->customProductData) ? $product->customProductData : $product->product_attribute; if (empty($variantmods)) { $productDB = VmModel::getModel('product')->getProduct($product->virtuemart_product_id); if ($productDB) { $product->customfields = $productDB->customfields; } } if (!is_array($variantmods)) { $variantmods = json_decode($variantmods, true); } $productCustoms = array(); foreach ($product->customfields as $prodcustom) { //We just add the customfields to be shown in the cart to the variantmods if (is_object($prodcustom)) { if ($prodcustom->is_cart_attribute and !$prodcustom->is_input) { $variantmods[$prodcustom->virtuemart_custom_id] = $prodcustom->virtuemart_customfield_id; } else { if (!empty($variantmods) and !empty($variantmods[$prodcustom->virtuemart_custom_id])) { } } $productCustoms[$prodcustom->virtuemart_customfield_id] = $prodcustom; } } foreach ($variantmods as $custom_id => $customfield_ids) { if (!is_array($customfield_ids)) { $customfield_ids = array($customfield_ids => false); } foreach ($customfield_ids as $customfield_id => $params) { if (empty($productCustoms) or !isset($productCustoms[$customfield_id])) { continue; } $productCustom = $productCustoms[$customfield_id]; //The stored result in vm2.0.14 looks like this {"48":{"textinput":{"comment":"test"}}} //and now {"32":[{"invala":"100"}]} if (!empty($productCustom)) { $html .= ' <span class="product-field-type-' . $productCustom->field_type . '">'; if ($productCustom->field_type == "E") { //$product->productCustom = $productCustom; //$product->row = $row; // if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); //vmdebug('displayProductCustomfieldSelected is PLUGIN use trigger '.$trigger,$product->virtuemart_product_id,$productCustom->virtuemart_customfield_id,$productCustom->custom_element); $dispatcher->trigger($trigger . 'VM3', array(&$product, &$productCustom, &$html)); } else { //vmdebug('customFieldDisplay $productCustom by self::getProductCustomField $variant: '.$variant.' $selected: '.$selected,$productCustom); $value = ''; if ($productCustom->field_type == "G") { $db = JFactory::getDBO(); $db->setQuery('SELECT `product_name` FROM `#__virtuemart_products_' . VmConfig::$vmlang . '` WHERE virtuemart_product_id=' . (int) $productCustom->customfield_value); $child = $db->loadObject(); $value = $child->product_name; } elseif ($productCustom->field_type == "M") { // $html .= $productCustom->custom_title.' '.self::displayCustomMedia($productCustom->custom_value); $value = self::displayCustomMedia($productCustom->customfield_value); } elseif ($productCustom->field_type == "S") { //$value = $productCustom->custom_title.' '.vmText::_($productCustom->customfield_value); $value = $productCustom->customfield_value; } else { // $html .= $productCustom->custom_title.' '.$productCustom->custom_value; //vmdebug('customFieldDisplay',$productCustom); $value = $productCustom->customfield_value; } $html .= ShopFunctionsF::translateTwoLangKeys($productCustom->custom_title, $value); } $html .= '</span><br />'; } else { // falldown method if customfield are deleted foreach ((array) $customfield_id as $key => $value) { $html .= '<br/ >Couldnt find customfield' . ($key ? '<span>' . $key . ' </span>' : '') . $value; } //vmdebug ('CustomsFieldOrderDisplay, $item->productCustom empty? ' . $variant); vmdebug('customFieldDisplay, $productCustom is EMPTY ' . $customfield_id); } } } return $html . '</div>'; }
/** * Sets fields encrypted * @author Max Milbers * @param $fieldNames */ public function setCryptedFields($fieldNames) { if (!$fieldNames) { vmTrace('setEncrytped fields false not catched'); return; } if (!is_array($fieldNames)) { $fieldNames = array($fieldNames); } if (isset($fieldNames[$this->_pkey])) { unset($fieldNames[$this->_pkey]); } $this->_cryptedFields = $fieldNames; }
function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('payment.*')->from('#__tsmart_payment AS payment')->leftJoin('#__tsmart_currencies AS currencies USING(tsmart_currency_id)')->select('CONCAT(currencies.currency_code_3," ",currencies.currency_symbol) AS currency_symbol'); //get list tour apply $query1 = $db->getQuery(true); $query1->select('GROUP_CONCAT(products_en_gb.product_name)')->from('#__tsmart_tour_id_payment_id AS tour_id_payment_id')->leftJoin('#__tsmart_products_en_gb AS products_en_gb USING(tsmart_product_id)')->where('tour_id_payment_id.tsmart_payment_id=payment.tsmart_payment_id'); $query->select("({$query1}) AS list_tour"); //end get list tour apply $user = JFactory::getUser(); $shared = ''; if (vmAccess::manager()) { //$query->where('payment.shared=1','OR'); } $search = vRequest::getCmd('search', false); if (empty($search)) { $search = vRequest::getString('search', false); } // add filters if ($search) { $db = JFactory::getDBO(); $search = '"%' . $db->escape($search, true) . '%"'; $query->where('payment.title LIKE ' . $search); } if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } $query->order($this->_selectedOrdering . ' ' . $this->_selectedOrderingDir); return $query; }
function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query1 = $db->getQuery(true); $query1->select('GROUP_CONCAT(products_en_gb.tsmart_product_id)')->from('#__tsmart_products_en_gb AS products_en_gb')->leftJoin('#__tsmart_products AS products USING(tsmart_product_id)')->leftJoin('#__tsmart_tour_id_hotel_addon_id AS tour_id_hotel_addon_id1 USING(tsmart_product_id)')->where('tour_id_hotel_addon_id1.tsmart_hotel_addon_id=hotel_addon.tsmart_hotel_addon_id'); $query->select('hotel_addon.*,hotel.hotel_name,cityarea.city_area_name,cityarea.tsmart_cityarea_id')->from('#__tsmart_hotel_addon AS hotel_addon')->leftJoin('#__tsmart_hotel AS hotel USING(tsmart_hotel_id)')->leftJoin('#__tsmart_cityarea AS cityarea ON cityarea.tsmart_cityarea_id=hotel.tsmart_cityarea_id')->select('(' . $query1 . ') AS list_tsmart_product_id'); $user = JFactory::getUser(); $shared = ''; if ($search = $this->getState('filter.search')) { $search = '"%' . $db->escape($search, true) . '%"'; $query->where('(hotel_addon.tsmart_hotel_addon_id LIKE ' . $search . ' OR hotel.hotel_name LIKE ' . $search . ')'); } if ($location_city = $this->getState('filter.location_city')) { $query->where('cityarea.tsmart_cityarea_id=' . (int) $location_city); } if ($vail_from = $this->getState('filter.vail_from')) { $vail_from = JFactory::getDate($vail_from); $query->where('hotel_addon.vail_from >=' . $query->q($vail_from->toSql())); } if ($vail_to = $this->getState('filter.vail_to')) { $vail_to = JFactory::getDate($vail_to); $query->where('hotel_addon.vail_to<=' . $query->q($vail_to->toSql())); } // Filter by published state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('hotel_addon.published = ' . (int) $state); } elseif ($state === '') { $query->where('(hotel_addon.published IN (0, 1))'); } if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } $query->order($this->_selectedOrdering . ' ' . $this->_selectedOrderingDir); return $query; }
/** * Main filter function, called by the others with set Parameters * The standard filter is non restrictiv. * * @author Max Milbers * @param $name * @param null $default * @param int $filter * @param int $flags * @return mixed|null */ public static function get($name, $default = null, $filter = FILTER_UNSAFE_RAW, $flags = FILTER_FLAG_STRIP_LOW) { //vmSetStartTime(); if (!empty($name)) { if (!isset($_REQUEST[$name])) { return $default; } //if(strpos($name,'[]'!==FALSE)){ if (is_array($_REQUEST[$name])) { return filter_var_array($_REQUEST[$name], $filter); } else { return filter_var($_REQUEST[$name], $filter, $flags); } } else { vmTrace('empty name in vRequest::get'); return $default; } }
function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('excursion_addon.*')->from('#__tsmart_excursion_addon AS excursion_addon')->leftJoin('me1u8_tsmart_cityarea AS cityarea USING(tsmart_cityarea_id)')->select('cityarea.city_area_name AS city_area_name'); $user = JFactory::getUser(); $shared = ''; if (vmAccess::manager()) { //$query->where('excursionaddon.shared=1','OR'); } $search = vRequest::getCmd('search', false); if (empty($search)) { $search = vRequest::getString('search', false); } // add filters if ($search) { $db = JFactory::getDBO(); $search = '"%' . $db->escape($search, true) . '%"'; $query->where('excursion_addon.excursion_addon_name LIKE ' . $search); } if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } $query->order($this->_selectedOrdering . ' ' . $this->_selectedOrderingDir); return $query; }
<?php $attentionText = JText::_('COM_VIRTUEMART_MIGRATION_WARN_VM1_EXTENSIONS'); vmWarn($attentionText); echo $attentionText; vmTrace('Called by');
/** * Shows an error message, sensible information should be only in the first one, the second one is for non BE users * @author Max Milbers */ function vmError($descr, $publicdescr = '') { $msg = ''; if (VmConfig::$maxMessageCount < VmConfig::$maxMessage + 5) { if (empty($descr)) { vmTrace('vmError message empty'); } $lang = JFactory::getLanguage(); JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php'); if (Permissions::getInstance()->check('admin')) { //$app = JFactory::getApplication(); $descr = $lang->_($descr); $msg = 'vmError: ' . $descr; } else { if (!empty($publicdescr)) { $msg = $lang->_($publicdescr); } } } else { if (VmConfig::$maxMessageCount == VmConfig::$maxMessage + 5) { $msg = 'Max messages reached'; } else { return false; } } if (!empty($msg)) { VmConfig::$maxMessageCount++; $app = JFactory::getApplication(); $app->enqueueMessage($msg, 'error'); return $msg; } return $msg; }
function saveAddressInCart($data, $type, $putIntoSession = true, $prefix = '') { // VirtueMartModelUserfields::getUserFields() won't work if (!class_exists('VirtueMartModelUserfields')) { require VMPATH_ADMIN . DS . 'models' . DS . 'userfields.php'; } $userFieldsModel = VmModel::getModel('userfields'); if ($type == 'STaddress' or $type == 'BTaddress') { vmTrace('STaddress found, seek and destroy'); } $prepareUserFields = $userFieldsModel->getUserFieldsFor('cart', $type); if (!is_array($data)) { $data = get_object_vars($data); } if ($type == 'ST') { $this->STsameAsBT = 0; } else { // BT if (empty($data['email'])) { $jUser = JFactory::getUser(); $address['email'] = $jUser->email; } } $address = array(); if (!class_exists('vmFilter')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmfilter.php'; } foreach ($prepareUserFields as $fld) { if (!empty($fld->name)) { $name = $fld->name; if (!isset($data[$prefix . $name])) { $tmp = vRequest::getString($prefix . $name, false); if ($tmp) { $data[$prefix . $name] = $tmp; } else { if ($fld->required and isset($this->{$type}[$name])) { //Why we have this fallback to the already stored value? $data[$prefix . $name] = $this->{$type}[$name]; } } /*if($fld->type=='text'){ } else { vmdebug('my fld ',$fld); }*/ } if (isset($data[$prefix . $name])) { if (!empty($data[$prefix . $name])) { if (is_array($data[$prefix . $name])) { foreach ($data[$prefix . $name] as $k => $v) { $data[$prefix . $name][$k] = self::filterCartInput($v); } } else { $data[$prefix . $name] = self::filterCartInput($data[$prefix . $name]); } } $address[$name] = $data[$prefix . $name]; } else { //vmdebug('Data not found for type '.$type.' and name '.$prefix.$name.' '); } } } //dont store passwords in the session unset($address['password']); unset($address['password2']); $this->{$type} = $address; if ($putIntoSession) { $this->setCartIntoSession(true); } }
/** * @author Max Milbers * @param */ function check() { if (!empty($this->_slugAutoName)) { $slugAutoName = $this->_slugAutoName; $slugName = $this->_slugName; if (in_array($slugAutoName, $this->_translatableFields)) { $checkTable = $this->_tbl_lang; vmTrace('Language table in normal check?'); } else { $checkTable = $this->_tbl; } if (empty($this->{$slugName})) { // vmdebug('table check use _slugAutoName '.$slugAutoName.' '.$slugName); if (!empty($this->{$slugAutoName})) { $this->{$slugName} = $this->{$slugAutoName}; } else { $pkey = $this->_pkey; vmError('VmTable ' . $checkTable . ' Check not passed. Neither slug nor obligatory value at ' . $slugAutoName . ' for auto slug creation is given ' . $this->{$pkey}); return false; } } //if (JVM_VERSION === 1) $this->$slugName = JFilterOutput::stringURLSafe($this->$slugName); //else $this->$slugName = JApplication::stringURLSafe($this->$slugName); //pro+#'!"§$%&/()=?duct-w-| ||cu|st|omfield-|str<ing> //vmdebug('my slugName '.$slugName,$this->$slugName); $this->{$slugName} = str_replace('-', ' ', $this->{$slugName}); $this->{$slugName} = html_entity_decode($this->{$slugName}, ENT_QUOTES); //$config =& JFactory::getConfig(); //$transliterate = $config->get('unicodeslugs'); $unicodeslugs = VmConfig::get('transliterateSlugs', false); if ($unicodeslugs) { $lang = JFactory::getLanguage(); $this->{$slugName} = $lang->transliterate($this->{$slugName}); } // Trim white spaces at beginning and end of alias and make lowercase $this->{$slugName} = trim(JString::strtolower($this->{$slugName})); $this->{$slugName} = str_replace(array('`', '´', "'"), '', $this->{$slugName}); $this->{$slugName} = vRequest::filterUword($this->{$slugName}, '-,_,|', '-'); while (strpos($this->{$slugName}, '--')) { $this->{$slugName} = str_replace('--', '-', $this->{$slugName}); } // Trim dashes at beginning and end of alias $this->{$slugName} = trim($this->{$slugName}, '-'); if ($unicodeslugs) { $this->{$slugName} = rawurlencode($this->{$slugName}); } $valid = $this->checkCreateUnique($checkTable, $slugName); vmdebug('my Final slugName ' . $slugName, $this->{$slugName}); if (!$valid) { return false; } } foreach ($this->_obkeys as $obkeys => $error) { if (empty($this->{$obkeys})) { $error = get_class($this) . ' ' . vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', 'COM_VIRTUEMART_' . strtoupper($obkeys)); vmError($error); return false; } } if ($this->_unique) { if (empty($this->_db)) { $this->_db = JFactory::getDBO(); } foreach ($this->_unique_name as $obkeys => $error) { if (empty($this->{$obkeys})) { $error = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', 'COM_VIRTUEMART_' . strtoupper($obkeys)); vmError('Non unique ' . $this->_unique_name . ' ' . $error); return false; } else { $valid = $this->checkCreateUnique($this->_tbl, $obkeys); if (!$valid) { return false; } } } } if (property_exists($this, 'virtuemart_vendor_id')) { if (empty($this->virtuemart_vendor_id) and $this->_pkey == 'virtuemart_vendor_id') { $this->virtuemart_vendor_id = $this->_pvalue; } $multix = Vmconfig::get('multix', 'none'); //Lets check if the user is admin or the mainvendor $virtuemart_vendor_id = false; if ($multix == 'none' and get_class($this) !== 'TableVmusers') { $this->virtuemart_vendor_id = 1; return true; } else { $loggedVendorId = VmConfig::isSuperVendor(); $user = JFactory::getUser(); $admin = $user->authorise('core.admin', 'com_virtuemart') || $user->authorise('core.manage', 'com_virtuemart') || $user->authorise('vm.user.edit', 'com_virtuemart'); $tbl_key = $this->_tbl_key; $className = get_class($this); if (strpos($this->_tbl, 'virtuemart_vmusers') === FALSE) { $q = 'SELECT `virtuemart_vendor_id` FROM `' . $this->_tbl . '` WHERE `' . $this->_tbl_key . '`="' . $this->{$tbl_key} . '" '; if (!isset(self::$_cache[md5($q)])) { $this->_db->setQuery($q); self::$_cache[md5($q)] = $virtuemart_vendor_id = $this->_db->loadResult(); } else { $virtuemart_vendor_id = self::$_cache[md5($q)]; } } else { $q = 'SELECT `virtuemart_vendor_id`,`user_is_vendor` FROM `' . $this->_tbl . '` WHERE `' . $this->_tbl_key . '`="' . $this->{$tbl_key} . '" '; if (!isset(self::$_cache[md5($q)])) { $this->_db->setQuery($q); $vmuser = $this->_db->loadRow(); self::$_cache[md5($q)] = $vmuser; } else { $vmuser = self::$_cache[md5($q)]; } if ($vmuser and count($vmuser) === 2) { $virtuemart_vendor_id = $vmuser[0]; $user_is_vendor = $vmuser[1]; if ($multix == 'none') { if (empty($user_is_vendor)) { $this->virtuemart_vendor_id = 0; } else { $this->virtuemart_vendor_id = 1; } return true; } else { if (!$admin) { $this->virtuemart_vendor_id = $loggedVendorId; return true; } } } else { //New User //vmInfo('We run in multivendor mode and you did not set any vendor for '.$className.' and '.$this->_tbl);//, Set to mainvendor '.$this->virtuemart_vendor_id } } if (!$admin and !empty($virtuemart_vendor_id) and !empty($loggedVendorId) and $loggedVendorId != $virtuemart_vendor_id) { //vmWarn('COM_VIRTUEMART_NOT_SAME_VENDOR',$loggedVendorId,$virtuemart_vendor_id //vmWarn('Stop try to hack this store, you got logged'); vmdebug('Blocked storing, logged vendor ' . $loggedVendorId . ' but data belongs to ' . $virtuemart_vendor_id); return false; } else { if (!$admin) { if ($virtuemart_vendor_id) { $this->virtuemart_vendor_id = $virtuemart_vendor_id; vmdebug('Non admin is storing using loaded vendor_id'); } else { if (empty($this->virtuemart_vendor_id)) { $this->virtuemart_vendor_id = $loggedVendorId; } //No id is stored, even users are allowed to use for the storage and vendorId, no change } } else { //Admins are allowed to do anything. We just trhow some messages if (!empty($virtuemart_vendor_id) and $loggedVendorId != $virtuemart_vendor_id) { vmdebug('Admin with vendor id ' . $loggedVendorId . ' is using for storing vendor id ' . $this->virtuemart_vendor_id); } else { if (empty($virtuemart_vendor_id) and empty($this->virtuemart_vendor_id)) { if (strpos($this->_tbl, 'virtuemart_vendors') === FALSE and strpos($this->_tbl, 'virtuemart_vmusers') === FALSE) { $this->virtuemart_vendor_id = $loggedVendorId; vmdebug('Fallback to ' . $this->virtuemart_vendor_id . ' for $loggedVendorId ' . $loggedVendorId . ': We run in multivendor mode and you did not set any vendor for ' . $className . ' and ' . $this->_tbl); } } } } } } } return true; }
/** * Shows an error message, sensible information should be only in the first one, the second one is for non BE users * @author Max Milbers */ function vmError($descr, $publicdescr = '') { VmConfig::$maxMessageCount++; $app = JFactory::getApplication(); if (VmConfig::$maxMessageCount < VmConfig::$maxMessage) { if (empty($descr)) { vmTrace('vmError message empty'); } $lang = JFactory::getLanguage(); if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } if (Permissions::getInstance()->check('admin')) { $app = JFactory::getApplication(); $descr = $lang->_($descr); $app->enqueueMessage('vmError: ' . $descr, 'error'); } else { if (!empty($publicdescr)) { $app = JFactory::getApplication(); $publicdescr = $lang->_($publicdescr); $app->enqueueMessage($publicdescr, 'error'); } } } else { if (VmConfig::$maxMessageCount == VmConfig::$maxMessage) { $app->enqueueMessage('Max messages reached', 'info'); } } }
function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('hotel.*')->from('#__tsmart_hotel AS hotel')->leftJoin('#__tsmart_cityarea AS cityarea USING(tsmart_cityarea_id)')->leftJoin('#__tsmart_states AS states ON states.tsmart_state_id=cityarea.tsmart_state_id')->leftJoin('#__tsmart_countries AS countries ON countries.tsmart_country_id=states.tsmart_country_id')->select('CONCAT(cityarea.city_area_name,",",states.state_name,",",countries.country_name) AS location'); $user = JFactory::getUser(); $shared = ''; if (vmAccess::manager()) { //$query->where('transferaddon.shared=1','OR'); } $search = vRequest::getCmd('search', false); if (empty($search)) { $search = vRequest::getString('search', false); } // add filters if ($search) { $db = JFactory::getDBO(); $search = '"%' . $db->escape($search, true) . '%"'; $query->where('hotel.title LIKE ' . $search); } if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } $query->order($this->_selectedOrdering . ' ' . $this->_selectedOrderingDir); //echo $query->dump(); return $query; }
function _getOrdering($preTable = '') { if (empty($this->_selectedOrdering)) { vmTrace('empty _getOrdering'); } if (empty($this->_selectedOrderingDir)) { vmTrace('empty _selectedOrderingDir'); } return ' ORDER BY ' . $preTable . $this->_selectedOrdering . ' ' . $this->_selectedOrderingDir; }
function saveAddressInCart($data, $type, $putIntoSession = true,$prefix='') { // VirtueMartModelUserfields::getUserFields() won't work if(!class_exists('VirtueMartModelUserfields')) require(VMPATH_ADMIN.DS.'models'.DS.'userfields.php' ); $userFieldsModel = VmModel::getModel('userfields'); if ($type == 'STaddress' or $type == 'BTaddress'){ vmTrace('STaddress found, seek and destroy'); } $prepareUserFields = $userFieldsModel->getUserFieldsFor('cart',$type); if(!is_array($data)){ $data = get_object_vars($data); } if ($type =='ST') { $this->STsameAsBT = 0; } else { // BT if(empty($data['email'])){ $jUser = JFactory::getUser(); $address['email'] = $jUser->email; } } $address = array(); if(!class_exists('vmFilter'))require(VMPATH_ADMIN.DS.'helpers'.DS.'vmfilter.php'); foreach ($prepareUserFields as $fld) { if(!empty($fld->name)){ $name = $fld->name; if(!isset($data[$prefix.$name])){ $tmp = vRequest::getString($prefix.$name,false); if($tmp){ $data[$prefix.$name] = $tmp; } else if($fld->required and isset($this->{$type}[$name])){ //Why we have this fallback to the already stored value? $data[$prefix.$name] = $this->{$type}[$name]; } /*if($fld->type=='text'){ } else { vmdebug('my fld ',$fld); }*/ } if(isset($data[$prefix.$name])){ if(!empty($data[$prefix.$name])){ $value = vmFilter::hl( $data[$prefix.$name],array('deny_attribute'=>'*')); //to strong /* $value = preg_replace('@<[\/\!]*?[^<>]*?>@si','',$value);//remove all html tags */ //lets use instead $value = JComponentHelper::filterText($value); $value = (string)preg_replace('#on[a-z](.+?)\)#si','',$value);//replace start of script onclick() onload()... $value = trim(str_replace('"', ' ', $value),"'") ; $data[$prefix.$name] = (string)preg_replace('#^\'#si','',$value); } $address[$name] = $data[$prefix.$name]; } else { vmdebug('Data not found for type '.$type.' and name '.$prefix.$name.' '); } } } //dont store passwords in the session unset($address['password']); unset($address['password2']); $this->{$type} = $address; if($putIntoSession){ $this->setCartIntoSession(true); } }
/** * Shows an error message, sensible information should be only in the first one, the second one is for non BE users * @author Max Milbers */ function vmError($descr, $publicdescr = '') { $msg = ''; $lang = JFactory::getLanguage(); $descr = $lang->_($descr); $adminmsg = 'vmError: ' . $descr; if (empty($descr)) { vmTrace('vmError message empty'); return; } logInfo($adminmsg, 'error'); if (VmConfig::$maxMessageCount < VmConfig::$maxMessage + 5) { if (VmConfig::$echoAdmin) { $msg = $adminmsg; } else { if (!empty($publicdescr)) { $msg = $lang->_($publicdescr); } } } else { if (VmConfig::$maxMessageCount == VmConfig::$maxMessage + 5) { $msg = 'Max messages reached'; VmConfig::$maxMessageCount++; } else { return false; } } if (!empty($msg)) { VmConfig::$maxMessageCount++; $app = JFactory::getApplication(); $app->enqueueMessage($msg, 'error'); return $msg; } return $msg; }
<?php if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php'; } VmConfig::loadConfig(); $attentionText = JText::_('COM_VIRTUEMART_MIGRATION_WARN_VM1_EXTENSIONS'); vmWarn($attentionText); echo $attentionText; vmTrace('Called by', TRUE);