function updateOrderItems() { vRequest::vmCheckToken(); $model = VmModel::getModel('report'); $model->updateOrderItems(); $this->setRedirect($this->redirectPath, 'Order Items updated'); }
/** * Handle the save task */ function save($data = 0){ vRequest::vmCheckToken(); $model = VmModel::getModel('config'); $data = vRequest::getPost(); if(strpos($data['offline_message'],'|')!==false){ $data['offline_message'] = str_replace('|','',$data['offline_message']); } $msg = ''; if ($model->store($data)) { $msg = vmText::_('COM_VIRTUEMART_CONFIG_SAVED'); // Load the newly saved values into the session. VmConfig::loadConfig(); } $redir = 'index.php?option=com_virtuemart'; if(vRequest::getCmd('task') == 'apply'){ $redir = $this->redirectPath; } $this->setRedirect($redir, $msg); }
/** * Paste the table in json format * */ public function paste() { // TODO Test user ? $json = array(); $json['fields'] = 'error'; $json['msg'] = 'Invalid Token'; $json['structure'] = 'empty'; if (!vRequest::vmCheckToken(-1)) { echo json_encode($json); jexit(); } $lang = vRequest::getvar('lg'); $langs = VmConfig::get('active_languages', array()); $language = JFactory::getLanguage(); if (!in_array($lang, $langs)) { $json['msg'] = 'Invalid language ! ' . $lang; $json['langs'] = $langs; echo json_encode($json); jexit(); } $lang = strtolower($lang); // Remove tag if defaut or // if ($language->getDefault() == $lang ) $dblang =''; $dblang = strtr($lang, '-', '_'); $id = vRequest::getInt('id', 0); $viewKey = vRequest::getCmd('editView'); // TODO temp trick for vendor if ($viewKey == 'vendor') { $id = 1; } $tables = array('category' => 'categories', 'product' => 'products', 'manufacturer' => 'manufacturers', 'manufacturercategories' => 'manufacturercategories', 'vendor' => 'vendors', 'paymentmethod' => 'paymentmethods', 'shipmentmethod' => 'shipmentmethods'); if (!array_key_exists($viewKey, $tables)) { $json['msg'] = "Invalid view " . $viewKey; echo json_encode($json); jExit(); } $tableName = '#__virtuemart_' . $tables[$viewKey] . '_' . $dblang; $db = JFactory::getDBO(); $q = 'select * FROM `' . $tableName . '` where `virtuemart_' . $viewKey . '_id` =' . $id; $db->setQuery($q); if ($json['fields'] = $db->loadAssoc()) { $json['structure'] = 'filled'; $json['msg'] = vmText::_('COM_VIRTUEMART_SELECTED_LANG') . ':' . $lang; } else { $json['structure'] = 'empty'; $db->setQuery('SHOW COLUMNS FROM ' . $tableName); $tableDescribe = $db->loadAssocList(); array_shift($tableDescribe); $fields = array(); foreach ($tableDescribe as $key => $val) { $fields[$val['Field']] = $val['Field']; } $json['fields'] = $fields; $json['msg'] = vmText::sprintf('COM_VIRTUEMART_LANG_IS_EMPTY', $lang, vmText::_('COM_VIRTUEMART_' . strtoupper($viewKey))); } echo json_encode($json); jExit(); }
/** * 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 save task * * @author Zasilkovna */ function save($data = 0) { vRequest::vmCheckToken(); $data = vRequest::getPost(); $db =& JFactory::getDBO(); $q = "UPDATE #__extensions SET custom_data='" . serialize($data) . "' WHERE element='zasilkovna'"; $db->setQuery($q); $db->query(); $redir = 'index.php?option=com_virtuemart'; if (JRequest::getCmd('task') == 'apply') { $redir = $this->redirectPath; } $this->updateZasilkovnaOrders(); $this->setRedirect($redir, $msg); }
/** * Handle the save task * * @author RickG */ function save($data = 0) { vRequest::vmCheckToken(); $model = VmModel::getModel('config'); $data = vRequest::getPost(); //$data['offline_message'] = vRequest::get('offline_message', '', FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW ); //array(FILTER_FLAG_STRIP_LOW,!FILTER_FLAG_STRIP_HIGH,FILTER_FLAG_ENCODE_HIGH) if (strpos($data['offline_message'], '|') !== false) { $data['offline_message'] = str_replace('|', '', $data['offline_message']); } if ($model->store($data)) { $msg = vmText::_('COM_VIRTUEMART_CONFIG_SAVED'); // Load the newly saved values into the session. VmConfig::loadConfig(); } else { $msg = $model->getError(); } $redir = 'index.php?option=com_virtuemart'; if (vRequest::getCmd('task') == 'apply') { $redir = $this->redirectPath; } $this->setRedirect($redir, $msg); }
/** Save and delete from database * all product custom_fields and xref @ var $table : the xref table(eg. product,category ...) @array $data : array of customfields @int $id : The concerned id (eg. product_id) */ public function storeProductCustomfields($table, $datas, $id) { vRequest::vmCheckToken('Invalid token in storeProductCustomfields'); //Sanitize id $id = (int) $id; //Table whitelist $tableWhiteList = array('product', 'category', 'manufacturer'); if (!in_array($table, $tableWhiteList)) { return false; } // Get old IDS $db = JFactory::getDBO(); $db->setQuery('SELECT `virtuemart_customfield_id` FROM `#__virtuemart_' . $table . '_customfields` as `PC` WHERE `PC`.virtuemart_' . $table . '_id =' . $id); $old_customfield_ids = $db->loadColumn(); if (array_key_exists('field', $datas)) { foreach ($datas['field'] as $key => $fields) { if (!empty($datas['field'][$key]['virtuemart_product_id']) and (int) $datas['field'][$key]['virtuemart_product_id'] != $id) { //aha the field is from the parent, what we do with it? $fields['override'] = (int) $fields['override']; $fields['disabler'] = (int) $fields['disabler']; if ($fields['override'] != 0 or $fields['disabler'] != 0) { //If it is set now as override, store it as clone, therefore set the virtuemart_customfield_id = 0 if ($fields['override'] != 0) { $fields['override'] = $fields['virtuemart_customfield_id']; } if ($fields['disabler'] != 0) { $fields['disabler'] = $fields['virtuemart_customfield_id']; } $fields['virtuemart_customfield_id'] = 0; } else { //we do not store customfields inherited by the parent, therefore $key = array_search($fields['virtuemart_customfield_id'], $old_customfield_ids); if ($key !== false) { unset($old_customfield_ids[$key]); } continue; } } if ($fields['field_type'] == 'C') { $cM = VmModel::getModel('custom'); $c = $cM->getCustom($fields['virtuemart_custom_id'], ''); if (!empty($c->sCustomId)) { $sCustId = $c->sCustomId; $labels = array(); foreach ($fields['selectoptions'] as $k => $option) { if ($option['voption'] == 'clabels' and !empty($option['clabel'])) { $labels[$k] = $option['clabel']; } } //for testing foreach ($fields['options'] as $prodId => $lvalue) { if ($prodId == $id) { continue; } $db->setQuery('SELECT `virtuemart_customfield_id` FROM `#__virtuemart_' . $table . '_customfields` as `PC` WHERE `PC`.virtuemart_' . $table . '_id ="' . $prodId . '" AND `virtuemart_custom_id`="' . $sCustId . '" '); $strIds = $db->loadColumn(); $i = 0; foreach ($lvalue as $k => $value) { if (!empty($labels[$k])) { $ts = array(); $ts['field_type'] = 'S'; $ts['virtuemart_product_id'] = $prodId; $ts['virtuemart_custom_id'] = $sCustId; if (isset($strIds[$i])) { $ts['virtuemart_customfield_id'] = $strIds[$i]; unset($strIds[$i++]); } $ts['customfield_value'] = $value; $tableCustomfields = $this->getTable($table . '_customfields'); $tableCustomfields->bindChecknStore($ts); } } if (count($strIds) > 0) { // delete old unused Customfields $db->setQuery('DELETE FROM `#__virtuemart_' . $table . '_customfields` WHERE `virtuemart_customfield_id` in ("' . implode('","', $strIds) . '") '); $db->execute(); } } } } $fields['virtuemart_' . $table . '_id'] = $id; $tableCustomfields = $this->getTable($table . '_customfields'); $tableCustomfields->setPrimaryKey('virtuemart_product_id'); if (!empty($datas['customfield_params'][$key]) and !isset($datas['clone'])) { if (array_key_exists($key, $datas['customfield_params'])) { $fields = array_merge((array) $fields, (array) $datas['customfield_params'][$key]); } } $tableCustomfields->_xParams = 'customfield_params'; if (!class_exists('VirtueMartModelCustom')) { require VMPATH_ADMIN . DS . 'models' . DS . 'custom.php'; } VirtueMartModelCustom::setParameterableByFieldType($tableCustomfields, $fields['field_type'], $fields['custom_element'], $fields['custom_jplugin_id']); $tableCustomfields->bindChecknStore($fields); $key = array_search($fields['virtuemart_customfield_id'], $old_customfield_ids); if ($key !== false) { unset($old_customfield_ids[$key]); } } } else { vmdebug('storeProductCustomfields nothing to store'); } vmdebug('Delete $old_customfield_ids', $old_customfield_ids); if (count($old_customfield_ids)) { // delete old unused Customfields $db->setQuery('DELETE FROM `#__virtuemart_' . $table . '_customfields` WHERE `virtuemart_customfield_id` in ("' . implode('","', $old_customfield_ids) . '") '); $db->execute(); vmdebug('Deleted $old_customfield_ids', $old_customfield_ids); } JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); if (isset($datas['customfield_params']) and is_array($datas['customfield_params'])) { foreach ($datas['customfield_params'] as $key => $plugin_param) { $dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param)); } } }
/** * This function stores a media and updates then the refered table * * @author Max Milbers * @author Patrick Kohl * @param array $data Data from a from * @param string $type type of the media category,product,manufacturer,shop, ... */ function storeMedia($data, $type) { vRequest::vmCheckToken('Invalid Token, while trying to save media ' . $type); if (empty($data['media_action'])) { $data['media_action'] = 'none'; } //the active media id is not empty, so there should be something done with it if ((!empty($data['active_media_id']) and isset($data['virtuemart_media_id'])) || $data['media_action'] == 'upload') { $oldIds = $data['virtuemart_media_id']; $data['file_type'] = $type; $this->setId($data['active_media_id']); $virtuemart_media_id = $this->store($data); //added by Mike $this->setId($virtuemart_media_id); if (!empty($oldIds)) { if (!is_array($oldIds)) { $oldIds = array($oldIds); } if (!empty($data['mediaordering']) && $data['media_action'] == 'upload') { $data['mediaordering'][$virtuemart_media_id] = count($data['mediaordering']); } $virtuemart_media_ids = array_merge((array) $virtuemart_media_id, $oldIds); $data['virtuemart_media_id'] = array_unique($virtuemart_media_ids); } else { $data['virtuemart_media_id'] = $virtuemart_media_id; } } if (!empty($data['mediaordering'])) { asort($data['mediaordering']); $sortedMediaIds = array(); foreach ($data['mediaordering'] as $k => $v) { $sortedMediaIds[] = $k; } $data['virtuemart_media_id'] = $sortedMediaIds; } //set the relations $table = $this->getTable($type . '_medias'); // Bind the form fields to the country table $table->bindChecknStore($data); return $table->virtuemart_media_id; }
public function updateXrefAndChildTables($data, $tableName, $preload = FALSE) { vRequest::vmCheckToken(); //First we load the xref table, to get the old data $product_table_Parent = $this->getTable($tableName); //We must go that way, because the load function of the vmtablexarry // is working different. if ($preload) { $product_table_Parent->load($data['virtuemart_product_id']); } $product_table_Parent->bindChecknStore($data); return $data; }
public function saveChildCustomRelation($table, $datas) { vRequest::vmCheckToken('Invalid token in saveChildCustomRelation'); //Table whitelist $tableWhiteList = array('product', 'category', 'manufacturer'); if (!in_array($table, $tableWhiteList)) { return false; } $db = JFactory::getDBO(); // delete existings from modelXref and table customfields foreach ($datas as $child_id => $fields) { $fields['virtuemart_' . $table . '_id'] = $child_id; $db->setQuery('DELETE PC FROM `#__virtuemart_' . $table . '_customfields` as `PC`, `#__virtuemart_customs` as `C` WHERE `PC`.`virtuemart_custom_id` = `C`.`virtuemart_custom_id` AND field_type="C" and virtuemart_' . $table . '_id =' . $child_id); if (!$db->execute()) { vmError('Error in deleting child relation '); //.$db->getQuery()); Dont give hackers too much info } $tableCustomfields = $this->getTable($table . '_customfields'); $tableCustomfields->bindChecknStore($fields); } }
/** * Delete all calcs selected * * @author Max Milbers * @param array $cids categories to remove * @return boolean if the item remove was successful */ public function remove($cids) { vRequest::vmCheckToken(); $table = $this->getTable($this->_maintablename); $cat = $this->getTable('calc_categories'); $sgrp = $this->getTable('calc_shoppergroups'); $countries = $this->getTable('calc_countries'); $states = $this->getTable('calc_states'); $manufacturers = $this->getTable('calc_manufacturers'); $ok = true; foreach ($cids as $id) { $id = (int) $id; vmdebug('remove ' . $id); if (!$table->delete($id)) { vmError(get_class($this) . '::remove ' . $id . ' ' . $table->getError()); $ok = false; } if (!$cat->delete($id)) { vmError(get_class($this) . '::remove ' . $id . ' ' . $cat->getError()); $ok = false; } if (!$sgrp->delete($id)) { vmError(get_class($this) . '::remove ' . $id . ' ' . $sgrp->getError()); $ok = false; } if (!$countries->delete($id)) { vmError(get_class($this) . '::remove ' . $id . ' ' . $countries->getError()); $ok = false; } if (!$states->delete($id)) { vmError(get_class($this) . '::remove ' . $id . ' ' . $states->getError()); $ok = false; } // Mod. <mediaDESIGN> St.Kraft 2013-02-24 if (!$manufacturers->delete($id)) { vmError(get_class($this) . '::remove ' . $id . ' ' . $manufacturers->getError()); $ok = false; } // if(!class_exists('vmPSPlugin')) require(JPATH_VM_PLUGINS.DS.'vmpsplugin.php'); JPluginHelper::importPlugin('vmcalculation'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmDeleteCalculationRow', array($id)); } return $ok; }
/** * This is executing the update table commands to adjust tables to the latest layout * @author Max Milbers */ function updateDatabase() { vRequest::vmCheckToken(); if (!class_exists('com_virtuemartInstallerScript')) { require VMPATH_ADMIN . DS . 'install' . DS . 'script.virtuemart.php'; } $updater = new com_virtuemartInstallerScript(); $updater->update(false); $this->setRedirect($this->redirectPath, 'Database updated'); }
/** * Save the categories order */ public function saveOrder() { //ACL if (!vmAccess::manager('category.edit')) { JFactory::getApplication()->redirect('index.php?option=com_tsmart', tsmText::_('JERROR_ALERTNOAUTHOR'), 'error'); } // Check for request forgeries vRequest::vmCheckToken(); $cid = vRequest::getInt('cid', array()); //is sanitized $model = tmsModel::getModel('category'); $order = vRequest::getInt('order', array()); $msg = ''; if ($model->setOrder($cid, $order)) { $msg = tsmText::_('com_tsmart_NEW_ORDERING_SAVED'); } $this->setRedirect('index.php?option=com_tsmart&view=category', $msg); }
$path = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; if (file_exists($path)) { require $path; tsmConfig::loadConfig(); } else { $app = JFactory::getApplication(); $app->enqueueMessage('VirtueMart Core is not installed, please install VirtueMart again, or uninstall the AIO component by the joomla extension manager'); return false; } } if (!class_exists('tsmText')) { require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'tsmtext.php'; } $task = vRequest::getCmd('task'); if ($task == 'updateDatabase') { vRequest::vmCheckToken('Invalid Token, in ' . $task); $app = JFactory::getApplication(); if (!class_exists('com_virtuemart_allinoneInstallerScript')) { require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_tsmart_allinone' . DS . 'script.vmallinone.php'; } $updater = new com_virtuemart_allinoneInstallerScript(); $updater->vmInstall(); $app->redirect('index.php?option=com_tsmart_allinone', 'Database updated'); } ?> <script type="text/javascript"> <!-- function confirmation(message, destnUrl) { var answer = confirm(message); if (answer) { window.location = destnUrl;
/** * 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; }
/** * Delete all calcs selected * * @author Max Milbers * @param array $cids categories to remove * @return boolean if the item remove was successful */ public function remove($cids) { vRequest::vmCheckToken(); if (!vmAccess::manager('calc.delete')) { vmWarn('Insufficient permission to delete calculation rule'); return false; } $table = $this->getTable($this->_maintablename); $cat = $this->getTable('calc_categories'); $sgrp = $this->getTable('calc_shoppergroups'); $countries = $this->getTable('calc_countries'); $states = $this->getTable('calc_states'); $manufacturers = $this->getTable('calc_manufacturers'); $ok = true; foreach ($cids as $id) { $id = (int) $id; if (!$table->delete($id)) { vmError(get_class($this) . '::remove error' . $id); $ok = false; } if (!$cat->delete($id)) { vmError(get_class($this) . '::remove error' . $id); $ok = false; } if (!$sgrp->delete($id)) { vmError(get_class($this) . '::remove error' . $id); $ok = false; } if (!$countries->delete($id)) { vmError(get_class($this) . '::remove error' . $id); $ok = false; } if (!$states->delete($id)) { vmError(get_class($this) . '::remove error ' . $id); $ok = false; } // Mod. <mediaDESIGN> St.Kraft 2013-02-24 if (!$manufacturers->delete($id)) { vmError(get_class($this) . '::remove error ' . $id); $ok = false; } JPluginHelper::importPlugin('vmcalculation'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmDeleteCalculationRow', array($id)); } return $ok; }
/** * Add customer to the waiting list for specific product * * @author Seyi Awofadeju * @return insert_id if the save was successful, false otherwise. */ public function adduser($data) { vRequest::vmCheckToken('Invalid Token, in adduser to waitinglist'); JSession::checkToken() or jexit(''); $field = $this->getTable('waitingusers'); if (!$field->bind($data)) { // Bind data vmError($field->getError()); return FALSE; } if (!$field->check()) { // Perform data checks vmError($field->getError()); return FALSE; } $_id = $field->store(); if ($_id === FALSE) { // Write data to the DB vmError($field->getError()); return FALSE; } //jexit(); return $_id; }
/** * Save the configuration record * * @author Max Milbers * @return boolean True is successful, false otherwise */ function store(&$data, $replace = FALSE) { vRequest::vmCheckToken(); //$data['active_languages'] = strtolower(strtr($data['active_languages'],'-','_')); //ATM we want to ensure that only one config is used $config = VmConfig::loadConfig(TRUE); if (!self::checkConfigTableExists()) { VmConfig::installVMconfig(false); } $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); vmInfo('Corrected safe path, replaced / by ' . DS); 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')); } } } if (!$config->get('active_languages', false)) { $confData['active_languages'] = array(VmConfig::$langTag); } $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(); /* 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; }
public function updateXrefAndChildTables($data, $tableName, $preload = FALSE) { vRequest::vmCheckToken(); //First we load the xref table, to get the old data $product_table_Parent = $this->getTable($tableName); //We must go that way, because the load function of the vmtablexarry // is working different. if ($preload) { //$product_table_Parent->setOrderable('ordering',false); $orderingA = $product_table_Parent->load($data['virtuemart_product_id']); /* if(isset($orderingA) and isset($orderingA[0])){ $product_table_Parent->ordering = $orderingA[0]; }*/ //$product_table_Parent->ordering = $product_table_Parent->load($data['virtuemart_product_id']); //vmdebug('my ordering ',$product_table_Parent->ordering); } $product_table_Parent->bindChecknStore($data); $errors = $product_table_Parent->getErrors(); foreach ($errors as $error) { vmError($error); } return $data; }
/** * This function stores a media and updates then the refered table * * @author Max Milbers * @author Patrick Kohl * @param array $data Data from a from * @param string $type type of the media category,product,manufacturer,shop, ... */ function storeMedia($data, $type) { // vmdebug('my data in media to store start',$data['virtuemart_media_id']); vRequest::vmCheckToken('Invalid Token, while trying to save media'); if (empty($data['media_action'])) { $data['media_action'] = 'none'; } //vmdebug('storeMedia',$data); //the active media id is not empty, so there should be something done with it //if( (!empty($data['active_media_id']) && !empty($data['virtuemart_media_id']) ) || $data['media_action']=='upload'){ if ((!empty($data['active_media_id']) and isset($data['virtuemart_media_id'])) || $data['media_action'] == 'upload') { $oldIds = $data['virtuemart_media_id']; $data['file_type'] = $type; //$data['virtuemart_media_id'] = (int)$data['active_media_id']; //done within the function now $this->setId($data['active_media_id']); $virtuemart_media_id = $this->store($data, $type); //added by Mike, Mike why did you add this? This function storeMedia is extremely nasty $this->setId($virtuemart_media_id); if (!empty($oldIds)) { if (!is_array($oldIds)) { $oldIds = array($oldIds); } if (!empty($data['mediaordering']) && $data['media_action'] == 'upload') { // array_push($data['mediaordering'],count($data['mediaordering'])+1); $data['mediaordering'][$virtuemart_media_id] = count($data['mediaordering']); } $virtuemart_media_ids = array_merge((array) $virtuemart_media_id, $oldIds); // vmdebug('merged old and new',$virtuemart_media_ids); $data['virtuemart_media_id'] = array_unique($virtuemart_media_ids); } else { $data['virtuemart_media_id'] = $virtuemart_media_id; } } if (!empty($data['mediaordering'])) { asort($data['mediaordering']); $sortedMediaIds = array(); foreach ($data['mediaordering'] as $k => $v) { $sortedMediaIds[] = $k; } // vmdebug('merging old and new',$oldIds,$virtuemart_media_id); $data['virtuemart_media_id'] = $sortedMediaIds; } // vmdebug('my data in media to store',$data['virtuemart_media_id'],$data['mediaordering']); //set the relations $table = $this->getTable($type . '_medias'); // Bind the form fields to the country table $table->bindChecknStore($data); $errors = $table->getErrors(); foreach ($errors as $error) { vmError($error); } return $table->virtuemart_media_id; }
/** * This is executing the update table commands to adjust joomla tables to the latest layout * @author Max Milbers */ function updateDatabaseJoomla() { vRequest::vmCheckToken(); if (JVM_VERSION < 3) { $p = VMPATH_ADMIN . DS . 'install' . DS . 'joomla2.sql'; } else { $p = ''; } //$p = VMPATH_ROOT.DS.'installation'.DS.'sql'.DS.'mysql'.DS.'joomla.sql'; $msg = 'You are using joomla 3, or File ' . $p . ' not found'; if (file_exists($p)) { if (!class_exists('GenericTableUpdater')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'tableupdater.php'; } $updater = new GenericTableUpdater(); $updater->updateMyVmTables($p, '_'); $msg = 'Joomla Database updated'; } $this->setRedirect($this->redirectPath, $msg); }
/** * Save the categories order */ public function saveOrder() { //ACL if (!JFactory::getUser()->authorise('vm.category.edit', 'com_virtuemart')) { JFactory::getApplication()->redirect('index.php?option=com_virtuemart', vmText::_('JERROR_ALERTNOAUTHOR'), 'error'); } // Check for request forgeries vRequest::vmCheckToken(); $cid = vRequest::getInt('cid', array()); //is sanitized $model = VmModel::getModel('category'); $order = vRequest::getInt('order', array()); $msg = ''; if ($model->setOrder($cid, $order)) { $msg = vmText::_('COM_VIRTUEMART_NEW_ORDERING_SAVED'); } $this->setRedirect('index.php?option=com_virtuemart&view=category', $msg); }
/** * Delete all categories selected * * @author jseros * @param array $cids categories to remove * @return boolean if the item remove was successful */ public function remove($cids) { vRequest::vmCheckToken(); if (!vmAccess::manager('category.delete')) { vmWarn('Insufficient permissions to delete category'); return false; } $table = $this->getTable('categories'); foreach ($cids as &$cid) { if (!$table->delete($cid)) { return false; } $db = JFactory::getDbo(); $q = 'SELECT `virtuemart_customfield_id` FROM `#__virtuemart_product_customfields` as pc '; $q .= 'LEFT JOIN `#__virtuemart_customs`as c using (`virtuemart_custom_id`) WHERE pc.`customfield_value` = "' . $cid . '" AND `field_type`= "Z"'; $db->setQuery($q); $list = $db->loadColumn(); if ($list) { $listInString = implode(',', $list); //Delete media xref $query = 'DELETE FROM `#__virtuemart_product_customfields` WHERE `virtuemart_customfield_id` IN (' . $listInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } } } $cidInString = implode(',', $cids); //Delete media xref $query = 'DELETE FROM `#__virtuemart_category_medias` WHERE `virtuemart_category_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } //deleting product relations $query = 'DELETE FROM `#__virtuemart_product_categories` WHERE `virtuemart_category_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } //deleting category relations $query = 'DELETE FROM `#__virtuemart_category_categories` WHERE `category_child_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } //updating parent relations $query = 'UPDATE `#__virtuemart_category_categories` SET `category_parent_id` = 0 WHERE `category_parent_id` IN (' . $cidInString . ') '; $db->setQuery($query); if (!$db->execute()) { vmError($db->getErrorMsg()); } $cache = JFactory::getCache('com_virtuemart_cats', 'callback'); $cache->clean(); return true; }
function storeReview($apply) { vRequest::vmCheckToken(); if (empty($data)) { $data = vRequest::getPost(); } $model = VmModel::getModel($this->_cname); $id = $model->saveRating($data); $msg = 'failed'; if (!empty($id)) { $msg = vmText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey); } $redir = $this->redirectPath; if ($apply) { $redir = 'index.php?option=com_virtuemart&view=ratings&task=edit_review&virtuemart_rating_review_id=' . $id; } 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; } $redir = 'index.php?option=com_virtuemart&view=ratings&task=listreviews&virtuemart_product_id=' . $virtuemart_product_id; } $this->setRedirect($redir, $msg); }
/** * Change the shopper * * @author Maik Künnemann */ public function changeShopper() { vRequest::vmCheckToken() or jexit('Invalid Token'); $app = JFactory::getApplication(); $redirect = vRequest::getString('redirect', false); if ($redirect) { $red = $redirect; } else { $red = JRoute::_('index.php?option=com_virtuemart&view=cart'); } $id = vmAccess::getBgManagerId(); $current = JFactory::getUser(); $manager = vmAccess::manager('user'); if (!$manager) { $app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_CART_CHANGE_SHOPPER_NO_PERMISSIONS', $current->name . ' (' . $current->username . ')'), 'error'); $app->redirect($red); return false; } $userID = vRequest::getCmd('userID'); if ($manager and !empty($userID) and $userID != $current->id) { if ($userID == $id) { } else { if (vmAccess::manager('user', $userID)) { //if($newUser->authorise('core.admin', 'com_virtuemart') or $newUser->authorise('vm.user', 'com_virtuemart')){ $app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_CART_CHANGE_SHOPPER_NO_PERMISSIONS', $current->name . ' (' . $current->username . ')'), 'error'); $app->redirect($red); } } } $searchShopper = vRequest::getString('searchShopper'); if (!empty($searchShopper)) { $this->display(); return false; } //update session $session = JFactory::getSession(); $adminID = $session->get('vmAdminID'); if (!isset($adminID)) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $session->set('vmAdminID', vmCrypt::encrypt($current->id)); } $newUser = JFactory::getUser($userID); $session->set('user', $newUser); //update cart data $cart = VirtueMartCart::getCart(); $usermodel = VmModel::getModel('user'); $data = $usermodel->getUserAddressList(vRequest::getCmd('userID'), 'BT'); if (isset($data[0])) { foreach ($data[0] as $k => $v) { $data[$k] = $v; } } $cart->BT['email'] = $newUser->email; $cart->ST = 0; $cart->STsameAsBT = 1; $cart->selected_shipto = 0; $cart->virtuemart_shipmentmethod_id = 0; $cart->saveAddressInCart($data, 'BT'); $msg = vmText::sprintf('COM_VIRTUEMART_CART_CHANGED_SHOPPER_SUCCESSFULLY', $newUser->name . ' (' . $newUser->username . ')'); if (empty($userID)) { $red = JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT'); $msg = vmText::sprintf('COM_VIRTUEMART_CART_CHANGED_SHOPPER_SUCCESSFULLY', ''); } $app->enqueueMessage($msg, 'info'); $app->redirect($red); }
public function massxref($layoutName) { vRequest::vmCheckToken(); $cids = vRequest::getInt('tsmart_product_id'); if (empty($cids)) { $session = JFactory::getSession(); $cids = json_decode($session->get('vm_product_ids', '', 'vm'), true); } else { $session = JFactory::getSession(); $session->set('vm_product_ids', json_encode($cids), 'vm'); $session->set('reset_pag', true, 'vm'); } if (!empty($cids)) { $q = 'SELECT `product_name` FROM `#__tsmart_products_' . tsmConfig::$vmlang . '` '; $q .= ' WHERE `tsmart_product_id` IN (' . implode(',', $cids) . ')'; $db = JFactory::getDbo(); $db->setQuery($q); $productNames = $db->loadColumn(); vmInfo('com_tsmart_PRODUCT_XREF_NAMES', implode(', ', $productNames)); } $this->addViewPath(VMPATH_ADMIN . DS . 'views'); $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView($this->_cname, $viewType); $view->setLayout($layoutName); $view->display(); }
/** * */ public function massxref($layoutName) { vRequest::vmCheckToken(); $cids = vRequest::getInt('virtuemart_product_id'); if (empty($cids)) { $session = JFactory::getSession(); $cids = unserialize($session->get('vm_product_ids', '', 'vm')); } else { $session = JFactory::getSession(); $session->set('vm_product_ids', serialize($cids), 'vm'); } if (!empty($cids)) { $q = 'SELECT `product_name` FROM `#__virtuemart_products_' . VmConfig::$vmlang . '` '; $q .= ' WHERE `virtuemart_product_id` IN (' . implode(',', $cids) . ')'; $db = JFactory::getDbo(); $db->setQuery($q); $productNames = $db->loadColumn(); vmInfo('COM_VIRTUEMART_PRODUCT_XREF_NAMES', implode(', ', $productNames)); } $this->addViewPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'views'); $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView($this->_cname, $viewType); $view->setLayout($layoutName); $view->display(); }
/** * Save the categories order */ public function saveOrder() { // Check for request forgeries vRequest::vmCheckToken(); $cid = vRequest::getInt('cid', array()); $model = tmsModel::getModel('calc'); $order = vRequest::getInt('order'); $msg = ''; if ($model->setOrder($cid, $order)) { $msg = tsmText::_('com_tsmart_NEW_ORDERING_SAVED'); } $this->setRedirect('index.php?option=com_tsmart&view=calc', $msg); }
/** * Bind the post data to the JUser object and the VM tables, then saves it * It is used to register new users * This function can also change already registered users, this is important when a registered user changes his email within the checkout. * * @author Max Milbers * @author Oscar van Eijk * @return boolean True is the save was successful, false otherwise. */ public function store(&$data, $checkToken = TRUE) { $message = ''; $user = ''; $newId = 0; if ($checkToken) { vRequest::vmCheckToken('Invalid Token, while trying to save user'); } else { vmError('You try to store a user without a valid token id'); return false; } if (empty($data)) { vmError('Developer notice, no data to store for user'); return false; } //To find out, if we have to register a new user, we take a look on the id of the usermodel object. //The constructor sets automatically the right id. $new = $this->_id < 1; if (empty($this->_id)) { //$user = JFactory::getUser(); $user = new JUser(); //thealmega http://forum.virtuemart.net/index.php?topic=99755.msg393758#msg393758 } else { $user = JFactory::getUser($this->_id); } $gid = $user->get('gid'); // Save original gid // Preformat and control user datas by plugin JPluginHelper::importPlugin('vmuserfield'); $dispatcher = JDispatcher::getInstance(); $valid = true; $dispatcher->trigger('plgVmOnBeforeUserfieldDataSave', array(&$valid, $this->_id, &$data, $user)); // $valid must be false if plugin detect an error if ($valid == false) { return false; } // Before I used this "if($cart && !$new)" // This construction is necessary, because this function is used to register a new JUser, so we need all the JUser data in $data. // On the other hand this function is also used just for updating JUser data, like the email for the BT address. In this case the // name, username, password and so on is already stored in the JUser and dont need to be entered again. if (empty($data['email'])) { $email = $user->get('email'); if (!empty($email)) { $data['email'] = $email; } } else { $data['email'] = vRequest::getString('email', ''); } $data['email'] = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $data['email']); //This is important, when a user changes his email address from the cart, //that means using view user layout edit_address (which is called from the cart) $user->set('email', $data['email']); if (empty($data['name'])) { $name = $user->get('name'); if (!empty($name)) { $data['name'] = $name; } } else { $data['name'] = vRequest::getString('name', ''); } $data['name'] = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $data['name']); if (empty($data['username'])) { $username = $user->get('username'); if (!empty($username)) { $data['username'] = $username; } else { $data['username'] = vRequest::getString('username', ''); } } if (empty($data['password'])) { $data['password'] = vRequest::getString('password', ''); } if (empty($data['password2'])) { $data['password2'] = vRequest::getString('password2', ''); } if (!$new && !empty($data['password']) && empty($data['password2'])) { unset($data['password']); unset($data['password2']); } if (!$user->authorise('core.admin', 'com_virtuemart')) { $whiteDataToBind = array(); if (isset($data['name'])) { $whiteDataToBind['name'] = $data['name']; } if (isset($data['username'])) { $whiteDataToBind['username'] = $data['username']; } if (isset($data['email'])) { $whiteDataToBind['email'] = $data['email']; } if (isset($data['language'])) { $whiteDataToBind['language'] = $data['language']; } if (isset($data['editor'])) { $whiteDataToBind['editor'] = $data['editor']; } if (isset($data['password'])) { $whiteDataToBind['password'] = $data['password']; } if (isset($data['password2'])) { $whiteDataToBind['password2'] = $data['password2']; } } else { $whiteDataToBind = $data; } // Bind Joomla userdata if (!$user->bind($whiteDataToBind)) { foreach ($user->getErrors() as $error) { // vmError('user bind '.$error); vmError('user bind ' . $error, vmText::sprintf('COM_VIRTUEMART_USER_STORE_ERROR', $error)); } vmdebug('Couldnt bind data to joomla user'); //array('user'=>$user,'password'=>$data['password'],'message'=>$message,'newId'=>$newId,'success'=>false); } if ($new) { // If user registration is not allowed, show 403 not authorized. // But it is possible for admins and storeadmins to save $usersConfig = JComponentHelper::getParams('com_users'); $cUser = JFactory::getUser(); if (!($cUser->authorise('core.admin', 'com_virtuemart') or $cUser->authorise('core.manage', 'com_virtuemart')) and $usersConfig->get('allowUserRegistration') == '0') { VmConfig::loadJLang('com_virtuemart'); vmError(vmText::_('COM_VIRTUEMART_ACCESS_FORBIDDEN')); return; } // Initialize new usertype setting $newUsertype = $usersConfig->get('new_usertype'); if (!$newUsertype) { $newUsertype = 2; } // Set some initial user values $user->set('usertype', $newUsertype); $user->groups[] = $newUsertype; $date = JFactory::getDate(); $user->set('registerDate', $date->toSQL()); // If user activation is turned on, we need to set the activation information $useractivation = $usersConfig->get('useractivation'); $doUserActivation = false; if ($useractivation == '1' or $useractivation == '2') { $doUserActivation = true; } vmdebug('user', $useractivation, $doUserActivation); if ($doUserActivation) { jimport('joomla.user.helper'); $user->set('activation', JApplication::getHash(JUserHelper::genRandomPassword())); $user->set('block', '1'); //$user->set('lastvisitDate', '0000-00-00 00:00:00'); } } $option = vRequest::getCmd('option'); // If an exising superadmin gets a new group, make sure enough admins are left... if (!$new && $user->get('gid') != $gid && $gid == __SUPER_ADMIN_GID) { if ($this->getSuperAdminCount() <= 1) { vmError(vmText::_('COM_VIRTUEMART_USER_ERR_ONLYSUPERADMIN')); return false; } } if (isset($data['language'])) { $user->setParam('language', $data['language']); } // Save the JUser object if (!$user->save()) { vmError(vmText::_($user->getError()), vmText::_($user->getError())); return false; } //vmdebug('my user, why logged in? ',$user); $newId = $user->get('id'); $data['virtuemart_user_id'] = $newId; //We need this in that case, because data is bound to table later $this->setUserId($newId); //Save the VM user stuff if (!$this->saveUserData($data) || !self::storeAddress($data)) { vmError('COM_VIRTUEMART_NOT_ABLE_TO_SAVE_USER_DATA'); // vmError(vmText::_('COM_VIRTUEMART_NOT_ABLE_TO_SAVE_USERINFO_DATA')); } else { if ($new) { $this->sendRegistrationEmail($user, $user->password_clear, $doUserActivation); if ($doUserActivation) { vmInfo('COM_VIRTUEMART_REG_COMPLETE_ACTIVATE'); } else { vmInfo('COM_VIRTUEMART_REG_COMPLETE'); $user->set('activation', ''); $user->set('block', '0'); $user->set('guest', '0'); } } else { vmInfo('COM_VIRTUEMART_USER_DATA_STORED'); } } //The extra check for isset vendor_name prevents storing of the vendor if there is no form (edit address cart) if ((int) $data['user_is_vendor'] == 1 and isset($data['vendor_currency'])) { vmdebug('vendor recognised ' . $data['virtuemart_vendor_id']); if ($this->storeVendorData($data)) { if ($new) { if ($doUserActivation) { vmInfo('COM_VIRTUEMART_REG_VENDOR_COMPLETE_ACTIVATE'); } else { vmInfo('COM_VIRTUEMART_REG_VENDOR_COMPLETE'); } } else { vmInfo('COM_VIRTUEMART_VENDOR_DATA_STORED'); } } } return array('user' => $user, 'password' => $data['password'], 'message' => $message, 'newId' => $newId, 'success' => true); }
function saveorder() { vRequest::vmCheckToken(); $cid = vRequest::getInt($this->_cidName, vRequest::getInt('cid', array())); $order = vRequest::getInt('order', array()); $model = $this->getModel($this->_cname); if (!$model->saveorder($cid, $order)) { $msg = 'error'; } else { if (JFactory::getApplication()->isAdmin() and VmConfig::showDebug()) { $msg = vmText::sprintf('COM_VIRTUEMART_NEW_ORDERING_SAVEDF', $this->mainLangKey); } else { $msg = vmText::sprintf('COM_VIRTUEMART_NEW_ORDERING_SAVED'); } } $this->setRedirect($this->redirectPath, $msg); }