function display($tpl = null) { if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $this->vendorId = VmConfig::isSuperVendor(); // TODO add icon for media view $this->SetViewTitle(); $model = VmModel::getModel('media'); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $this->media = $model->getFile(); $this->addStandardEditViewCommands(); } else { $virtuemart_product_id = vRequest::getInt('virtuemart_product_id'); if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) { $virtuemart_product_id = (int) $virtuemart_product_id[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_id; } $cat_id = vRequest::getInt('virtuemart_category_id', 0); JToolBarHelper::custom('synchronizeMedia', 'new', 'new', vmText::_('COM_VIRTUEMART_TOOLS_SYNC_MEDIA_FILES'), false); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model, null, null, 'searchMedia'); $options = array('' => vmText::_('COM_VIRTUEMART_LIST_ALL_TYPES'), 'product' => vmText::_('COM_VIRTUEMART_PRODUCT'), 'category' => vmText::_('COM_VIRTUEMART_CATEGORY'), 'manufacturer' => vmText::_('COM_VIRTUEMART_MANUFACTURER'), 'vendor' => vmText::_('COM_VIRTUEMART_VENDOR')); $this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options, 1, '', 'onchange="this.form.submit();"'); $options = array('' => vmText::_('COM_VIRTUEMART_LIST_ALL_ROLES'), 'file_is_displayable' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_DISPLAYABLE'), 'file_is_downloadable' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_DOWNLOADABLE'), 'file_is_forSale' => vmText::_('COM_VIRTUEMART_FORM_MEDIA_SET_FORSALE')); $this->lists['search_role'] = VmHTML::selectList('search_role', vRequest::getVar('search_role'), $options, 1, '', 'onchange="this.form.submit();"'); $this->files = $model->getFiles(false, false, $virtuemart_product_id, $cat_id); $this->pagination = $model->getPagination(); } parent::display($tpl); }
/** * Send the ask question email. * @author Kohl Patrick, Christopher Roussel */ public function mailAskquestion() { vRequest::vmCheckToken(); if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $model = tmsModel::getModel('vendor'); $mainframe = JFactory::getApplication(); $vars = array(); $min = tsmConfig::get('asks_minimum_comment_length', 50) + 1; $max = tsmConfig::get('asks_maximum_comment_length', 2000) - 1; $commentSize = vRequest::getString('comment'); if (function_exists('mb_strlen')) { $commentSize = mb_strlen($commentSize); } else { $commentSize = strlen($commentSize); } $validMail = filter_var(vRequest::getVar('email'), FILTER_VALIDATE_EMAIL); $virtuemart_vendor_id = vRequest::getInt('virtuemart_vendor_id', 1); if (!class_exists('VirtueMartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $userId = VirtueMartModelVendor::getUserIdByVendorId($virtuemart_vendor_id); //$vendorUser = JFactory::getUser($userId); if ($commentSize < $min || $commentSize > $max || !$validMail) { $this->setRedirect(JRoute::_('index.php?option=com_virtuemart&view=vendor&task=contact&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE), tsmText::_('COM_VIRTUEMART_COMMENT_NOT_VALID_JS')); return; } $user = JFactory::getUser(); $fromMail = vRequest::getVar('email'); //is sanitized then $fromName = vRequest::getVar('name', ''); //is sanitized then $fromMail = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromMail); $fromName = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromName); if (!empty($user->id)) { if (empty($fromMail)) { $fromMail = $user->email; } if (empty($fromName)) { $fromName = $user->name; } } $vars['user'] = array('name' => $fromName, 'email' => $fromMail); $VendorEmail = $model->getVendorEmail($virtuemart_vendor_id); $vars['vendor'] = array('vendor_store_name' => $fromName); if (shopFunctionsF::renderMail('vendor', $VendorEmail, $vars, 'vendor')) { $string = 'COM_VIRTUEMART_MAIL_SEND_SUCCESSFULLY'; } else { $string = 'COM_VIRTUEMART_MAIL_NOT_SEND_SUCCESSFULLY'; } $mainframe->enqueueMessage(tsmText::_($string)); // Display it all $view = $this->getView('vendor', 'html'); $view->setLayout('mail_confirmed'); $view->display(); }
/** * Handle the edit task */ function edit($view=0){ //We set here the virtuemart_user_id, when no virtuemart_user_id is set to 0, for adding a new user //In every other case the virtuemart_user_id is sent. $cid = vRequest::getVar('virtuemart_user_id'); if(!isset($cid)) vRequest::setVar('virtuemart_user_id', (int)0); parent::edit('edit'); }
/** * @return null * @throws KlarnaApiException */ public function languagepack() { $sSubAction = vRequest::getWord('subAction'); if (!isset($this->template['name']) || $this->template['name'] == '') { $this->template['name'] = "default"; } if ($sSubAction == "klarna_box") { $sNewISO = vRequest::getWord('newIso'); $sCountry = vRequest::getWord('country'); $iSum = vRequest::getFloat('sum', 0); $iInvoiceFee = vRequest::getFloat('fee', 0); $iFlag = vRequest::getInt('flag'); $sType = vRequest::getWord('type'); $aParams = vRequest::getVar('params'); $aValues = vRequest::getVar('values'); // foreach($aValues as $key => $value) { // $aValues[$key] = utf8_encode($value); // } // foreach($aParams as $key => $value) { // $aParams[$key] = utf8_decode($value); // } if ($sType != "part" && $sType != "invoice" && $sType != "spec") { throw new KlarnaApiException("Invalid parameters"); } $this->api->setCountry($sCountry); if ($sType == 'spec') { $types = array(KlarnaPClass::SPECIAL); } else { $types = array(KlarnaPClass::CAMPAIGN, KlarnaPClass::ACCOUNT, KlarnaPClass::FIXED); } $oApi = new KlarnaAPI($sCountry, $sNewISO, $sType, $iSum, $iFlag, $this->api, $types, VMKLARNAPLUGINWEBROOT); // $oApi->addSetupValue ('web_root', $this->webroot); // $oApi->setPaths (); $oApi->addSetupValue('eid', $this->eid); if ($sType == 'invoice') { $oApi->setInvoiceFee($iInvoiceFee); } $oApi->setCurrency($this->api->getCurrency()); if (count($this->coSetup) > 0) { $oApi->addMultipleSetupValues($this->coSetup); } return $oApi->retrieveLayout($aParams, $aValues); // if ($sType == 'spec') { // return $oApi->retrieveHTML($aParams, $aValues, null, $this->template); // } else { // return $oApi->retrieveHTML ($aParams, $aValues); // } } else { if ($sSubAction == 'jsLanguagePack') { $sNewISO = vRequest::getWord('newIso'); $sFetch = ""; } else { throw new KlarnaApiException("Invalid sub-action"); } } }
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(); }
function display($tpl = null) { //Load helpers if (!class_exists('CurrencyDisplay')) require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'); if (!class_exists('VmHTML')) require(VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'); // Get the data $model = VmModel::getModel('product'); // Create filter $this->addStandardDefaultViewLists($model); $inventorylist = $model->getProductListing(); $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); // Apply currency $currencydisplay = CurrencyDisplay::getInstance(); foreach ($inventorylist as $virtuemart_product_id => $product) { //TODO oculd be interesting to show the price for each product, and all stored ones $product->product_in_stock $price = isset($product->allPrices[$product->selectedPrice]['product_price'])? $product->allPrices[$product->selectedPrice]['product_price']:0; $product->product_instock_value = $currencydisplay->priceDisplay($price,'',$product->product_in_stock,false); $product->product_price_display = $currencydisplay->priceDisplay($price,'',1,false); $product->weigth_unit_display= ShopFunctions::renderWeightUnit($product->product_weight_uom); } $this->assignRef('inventorylist', $inventorylist); $options = array(); $options[] = JHtml::_('select.option', '', vmText::_('COM_VIRTUEMART_DISPLAY_STOCK').':'); $options[] = JHtml::_('select.option', 'stocklow', vmText::_('COM_VIRTUEMART_STOCK_LEVEL_LOW')); $options[] = JHtml::_('select.option', 'stockout', vmText::_('COM_VIRTUEMART_STOCK_LEVEL_OUT')); $this->lists['stockfilter'] = JHtml::_('select.genericlist', $options, 'search_type', 'onChange="document.adminForm.submit(); return false;"', 'value', 'text', vRequest::getVar('search_type')); $this->lists['filter_product'] = vRequest::getVar('filter_product'); // $this->assignRef('lists', $lists); /* Toolbar */ $this->SetViewTitle('PRODUCT_INVENTORY'); JToolBarHelper::publish(); JToolBarHelper::unpublish(); parent::display($tpl); }
/** * Clone a shipment * * @author Valérie Isaksen */ public function CloneShipment() { $mainframe = Jfactory::getApplication(); /* Load the view object */ $view = $this->getView('shipmentmethod', 'html'); $model = VmModel::getModel('shipmentmethod'); $msgtype = ''; $cids = vRequest::getVar($this->_cidName, vRequest::getInt('virtuemart_shipment_id')); foreach ($cids as $cid) { if ($model->createClone($cid)) { $msg = vmText::_('COM_VIRTUEMART_SHIPMENT_CLONED_SUCCESSFULLY'); } else { $msg = vmText::_('COM_VIRTUEMART_SHIPMENT_NOT_CLONED_SUCCESSFULLY'); $msgtype = 'error'; } } $mainframe->redirect('index.php?option=com_virtuemart&view=shipmentmethod', $msg, $msgtype); }
/** * Collect the filters for the query * @author Max Milbers */ private function getInventoryFilter() { // Check some filters $filters = array(); if ($search = vRequest::getVar('filter_inventory', false)) { $db = JFactory::getDBO(); $search = '"%' . $db->escape($search, true) . '%"'; $filters[] = '`#__tsmart_products`.`product_name` LIKE ' . $search; } if (vRequest::getInt('stockfilter', 0) == 1) { $filters[] = '`#__tsmart_products`.`product_in_stock` > 0'; } if ($catId = vRequest::getInt('tsmart_category_id', 0) > 0) { $filters[] = '`#__tsmart_categories`.`tsmart_category_id` = ' . $catId; } $filters[] = '(`#__tsmart_shoppergroups`.`default` = 1 OR `#__tsmart_shoppergroups`.`default` is NULL)'; return ' WHERE ' . implode(' AND ', $filters) . $this->_getOrdering(); }
/** * ResponseReceived() * From the payment page, the user returns to the shop. The order email is sent, and the cart emptied. * */ function PaymentResponseReceived() { if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmpayment'); $return_context = ""; $dispatcher = JDispatcher::getInstance(); $html = ""; $paymentResponse = vmText::_('COM_VIRTUEMART_CART_THANKYOU'); $returnValues = $dispatcher->trigger('plgVmOnPaymentResponseReceived', array('html' => &$html, &$paymentResponse)); $view = $this->getView('vmplg', 'html'); $layoutName = vRequest::getVar('layout', 'default'); $view->setLayout($layoutName); $view->assignRef('paymentResponse', $paymentResponse); $view->assignRef('paymentResponseHtml', $html); // Display it all $view->display(); }
function display($tpl = null) { $latestVersion = vRequest::getVar('latestverison', ''); JToolBarHelper::title(vmText::_('COM_VIRTUEMART_UPDATE_MIGRATION'), 'head vm_config_48'); if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $this->assignRef('checkbutton_style', $checkbutton_style); $this->assignRef('downloadbutton_style', $downloadbutton_style); $this->assignRef('latestVersion', $latestVersion); $freshInstall = vRequest::getInt('redirected', 0); if ($freshInstall) { $this->setLayout('install'); } parent::display($tpl); }
/** * Clone a payment * * @author Valérie Isaksen */ public function ClonePayment() { $mainframe = Jfactory::getApplication(); /* Load the view object */ $view = $this->getView('paymentmethod', 'html'); $model = VmModel::getModel('paymentmethod'); $msgtype = ''; //$cids = vRequest::getInt('virtuemart_product_id',0); $cids = vRequest::getVar($this->_cidName, vRequest::getVar('virtuemart_payment_id')); //jimport( 'joomla.utilities.arrayhelper' ); JArrayHelper::toInteger($cids); foreach ($cids as $cid) { if ($model->createClone($cid)) { $msg = vmText::_('COM_VIRTUEMART_PAYMENT_CLONED_SUCCESSFULLY'); } else { $msg = vmText::_('COM_VIRTUEMART_PAYMENT_NOT_CLONED_SUCCESSFULLY'); $msgtype = 'error'; } } $mainframe->redirect('index.php?option=com_virtuemart&view=paymentmethod', $msg, $msgtype); }
function display($tpl = null) { $mainframe = Jfactory::getApplication(); $option = vRequest::getCmd('option'); //Load helpers if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } /* Get the review IDs to retrieve (input variable may be cid, cid[] or virtuemart_rating_review_id */ $cids = vRequest::getInt('cid', vRequest::getVar('virtuemart_rating_review_id', 0)); if ($cids && !is_array($cids)) { $cids = array($cids); } // Figure out maximum rating scale (default is 5 stars) $this->max_rating = VmConfig::get('vm_maximum_rating_scale', 5); $model = VmModel::getModel(); $this->SetViewTitle('REVIEW_RATE'); /* Get the task */ $task = vRequest::getCmd('task'); switch ($task) { case 'edit': /* Get the data $rating = $model->getRating($cids); $this->addStandardEditViewCommands(); break;*/ /* Get the data $rating = $model->getRating($cids); $this->addStandardEditViewCommands(); break;*/ case 'listreviews': /* Get the data */ $this->addStandardDefaultViewLists($model); $virtuemart_product_id = vRequest::getInt('virtuemart_product_id'); if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) { $virtuemart_product_id = (int) $virtuemart_product_id[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_id; } $this->reviewslist = $model->getReviews($virtuemart_product_id); $lists = array(); $lists['filter_order'] = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', '', 'cmd'); $lists['filter_order_Dir'] = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word'); $this->pagination = $model->getPagination(); $this->addStandardDefaultViewCommands(false, true); break; case 'edit_review': JToolBarHelper::divider(); // Get the data $this->rating = $model->getReview($cids); if (!empty($this->rating)) { $this->SetViewTitle('REVIEW_RATE', $this->rating->product_name . " (" . $this->rating->customer . ")"); JToolBarHelper::custom('saveReview', 'save', 'save', vmText::_('COM_VIRTUEMART_SAVE'), false); JToolBarHelper::custom('applyReview', 'apply', 'apply', vmText::_('COM_VIRTUEMART_APPLY'), false); } else { $this->SetViewTitle('REVIEW_RATE', 'ERROR'); } JToolBarHelper::custom('cancelEditReview', 'cancel', 'cancel', vmText::_('COM_VIRTUEMART_CANCEL'), false); break; default: $this->addStandardDefaultViewCommands(false, true); $this->addStandardDefaultViewLists($model); $this->ratingslist = $model->getRatings(); $this->pagination = $model->getPagination(); break; } parent::display($tpl); }
/** * * @author Max Milbers * @param unknown_type $currency * @param unknown_type $price * @param unknown_type $shop */ function convertCurrencyTo($currency, $price, $shop = true) { if (empty($currency)) { // vmdebug('empty $currency ',$price); return $price; } // If both currency codes match, do nothing if (is_Object($currency) and $currency->_currency_id == $this->_vendorCurrency or !is_Object($currency) and $currency == $this->_vendorCurrency) { // vmdebug(' $currency == $this->_vendorCurrency ',$price); return $price; } if (is_Object($currency)) { $exchangeRate = (double) $currency->exchangeRateShopper; vmdebug('convertCurrencyTo OBJECT ' . $exchangeRate); } else { static $currency_exchange_rate = array(); if (!isset($currency_exchange_rate[$currency])) { $q = 'SELECT `currency_exchange_rate` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id` ="' . (int) $currency . '" '; $this->_db->setQuery($q); $currency_exchange_rate[$currency] = (double) $this->_db->loadResult(); } if (!empty($currency_exchange_rate[$currency])) { $exchangeRate = $currency_exchange_rate[$currency]; } else { $exchangeRate = 0; } } if (!empty($exchangeRate)) { if ($shop) { $price = $price / $exchangeRate; } else { $price = $price * $exchangeRate; } } else { $currencyCode = self::ensureUsingCurrencyCode($currency); $vendorCurrencyCode = self::ensureUsingCurrencyCode($this->_vendorCurrency); $globalCurrencyConverter = vRequest::getVar('globalCurrencyConverter'); if ($shop) { $price = $this->_currencyConverter->convert($price, $currencyCode, $vendorCurrencyCode); //vmdebug('convertCurrencyTo Use dynamic rate in shop '.$oldprice .' => '.$price); } else { //vmdebug('convertCurrencyTo Use dynamic rate to shopper currency '.$price); $price = $this->_currencyConverter->convert($price, $vendorCurrencyCode, $currencyCode); } // vmdebug('convertCurrencyTo my currency ',$this->exchangeRateShopper); } return $price; }
function renderMailLayout() { $this->setLayout('mail_html_question'); $this->comment = vRequest::getString('comment'); $this->user = JFactory::getUser(); if (empty($this->user->id)) { $fromMail = vRequest::getVar('email'); //is sanitized then $fromName = vRequest::getVar('name', ''); //is sanitized then $fromMail = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromMail); $fromName = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromName); } else { $fromMail = $this->user->email; $fromName = $this->user->name; } $vars['user'] = array('name' => $fromName, 'email' => $fromMail); $vendorModel = VmModel::getModel('vendor'); if (empty($this->vendor)) { $this->vendor = $vendorModel->getVendor(); $this->vendor->vendor_store_name = $fromName; } $vendorModel->addImages($this->vendor); $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', 0); $productModel = VmModel::getModel('product'); if (empty($this->product)) { $this->product = $productModel->getProduct($virtuemart_product_id); } $productModel->addImages($this->product); $this->subject = Jtext::_('COM_VIRTUEMART_QUESTION_ABOUT') . $this->product->product_name; $this->vendorEmail = $this->user['email']; // in this particular case, overwrite the value for fix the recipient name $this->vendor->vendor_name = $this->user['name']; if (VmConfig::get('order_mail_html')) { $tpl = 'mail_html_question'; } else { $tpl = 'mail_raw_question'; } $this->setLayout($tpl); parent::display(); }
/** * For Express Checkout * @param $type * @param $name * @param $render * @return bool|null */ function plgVmOnSelfCallFE($type, $name, &$render) { if ($name != $this->_name || $type != 'vmpayment') { return FALSE; } $action = vRequest::getCmd('action'); $virtuemart_paymentmethod_id = vRequest::getInt('pm'); //Load the method if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->_currentMethod->payment_element)) { return FALSE; } if ($action != 'SetExpressCheckout') { return false; } $expressCheckout = vRequest::getVar('SetExpressCheckout', ''); if($expressCheckout=='done') { if (!class_exists('VirtueMartCart')) { require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(); $cart->prepareCartData(); $cart->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id; $cart->setCartIntoSession(); //$this->_currentMethod = $currentMethod; $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->setCart($cart); $paypalInterface->setTotal($cart->cartPrices['billTotal']); $paypalInterface->loadCustomerData(); // will perform $this->getExpressCheckoutDetails(); $paypalInterface->getExtraPluginInfo($this->_currentMethod); if (!$paypalInterface->validate()) { VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID'); return false; } else { $app = JFactory::getApplication(); $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . vRequest::getInt('Itemid'), false)); } } elseif($expressCheckout=='cancel') { $this->customerData->clear(); if (!class_exists('VirtueMartCart')) { require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(); $cart->virtuemart_paymentmethod_id = 0; $cart->setCartIntoSession(); $app = JFactory::getApplication(); $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . vRequest::getInt('Itemid'), false), vmText::_('VMPAYMENT_PAYPAL_PAYMENT_CANCELLED')); } }
public function ajax_notifyUsers() { $virtuemart_product_id = vRequest::getInt('virtuemart_product_id'); if (is_array($virtuemart_product_id) and count($virtuemart_product_id) > 0) { $virtuemart_product_id = (int) $virtuemart_product_id[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_id; } $subject = vRequest::getVar('subject', ''); $mailbody = vRequest::getVar('mailbody', ''); $max_number = (int) vRequest::getVar('max_number', ''); $waitinglist = VmModel::getModel('Waitinglist'); $waitinglist->notifyList($virtuemart_product_id, $subject, $mailbody, $max_number); exit; }
private function jumpRedirect() { // url sent in get $url = vRequest::getVar('gateway_url'); unset($_POST['gateway_url']); ?> <html> <head> <title>Transferring...</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <form name="form1" action="<?php echo $url; ?> " method="POST"> <?php // get the posted vars $field_array = array_keys($_POST); //loop posted fields for ($i = 0; $i < count($field_array); $i++) { $actual_var = $field_array[$i]; $actual_val = stripslashes(vRequest::getVar($actual_var)); //hidden form field echo "<input type=\"hidden\" name=\""; echo $actual_var . "\" value=\""; echo trim($actual_val) . "\" />\n"; } ?> </form> <script language="javascript"> var f = document.forms; f = f[0]; f.submit(); </script> </body> </html> <?php }
public function updateOrderHead() { $mainframe = Jfactory::getApplication(); $model = VmModel::getModel(); $_items = vRequest::getVar('item_id', 0, '', 'array'); $_orderID = vRequest::getInt('virtuemart_order_id', ''); $model->UpdateOrderHead((int) $_orderID, vRequest::getRequest()); $model->deleteInvoice($_orderID); $mainframe->redirect('index.php?option=com_virtuemart&view=orders&task=edit&virtuemart_order_id=' . $_orderID); }
echo vmText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL'); } ?> </h2> <!--<form method="post" id="userForm" name="userForm" action="<?php echo JRoute::_('index.php'); ?> " class="form-validate">--> <?php // captcha addition if (VmConfig::get('reg_captcha')) { JHTML::_('behavior.framework'); JPluginHelper::importPlugin('captcha'); $captcha_visible = vRequest::getVar('captcha'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onInit', 'dynamic_recaptcha_1'); $hide_captcha = (VmConfig::get('oncheckout_only_registered') or $captcha_visible) ? '' : 'style="display: none;"'; ?> <fieldset id="recaptcha_wrapper" <?php echo $hide_captcha; ?> > <?php if (!VmConfig::get('oncheckout_only_registered')) { ?> <span class="userfields_info"><?php echo vmText::_('COM_VIRTUEMART_USER_FORM_CAPTCHA'); ?> </span>
/** * This is for adding the input data of the payment method to the cart, after selecting * * @author Valerie Isaksen * * @param VirtueMartCart $cart * @return null if payment not selected; true if card infos are correct; string containing the errors id cc is not valid */ public function plgVmOnSelectCheckPayment(VirtueMartCart $cart, &$msg) { if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) { return FALSE; } //$cart->creditcard_id = vRequest::getVar('creditcard', '0'); $this->_cc_type = vRequest::getVar('cc_type_' . $cart->virtuemart_paymentmethod_id, ''); $this->_cc_name = vRequest::getVar('cc_name_' . $cart->virtuemart_paymentmethod_id, ''); $this->_cc_number = str_replace(" ", "", vRequest::getVar('cc_number_' . $cart->virtuemart_paymentmethod_id, '')); $this->_cc_cvv = vRequest::getVar('cc_cvv_' . $cart->virtuemart_paymentmethod_id, ''); $this->_cc_expire_month = vRequest::getVar('cc_expire_month_' . $cart->virtuemart_paymentmethod_id, ''); $this->_cc_expire_year = vRequest::getVar('cc_expire_year_' . $cart->virtuemart_paymentmethod_id, ''); if (!$this->_validate_creditcard_data(TRUE)) { return FALSE; // returns string containing errors } $this->_setAuthorizeNetIntoSession(); return TRUE; }
/** * Method to display the view * * @access public */ function __construct() { parent::__construct(); $task = vRequest::getVar('task'); }
/** * Validate payment on checkout * @param VirtueMartCart $cart * @return bool|null */ function plgVmOnCheckoutCheckDataPayment(VirtueMartCart $cart) { if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) { return FALSE; } //If PayPal express, make sure we have a valid token. //If not, redirect to PayPal to get one. $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->setCart($cart); $cart->getCartPrices(); $paypalInterface->setTotal($cart->cartPrices['billTotal']); // Here we only check for token, but should check for payer id ? $paypalInterface->loadCustomerData(); $paypalInterface->getExtraPluginInfo($this->_currentMethod); $expressCheckout = vRequest::getVar('expresscheckout', ''); if ($expressCheckout == 'cancel') { return true; } if (!$paypalInterface->validate()) { return false; } return true; //Validate amount //if ($totalInPaymentCurrency <= 0) { // vmInfo (vmText::_ ('VMPAYMENT_PAYPAL_PAYMENT_AMOUNT_INCORRECT')); // return FALSE; //} }
function display($tpl = null) { //Load helpers if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('vmPSPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php'; } $orderStatusModel = tmsModel::getModel('orderstatus'); $orderStates = $orderStatusModel->getOrderStatusList(true); $this->SetViewTitle('ORDER'); $orderModel = tmsModel::getModel(); $curTask = vRequest::getCmd('task'); if ($curTask == 'edit') { tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); tsmConfig::loadJLang('com_tsmart_orders', true); //For getOrderStatusName if (!class_exists('ShopFunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } // Load addl models $userFieldsModel = tmsModel::getModel('userfields'); // Get the data $tsmart_order_id = vRequest::getInt('tsmart_order_id'); $order = $orderModel->getOrder($tsmart_order_id); if (empty($order['details'])) { JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=orders', tsmText::_('com_tsmart_ORDER_NOTFOUND')); } $_orderID = $order['details']['BT']->tsmart_order_id; $orderbt = $order['details']['BT']; $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt; $orderbt->invoiceNumber = $orderModel->getInvoiceNumber($orderbt->tsmart_order_id); $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->tsmart_vendor_id); $this->assignRef('currency', $currency); $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'name', 'password', 'password2', 'agreed', 'address_type')); $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type')); $_userFields = array_merge($userFieldsCart, $_userFields); //Fallback for customer_note if (empty($orderbt->customer_note) and !empty($orderbt->oc_note)) { $orderbt->customer_note = $orderbt->oc_note; } $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt, 'BT_'); $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type')); $shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst, 'ST_'); // Create an array to allow orderlinestatuses to be translated // We'll probably want to put this somewhere in ShopFunctions... $_orderStatusList = array(); foreach ($orderStates as $orderState) { //$_orderStatusList[$orderState->tsmart_orderstate_id] = $orderState->order_status_name; //When I use update, I have to use this? $_orderStatusList[$orderState->order_status_code] = tsmText::_($orderState->order_status_name); } $_itemStatusUpdateFields = array(); $_itemAttributesUpdateFields = array(); foreach ($order['items'] as $_item) { $_itemStatusUpdateFields[$_item->tsmart_order_item_id] = JHtml::_('select.genericlist', $orderStates, "item_id[" . $_item->tsmart_order_item_id . "][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->tsmart_order_item_id, true); } if (!isset($_orderStatusList[$orderbt->order_status])) { if (empty($orderbt->order_status)) { $orderbt->order_status = 'unknown'; } $_orderStatusList[$orderbt->order_status] = tsmText::_('com_tsmart_UNKNOWN_ORDER_STATUS'); } $this->lists['search'] = ''; /* Assign the data */ $this->assignRef('orderdetails', $order); $this->assignRef('orderID', $_orderID); $this->assignRef('userfields', $userfields); $this->assignRef('shipmentfields', $shipmentfields); $this->assignRef('orderstatuslist', $_orderStatusList); $this->assignRef('itemstatusupdatefields', $_itemStatusUpdateFields); $this->assignRef('itemattributesupdatefields', $_itemAttributesUpdateFields); $this->assignRef('orderbt', $orderbt); $this->assignRef('orderst', $orderst); $this->assignRef('tsmart_shipmentmethod_id', $orderbt->tsmart_shipmentmethod_id); /* Data for the Edit Status form popup */ $_currentOrderStat = $order['details']['BT']->order_status; // used to update all item status in one time $_orderStatusSelect = JHtml::_('select.genericlist', $orderStates, 'order_status', 'style="width:100px;"', 'order_status_code', 'order_status_name', $_currentOrderStat, 'order_items_status', true); $this->assignRef('orderStatSelect', $_orderStatusSelect); $this->assignRef('currentOrderStat', $_currentOrderStat); /* Toolbar */ if (JVM_VERSION < 3) { $backward = "back"; $list = 'back'; } else { $backward = 'backward'; $list = 'list'; } JToolBarHelper::custom('prevItem', $backward, '', 'com_tsmart_ITEM_PREVIOUS', false); JToolBarHelper::custom('nextItem', 'forward', '', 'com_tsmart_ITEM_NEXT', false); JToolBarHelper::divider(); JToolBarHelper::custom('cancel', $list, '', 'com_tsmart_ORDER_LIST_LBL', false, false); } else { if ($curTask == 'editOrderItem') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $this->assignRef('orderstatuses', $orderStates); $model = tmsModel::getModel(); $orderId = vRequest::getString('orderId', ''); $orderLineItem = vRequest::getVar('orderLineId', ''); $this->assignRef('tsmart_order_id', $orderId); $this->assignRef('tsmart_order_item_id', $orderLineItem); $orderItem = $model->getOrderLineDetails($orderId, $orderLineItem); $this->assignRef('orderitem', $orderItem); } else { $this->setLayout('orders'); $model = tmsModel::getModel(); $this->addStandardDefaultViewLists($model, 'created_on'); $orderStatusModel = tmsModel::getModel('orderstatus'); $orderstates = vRequest::getCmd('order_status_code', ''); $this->lists['state_list'] = $orderStatusModel->renderOSList($orderstates, 'order_status_code', FALSE, ' onchange="this.form.submit();" '); $orderslist = $model->getOrdersList(); $this->assignRef('orderstatuses', $orderStates); if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } /* Apply currency This must be done per order since it's vendor specific */ $_currencies = array(); // Save the currency data during this loop for performance reasons if ($orderslist) { foreach ($orderslist as $tsmart_order_id => $order) { if (!empty($order->order_currency)) { $currency = $order->order_currency; } else { if ($order->tsmart_vendor_id) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $currObj = tsmartModelVendor::getVendorCurrency($order->tsmart_vendor_id); $currency = $currObj->tsmart_currency_id; } } //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code if (!array_key_exists('curr' . $currency, $_currencies)) { $_currencies['curr' . $currency] = CurrencyDisplay::getInstance($currency, $order->tsmart_vendor_id); } $order->order_total = $_currencies['curr' . $currency]->priceDisplay($order->order_total); $order->invoiceNumber = $model->getInvoiceNumber($order->tsmart_order_id); } } //update order items button /*$q = 'SELECT * FROM #__tsmart_order_items WHERE `product_discountedPriceWithoutTax` IS NULL '; $db = JFactory::getDBO(); $db->setQuery($q); //$res = $db->loadRow(); if(true) { JToolBarHelper::custom('updateCustomsOrderItems', 'new', 'new', vmText::_('com_tsmart_REPORT_UPDATEORDERITEMS'),false); vmError('com_tsmart_UPDATEORDERITEMS_WARN'); }*/ /* * UpdateStatus removed from the toolbar; don't understand how this was intented to work but * the order ID's aren't properly passed. Might be readded later; the controller needs to handle * the arguments. */ /* Toolbar */ //JToolBarHelper::customX( 'CreateOrderHead', 'new','new','New',false); JToolBarHelper::save('updatestatus', tsmText::_('com_tsmart_UPDATE_STATUS')); if (vmAccess::manager('orders.delete')) { JToolBarHelper::spacer('80'); JToolBarHelper::deleteList(); } /* Assign the data */ $this->assignRef('orderslist', $orderslist); $this->pagination = $model->getPagination(); } } if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0'); } shopFunctions::checkSafePath(); parent::display($tpl); }
/** * Send the Recommend to a friend email. * * @author Kohl Patrick * @author Max Milbers */ public function mailRecommend() { JSession::checkToken() or jexit('Invalid Token'); $app = JFactory::getApplication(); if (!VmConfig::get('show_emailfriend', false)) { $app->redirect(JRoute::_('index.php?option=com_virtuemart&tmpl=component&view=productdetails&task=askquestion&virtuemart_product_id=' . vRequest::getInt('virtuemart_product_id', 0)), 'Function disabled'); } if (JFactory::getUser()->guest == 1 and VmConfig::get('ask_captcha')) { $recaptcha = vRequest::getVar('recaptcha_response_field'); JPluginHelper::importPlugin('captcha'); $dispatcher = JDispatcher::getInstance(); $res = $dispatcher->trigger('onCheckAnswer', $recaptcha); $session = JFactory::getSession(); if (!$res[0]) { $mailrecommend = array('email' => vRequest::getVar('email'), 'comment' => vRequest::getString('comment')); $session->set('mailrecommend', $mailrecommend, 'vm'); $errmsg = vmText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL'); $this->setRedirect(JRoute::_('index.php?option=com_virtuemart&tmpl=component&view=productdetails&task=recommend&virtuemart_product_id=' . vRequest::getInt('virtuemart_product_id', 0)), $errmsg); return; } else { $session->set('mailrecommend', 0, 'vm'); } } $vars = array(); $toMail = vRequest::getVar('email'); //is sanitized then $toMail = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $toMail); if (shopFunctionsF::renderMail('recommend', $toMail, $vars, 'productdetails', TRUE)) { $string = 'COM_VIRTUEMART_MAIL_SEND_SUCCESSFULLY'; } else { $string = 'COM_VIRTUEMART_MAIL_NOT_SEND_SUCCESSFULLY'; } $app->enqueueMessage(vmText::_($string)); $view = $this->getView('recommend', 'html'); $view->setLayout('mail_confirmed'); $view->display(); }
public function __construct($cidName = 'cid', $config = array()) { // Guess the option from the class name (Option)Model(View). if (empty($this->option)) { $r = null; if (!preg_match('/(.*)Model/i', get_class($this), $r)) { throw new Exception(vmText::_('JLIB_APPLICATION_ERROR_MODEL_GET_NAME'), 500); } $this->option = 'com_' . strtolower($r[1]); } // Set the view name if (empty($this->name)) { if (array_key_exists('name', $config)) { $this->name = $config['name']; } else { $this->name = $this->getName(); } } // Set the model state if (array_key_exists('state', $config)) { $this->state = $config['state']; } else { $this->state = new JObject(); } // Set the model dbo if (array_key_exists('dbo', $config)) { $this->_db = $config['dbo']; } else { $this->_db = JFactory::getDbo(); } // Set the default view search path if (array_key_exists('table_path', $config)) { $this->addTablePath($config['table_path']); } elseif (defined('VMPATH_ADMIN')) { $this->addTablePath(VMPATH_ADMIN . '/tables'); } // Set the internal state marker - used to ignore setting state from the request if (!empty($config['ignore_request'])) { $this->__state_set = true; } // Set the clean cache event if (isset($config['event_clean_cache'])) { $this->event_clean_cache = $config['event_clean_cache']; } elseif (empty($this->event_clean_cache)) { $this->event_clean_cache = 'onContentCleanCache'; } $this->_cidName = $cidName; // Get the task $task = vRequest::getCmd('task', ''); if ($task !== 'add' and !empty($this->_cidName)) { // Get the id or array of ids. $idArray = vRequest::getVar($this->_cidName, 0); if ($idArray) { if (is_array($idArray) and isset($idArray[0])) { $this->setId((int) $idArray[0]); } else { $this->setId((int) $idArray); } } } $this->_db = JFactory::getDbo(); $this->setToggleName('published'); }
function display($tpl = null) { // Get the task $task = vRequest::getCmd('task', $this->getLayout()); $this->assignRef('task', $task); // Load helpers if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } $model = tmsModel::getModel(); // Handle any publish/unpublish switch ($task) { case 'add': case 'edit': //this was in the controller for the edit tasks, we need this for the access by FE //$this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'product'.DS.'tmpl'); tsmConfig::loadJLang('com_tsmart_orders', TRUE); tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); $model_country = tmsModel::getModel('country'); $this->countries = $model_country->getItemList(); $tsmart_product_id = vRequest::getInt('tsmart_product_id'); if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) { $tsmart_product_id = (int) $tsmart_product_id[0]; } else { $tsmart_product_id = (int) $tsmart_product_id; } $product = $model->getItem($tsmart_product_id); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $product->tsmart_service_class_ids = tsmserviceclass::get_list_service_class_ids_by_tour_id($tsmart_product_id); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php'; $product->tsmart_group_size_ids = tsmGroupSize::get_list_group_size_ids_by_tour_id($tsmart_product_id); //$user = JFactory::getUser(); $superVendor = vmAccess::isSuperVendor(); if ($superVendor != 1 and $superVendor != $product->tsmart_vendor_id) { vmdebug('Product view.html.php ' . $superVendor, $product->tsmart_vendor_id); JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=tsmart', tsmText::_('com_tsmart_ALERTNOTAUTHOR'), 'error'); } if (!empty($product->product_parent_id)) { $product_parent = $model->getProductSingle($product->product_parent_id, false); } require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $this->tour_service_class = tsmserviceclass::get_list_tour_service_class(); $customfields = tmsModel::getModel('Customfields'); $product->allIds[] = $product->tsmart_product_id; if (!empty($product->product_parent_id)) { $product->allIds[] = $product->product_parent_id; } $product->customfields = $customfields->getCustomEmbeddedProductCustomFields($product->allIds); // Get the category tree if (isset($product->categories)) { $this->category_tree = ShopFunctions::categoryListTree($product->categories); } else { $this->category_tree = ShopFunctions::categoryListTree(); } //Fallback for categories inherited by parent to correctly calculate the prices if (empty($product->categories) and !empty($product_parent->categories)) { $product->categories = $product_parent->categories; } //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility if (!isset($product->shoppergroups)) { $product->shoppergroups = 0; } $this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups); // Load the product price if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } //Do we need the children? If there is a C customfield, we dont want them $isCustomVariant = false; foreach ($product->customfields as $custom) { if ($custom->field_type == 'C' and $custom->tsmart_product_id == $tsmart_product_id) { $isCustomVariant = true; break; } } if (!class_exists('tsmartModelConfig')) { require VMPATH_ADMIN . '/models/config.php'; } $productLayouts = tsmartModelConfig::getLayoutList('productdetails'); $this->productLayouts = $productLayouts; // Load Images $model->addImages($product); if (!class_exists('VmTemplate')) { require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php'; } $vmtemplate = VmTemplate::loadVmTemplateStyle(); $this->imagePath = shopFunctions::getAvailabilityIconUrl($vmtemplate); // Load the vendors $vendor_model = tmsModel::getModel('vendor'); $lists['vendors'] = ''; if ($this->showVendors()) { $lists['vendors'] = Shopfunctions::renderVendorList($product->tsmart_vendor_id); } // Load the currencies $currency_model = tmsModel::getModel('currency'); $vendor_model->setId(vmAccess::isSuperVendor()); $this->vendor = $vendor_model->getVendor(); $currency = $currency_model->getItemList(); $this->vendor_currency_symb = $currency->currency_symbol; $lists['manufacturers'] = shopFunctions::renderManufacturerList($product->tsmart_manufacturer_id, true); if (!empty($product->product_weight_uom)) { $product_weight_uom = $product->product_weight_uom; } else { if (!empty($product_parent)) { $product_weight_uom = $product_parent->product_weight_uom; } else { $product_weight_uom = tsmConfig::get('weight_unit_default'); } } if (!empty($product->product_lwh_uom)) { $product_lwh_uom = $product->product_lwh_uom; } else { if (!empty($product_parent)) { $product_lwh_uom = $product_parent->product_lwh_uom; } else { $product_lwh_uom = tsmConfig::get('lwh_unit_default'); } } if (!empty($product->product_unit)) { $product_unit = $product->product_unit; } else { if (!empty($product_parent)) { $product_unit = $product_parent->product_unit; } else { $product_unit = tsmConfig::get('product_unit_default', 'KG'); } } $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $product_weight_uom); $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $product_unit); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $product_lwh_uom); if (empty($product->product_available_date)) { $product->product_available_date = date("Y-m-d"); } $waitinglistmodel = tmsModel::getModel('waitinglist'); /* Load waiting list */ if ($product->tsmart_product_id) { //$waitinglist = $this->get('waitingusers', 'waitinglist'); $waitinglist = $waitinglistmodel->getWaitingusers($product->tsmart_product_id); $this->assignRef('waitinglist', $waitinglist); } $orderstatusModel = tmsModel::getModel('orderstatus'); $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE); // Add the tsmart_shoppergroup_ids $cid = JFactory::getUser()->id; $this->activeShoppergroups = shopfunctions::renderGuiList($cid, 'shoppergroups', 'shopper_group_name', 'category', 'vmuser_shoppergroups', 'tsmart_user_id'); if (!empty($this->activeShoppergroups)) { $shoppergroupModel = tmsModel::getModel('shoppergroup'); $this->activeShoppergroups = tsmText::_($shoppergroupModel->getDefault(0)->shopper_group_name); } // Load protocustom lists $customModel = tmsModel::getModel('custom'); $this->fieldTypes = tsmartModelCustom::getCustomTypes(); $customsList = $customModel->getCustomsList(); $attribs = 'style= "width: 300px;"'; $customlist = JHtml::_('select.genericlist', $customsList, 'customlist', $attribs, 'value', 'text', null, false, true); $this->assignRef('customsList', $customlist); if ($product->product_parent_id > 0) { // Set up labels $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_INFO_LBL'); $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_STATUS_LBL'); $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL'); $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_IMAGES_LBL'); $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_ITEM_MSG'); } else { if ($task == 'add') { $action = tsmText::_('com_tsmart_PRODUCT_FORM_NEW_PRODUCT_LBL'); } else { $action = tsmText::_('com_tsmart_PRODUCT_FORM_UPDATE_ITEM_LBL'); } $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_INFO_LBL'); $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_STATUS_LBL'); $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL'); $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_IMAGES_LBL'); $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_PRODUCT_MSG'); } //get countries require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php'; $countries = tsmcountries::get_countries(); $this->assignRef('countries', $countries); //end get countries //get cities require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmcities.php'; $cities = tsmcities::get_cities(); $this->assignRef('cities', $cities); //end get cities //get tour style require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourstyle.php'; $list_tour_style = tsmtourstyle::get_list_tour_style(); $this->assignRef('list_tour_style', $list_tour_style); //end get toursyle //get tour section require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtoursection.php'; $list_tour_section = tsmtoursection::get_list_tour_section(); $this->assignRef('list_tour_section', $list_tour_section); //end get toursyle //get tour physicalgrade require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmphysicalgrade.php'; $list_physical_grade = vmphysicalgrade::get_physical_grade(); $this->assignRef('list_physical_grade', $list_physical_grade); //end get physicalgrade //get tour_type require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourtype.php'; $list_tour_type = tsmtourtype::get_list_tour_type(); $this->assignRef('list_tour_type', $list_tour_type); //end get tour_type //get tour_type require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $list_tour_service_class = tsmserviceclass::get_list_tour_service_class(); $product->list_tour_service_class_id = tsmserviceclass::get_list_service_class_ids_by_tour_id($product->tsmart_product_id); $this->assignRef('list_tour_service_class', $list_tour_service_class); //end get tour_type //get activities require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmactivities.php'; $product->list_activity_id = tsmactivities::get_list_activity_id_by_tour_id($product->tsmart_product_id); $activities = tsmactivities::get_activities(); $this->assignRef('activities', $activities); //end get activities //get list group size require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php'; $list_group_size = tsmGroupSize::get_list_group_size(); $product->list_group_size_id = tsmGroupSize::get_list_group_size_ids_by_tour_id($product->tsmart_product_id); $this->assignRef('list_group_size', $list_group_size); //end get list group size //get list country require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php'; $product->list_tsmart_country_id = tsmcountries::get_list_tsmart_country_id_by_tour_id($product->tsmart_product_id); //end get list group size require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php'; $this->list_price_type = vmprice::get_list_price_type(); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmproduct.php'; $this->list_tour_method = vmproduct::get_list_tour_method(); $this->assignRef('product', $product); $this->assignRef('product_parent', $product_parent); /* Assign label values */ $this->assignRef('action', $action); $this->assignRef('info_label', $info_label); $this->assignRef('status_label', $status_label); $this->assignRef('dim_weight_label', $dim_weight_label); $this->assignRef('images_label', $images_label); $this->assignRef('delete_message', $delete_message); $this->assignRef('lists', $lists); // Toolbar if ($product->product_sku) { $sku = ' (' . $product->product_sku . ')'; } else { $sku = ""; } //if (!empty($product->canonCatLink)) $canonLink = '&tsmart_category_id=' . $product->canonCatLink; else $canonLink = ''; if (!empty($product->tsmart_product_id)) { if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag()); $canonLink = ''; if ($product->canonCatId) { $canonLink = '&tsmart_category_id=' . $product->canonCatId; } $text = '<a href="' . juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>'; if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE_TO_PRODUCT', juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID); } } else { $text = $product->product_name . $sku; } $this->SetViewTitle('PRODUCT', $text); $this->addStandardEditViewCommandsNoValidate($product->tsmart_product_id); break; case 'massxref_cats': case 'massxref_cats_exe': $this->SetViewTitle('PRODUCT_MASSXREF'); $showVendors = $this->showVendors(); $this->assignRef('showVendors', $showVendors); $keyWord = ''; $catmodel = tmsModel::getModel('category'); $this->assignRef('catmodel', $catmodel); $this->addStandardDefaultViewCommandsNoValidate(); $this->addStandardDefaultViewLists($catmodel, 'category_name'); $session = JFactory::getSession(); $reset = $session->get('reset_pag', false, 'vm'); $limit = ''; if ($reset) { $limit = 0; $session->set('reset_pag', false, 'vm'); } $this->categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search'], $limit); $catpagination = $catmodel->getPagination(); $this->assignRef('catpagination', $catpagination); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_CAT_EXE'), false); break; case 'massxref_sgrps': case 'massxref_sgrps_exe': $sgrpmodel = tmsModel::getModel('shoppergroup'); $this->addStandardDefaultViewLists($sgrpmodel); $shoppergroups = $sgrpmodel->getShopperGroups(false, true); $this->assignRef('shoppergroups', $shoppergroups); $sgrppagination = $sgrpmodel->getPagination(); $this->assignRef('sgrppagination', $sgrppagination); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_sgrps_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_SGRPS_EXE'), false); break; default: if ($product_parent_id = vRequest::getInt('product_parent_id', false)) { $product_parent = $model->getProductSingle($product_parent_id, false); if ($product_parent) { $title = 'PRODUCT_CHILDREN_LIST'; $link_to_parent = JHtml::_('link', JRoute::_('index.php?view=product&task=edit&tsmart_product_id=' . $product_parent->tsmart_product_id . '&option=com_tsmart'), $product_parent->product_name, array('title' => tsmText::_('com_tsmart_EDIT_PARENT') . ' ' . $product_parent->product_name)); $msg = tsmText::_('com_tsmart_PRODUCT_OF') . " " . $link_to_parent; } else { $title = 'PRODUCT_CHILDREN_LIST'; $msg = 'Parent with product_parent_id ' . $product_parent_id . ' not found'; } } else { $title = 'PRODUCT'; $msg = ""; } $this->SetViewTitle($title, $msg); $this->addStandardDefaultViewLists($model, 'created_on'); if ($cI = vRequest::getInt('tsmart_category_id', false)) { $app = JFactory::getApplication(); //$old_state = $app->getUserState('tsmart_category_id'); $old_state = $app->getUserState('tsmart_category_id'); if (empty($old_state) or $old_state != $cI) { vRequest::setVar('com_tsmart.product.filter_order', 'pc.ordering'); $model->filter_order = 'pc.ordering'; $old_state = $app->setUserState('tsmart_category_id', $cI); } } //Get the list of products $productlist = $model->getItemList(); //The pagination must now always set AFTER the model load the listing $this->pagination = $model->getPagination(); //Get the category tree $categoryId = $model->tsmart_category_id; //OSP switched to filter in model, was vRequest::getInt('tsmart_category_id'); $category_tree = ShopFunctions::categoryListTree(array($categoryId)); $this->assignRef('category_tree', $category_tree); //load service class //Load the product price if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $vendor_model = tmsModel::getModel('vendor'); $productreviews = tmsModel::getModel('ratings'); $this->mfTable = $model->getTable('manufacturers'); $this->catTable = $model->getTable('categories'); $this->lists['vendors'] = ''; if ($this->showVendors()) { $this->lists['vendors'] = Shopfunctions::renderVendorList(vmAccess::getVendorId()); } foreach ($productlist as $tsmart_product_id => $product) { $product->mediaitems = count($product->tsmart_media_id); $product->reviews = $productreviews->countReviewsForProduct($product->tsmart_product_id); $vendor_model->setId($product->tsmart_vendor_id); $vendor = $vendor_model->getVendor(); $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->tsmart_vendor_id); if (!empty($product->allPrices[$product->selectedPrice]['product_price']) && !empty($product->allPrices[$product->selectedPrice]['product_currency'])) { $product->product_price_display = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['product_price'], (int) $product->allPrices[$product->selectedPrice]['product_currency'], 1, true); } else { if (!empty($product->allPrices) and count($product->allPrices) > 1) { $product->product_price_display = tsmText::_('com_tsmart_MULTIPLE_PRICES'); } else { $product->product_price_display = tsmText::_('com_tsmart_NO_PRICE_SET'); } } // Write the first 5 categories in the list $product->categoriesList = ''; if (!empty($product->categories[0])) { $product->categoriesList = shopfunctions::renderGuiList($product->categories, 'categories', 'category_name', 'category'); } // Write the first 5 manufacturers in the list $product->manuList = ''; if (!empty($product->tsmart_manufacturer_id[0])) { $product->manuList = shopfunctions::renderGuiList($product->tsmart_manufacturer_id, 'manufacturers', 'mf_name', 'manufacturer'); } } $mf_model = tmsModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown(); $this->assignRef('manufacturers', $manufacturers); /* add Search filter in lists*/ /* Search type */ $options = array('' => tsmText::_('com_tsmart_LIST_EMPTY_OPTION'), 'parent' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE')); $this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options); /* Search order */ $options = array('bf' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')); $this->lists['search_order'] = VmHTML::selectList('search_order', vRequest::getVar('search_order'), $options); // Toolbar /*if (vmAccess::manager('product.edit')) { JToolBarHelper::custom('massxref_cats', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_CAT'), true); JToolBarHelper::custom('massxref_sgrps', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_SGRPS'), true); } if (vmAccess::manager('product.create')) { JToolBarHelper::custom('createchild', 'new', 'new', vmText::_('com_tsmart_PRODUCT_CHILD'), true); JToolBarHelper::custom('cloneproduct', 'copy', 'copy', vmText::_('com_tsmart_PRODUCT_CLONE'), true); }*/ // JToolBarHelper::custom('addrating', 'default', '', vmText::_('com_tsmart_ADD_RATING'), true); $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart')); JToolBarHelper::divider(); if (vmAccess::manager($view . '.edit.state')) { JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); } if (vmAccess::manager($view . '.delete')) { JToolBarHelper::spacer('10'); JToolBarHelper::deleteList(); } $this->assignRef('productlist', $productlist); $this->assignRef('tsmart_category_id', $categoryId); $this->assignRef('model', $model); break; } parent::display($tpl); }
/** * Description * * @author Joomla Team, Max Milbers * @access public * @param $dirn * @param $where */ function move($dirn, $where = '', $orderingkey = 0) { // for some reason this function is not used from categories $this->fixOrdering(); $k = $this->_tbl_key; // problem here was that $this->$k returned (0) $cid = vRequest::getInt($this->_pkeyForm); if (!empty($cid) && is_array($cid)) { $cid = reset($cid); } else { // either we fix custom fields or fix it here: $cid = vRequest::getVar('virtuemart_custom_id'); if (!empty($cid) && is_array($cid)) { $cid = reset($cid); } else { vmError(get_class($this) . ' is missing cid information !'); return false; } } // stAn: if somebody knows how to get current `ordering` of selected cid (i.e. virtuemart_userinfo_id or virtuemart_category_id from defined vars, you can review the code below) $q = "SELECT `" . $this->_orderingKey . '` FROM `' . $this->_tbl . '` WHERE `' . $this->_tbl_key . "` = '" . (int) $cid . "' limit 0,1"; if (!isset(self::$_cache[md5($q)])) { $this->_db->setQuery($q); $c_order = $this->_db->loadResult(); // current ordering value of cid } else { $c_order = self::$_cache[md5($q)]; } $this->{$orderingkey} = $c_order; $e = $this->_db->getErrorMsg(); if (!empty($e)) { vmError(get_class($this) . $e); } // stAn addition: $where .= ' `' . $this->_tbl_key . '` <> ' . (int) $cid . ' '; // explanation: // select one above or under which is not cid and update/set it's ordering of the original cid // could be done with one complex query... but this is more straitforward and the speed is not that much needed in this one if (!empty($orderingkey)) { $this->_orderingKey = $orderingkey; } if (!in_array($this->_orderingKey, array_keys($this->getProperties()))) { vmError(get_class($this) . ' does not support ordering'); return false; } $k = $this->_tbl_key; // virtuemart_userfield_id column name $orderingKey = $this->_orderingKey; // ordering column name $sql = 'SELECT `' . $this->_tbl_key . '`, `' . $this->_orderingKey . '` FROM ' . $this->_tbl; if ($dirn < 0) { $sql .= ' WHERE `' . $this->_orderingKey . '` <= ' . (int) $c_order; $sql .= $where ? ' AND ' . $where : ''; $sql .= ' ORDER BY `' . $this->_orderingKey . '` DESC'; } else { if ($dirn > 0) { $sql .= ' WHERE `' . $this->_orderingKey . '` >= ' . (int) $c_order; $sql .= $where ? ' AND ' . $where : ''; $sql .= ' ORDER BY `' . $this->_orderingKey . '`'; } else { $sql .= ' WHERE `' . $this->_orderingKey . '` = ' . (int) $c_order; $sql .= $where ? ' AND ' . $where : ''; $sql .= ' ORDER BY `' . $this->_orderingKey . '`'; } } if (!isset(self::$_cache[md5($sql)])) { $this->_db->setQuery($sql, 0, 1); $row = null; $row = $this->_db->loadObject(); } else { $row = self::$_cache[md5($sql)]; } if (isset($row)) { // ok, we have a problem here - previous or next item has the same ordering as the current one // we need to fix the ordering be reordering it all if ((int) $row->{$orderingKey} == $c_order) { // if we fix this while loading the ordering, it will slow down FE } // update the next or previous to have the same ordering as the selected $query = 'UPDATE ' . $this->_tbl . ' SET `' . $this->_orderingKey . '` = ' . (int) $c_order . ' WHERE ' . $this->_tbl_key . ' = ' . (int) $row->{$k} . ' LIMIT 1'; $this->_db->setQuery($query); echo "\n" . $query . '<br />'; if (!$this->_db->execute()) { $err = $this->_db->getErrorMsg(); JError::raiseError(500, get_class($this) . ':: move isset row $row->$k' . $err); } // update the currently selected to have the same ordering as the next or previous $query = 'UPDATE ' . $this->_tbl . ' SET `' . $this->_orderingKey . '` = ' . (int) $row->{$orderingKey} . ' WHERE ' . $this->_tbl_key . ' = "' . (int) $cid . '" LIMIT 1'; $this->_db->setQuery($query); //echo $query.'<br />'; die(); if (!$this->_db->execute()) { $err = $this->_db->getErrorMsg(); JError::raiseError(500, get_class($this) . ':: move isset row $row->$k' . $err); } // stAn, what for is this? $this->ordering = $row->{$orderingKey}; } else { // stAn: why should we update the same line with the same information when no next or previous found (?) $query = 'UPDATE ' . $this->_tbl . ' SET `' . $this->_orderingKey . '` = ' . (int) $this->{$orderingKey} . ' WHERE ' . $this->_tbl_key . ' = "' . $this->_db->escape($this->{$k}) . '" LIMIT 1'; $this->_db->setQuery($query); if (!$this->_db->execute()) { $err = $this->_db->getErrorMsg(); JError::raiseError(500, get_class($this) . ':: move update $this->$k' . $err); } } return true; }
/** * Prepare a user field for database update */ public function prepareFieldDataSave($field, &$data) { // $post = vRequest::getRequest(); $fieldType = $field->type; $fieldName = $field->name; $value = $data[$field->name]; $params = $field->userfield_params; if(!class_exists('vmFilter'))require(VMPATH_ADMIN.DS.'helpers'.DS.'vmfilter.php'); switch(strtolower($fieldType)) { case 'webaddress': if (isset($post[$fieldName."Text"]) && ($post[$fieldName."Text"])) { $oValuesArr = array(); $oValuesArr[0] = str_replace(array('mailto:','http://','https://'),'', $value); $oValuesArr[1] = str_replace(array('mailto:','http://','https://'),'', $post[$fieldName."Text"]); $value = implode("|*|",$oValuesArr); } else { if ($value = vmFilter::urlcheck($value) ) $value = str_replace(array('mailto:','http://','https://'),'', $value); } break; case 'email': case 'emailaddress': //vmdebug('emailaddress before filter',$value); $value = vmFilter::mail( $value ); //$value = str_replace('mailto:','', $value); //$value = str_replace(array('\'','"',',','%','*','/','\\','?','^','`','{','}','|','~'),array(''),$value); //vmdebug('emailaddress after filter',$value); break; // case 'phone': // $value = vmFilter::phone( $value ); // break; case 'multiselect': case 'multicheckbox': case 'select': if (is_array($value)) $value = implode("|*|",$value); break; case 'age_verification': $value = vRequest::getInt('birthday_selector_year') .'-'.vRequest::getInt('birthday_selector_month') .'-'.vRequest::getInt('birthday_selector_day'); break; case 'textarea': $value = vRequest::getVar($fieldName, '', 'post', 'string' ,JREQUEST_ALLOWRAW); $value = vmFilter::hl( $value,'text' ); break; case 'editorta': $value = vRequest::getVar($fieldName, '', 'post', 'string' ,JREQUEST_ALLOWRAW); $value = vmFilter::hl( $value,'no_js_flash' ); break; default: // //*** code for htmlpurifier *** // //SEE http://htmlpurifier.org/ // // must only add all htmlpurifier in library/htmlpurifier/ // if (!$this->htmlpurifier) { // require(VMPATH_ADMIN.DS.'library'.DS.'htmlpurifier'.DS.'HTMLPurifier.auto.php'); // $config = HTMLPurifier_Config::createDefault(); // $this->htmlpurifier = new HTMLPurifier($config); // } // $value = $this->htmlpurifier->purify($value); // vmdebug( "purified filter" , $value); //$config->set('URI.HostBlacklist', array('google.com'));// set eg .add google.com in black list if (strpos($fieldType,'plugin')!==false){ JPluginHelper::importPlugin('vmuserfield'); $dispatcher = JDispatcher::getInstance(); // vmdebug('params',$params); $dispatcher->trigger('plgVmPrepareUserfieldDataSave',array($fieldType, $fieldName, &$data, &$value, $params) ); return $value; } // no HTML TAGS but permit all alphabet $value = vmFilter::hl( $value,array('deny_attribute'=>'*')); $value = preg_replace('@<[\/\!]*?[^<>]*?>@si','',$value);//remove all html tags $value = (string)preg_replace('#on[a-z](.+?)\)#si','',$value);//replace start of script onclick() onload()... $value = trim(str_replace('"', ' ', $value),"'") ; $value = (string)preg_replace('#^\'#si','',$value);//replace ' at start break; } return $value; }
function addStandardEditViewCommandsNoValidate($id = 0, $object = null) { $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart')); if (!class_exists('JToolBarHelper')) { require JPATH_ADMINISTRATOR . DS . 'includes' . DS . 'toolbar.php'; } JToolBarHelper::divider(); if (vmAccess::manager($view . '.edit')) { JToolBarHelper::save(); JToolBarHelper::apply(); } JToolBarHelper::cancel(); //self::showHelp(); //self::showACLPref($view); if ($view != 'shipmentmethod' and $view != 'paymentmethod' and $view != 'media') { $validate = true; } else { $validate = false; } $this->addJsJoomlaSubmitButtonNoValidate($validate); $editView = vRequest::getCmd('view', vRequest::getCmd('controller', '')); $params = JComponentHelper::getParams('com_languages'); $selectedLangue = $params->get('site', 'en-GB'); $this->lang = strtolower(strtr($selectedLangue, '-', '_')); // Get all the published languages defined in Language manager > Content $allLanguages = JLanguageHelper::getLanguages(); foreach ($allLanguages as $jlang) { $languagesByCode[$jlang->lang_code] = $jlang; } // only add if ID and view not null if ($editView and $id and count(tsmConfig::get('active_languages')) > 1) { if ($editView == 'user') { $editView = 'vendor'; } jimport('joomla.language.helper'); $this->lang = vRequest::getVar('vmlang', $this->lang); // list of languages installed in #__extensions (may be more than the ones in the Language manager > Content if the user did not added them) $languages = JLanguageHelper::createLanguageList($selectedLangue, constant('VMPATH_ROOT'), true); $activeVmLangs = tsmConfig::get('active_languages'); $flagCss = ""; foreach ($languages as $k => &$joomlaLang) { if (!in_array($joomlaLang['value'], $activeVmLangs)) { unset($languages[$k]); } else { $key = $joomlaLang['value']; if (!isset($languagesByCode[$key])) { $img = substr($key, 0, 2); //We try a fallback vmdebug('com_tsmart_MISSING_FLAG', $img, $joomlaLang['text']); } else { $img = $languagesByCode[$key]->image; } $image_flag = VMPATH_ROOT . "/media/mod_languages/images/" . $img . ".gif"; $image_flag_url = JURI::root() . "media/mod_languages/images/" . $img . ".gif"; if (!file_exists($image_flag)) { vmerror(tsmText::sprintf('com_tsmart_MISSING_FLAG', $image_flag, $joomlaLang['text'])); } else { $flagCss .= "td.flag-" . $key . ",.flag-" . $key . "{background: url( " . $image_flag_url . ") no-repeat 0 0; padding-left:20px !important;}\n"; } } } JFactory::getDocument()->addStyleDeclaration($flagCss); $this->langList = JHtml::_('select.genericlist', $languages, 'vmlang', 'class="inputbox" style="width:176px;"', 'value', 'text', $selectedLangue, 'vmlang'); if ($editView == 'product') { $productModel = tmsModel::getModel('product'); $childproducts = $productModel->getProductChilds($id) ? $productModel->getProductChilds($id) : ''; } $token = vRequest::getFormToken(); $j = ' jQuery(function($) { var oldflag = ""; $("select#vmlang").chosen().change(function() { langCode = $(this).find("option:selected").val(); flagClass = "flag-"+langCode; jQuery.ajax({ type: "GET", cache: false, dataType: "json", url: "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $id . '&editView=' . $editView . '&' . $token . '=1", }).done( function(data) { var items = []; var theForm = document.forms["adminForm"]; if(typeof theForm.vmlang==="undefined"){ var input = document.createElement("input"); input.type = "hidden"; input.name = "vmlang"; input.value = langCode; theForm.appendChild(input); } else { theForm.vmlang.value = langCode; } if (data.fields !== "error" ) { if (data.structure == "empty") alert(data.msg); $.each(data.fields , function(key, val) { cible = jQuery("#"+key); if (oldflag !== "") cible.parent().removeClass(oldflag) var tmce_ver = 0; if(typeof window.tinyMCE!=="undefined"){ var tmce_ver=window.tinyMCE.majorVersion; } if (tmce_ver>="4") { if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) { tinyMCE.get(key).execCommand("mceSetContent", false,val); cible.val(val); } else if (data.structure !== "empty") cible.val(val); } else { if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) { tinyMCE.execInstanceCommand(key,"mceSetContent",false,val); cible.val(val); } else if (data.structure !== "empty") cible.val(val); } }); } else alert(data.msg);'; if ($editView == 'product' && !empty($childproducts)) { foreach ($childproducts as $child) { $j .= 'jQuery.ajax({ type: "GET", cache: false, dataType: "json", url: "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $child->tsmart_product_id . '&editView=' . $editView . '&' . $token . '=1", }).done( // $.getJSON( "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $child->tsmart_product_id . '&editView=' . $editView . '&' . $token . '=1" , function(data) { cible = jQuery("#child' . $child->tsmart_product_id . 'product_name"); if (oldflag !== "") cible.parent().removeClass(oldflag) cible.parent().addClass(flagClass); cible.val(data.fields.product_name); jQuery("#child' . $child->tsmart_product_id . 'slug").val(data.fields["slug"]); } ) '; } } $j .= 'oldflag = flagClass ; } ) }); })'; vmJsApi::addJScript('vmlang', $j); } else { $jlang = JFactory::getLanguage(); $langs = $jlang->getKnownLanguages(); $defautName = $selectedLangue; $flagImg = $selectedLangue; if (isset($languagesByCode[$selectedLangue])) { $defautName = $langs[$selectedLangue]['name']; $flagImg = JHtml::_('image', 'mod_languages/' . $languagesByCode[$selectedLangue]->image . '.gif', $languagesByCode[$selectedLangue]->title_native, array('title' => $languagesByCode[$selectedLangue]->title_native), true); } else { vmWarn(tsmText::sprintf('com_tsmart_MISSING_FLAG', $selectedLangue, $selectedLangue)); } $this->langList = '<input name ="vmlang" type="hidden" value="' . $selectedLangue . '" >' . $flagImg . ' <b> ' . $defautName . '</b>'; } if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0'); } }
/** * Check the Joomla ReCaptcha Plg * * @author Maik Künnemann */ function checkCaptcha($retUrl) { if (JFactory::getUser()->guest == 1 and VmConfig::get('reg_captcha')) { $recaptcha = vRequest::getVar('recaptcha_response_field'); JPluginHelper::importPlugin('captcha'); $dispatcher = JDispatcher::getInstance(); $res = $dispatcher->trigger('onCheckAnswer', $recaptcha); if (!$res[0]) { $data = vRequest::getPost(); $data['address_type'] = vRequest::getVar('addrtype', 'BT'); if (!class_exists('VirtueMartCart')) { require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); $prefix = ''; if ($data['address_type'] == 'STaddress' || $data['address_type'] == 'ST') { $prefix = 'shipto_'; } $cart->saveAddressInCart($data, $data['address_type'], true, $prefix); $errmsg = vmText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL'); $this->setRedirect(JRoute::_($retUrl . '&captcha=1', FALSE), $errmsg); return FALSE; } else { return TRUE; } } else { return TRUE; } }