function display($tpl = null) { $this->loadHelper('image'); $this->loadHelper('html'); $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); if (!empty($config->_params)) { unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os } $this->config = $config; $this->userparams = JComponentHelper::getParams('com_users'); $this->jTemplateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->vmLayoutList = $model->getLayoutList('virtuemart', VmConfig::get('vmlayout', 0), 'vmlayout'); $this->categoryLayoutList = $model->getLayoutList('category', VmConfig::get('categorylayout', 0), 'categorylayout'); $this->productLayoutList = $model->getLayoutList('productdetails', VmConfig::get('productlayout', 0), 'productlayout'); $this->noimagelist = $model->getNoImageList(); $this->orderStatusModel = VmModel::getModel('orderstatus'); $this->currConverterList = $model->getCurrencyConverterList(); $this->moduleList = $model->getModuleList(); $this->activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->orderByFields = $model->getProductFilterFields('browse_orderby_fields'); $this->searchFields = $model->getProductFilterFields('browse_search_fields'); $this->aclGroups = $usermodel->getAclGroupIndentedTree(); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->imagePath = $imagePath; shopFunctions::checkSafePath(); $this->checkVmUserVendor(); parent::display($tpl); }
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); }
/** * Sets the file information and paths/urls and so on. * * @author Max Milbers * @param unknown_type $filename * @param unknown_type $url * @param unknown_type $path */ function setFileInfo($type = 0) { $this->file_url_folder = ''; $this->file_path_folder = ''; $this->file_url_folder_thumb = ''; if ($this->file_is_forSale == 0 and $type != 'forSale') { $this->file_url_folder = $this->getMediaUrlByView($type); $this->file_url_folder_thumb = $this->file_url_folder . 'resized/'; $this->file_path_folder = str_replace('/', DS, $this->file_url_folder); } else { if (!class_exists('shopFunctions')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctions.php'; } $safePath = shopFunctions::checkSafePath(); if (!$safePath) { return FALSE; } $this->file_path_folder = $safePath; $this->file_url_folder = $this->file_path_folder; //str_replace(DS,'/',$this->file_path_folder); $this->file_url_folder_thumb = VmConfig::get('forSale_path_thumb'); } //Clean from possible injection while (strpos($this->file_path_folder, '..') !== false) { $this->file_path_folder = str_replace('..', '', $this->file_path_folder); } $this->file_path_folder = preg_replace('#[/\\\\]+#', DS, $this->file_path_folder); if (empty($this->file_url)) { $this->file_url = $this->file_url_folder; $this->file_name = ''; $this->file_extension = ''; } else { if (!class_exists('JFile')) { require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php'; } if ($this->file_is_forSale == 1) { $rdspos = strrpos($this->file_url, DS); if ($rdspos !== false) { $name = substr($this->file_url, $rdspos + 1); } else { vmdebug('$name', $this->file_url, $rdspos); } } else { //This construction is only valid for the images, it is for own structuring using folders $name = str_replace($this->file_url_folder, '', $this->file_url); } if (!empty($name) && $name !== '/') { $this->file_name = JFile::stripExt($name); //$this->file_extension = strtolower(JFile::getExt($name)); $this->file_extension = strtolower(JFile::getExt($name)); //Ensure using right directory $file_url = $this->getMediaUrlByView($type) . $name; if ($this->file_is_forSale == 1) { if (JFile::exists($file_url)) { $this->file_url = $file_url; } else { // vmdebug('MediaHandler, file does not exist in safepath '.$file_url); } } else { $pathToTest = VMPATH_ROOT . DS . str_replace('/', DS, $file_url); if (JFile::exists($pathToTest)) { $this->file_url = $file_url; } else { // vmdebug('MediaHandler, file does not exist in '.$pathToTest); } } } } if ($this->file_is_downloadable) { $this->media_role = 'file_is_downloadable'; } if ($this->file_is_forSale) { $this->media_role = 'file_is_forSale'; } if (empty($this->media_role)) { $this->media_role = 'file_is_displayable'; } // vmdebug('$this->media_role',$this->media_role); $this->determineFoldersToTest(); if (!empty($this->file_url) && empty($this->file_url_thumb)) { $this->displayMediaThumb('', true, '', false); } }
function display($tpl = null) { if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = tmsModel::getModel(); $usermodel = tmsModel::getModel('user'); JToolBarHelper::title(tsmText::_('com_tsmart_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $this->config = tsmConfig::loadConfig(); if (!empty($this->config->_params)) { unset($this->config->_params['pdf_invoice']); // parameter remove and replaced by inv_os } $this->userparams = JComponentHelper::getParams('com_users'); $this->jTemplateList = ShopFunctions::renderTemplateList(tsmText::_('com_tsmart_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->vmLayoutList = $model->getLayoutList('tsmart'); $this->cartLayoutList = $model->getLayoutList('cart', array('padded.php', 'perror.php')); $this->categoryLayoutList = $model->getLayoutList('category'); $this->productLayoutList = $model->getLayoutList('productdetails'); $this->productsFieldList = $model->getFieldList('products'); $this->noimagelist = $model->getNoImageList(); $this->orderStatusModel = tmsModel::getModel('orderstatus'); $this->os_Options = $this->osWoP_Options = $this->osDel_Options = $this->orderStatusModel->getOrderStatusNames(); $emptyOption = JHtml::_('select.option', -1, tsmText::_('com_tsmart_NONE'), 'order_status_code', 'order_status_name'); array_unshift($this->os_Options, $emptyOption); unset($this->osWoP_Options['P']); array_unshift($this->osWoP_Options, $emptyOption); $deldate_inv = JHtml::_('select.option', 'm', tsmText::_('com_tsmart_DELDATE_INV'), 'order_status_code', 'order_status_name'); unset($this->osDel_Options['P']); array_unshift($this->osDel_Options, $deldate_inv); array_unshift($this->osDel_Options, $emptyOption); //vmdebug('my $this->os_Options',$this->osWoP_Options); $this->currConverterList = $model->getCurrencyConverterList(); $this->activeLanguages = $model->getActiveLanguages(tsmConfig::get('active_languages')); $this->orderByFieldsProduct = $model->getProductFilterFields('browse_orderby_fields'); tmsModel::getModel('category'); foreach (tsmartModelCategory::$_validOrderingFields as $key => $field) { if ($field == 'c.category_shared') { continue; } $fieldWithoutPrefix = $field; $dotps = strrpos($fieldWithoutPrefix, '.'); if ($dotps !== false) { $prefix = substr($field, 0, $dotps + 1); $fieldWithoutPrefix = substr($field, $dotps + 1); } $text = tsmText::_('com_tsmart_' . strtoupper(str_replace(array(',', ' '), array('_', ''), $fieldWithoutPrefix))); $orderByFieldsCat[] = JHtml::_('select.option', $field, $text); } $this->orderByFieldsCat = $orderByFieldsCat; $this->searchFields = $model->getProductFilterFields('browse_search_fields'); $this->aclGroups = $usermodel->getAclGroupIndentedTree(); if (!class_exists('VmTemplate')) { require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php'; } $this->vmtemplate = VmTemplate::loadVmTemplateStyle(); $this->imagePath = shopFunctions::getAvailabilityIconUrl($this->vmtemplate); $this->listShipment = $this->listIt('shipment'); $this->listPayment = $this->listIt('payment'); shopFunctions::checkSafePath(); $this->checkTCPDFinstalled(); $this->checkVmUserVendor(); //$this -> checkClientIP(); parent::display($tpl); }
function display($tpl = null) { //Load helpers $this->loadHelper('currencydisplay'); $this->loadHelper('html'); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } $orderStatusModel = VmModel::getModel('orderstatus'); $orderStates = $orderStatusModel->getOrderStatusList(); $this->SetViewTitle('ORDER'); $model = VmModel::getModel(); $curTask = JRequest::getWord('task'); if ($curTask == 'edit') { VmConfig::loadJLang('com_virtuemart_shoppers', TRUE); // Load addl models $userFieldsModel = VmModel::getModel('userfields'); $productModel = VmModel::getModel('product'); // Get the data $virtuemart_order_id = JRequest::getInt('virtuemart_order_id'); $order = $model->getOrder($virtuemart_order_id); $this->orderID = $order['details']['BT']->virtuemart_order_id; $orderbt = $order['details']['BT']; $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt; $orderbt->invoiceNumber = $model->getInvoiceNumber($orderbt->virtuemart_order_id); $this->currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id); $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type')); $this->userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt, 'BT_'); $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type')); $this->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->virtuemart_orderstate_id] = $orderState->order_status_name; //When I use update, I have to use this? $_orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name); } $_itemStatusUpdateFields = array(); $_itemAttributesUpdateFields = array(); foreach ($order['items'] as $_item) { $_itemStatusUpdateFields[$_item->virtuemart_order_item_id] = JHTML::_('select.genericlist', $orderStates, "item_id[" . $_item->virtuemart_order_item_id . "][order_status]", 'class="selectItemStatusCode input-medium"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->virtuemart_order_item_id, true); } if (!isset($_orderStatusList[$orderbt->order_status])) { if (empty($orderbt->order_status)) { $orderbt->order_status = 'unknown'; } $_orderStatusList[$orderbt->order_status] = JText::_('COM_VIRTUEMART_UNKNOWN_ORDER_STATUS'); } /* Assign the data */ $this->orderdetails = $order; $this->orderstatuslist = $_orderStatusList; $this->itemstatusupdatefields = $_itemStatusUpdateFields; $this->itemattributesupdatefields = $_itemAttributesUpdateFields; $this->orderbt = $orderbt; $this->orderst = $orderst; $this->virtuemart_shipmentmethod_id = $orderbt->virtuemart_shipmentmethod_id; /* Data for the Edit Status form popup */ $this->currentOrderStat = $order['details']['BT']->order_status; // used to update all item status in one time $this->orderStatusSelect = JHTML::_('select.genericlist', $orderStates, 'order_status', '', 'order_status_code', 'order_status_name', $this->currentOrderStat, 'order_items_status', true); /* Toolbar */ JToolBarHelper::custom('prevItem', 'backward', '', 'COM_VIRTUEMART_ITEM_PREVIOUS', false); JToolBarHelper::custom('nextItem', 'forward', '', 'COM_VIRTUEMART_ITEM_NEXT', false); JToolBarHelper::divider(); JToolBarHelper::custom('cancel', 'cancel', 'back', 'COM_VIRTUEMART_CLOSE', false, false); } else { if ($curTask == 'editOrderItem') { $this->loadHelper('calculationh'); $this->orderstatuses = $orderStates; $this->virtuemart_order_id = JRequest::getString('orderId', ''); $this->virtuemart_order_item_id = JRequest::getVar('orderLineId', ''); $this->orderItem = $model->getOrderLineDetails($this->virtuemart_order_id, $this->virtuemart_order_item_id); } else { if (JRequest::getWord('format', '') === 'raw') { $tpl = 'results'; } else { /* Toolbar */ JToolBarHelper::save('updatestatus', JText::_('COM_VIRTUEMART_UPDATE_STATUS')); JToolBarHelper::deleteList(); } $this->addStandardDefaultViewLists($model, 'created_on'); $orderStatusModel = VmModel::getModel('orderstatus'); $orderstates = JRequest::getWord('order_status_code', ''); $this->lists['state_list'] = $orderStatusModel->renderOSList($orderstates, 'order_status_code', FALSE, ' onchange="this.form.submit();" '); $orderslist = $model->getOrdersList(); $this->orderstatuses = $orderStates; foreach ($orderStates as $orderState) { //$_orderStatusList[$orderState->virtuemart_orderstate_id] = $orderState->order_status_name; //When I use update, I have to use this? $_orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name); } $this->orderStatusList = $_orderStatusList; $this->loadHelper('currencydisplay'); if ($this->adminVendor > 1) { $this->setLayout('vendor'); } /* 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 $virtuemart_order_id => $order) { if (!empty($order->order_currency)) { $currency = $order->order_currency; } else { if ($order->virtuemart_vendor_id) { if (!class_exists('VirtueMartModelVendor')) { require JPATH_VM_ADMINISTRATOR . '/models' . DS . 'vendor.php'; } $currObj = VirtueMartModelVendor::getVendorCurrency($order->virtuemart_vendor_id); $currency = $currObj->virtuemart_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->virtuemart_vendor_id); } $order->order_total = $_currencies['curr' . $currency]->priceDisplay($order->order_total); $order->invoiceNumber = $model->getInvoiceNumber($order->virtuemart_order_id); } } /* * 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. */ /* Assign the data */ $this->orderslist = $orderslist; $this->pagination = $model->getPagination(); } } shopFunctions::checkSafePath(); parent::display($tpl); }
public static function getInvoiceDownloadButton($orderInfo, $descr = 'COM_VIRTUEMART_PRINT', $icon = 'system/pdf_button.png') { $html = ''; if (!empty($orderInfo->invoiceNumber)) { if (!($sPath = shopFunctions::checkSafePath())) { return $html; } $path = $sPath . self::getInvoiceFolderName() . DS . self::getInvoiceName($orderInfo->invoiceNumber) . '.pdf'; //$path .= preg_replace('/[^A-Za-z0-9_\-\.]/', '_', 'vm'.$layout.'_'.$orderInfo->invoiceNumber.'.pdf'); if (file_exists($path)) { $link = JURI::root(true) . '/index.php?option=com_virtuemart&view=invoice&layout=invoice&format=pdf&tmpl=component&order_number=' . $orderInfo->order_number . '&order_pass='******'" . $link . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');\" >"; $pdf_link .= JHtml::_('image', $icon, vmText::_($descr), NULL, true); $pdf_link .= '</a>'; $html = $pdf_link; } } return $html; }
/** * Save the configuration record * * @author RickG * @return boolean True is successful, false otherwise */ function store(&$data) { JRequest::checkToken() or jexit('Invalid Token, in store config'); //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_')); //ATM we want to ensure that only one config is used $config = VmConfig::loadConfig(); unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os $config->setParams($data); $confData = array(); $query = 'SELECT * FROM `#__virtuemart_configs`'; $this->_db->setQuery($query); if ($this->_db->loadResult()) { $confData['virtuemart_config_id'] = 1; } else { $confData['virtuemart_config_id'] = 0; } $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path'); foreach ($urls as $urlkey) { $url = trim($config->get($urlkey)); $length = strlen($url); if (strrpos($url, '/') != $length - 1) { $config->set($urlkey, $url . '/'); vmInfo('Corrected media url ' . $urlkey . ' added missing /'); } } /* $path = trim($config->get('forSale_path')); $length = strlen($path); if(strrpos($url,DS)!=($length-1)){ if(is_dir()){ $config->set('forSale_path',$path.DS); vmInfo('Corrected safe path added missing '.DS); } else { } } */ $safePath = trim($config->get('forSale_path')); if (!empty($safePath)) { $length = strlen($safePath); if (strrpos($safePath, DS) != $length - 1) { $safePath = $safePath . DS; $config->set('forSale_path', $safePath); vmInfo('Corrected safe path added missing ' . DS); } } if (!class_exists('shopfunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } $safePath = shopFunctions::checkSafePath($safePath); if (!empty($safePath)) { $exists = JFolder::exists($safePath . 'invoices'); if (!$exists) { $created = JFolder::create($safePath . 'invoices'); if ($created) { vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED'); } else { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')); } } } $confData['config'] = $config->toString(); // vmdebug('config to store',$confData); $confTable = $this->getTable('configs'); if (!$confTable->bindChecknStore($confData)) { vmError($confTable->getError()); } // Load the newly saved values into the session. $config = VmConfig::loadConfig(true); if (!class_exists('GenericTableUpdater')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php'; } $updater = new GenericTableUpdater(); $result = $updater->createLanguageTables(); return true; }
/** * Save the configuration record * * @author Max Milbers * @return boolean True is successful, false otherwise */ function store(&$data) { vRequest::vmCheckToken(); //We create a fresh config $config = VmConfig::loadConfig(false, true); //We load the config file $_raw = self::readConfigFile(FALSE); $_value = join('|', $_raw); //We set the config file values as parameters into the config $config->setParams($_value); //We merge the array from the file with the array from the form //in case it the form has the same key as the file, the value is taken from the form $config->_params = array_merge($config->_params, $data); //We need this to know if we should delete the cache $browse_cat_orderby_field = $config->get('browse_cat_orderby_field'); $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir'); $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path'); foreach ($urls as $urlkey) { $url = trim($config->get($urlkey)); $length = strlen($url); if ($length <= 1) { vmdebug('Urlkey was TOO SHORT ' . $urlkey . ' = ' . $url . ' and length ' . $length, $_raw[$urlkey]); unset($config->_params[$urlkey]); continue; } if (strrpos($url, '/') != $length - 1) { $config->set($urlkey, $url . '/'); vmInfo('Corrected media url ' . $urlkey . ' added missing /'); } } //If empty it is not sent by the form, other forms do it by using a table to store, //the config is like a big xparams and so we check some values for this form manually /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s'); foreach($toSetEmpty as $item){ if(!isset($data[$item])) { $config->set($item,array()); } }*/ $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5'); foreach ($checkCSVInput as $csValueKey) { $csValue = $config->get($csValueKey); if (!empty($csValue)) { $sequenceArray = explode(',', $csValue); foreach ($sequenceArray as &$csV) { $csV = (int) trim($csV); } $csValue = implode(',', $sequenceArray); $config->set($csValueKey, $csValue); } } if (!class_exists('JFolder')) { require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php'; } $safePath = trim($config->get('forSale_path')); if (!empty($safePath)) { if (DS != '/' and strpos($safePath, '/') !== false) { $safePath = str_replace('/', DS, $safePath); vmInfo('Corrected safe path, replaced / by ' . DS); } $length = strlen($safePath); if (strrpos($safePath, DS) != $length - 1) { $safePath = $safePath . DS; vmInfo('Corrected safe path, added missing ' . DS); } $config->set('forSale_path', $safePath); } else { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')); /* $safePath = JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'vmfiles'; $exists = JFolder::exists($safePath); if(!$exists){ $created = JFolder::create($safePath); $safePath = $safePath.DS; if($created){ vmInfo('COM_VIRTUEMART_SAFE_PATH_DEFAULT_CREATED',$safePath); // create htaccess file $fileData = "order deny, allow\ndeny from all\nallow from none"; JLoader::import('joomla.filesystem.file'); $fileName = $safePath.DS.'.htaccess'; $result = JFile::write($fileName, $fileData); if (!$result) { VmWarn('COM_VIRTUEMART_HTACCESS_DEFAULT_NOT_CREATED',$safePath,$fileData); } $config->set('forSale_path',$safePath); } else { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE',vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')); } }*/ } if (!class_exists('shopfunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } $safePath = shopFunctions::checkSafePath($safePath); if (!empty($safePath)) { $exists = JFolder::exists($safePath . 'invoices'); if (!$exists) { $created = JFolder::create($safePath . 'invoices'); if ($created) { vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED'); } else { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')); } } } $active_langs = $config->get('active_languages'); if (empty($active_langs)) { $config->set('active_languages', array(VmConfig::$vmlangTag)); } //ATM we want to ensure that only one config is used $confData = array(); $confData['virtuemart_config_id'] = 1; $confData['config'] = $config->toString(); $confTable = $this->getTable('configs'); if (!$confTable->bindChecknStore($confData)) { vmError($confTable->getError()); } VmConfig::loadConfig(true); if (!class_exists('GenericTableUpdater')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php'; } $updater = new GenericTableUpdater(); $result = $updater->createLanguageTables(); /* This conditions is not enough, if the language changes we need to recall the cache. $newbrowse_cat_orderby_field = $config->get('browse_cat_orderby_field'); $newcat_brws_orderby_dir = $config->get('cat_brws_orderby_dir'); if($browse_cat_orderby_field!=$newbrowse_cat_orderby_field or $newcat_brws_orderby_dir!=$cat_brws_orderby_dir){ $cache = JFactory::getCache('com_virtuemart_cats','callback'); $cache->clean(); }*/ $cache = JFactory::getCache('com_virtuemart_cats', 'callback'); $cache->clean(); $cache = JFactory::getCache('com_virtuemart_rss', 'callback'); $cache->clean(); $cache = JFactory::getCache('convertECB', 'callback'); $cache->clean(); $cache = JFactory::getCache('_virtuemart'); $cache->clean(); $cache = JFactory::getCache('com_plugins'); $cache->clean(); $cache = JFactory::getCache('_system'); $cache->clean(); $cache = JFactory::getCache('page'); $cache->clean(); return true; }
/** * Save the configuration record * * @author Max Milbers * @return boolean True is successful, false otherwise */ function store(&$data, $replace = FALSE) { JRequest::checkToken() or jexit('Invalid Token, in store config'); //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_')); //ATM we want to ensure that only one config is used $config = VmConfig::loadConfig(TRUE); $browse_cat_orderby_field = $config->get('browse_cat_orderby_field'); $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir'); $config->setParams($data, $replace); $confData = array(); $query = 'SELECT * FROM `#__virtuemart_configs`'; $this->_db->setQuery($query); if ($this->_db->loadResult()) { $confData['virtuemart_config_id'] = 1; } else { $confData['virtuemart_config_id'] = 0; } $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path'); foreach ($urls as $urlkey) { $url = trim($config->get($urlkey)); $length = strlen($url); if (strrpos($url, '/') != $length - 1) { $config->set($urlkey, $url . '/'); vmInfo('Corrected media url ' . $urlkey . ' added missing /'); } } //If empty it is not sent by the form, other forms do it by using a table to store, //the config is like a big xparams and so we check some values for this form manually /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s'); foreach($toSetEmpty as $item){ if(!isset($data[$item])) { $config->set($item,array()); } }*/ $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5'); foreach ($checkCSVInput as $csValueKey) { $csValue = $config->get($csValueKey); if (!empty($csValue)) { $sequenceArray = explode(',', $csValue); foreach ($sequenceArray as &$csV) { $csV = (int) trim($csV); } $csValue = implode(',', $sequenceArray); $config->set($csValueKey, $csValue); } } $safePath = trim($config->get('forSale_path')); if (!empty($safePath)) { if (DS != '/' and strpos($safePath, '/') !== false) { $safePath = str_replace('/', DS, $safePath); vmdebug('$safePath', $safePath); } $length = strlen($safePath); if (strrpos($safePath, DS) != $length - 1) { $safePath = $safePath . DS; vmInfo('Corrected safe path added missing ' . DS); } $config->set('forSale_path', $safePath); } else { $safePath = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'vmfiles'; $exists = JFolder::exists($safePath); if (!$exists) { $created = JFolder::create($safePath); $safePath = $safePath . DS; if ($created) { vmInfo('COM_VIRTUEMART_SAFE_PATH_DEFAULT_CREATED', $safePath); /* create htaccess file */ $fileData = "order deny, allow\ndeny from all\nallow from none"; JLoader::import('joomla.filesystem.file'); $fileName = $safePath . DS . '.htaccess'; $result = JFile::write($fileName, $fileData); if (!$result) { VmWarn('COM_VIRTUEMART_HTACCESS_DEFAULT_NOT_CREATED', $safePath, $fileData); } $config->set('forSale_path', $safePath); } else { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')); } } } if (!class_exists('shopfunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } $safePath = shopFunctions::checkSafePath($safePath); if (!empty($safePath)) { $exists = JFolder::exists($safePath . 'invoices'); if (!$exists) { $created = JFolder::create($safePath . 'invoices'); if ($created) { vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED'); } else { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')); } } } $confData['config'] = $config->toString(); $confTable = $this->getTable('configs'); if (!$confTable->bindChecknStore($confData)) { vmError($confTable->getError()); } // Load the newly saved values into the session. $config = VmConfig::loadConfig(true); if (!class_exists('GenericTableUpdater')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php'; } $updater = new GenericTableUpdater(); $result = $updater->createLanguageTables(); $newbrowse_cat_orderby_field = $config->get('browse_cat_orderby_field'); $newcat_brws_orderby_dir = $config->get('cat_brws_orderby_dir'); if ($browse_cat_orderby_field != $newbrowse_cat_orderby_field or $newcat_brws_orderby_dir != $cat_brws_orderby_dir) { $cache = JFactory::getCache('com_virtuemart_cats', 'callback'); $cache->clean(); } return true; }
function display($tpl = null) { if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); if (!empty($config->_params)) { unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os } $this->assignRef('config', $config); $mainframe = JFactory::getApplication(); $this->assignRef('joomlaconfig', $mainframe); $userparams = JComponentHelper::getParams('com_users'); $this->assignRef('userparams', $userparams); $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $vmLayoutList = $model->getLayoutList('virtuemart'); $this->assignRef('vmLayoutList', $vmLayoutList); $categoryLayoutList = $model->getLayoutList('category'); $this->assignRef('categoryLayoutList', $categoryLayoutList); $productLayoutList = $model->getLayoutList('productdetails'); $this->assignRef('productLayoutList', $productLayoutList); $noimagelist = $model->getNoImageList(); $this->assignRef('noimagelist', $noimagelist); $orderStatusModel = VmModel::getModel('orderstatus'); $this->assignRef('orderStatusModel', $orderStatusModel); $currConverterList = $model->getCurrencyConverterList(); $this->assignRef('currConverterList', $currConverterList); $moduleList = $model->getModuleList(); $this->assignRef('moduleList', $moduleList); $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->assignRef('activeLanguages', $activeLanguages); $orderByFieldsProduct = $model->getProductFilterFields('browse_orderby_fields'); $this->assignRef('orderByFieldsProduct', $orderByFieldsProduct); VmModel::getModel('category'); foreach (VirtueMartModelCategory::$_validOrderingFields as $key => $field) { if ($field == 'c.category_shared') { continue; } $fieldWithoutPrefix = $field; $dotps = strrpos($fieldWithoutPrefix, '.'); if ($dotps !== false) { $prefix = substr($field, 0, $dotps + 1); $fieldWithoutPrefix = substr($field, $dotps + 1); } $text = JText::_('COM_VIRTUEMART_' . strtoupper($fieldWithoutPrefix)); $orderByFieldsCat[] = JHTML::_('select.option', $field, $text); } //$orderByFieldsCat = $model->get; $this->assignRef('orderByFieldsCat', $orderByFieldsCat); $searchFields = $model->getProductFilterFields('browse_search_fields'); $this->assignRef('searchFields', $searchFields); $aclGroups = $usermodel->getAclGroupIndentedTree(); $this->assignRef('aclGroups', $aclGroups); if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $vmtemplate = shopFunctionsF::loadVmTemplateStyle(); if (is_Dir(JPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) { $imagePath = '/templates/' . $vmtemplate . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); shopFunctions::checkSafePath(); $this->checkVmUserVendor(); parent::display($tpl); }
function display($tpl = null) { if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); if (!empty($config->_params)) { unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os } $this->assignRef('config', $config); $mainframe = JFactory::getApplication(); $this->assignRef('joomlaconfig', $mainframe); $userparams = JComponentHelper::getParams('com_users'); $this->assignRef('userparams', $userparams); $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $vmLayoutList = $model->getLayoutList('virtuemart'); $this->assignRef('vmLayoutList', $vmLayoutList); $categoryLayoutList = $model->getLayoutList('category'); $this->assignRef('categoryLayoutList', $categoryLayoutList); $productLayoutList = $model->getLayoutList('productdetails'); $this->assignRef('productLayoutList', $productLayoutList); $noimagelist = $model->getNoImageList(); $this->assignRef('noimagelist', $noimagelist); $orderStatusModel = VmModel::getModel('orderstatus'); $this->assignRef('orderStatusModel', $orderStatusModel); $currConverterList = $model->getCurrencyConverterList(); $this->assignRef('currConverterList', $currConverterList); $moduleList = $model->getModuleList(); $this->assignRef('moduleList', $moduleList); $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->assignRef('activeLanguages', $activeLanguages); $orderByFields = $model->getProductFilterFields('browse_orderby_fields'); $this->assignRef('orderByFields', $orderByFields); $searchFields = $model->getProductFilterFields('browse_search_fields'); $this->assignRef('searchFields', $searchFields); $aclGroups = $usermodel->getAclGroupIndentedTree(); $this->assignRef('aclGroups', $aclGroups); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); shopFunctions::checkSafePath(); $this->checkVmUserVendor(); $cache = JFactory::getCache('_virtuemart'); $cached = $cache->getCaching(); if ($cached) { vmInfo('COM_VIRTUEMART_CFG_CACHE_ACTIVE'); } parent::display($tpl); }
function display($tpl = null) { // Load the helper(s) $this->loadHelper('image'); $this->loadHelper('html'); $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os $this->assignRef('config', $config); $mainframe = JFactory::getApplication(); $this->assignRef('joomlaconfig', $mainframe); $userparams = JComponentHelper::getParams('com_users'); $this->assignRef('userparams', $userparams); $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $vmLayoutList = $model->getLayoutList('virtuemart'); $this->assignRef('vmLayoutList', $vmLayoutList); // Outcommented to revert rev. 2916 // $vendorList = ShopFunctions::renderVendorList(VmConfig::get('default_virtuemart_vendor_id')); // // We must replace the fieldname and ID 'virtuemart_vendor_id' to 'default_vendor' // $vendorList = preg_replace('/"virtuemart_vendor_id"/', '"default_virtuemart_vendor_id"', $vendorList); // $this->assignRef('vendorList', $vendorList); $categoryLayoutList = $model->getLayoutList('category'); $this->assignRef('categoryLayoutList', $categoryLayoutList); $productLayoutList = $model->getLayoutList('productdetails'); $this->assignRef('productLayoutList', $productLayoutList); $noimagelist = $model->getNoImageList(); $this->assignRef('noimagelist', $noimagelist); $orderStatusModel = VmModel::getModel('orderstatus'); /* $orderStates = $orderStatusModel->getOrderStatusList(); $orderStatusList = array(); $orderStatusList[0] = JText::_('COM_VIRTUEMART_NONE'); foreach ($orderStates as $orderState) { $orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name); }*/ $this->assignRef('orderStatusModel', $orderStatusModel); /* $oderstatusModel = VmModel::getModel('Orderstatus'); $orderStatusList = $oderstatusModel->getOrderStatusList(); $this->assignRef('orderStatusList', $orderStatusList); */ $currConverterList = $model->getCurrencyConverterList(); $this->assignRef('currConverterList', $currConverterList); $moduleList = $model->getModuleList(); $this->assignRef('moduleList', $moduleList); //$contentLinks = $model->getContentLinks(); //$this->assignRef('contentLinks', $contentLinks); $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->assignRef('activeLanguages', $activeLanguages); $orderByFields = $model->getProductFilterFields('browse_orderby_fields'); $this->assignRef('orderByFields', $orderByFields); $searchFields = $model->getProductFilterFields('browse_search_fields'); $this->assignRef('searchFields', $searchFields); $aclGroups = $usermodel->getAclGroupIndentedTree(); $this->assignRef('aclGroups', $aclGroups); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); shopFunctions::checkSafePath(); parent::display($tpl); }
/** * Save the configuration record * * @author Max Milbers * @return boolean True is successful, false otherwise */ function store(&$data) { vRequest::vmCheckToken(); if (!vmAccess::manager('config')) { vmWarn('Insufficient permissions to delete product'); return false; } //We create a fresh config $config = tsmConfig::loadConfig(false, true); //We load the config file $_raw = self::readConfigFile(FALSE); $_value = join('|', $_raw); //We set the config file values as parameters into the config $config->setParams($_value); //We merge the array from the file with the array from the form //in case it the form has the same key as the file, the value is taken from the form $config->_params = array_merge($config->_params, $data); //We need this to know if we should delete the cache $browse_cat_orderby_field = $config->get('browse_cat_orderby_field'); $cat_brws_orderby_dir = $config->get('cat_brws_orderby_dir'); $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path'); foreach ($urls as $urlkey) { $url = trim($config->get($urlkey)); $length = strlen($url); if ($length <= 1) { vmdebug('Urlkey was TOO SHORT ' . $urlkey . ' = ' . $url . ' and length ' . $length, $_raw[$urlkey]); unset($config->_params[$urlkey]); continue; } if (strrpos($url, '/') != $length - 1) { $config->set($urlkey, $url . '/'); vmInfo('Corrected media url ' . $urlkey . ' added missing /'); } } $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5'); foreach ($checkCSVInput as $csValueKey) { $csValue = $config->get($csValueKey); if (!empty($csValue)) { $sequenceArray = explode(',', $csValue); foreach ($sequenceArray as &$csV) { $csV = (int) trim($csV); } $csValue = implode(',', $sequenceArray); $config->set($csValueKey, $csValue); } } if (!class_exists('JFolder')) { require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php'; } $safePath = trim($config->get('forSale_path')); if (!empty($safePath)) { if (DS != '/' and strpos($safePath, '/') !== false) { $safePath = str_replace('/', DS, $safePath); vmInfo('Corrected safe path, replaced / by ' . DS); } $length = strlen($safePath); if (strrpos($safePath, DS) != $length - 1) { $safePath = $safePath . DS; vmInfo('Corrected safe path, added missing ' . DS); } $p = VMPATH_ROOT . DS; if (strtolower($safePath) == strtolower($p)) { $safePath = ''; vmError('Do not use as safepath your tsmart root folder'); } $config->set('forSale_path', $safePath); } else { VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE', tsmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH')); /* $safePath = VMPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_tsmart'.DS.'vmfiles'; $exists = JFolder::exists($safePath); if(!$exists){ $created = JFolder::create($safePath); $safePath = $safePath.DS; if($created){ vmInfo('com_tsmart_SAFE_PATH_DEFAULT_CREATED',$safePath); // create htaccess file $fileData = "order deny, allow\ndeny from all\nallow from none"; JLoader::import('joomla.filesystem.file'); $fileName = $safePath.DS.'.htaccess'; $result = JFile::write($fileName, $fileData); if (!$result) { VmWarn('com_tsmart_HTACCESS_DEFAULT_NOT_CREATED',$safePath,$fileData); } $config->set('forSale_path',$safePath); } else { VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE',vmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH')); } }*/ } if (!class_exists('shopfunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } $safePath = shopFunctions::checkSafePath($safePath); if (!empty($safePath)) { $exists = JFolder::exists($safePath . 'invoices'); if (!$exists) { $created = JFolder::create($safePath . 'invoices'); if ($created) { vmInfo('com_tsmart_SAFE_PATH_INVOICE_CREATED'); } else { VmWarn('com_tsmart_WARN_SAFE_PATH_NO_INVOICE', tsmText::_('com_tsmart_ADMIN_CFG_MEDIA_FORSALE_PATH')); } } } $active_langs = $config->get('active_languages'); if (empty($active_langs)) { $config->set('active_languages', array(tsmConfig::$vmlangTag)); } //ATM we want to ensure that only one config is used $confData = array(); $confData['tsmart_config_id'] = 1; $confData['config'] = $config->toString(); $confTable = $this->getTable('configs'); $confTable->bindChecknStore($confData); tsmConfig::loadConfig(true); if (!class_exists('GenericTableUpdater')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php'; } $updater = new GenericTableUpdater(); $result = $updater->createLanguageTables(); $cache = JFactory::getCache(); $cache->clean('com_tsmart_cats'); $cache->clean('mod_tsmart_product'); $cache->clean('mod_tsmart_category'); $cache->clean('com_tsmart_rss'); $cache->clean('com_tsmart_cat_manus'); $cache->clean('convertECB'); $cache->clean('_tsmart'); $cache->clean('com_plugins'); $cache->clean('_system'); $cache->clean('page'); return true; }
/** * Save the configuration record * * @author RickG * @return boolean True is successful, false otherwise */ function store(&$data, $replace = FALSE) { JSession::checkToken() or JSession::checkToken('get') or jexit('Invalid Token, in store config'); //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_')); //ATM we want to ensure that only one config is used $config = VmConfig::loadConfig(TRUE); unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os $config->setParams($data, $replace); $confData = array(); $query = 'SELECT * FROM `#__virtuemart_configs`'; $this->_db->setQuery($query); if ($this->_db->loadResult()) { $confData['virtuemart_config_id'] = 1; } else { $confData['virtuemart_config_id'] = 0; } $urls = array('assets_general_path', 'media_category_path', 'media_product_path', 'media_manufacturer_path', 'media_vendor_path'); foreach ($urls as $urlkey) { $url = trim($config->get($urlkey)); $length = strlen($url); if (strrpos($url, '/') != $length - 1) { $config->set($urlkey, $url . '/'); vmInfo('Corrected media url ' . $urlkey . ' added missing /'); } } //If empty it is not sent by the form, other forms do it by using a table to store, //the config is like a big xparams and so we check some values for this form manually /*$toSetEmpty = array('active_languages','inv_os','email_os_v','email_os_s'); foreach($toSetEmpty as $item){ if(!isset($data[$item])) { $config->set($item,array()); } }*/ $checkCSVInput = array('pagseq', 'pagseq_1', 'pagseq_2', 'pagseq_3', 'pagseq_4', 'pagseq_5'); foreach ($checkCSVInput as $csValueKey) { $csValue = $config->get($csValueKey); if (!empty($csValue)) { $sequenceArray = explode(',', $csValue); foreach ($sequenceArray as &$csV) { $csV = (int) trim($csV); } $csValue = implode(',', $sequenceArray); $config->set($csValueKey, $csValue); } } $safePath = trim($config->get('forSale_path')); if (!empty($safePath)) { $length = strlen($safePath); if (strrpos($safePath, DS) != $length - 1) { $safePath = $safePath . DS; $config->set('forSale_path', $safePath); vmInfo('Corrected safe path added missing ' . DS); } } if (!class_exists('shopfunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } $safePath = shopFunctions::checkSafePath($safePath); if (!empty($safePath)) { $exists = JFolder::exists($safePath . 'invoices'); if (!$exists) { $created = JFolder::create($safePath . 'invoices'); if ($created) { vmInfo('COM_VIRTUEMART_SAFE_PATH_INVOICE_CREATED'); } else { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_NO_INVOICE', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH')); } } } $confData['config'] = $config->toJson(); // vmdebug('config to store',$confData); $confTable = $this->getTable('configs'); if (!$confTable->bindChecknStore($confData)) { vmError($confTable->getError()); } // Load the newly saved values into the session. $config = VmConfig::loadConfig(true); if (!class_exists('GenericTableUpdater')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php'; } $updater = new GenericTableUpdater(); $result = $updater->createLanguageTables(); return true; }