public static function storeConfig() { $user = JFactory::getUser(); if ($user->authorise('core.admin', 'com_virtuemart')) { $installed = VirtueMartModelConfig::checkVirtuemartInstalled(); if ($installed) { VirtueMartModelConfig::installVMconfigTable(); $confData = array(); $confData['virtuemart_config_id'] = 1; $confData['config'] = VmConfig::$_jpConfig->toString(); $confTable = VmTable::getInstance('configs', 'Table', array()); if (!$confTable->bindChecknStore($confData)) { vmError('storeConfig was not able to store config'); } } else { self::$_virtuemart_vendor_id = 1; } } }
/** * Check if an item is checked out * * This function can be used as a static function too, when you do so you need to also provide the * a value for the $against parameter. * * @static * @access public * @param integer $with The userid to preform the match with, if an item is checked out * by this user the function will return false * @param integer $against The userid to perform the match against when the function is used as * a static function. * @return boolean */ function isCheckedOut($with = 0, $against = null) { if (isset($this) && is_a($this, 'VmTable') && is_null($against)) { $against = $this->get('locked_by'); } //item is not checked out, or being checked out by the same user if (!$against || $against == $with) { return false; } $session = VmTable::getInstance('session'); return $session->exists($against); }
/** * Method to load and return a model object. * * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE * * @param string $name The name of the view * @param string $prefix The class prefix. Optional. * @param array $config Configuration settings to pass to JTable::getInstance * * @return mixed Model object or boolean false if failed * * @since 11.1 * @see JTable::getInstance */ protected function _createTable($name, $prefix = 'Table', $config = array()) { // Clean the model name $name = preg_replace('/[^A-Z0-9_]/i', '', $name); $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); // Make sure we are returning a DBO object if (!array_key_exists('dbo', $config)) { $config['dbo'] = JFactory::getDbo(); } return VmTable::getInstance($name, $prefix, $config); }
/** * */ private function migratecomplete($uuid) { if (empty($uuid)) { JFactory::getApplication()->redirect('/'); } $exists = false; $merchant = $this->app['merchant.provider']->getMerchant(); $event = new Expressly\Event\CustomerMigrateEvent($merchant, $uuid); try { $this->app['dispatcher']->dispatch(\Expressly\Subscriber\CustomerMigrationSubscriber::CUSTOMER_MIGRATE_DATA, $event); $json = $event->getContent(); if (!$event->isSuccessful()) { if (!empty($json['code']) && $json['code'] == 'USER_ALREADY_MIGRATED') { $exists = true; } throw new \Expressly\Exception\UserExistsException(ExpresslyHelper::error_formatter($event)); } $email = $json['migration']['data']['email']; $user = ExpresslyHelper::get_user_by_email($email); if (null === $user) { $customer = $json['migration']['data']['customerData']; $model = JModelLegacy::getInstance('Registration', 'UsersModel', array('ignore_request' => true)); $user_id = $model->register(['name' => $customer['firstName'] . ' ' . $customer['lastName'], 'username' => 'user' . time() . rand(1000, 9999), 'email1' => $email, 'password1' => JUserHelper::genRandomPassword()]); if (isset($customer['billingAddress'])) { $userInfo = VmTable::getInstance('userinfos', 'Table', array('dbo' => JFactory::getDbo())); $userInfo->bindChecknStore(array_merge(array('virtuemart_userinfo_id' => 0, 'virtuemart_user_id' => $user_id, 'address_type' => 'BT'), $this->parse_address($customer['addresses'][$customer['billingAddress']], $customer))); } if (isset($customer['shippingAddress'])) { $userInfo = VmTable::getInstance('userinfos', 'Table', array('dbo' => JFactory::getDbo())); $userInfo->bindChecknStore(array_merge(array('virtuemart_userinfo_id' => 0, 'virtuemart_user_id' => $user_id, 'address_type' => 'ST'), $this->parse_address($customer['addresses'][$customer['shippingAddress']], $customer))); } // TODO: Need to do programmatically authorize here (if some way exists for Joomla!) } else { $exists = true; $event = new \Expressly\Event\CustomerMigrateEvent($merchant, $uuid, \Expressly\Event\CustomerMigrateEvent::EXISTING_CUSTOMER); } // ************************************* // * Add items (product/coupon) to cart // ************************************* if (!empty($json['cart'])) { if (!class_exists('VirtueMartCart')) { require_once JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); if (!empty($json['cart']['productId'])) { $cartProductsData = array(); $cartProductsData[intval($json['cart']['productId'])] = array('virtuemart_product_id' => intval($json['cart']['productId']), 'quantity' => 1); $cart->cartProductsData = $cartProductsData; } if (!empty($json['cart']['couponCode'])) { $cart->setCouponCode(strval($json['cart']['couponCode'])); } $cart->setCartIntoSession(); } $this->app['dispatcher']->dispatch(\Expressly\Subscriber\CustomerMigrationSubscriber::CUSTOMER_MIGRATE_SUCCESS, $event); } catch (\Exception $e) { $this->app['logger']->error(\Expressly\Exception\ExceptionFormatter::format($e)); } if ($exists) { $session = JFactory::getSession(); $session->set('__xly', array('action' => 'exists')); } JFactory::getApplication()->redirect('/'); }