/** * * Task for disabling dangerous database tools, used after install * @author Max Milbers */ public function disableDangerousTools(){ $data = vRequest::getRequest(); $config = VmModel::getInstance('config', 'VirtueMartModel'); $config->setDangerousToolsOff(); $this->display(); }
function saveJS() { vRequest::vmCheckToken(); $model = VmModel::getModel($this->_cname); $data = vRequest::getRequest(); $id = $model->store($data); $errors = $model->getErrors(); if (empty($errors)) { $msg = vmText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey); $type = 'message'; } else { $type = 'error'; } foreach ($errors as $error) { $msg = $error . '<br />'; } $json['msg'] = $msg; if ($id) { $json['product_id'] = $id; $json['ok'] = 1; } else { $json['ok'] = 0; } echo json_encode($json); jExit(); }
function save($data = 0) { $fileModel = VmModel::getModel('media'); //Now we try to determine to which this media should be long to $data = array_merge(vRequest::getRequest(), vRequest::get('media')); //$data['file_title'] = vRequest::getVar('file_title','','post','STRING',JREQUEST_ALLOWHTML); if (!empty($data['file_description'])) { $data['file_description'] = JComponentHelper::filterText($data['file_description']); //vRequest::filter(); vRequest::getHtml('file_description',''); } /*$data['media_action'] = vRequest::getCmd('media[media_action]'); $data['media_attributes'] = vRequest::getCmd('media[media_attributes]'); $data['file_type'] = vRequest::getCmd('media[file_type]');*/ if (empty($data['file_type'])) { $data['file_type'] = $data['media_attributes']; } $msg = ''; if ($id = $fileModel->store($data)) { $msg = vmText::_('COM_VIRTUEMART_FILE_SAVED_SUCCESS'); } $cmd = vRequest::getCmd('task'); if ($cmd == 'apply') { $redirection = 'index.php?option=com_virtuemart&view=media&task=edit&virtuemart_media_id=' . $id; } else { $redirection = 'index.php?option=com_virtuemart&view=media'; } $this->setRedirect($redirection, $msg); }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { $data = vRequest::getRequest(); $data['calc_name'] = vRequest::getHtml('calc_name', ''); $data['calc_descr'] = vRequest::getHtml('calc_descr', ''); parent::save($data); }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { $data = vRequest::getRequest(); $data['currency_positive_style'] = vRequest::getHtml('currency_positive_style', ''); $data['currency_negative_style'] = vRequest::getHtml('currency_negative_style', ''); parent::save($data); }
/** * Handle the save task * Checks already in the controller the rights and sets the data by filtering the post * * @author Max Milbers */ function save($data = 0) { /* Load the data */ $data = vRequest::getRequest(); /* add the mf desc as html code */ $data['mf_desc'] = vRequest::getHtml('mf_desc', ''); parent::save($data); }
/** * We want to allow html in the descriptions. * * @author Max Milbers */ function save($data = 0) { $data = vRequest::getRequest(); // TODO disallow shipment_name as HTML $data['shipment_name'] = vRequest::getHtml('shipment_name', ''); $data['shipment_desc'] = vRequest::getHtml('shipment_desc', ''); parent::save($data); }
function save($data = 0) { $data = vRequest::getRequest(); // TODO disallow html in paym_name ? $data['payment_name'] = vRequest::getHtml('payment_name', ''); $data['payment_desc'] = vRequest::getHtml('payment_desc', ''); parent::save($data); }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { $data = vRequest::getRequest(); $data['calc_name'] = vRequest::getHtml('calc_name', ''); $data['calc_descr'] = vRequest::getHtml('calc_descr', ''); if (isset($data['params'])) { $data['params'] = vRequest::getHtml('params', ''); } parent::save($data); }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { //ACL if (!JFactory::getUser()->authorise('vm.category.edit', 'com_virtuemart')) { JFactory::getApplication()->redirect('index.php?option=com_virtuemart', vmText::_('JERROR_ALERTNOAUTHOR'), 'error'); } $data = vRequest::getRequest(); $data['category_name'] = vRequest::getHtml('category_name', ''); $data['category_description'] = vRequest::getHtml('category_description', ''); parent::save($data); }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { //ACL if (!vmAccess::manager('category.edit')) { JFactory::getApplication()->redirect('index.php?option=com_tsmart', tsmText::_('JERROR_ALERTNOAUTHOR'), 'error'); } $data = vRequest::getRequest(); $data['category_name'] = vRequest::getHtml('category_name', ''); $data['category_description'] = vRequest::getHtml('category_description', ''); parent::save($data); }
/** * Override of display * * @return JController A JController object to support chaining. * @since 11.1 */ public function display($cachable = false, $urlparams = false) { if (VmConfig::get('use_as_catalog', 0)) { // Get a continue link $virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId(); $categoryLink = ''; if ($virtuemart_category_id) { $categoryLink = '&virtuemart_category_id=' . $virtuemart_category_id; } $ItemId = shopFunctionsF::getLastVisitedItemId(); $ItemIdLink = ''; if ($ItemId) { $ItemIdLink = '&Itemid=' . $ItemId; } $continue_link = JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . $ItemIdLink, FALSE); $app = JFactory::getApplication(); $app->redirect($continue_link, 'This is a catalogue, you cannot acccess the cart'); } $document = JFactory::getDocument(); $viewType = $document->getType(); $viewName = vRequest::getCmd('view', $this->default_view); $viewLayout = vRequest::getCmd('layout', 'default'); $view = $this->getView($viewName, $viewType, '', array('layout' => $viewLayout)); $view->assignRef('document', $document); $cart = VirtueMartCart::getCart(); $cart->order_language = vRequest::getString('order_language', $cart->order_language); $cart->prepareCartData(); $request = vRequest::getRequest(); $task = vRequest::getCmd('task'); if (($task == 'confirm' or isset($request['confirm'])) and !$cart->getInCheckOut()) { $cart->confirmDone(); $view = $this->getView('cart', 'html'); $view->setLayout('order_done'); $cart->_fromCart = false; $view->display(); return true; } else { //$cart->_inCheckOut = false; $redirect = (isset($request['checkout']) or $task == 'checkout'); $cart->_inConfirm = false; $cart->checkoutData($redirect); } $cart->_fromCart = false; $view->display(); return $this; }
/** * Handle the save task * Checks already in the controller the rights todo so and sets the data by filtering the post * * @author Max Milbers */ function save($data = 0) { $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView('user', $viewType); $_currentUser = JFactory::getUser(); // TODO sortout which check is correctt..... // if (!$_currentUser->authorise('administration', 'manage', 'components', 'com_users')) { if (!$_currentUser->authorise('core.edit', 'com_users')) { $msg = vmText::_(_NOT_AUTH); } else { $model = VmModel::getModel('user'); $data = vRequest::getRequest(); // Store multiple selectlist entries as a ; separated string if (array_key_exists('vendor_accepted_currencies', $data) && is_array($data['vendor_accepted_currencies'])) { $data['vendor_accepted_currencies'] = implode(',', $data['vendor_accepted_currencies']); } // TODO disallow vendor_store_name as HTML ? $data['vendor_store_name'] = vRequest::getHtml('vendor_store_name'); $data['vendor_store_desc'] = vRequest::getHtml('vendor_store_desc'); $data['vendor_terms_of_service'] = vRequest::getHtml('vendor_terms_of_service'); $data['vendor_legal_info'] = vRequest::getHtml('vendor_legal_info'); $data['vendor_letter_css'] = vRequest::getHtml('vendor_letter_css'); $data['vendor_letter_header_html'] = vRequest::getHtml('vendor_letter_header_html'); $data['vendor_letter_footer_html'] = vRequest::getHtml('vendor_letter_footer_html'); $ret = $model->store($data); if (!$ret) { $msg = ''; } else { $msg = $ret['message']; } } $cmd = vRequest::getCmd('task'); $lastTask = vRequest::getCmd('last_task'); if ($cmd == 'apply') { if ($lastTask == 'editshop') { $redirection = 'index.php?option=com_virtuemart&view=user&task=editshop'; } else { $redirection = 'index.php?option=com_virtuemart&view=user&task=edit&virtuemart_user_id[]=' . $ret['newId']; } } else { if ($lastTask == 'editshop') { $redirection = 'index.php?option=com_virtuemart'; } else { $redirection = 'index.php?option=com_virtuemart&view=user'; } } // $this->setRedirect($redirection, $ret['message']); $this->setRedirect($redirection); }
/** * Generic save task * * @author Max Milbers * @param post $data sometimes we just want to override the data to process */ function save($data = 0) { vRequest::vmCheckToken(); $input = JFactory::getApplication()->input; if ($data === 0) { $data = vRequest::getRequest(); } $model = tmsModel::getModel($this->_cname); $id = $model->store($data); $msg = 'failed'; if (!empty($id)) { $msg = tsmText::sprintf('com_tsmart_STRING_SAVED', $this->mainLangKey); $type = 'message'; } else { $type = 'error'; } $redir = $this->redirectPath; if (JFactory::getApplication()->isSite()) { $redir .= ''; } $task = vRequest::getCmd('task'); $show_in_parent_window = $data['show_in_parent_window']; if ($show_in_parent_window == 1 & $task == 'save') { $redir .= '&task=edit&close_window_children=1&show_in_parent_window=1&' . $this->_cidName . '[]=' . $id; } elseif ($show_in_parent_window == 1 & $task == 'apply') { $redir .= '&task=edit&show_in_parent_window=1&' . $this->_cidName . '[]=' . $id; } elseif ($show_in_parent_window == 1 & $task == 'apply') { $redir .= '&task=edit&show_in_parent_window=1&' . $this->_cidName . '[]=' . $id; } else { if ($task == 'apply') { $redir .= '&task=edit&' . $this->_cidName . '[]=' . $id; } } $this->setRedirect($redir, $msg, $type); }
/** * Add a product to the cart * * @author Max Milbers * @access public */ public function add($virtuemart_product_ids = null, &$errorMsg = '') { $updateSession = false; $post = vRequest::getRequest(); if (empty($virtuemart_product_ids)) { $virtuemart_product_ids = vRequest::getInt('virtuemart_product_id'); //is sanitized then } if (empty($virtuemart_product_ids)) { vmWarn('COM_VIRTUEMART_CART_ERROR_NO_PRODUCT_IDS'); return false; } $products = array(); $this->_productAdded = true; $productModel = VmModel::getModel('product'); $customFieldsModel = VmModel::getModel('customfields'); //Iterate through the prod_id's and perform an add to cart for each one foreach ($virtuemart_product_ids as $p_key => $virtuemart_product_id) { $product = false; $updateSession = true; $productData = array(); if (empty($virtuemart_product_id)) { vmWarn('Product could not be added with virtuemart_product_id = 0'); return false; } else { $productData['virtuemart_product_id'] = (int) $virtuemart_product_id; } if (!empty($post['quantity'][$p_key])) { $productData['quantity'] = (int) $post['quantity'][$p_key]; } else { continue; } if (!empty($post['customProductData'][$virtuemart_product_id])) { //$productData['customProductData'] $customProductData = $post['customProductData'][$virtuemart_product_id]; } else { $customProductData = array(); } //Now we check if the delivered customProductData is correct and add missing $product = $productModel->getProduct($virtuemart_product_id, true, false, true, $productData['quantity']); if (VmConfig::get('multixcart', 0) == 'byproduct') { if (empty($this->vendorId)) { $this->vendorId = $product->virtuemart_vendor_id; } if (!empty($this->vendorId) and $this->vendorId != $product->virtuemart_vendor_id) { //Product of another vendor recognised, for now we just return false, //later we will create here another cart (multicart) return false; } } $product->customfields = $customFieldsModel->getCustomEmbeddedProductCustomFields($product->allIds, 0, 1); $customProductDataTmp = array(); // Some customfields may prevent the product being added to the cart $customFiltered = false; foreach ($product->customfields as $customfield) { if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $addToCartReturnValues = $dispatcher->trigger('plgVmOnAddToCartFilter', array(&$product, &$customfield, &$customProductData, &$customFiltered)); if (!$customFiltered && $customfield->is_input == 1) { if (isset($customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id])) { if (is_array($customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id])) { if (!class_exists('vmFilter')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmfilter.php'; } foreach ($customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id] as &$customData) { $value = vmFilter::hl($customData, 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), "'"); $customData = (string) preg_replace('#^\'#si', '', $value); } } if (!isset($customProductDataTmp[$customfield->virtuemart_custom_id])) { $customProductDataTmp[$customfield->virtuemart_custom_id] = array(); } $customProductDataTmp[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id] = $customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id]; } else { if (isset($customProductData[$customfield->virtuemart_custom_id])) { $customProductDataTmp[$customfield->virtuemart_custom_id] = $customProductData[$customfield->virtuemart_custom_id]; vmdebug('my customp product data ', $customProductData[$customfield->virtuemart_custom_id]); } } } else { if (!isset($customProductDataTmp[$customfield->virtuemart_custom_id])) { $customProductDataTmp[$customfield->virtuemart_custom_id] = array(); } else { if (!is_array($customProductDataTmp[$customfield->virtuemart_custom_id])) { $customProductDataTmp[$customfield->virtuemart_custom_id] = array($customProductDataTmp[$customfield->virtuemart_custom_id]); } } $customProductDataTmp[$customfield->virtuemart_custom_id][(int) $customfield->virtuemart_customfield_id] = false; } } $productData['customProductData'] = $customProductDataTmp; $unsetA = array(); $found = false; //Now lets check if there is already a product stored with the same id, if yes, increase quantity and recalculate foreach ($this->cartProductsData as $k => &$cartProductData) { $cartProductData = (array) $cartProductData; if (empty($cartProductData['virtuemart_product_id'])) { $unsetA[] = $k; $errorMsg = true; } else { if ($cartProductData['virtuemart_product_id'] == $productData['virtuemart_product_id']) { //Okey, the id is already the same, so lets check the customProductData $diff = !$this->deepCompare($cartProductData['customProductData'], $productData['customProductData']); if (!$diff) { $newTotal = $cartProductData['quantity'] + $productData['quantity']; if (!$product) { $product = $this->getProduct((int) $productData['virtuemart_product_id'], $cartProductData['quantity']); } if (empty($product->virtuemart_product_id)) { vmWarn('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); $unsetA[] = $k; } else { $this->checkForQuantities($product, $newTotal); vmdebug("add to cart did checkForQuantities", $newTotal, $cartProductData['quantity'], $productData['quantity']); $product->quantity = $newTotal - $cartProductData['quantity']; $cartProductData['quantity'] = $newTotal; vmdebug('add to cart did $product->quantityAdded ', $cartProductData['quantity']); } $found = TRUE; break; } else { vmdebug('product variant is different, I add to cart'); } } } //add products to remove to array if ($cartProductData['quantity'] == 0) { $unsetA[] = $k; } } if (!$found) { if (!$product) { $product = $this->getProduct((int) $productData['virtuemart_product_id'], $productData['quantity']); } if (!empty($product->virtuemart_product_id)) { $this->checkForQuantities($product, $product->quantity); vmdebug('my $productData $productData ', $productData); if (!empty($product->quantity)) { $productData['quantity'] = $product->quantity; $this->cartProductsData[] = $productData; } else { $errorMsg = true; } } else { $errorMsg = true; } } if ($product) { $products[] = $product; } //Remove the products which have quantity=0 foreach ($unsetA as $v) { unset($this->cartProductsData[$v]); } } if ($updateSession == false) { return false; } $this->_dataValidated = false; // End Iteration through Prod id's $this->setCartIntoSession(true); return $products; }
* @subpackage Modules * @license GNU/GPL, see LICENSE.php * @link http://docs.joomla.org/J3.x:Creating_a_simple_module/Developing_a_Basic_Module * mod_helloworld is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. */ // No direct access defined('_JEXEC') or die; defined('DS') or define('DS', DIRECTORY_SEPARATOR); JLoader::import('expressly.vendor.autoload'); JLoader::import('expressly.ExpresslyMerchantProvider'); // require helper file JLoader::register('ExpresslyHelper', JPATH_SITE . DS . "components" . DS . "com_expressly" . DS . 'helpers' . DS . 'expressly.php'); $request = vRequest::getRequest(); $task = vRequest::getCmd('task'); if ($task == 'confirm' || isset($request['confirm'])) { // TODO: Need to create MerchantType VIRTUEMART /*$client = new \Expressly\Client(\Expressly\Entity\MerchantType::WOOCOMMERCE); $app = $client->getApp(); $app['merchant.provider'] = $app->share(function () { return new ExpresslyMerchantProvider(); }); $app['version'] = $app->share(function () { return 'v2'; }); $merchant = $app['merchant.provider']->getMerchant(); $user = JFactory::getUser();
/** * Handle the save task * Checks already in the controller the rights todo so and sets the data by filtering the post * * @author Max Milbers */ function save($data = 0) { $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView('user', $viewType); if (!vmAccess::manager('user.edit')) { $msg = vmText::_('_NOT_AUTH'); } else { $model = VmModel::getModel('user'); if ($data === 0) { $data = vRequest::getRequest(); } // Store multiple selectlist entries as a ; separated string if (array_key_exists('vendor_accepted_currencies', $data) && is_array($data['vendor_accepted_currencies'])) { $data['vendor_accepted_currencies'] = implode(',', $data['vendor_accepted_currencies']); } // TODO disallow vendor_store_name as HTML ? $data['vendor_store_name'] = vRequest::getHtml('vendor_store_name'); $data['vendor_store_desc'] = vRequest::getHtml('vendor_store_desc'); $data['vendor_terms_of_service'] = vRequest::getHtml('vendor_terms_of_service'); $data['vendor_legal_info'] = vRequest::getHtml('vendor_legal_info'); $data['vendor_letter_css'] = vRequest::getHtml('vendor_letter_css'); $data['vendor_letter_header_html'] = vRequest::getHtml('vendor_letter_header_html'); $data['vendor_letter_footer_html'] = vRequest::getHtml('vendor_letter_footer_html'); $ids = vRequest::getInt('virtuemart_user_id'); if ($ids) { if (is_array($ids) and isset($ids[0])) { $model->setId((int) $ids[0]); vmdebug('my user controller set ' . (int) $ids[0], $ids); } else { $model->setId((int) $ids); vmdebug('my user controller set ' . (int) $ids, $ids); } } $ret = $model->store($data); if (!$ret) { $msg = ''; } else { $msg = $ret['message']; } } $cmd = vRequest::getCmd('task'); $lastTask = vRequest::getCmd('last_task'); if ($cmd == 'apply') { if ($lastTask == 'editshop') { $redirection = 'index.php?option=com_virtuemart&view=user&task=editshop'; } else { $redirection = 'index.php?option=com_virtuemart&view=user&task=edit&virtuemart_user_id[]=' . $ret['newId']; } } else { if ($lastTask == 'editshop') { $redirection = 'index.php?option=com_virtuemart'; } else { $redirection = 'index.php?option=com_virtuemart&view=user'; } } // $this->setRedirect($redirection, $ret['message']); $this->setRedirect($redirection); }
function saveJS() { vRequest::vmCheckToken(); $model = tmsModel::getModel($this->_cname); $data = vRequest::getRequest(); $id = $model->store($data); $msg = 'failed'; if (!empty($id)) { $msg = tsmText::sprintf('com_tsmart_STRING_SAVED', $this->mainLangKey); $type = 'message'; } else { $type = 'error'; } $json['msg'] = $msg; if ($id) { $json['product_id'] = $id; $json['ok'] = 1; } else { $json['ok'] = 0; } echo vmJsApi::safe_json_encode($json); jExit(); }
/** * Generic save task * * @author Max Milbers * @param post $data sometimes we just want to override the data to process */ function save($data = 0) { vRequest::vmCheckToken(); if ($data === 0) { $data = vRequest::getRequest(); } $model = $this->getModel($this->_cname); $id = $model->store($data); $msg = 'failed'; if (!empty($id)) { $msg = vmText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey); $type = 'message'; } else { $type = 'error'; } $redir = $this->redirectPath; if (JFactory::getApplication()->isSite()) { $redir .= '&tmpl=component'; } $task = vRequest::getCmd('task'); if ($task == 'apply') { $redir .= '&task=edit&' . $this->_cidName . '[]=' . $id; } $this->setRedirect($redir, $msg, $type); }
public function newOrderItem() { $orderId = vRequest::getInt('virtuemart_order_id', ''); $msg = ''; if (!vmAccess::manager('orders.edit')) { vmInfo('Restricted'); $view = $this->getView('orders', 'html'); $view->display(); return false; } $model = VmModel::getModel(); $data = vRequest::getRequest(); $model->saveOrderLineItem($data); $model->deleteInvoice($orderId); $editLink = 'index.php?option=com_virtuemart&view=orders&task=edit&virtuemart_order_id=' . $orderId; $this->setRedirect($editLink, $msg); }
public function newOrderItem() { $orderId = vRequest::getInt('virtuemart_order_id', ''); $model = VmModel::getModel(); $msg = ''; $data = vRequest::getRequest(); $model->saveOrderLineItem($data); $model->deleteInvoice($orderId); $editLink = 'index.php?option=com_virtuemart&view=orders&task=edit&virtuemart_order_id=' . $orderId; $this->setRedirect($editLink, $msg); }
/** * We want to allow html so we need to overwrite some request data * * @author Max Milbers */ function save($data = 0) { $data = vRequest::getRequest(); parent::save($data); }
function save($data = 0) { $data = vRequest::getRequest(); // onSaveCustom plugin; parent::save($data); }