/** * Retrieve the detail record for the current $id if the data has not already been loaded. * * @author RickG */ function getShipment() { if (empty($this->_data[$this->_id])) { $this->_data[$this->_id] = $this->getTable('shipmentmethods'); $this->_data[$this->_id]->load((int) $this->_id); if (empty($this->_data[$this->_id]->virtuemart_vendor_id)) { if (!class_exists('VirtueMartModelVendor')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'; } $this->_data[$this->_id]->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor(); } if ($this->_data[$this->_id]->shipment_jplugin_id) { JPluginHelper::importPlugin('vmshipment'); $dispatcher = JDispatcher::getInstance(); $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsShipment', array($this->_data[$this->_id]->shipment_element, $this->_data[$this->_id]->shipment_jplugin_id, &$this->_data[$this->_id])); } if ($this->_data[$this->_id]->getCryptedFields()) { if (!class_exists('vmCrypt')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmcrypt.php'; } if (isset($this->_data[$this->_id]->modified_on)) { $date = JFactory::getDate($this->_data[$this->_id]->modified_on); $date = $date->toUnix(); } else { $date = 0; } foreach ($this->_data[$this->_id]->getCryptedFields() as $field) { if (isset($this->_data[$this->_id]->{$field})) { $this->_data[$this->_id]->{$field} = vmCrypt::decrypt($this->_data[$this->_id]->{$field}, $date); } } } // vmdebug('$$this->_data getShipment',$this->_data); //if(!empty($this->_id)){ /* Add the shipmentcarreir shoppergroups */ $q = 'SELECT `virtuemart_shoppergroup_id` FROM #__virtuemart_shipmentmethod_shoppergroups WHERE `virtuemart_shipmentmethod_id` = "' . $this->_id . '"'; $this->_db->setQuery($q); $this->_data[$this->_id]->virtuemart_shoppergroup_ids = $this->_db->loadResultArray(); # if (empty($this->_data[$this->_id]->virtuemart_shoppergroup_ids)) { $this->_data[$this->_id]->virtuemart_shoppergroup_ids = 0; } //} } return $this->_data[$this->_id]; }
/** * Todo, works only for small stores, we need a new solution there with a bit filtering * For example by time, if already shopper, and a simple search * @return object list of users */ function getUserList() { $cart = $this->cart; $result = false; if ($this->allowChangeShopper) { $this->adminID = JFactory::getSession()->get('vmAdminID', false); if ($this->adminID) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $this->adminID = vmCrypt::decrypt($this->adminID); } $superVendor = VmConfig::isSuperVendor($this->adminID); if ($superVendor) { $uModel = VmModel::getModel('user'); $result = $uModel->getSwitchUserList($superVendor, $this->adminID); } } //vmdebug('my user list ',$result); if (!$result) { $this->allowChangeShopper = false; } return $result; }
public static function getFormToken($fNew = false) { $sess = JFactory::getSession(); $user = JFactory::getUser(); if (empty($user->id)) { $user->id = 0; } if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $token = $sess->get('session.token'); if ($token === null || $fNew) { $token = vmCrypt::getToken(); $sess->set('session.token', $token); } $hash = self::getHash($user->id . $token); return $hash; }
/** * Save the user info. The saveData function don't use the userModel store function for anonymous shoppers, because it would register them. * We make this function private, so we can do the tests in the tasks. * * @author Max Milbers * @author Valérie Isaksen * * @param boolean Defaults to false, the param is for the userModel->store function, which needs it to determine how to handle the data. * @return String it gives back the messages. */ private function saveData($cartObj) { $mainframe = JFactory::getApplication(); $msg = ''; $data = vRequest::getPost(FILTER_SANITIZE_STRING); $register = isset($_REQUEST['register']); $userModel = VmModel::getModel('user'); $currentUser = JFactory::getUser(); if (empty($data['address_type'])) { $data['address_type'] = vRequest::getCmd('addrtype', 'BT'); } if ($cartObj) { if ($cartObj->_fromCart or $cartObj->getInCheckOut()) { if (!class_exists('VirtueMartCart')) { require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); $prefix = ''; if ($data['address_type'] == 'STaddress' || $data['address_type'] == 'ST') { $prefix = 'shipto_'; vmdebug('Storing user ST prefix ' . $prefix); } $cart->saveAddressInCart($data, $data['address_type'], true, $prefix); } } if (isset($data['vendor_accepted_currencies'])) { // Store multiple selectlist entries as a ; separated string if (array_key_exists('vendor_accepted_currencies', $data) && is_array($data['vendor_accepted_currencies'])) { $data['vendor_accepted_currencies'] = implode(',', $data['vendor_accepted_currencies']); } $data['vendor_store_name'] = vRequest::getHtml('vendor_store_name'); $data['vendor_store_desc'] = vRequest::getHtml('vendor_store_desc'); $data['vendor_terms_of_service'] = vRequest::getHtml('vendor_terms_of_service'); $data['vendor_letter_css'] = vRequest::getHtml('vendor_letter_css'); $data['vendor_letter_header_html'] = vRequest::getHtml('vendor_letter_header_html'); $data['vendor_letter_footer_html'] = vRequest::getHtml('vendor_letter_footer_html'); } if ($data['address_type'] == 'ST' and !$currentUser->guest) { $ret = $userModel->storeAddress($data); if ($cartObj and !empty($ret)) { $cartObj->selected_shipto = $ret; $cartObj->setCartIntoSession(); } } else { if ($currentUser->guest == 1 and ($register or !$cartObj)) { if ($this->checkCaptcha('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT') == FALSE) { $msg = vmText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL'); if ($cartObj and $cartObj->_fromCart) { $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT'), $msg); } else { if ($cartObj and $cartObj->getInCheckOut()) { $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscheckout&addrtype=BT'), $msg); } else { $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=edit&addrtype=BT'), $msg); } } return $msg; } } if ($currentUser->guest != 1 or !$cartObj or $currentUser->guest == 1 and $register) { $switch = false; if ($currentUser->guest == 1 and $register) { $userModel->setId(0); $adminID = JFactory::getSession()->get('vmAdminID', false); if ($adminID) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $adminID = vmCrypt::decrypt($adminID); $adminIdUser = JFactory::getUser($adminID); if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) { $superUser = VmConfig::isSuperVendor($adminID); if ($superUser > 1) { $data['vendorId'] = $superUser; } $switch = true; } } } if (!class_exists('VirtueMartCart')) { require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); if (!empty($cart->vendorId) and $cart->vendorId != 1) { $data['vendorId'] = $cart->vendorId; } $ret = $userModel->store($data); if ($switch) { //and VmConfig::get ('oncheckout_change_shopper')){ //update session $current = JFactory::getUser($ret['newId']); $session = JFactory::getSession(); $session->set('user', $current); } } if ($currentUser->guest == 1 and ($register or !$cartObj)) { $msg = is_array($ret) ? $ret['message'] : $ret; $usersConfig = JComponentHelper::getParams('com_users'); $useractivation = $usersConfig->get('useractivation'); if (is_array($ret) and $ret['success'] and !$useractivation) { // Username and password must be passed in an array $credentials = array('username' => $ret['user']->username, 'password' => $ret['user']->password_clear); $return = $mainframe->login($credentials); } else { if (VmConfig::get('oncheckout_only_registered', 0)) { $layout = vRequest::getCmd('layout', 'edit'); $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&layout=' . $layout, FALSE), $msg); } } } } return $msg; }
/** * Derived from JTable * Records in this table do not need to exist, so we might need to create a record even * if the primary key is set. Therefore we need to overload the store() function. * Technic to inject params as table attributes and to encrypt data * @author Max Milbers * @copyright for derived parts, (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @see libraries/joomla/database/JTable#store($updateNulls) */ function store($updateNulls = false) { $this->setLoggableFieldsForStore(); if ($this->_cryptedFields) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } foreach ($this->_cryptedFields as $field) { if (isset($this->{$field})) { $this->{$field} = vmCrypt::encrypt($this->{$field}); } } } $this->storeParams(); if (!empty($this->asset_id)) { $currentAssetId = $this->asset_id; } // The asset id field is managed privately by this class. if ($this->_trackAssets) { unset($this->asset_id); } $tblKey = $this->_tbl_key; if (!empty($this->{$tblKey})) { $_qry = 'SELECT `' . $tblKey . '` ' . 'FROM `' . $this->_tbl . '` ' . 'WHERE `' . $tblKey . '` = "' . $this->{$tblKey} . '" '; $this->_db->setQuery($_qry); $this->{$tblKey} = $this->_db->loadResult(); } if (!empty($this->{$tblKey})) { $ok = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); } else { $ok = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); } //reset Params if (isset($this->_tmpParams) and is_array($this->_tmpParams)) { foreach ($this->_tmpParams as $k => $v) { $this->{$k} = $v; } } $this->_tmpParams = false; // If the store failed return false. if (!$ok) { $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $this->_db->getErrorMsg())); vmError($e); return false; } // If the table is not set to track assets return true. if (!$this->_trackAssets) { return true; } if ($this->_locked) { $this->_unlock(); } $parentId = $this->_getAssetParentId(); $name = $this->_getAssetName(); $title = $this->_getAssetTitle(); $asset = JTable::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo())); $asset->loadByName($name); // Re-inject the asset id. $this->asset_id = $asset->id; // Check for an error. if ($error = $asset->getError()) { vmError($error); return false; } // Specify how a new or moved node asset is inserted into the tree. if (empty($this->asset_id) || $asset->parent_id != $parentId) { $asset->setLocation($parentId, 'last-child'); } // Prepare the asset to be stored. $asset->parent_id = $parentId; $asset->name = $name; $asset->title = $title; if ($this->_rules instanceof JAccessRules) { $asset->rules = (string) $this->_rules; } if (!$asset->check() || !$asset->store($updateNulls)) { vmError($asset->getError()); return false; } // Create an asset_id or heal one that is corrupted. if (empty($this->asset_id) || $currentAssetId != $this->asset_id && !empty($this->asset_id)) { // Update the asset_id field in this table. $this->asset_id = (int) $asset->id; $query = $this->_db->getQuery(true); $query->update($this->_db->quoteName($this->_tbl)); $query->set('asset_id = ' . (int) $this->asset_id); $query->where($this->_db->quoteName($tblKey) . ' = ' . (int) $this->{$tblKey}); $this->_db->setQuery($query); if (!$this->_db->execute()) { $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED_UPDATE_ASSET_ID', $this->_db->getErrorMsg())); vmError($e); return false; } } return $ok; }
function getMd($cryptedMd) { if (!class_exists('vmCrypt')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmCrypt.php'; } $decryptedMd = vmCrypt::decrypt($cryptedMd); $md = unserialize($decryptedMd); return $md; }
function _getAuthorizeNetFromSession() { if (!class_exists('vmCrypt')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmcrypt.php'; } $session = JFactory::getSession(); $authorizenetSession = $session->get('authorizenet', 0, 'vm'); if (!empty($authorizenetSession)) { $authorizenetData = (object) json_decode($authorizenetSession, true); $this->_cc_type = $authorizenetData->cc_type; $this->_cc_number = vmCrypt::decrypt($authorizenetData->cc_number); $this->_cc_cvv = vmCrypt::decrypt($authorizenetData->cc_cvv); $this->_cc_expire_month = $authorizenetData->cc_expire_month; $this->_cc_expire_year = $authorizenetData->cc_expire_year; $this->_cc_valid = $authorizenetData->cc_valid; } }
/** * This function is called, when the order is confirmed by the shopper. * * Here are the last checks done by payment plugins. * The mails are created and send to vendor and shopper * will show the orderdone page (thank you page) * */ function confirmedOrder() { //Just to prevent direct call if ($this->_dataValidated && $this->_confirmDone and !$this->_inCheckOut) { if ($this->_inConfirm) { vmdebug('Already in CONFIRM,.. RETURN'); return false; } //We set this in the trigger of the plugin. so old plugins keep the old behaviour //$this->_inConfirm = true; //$this->setCartIntoSession(); //session_write_close(); //session_start(); $orderModel = VmModel::getModel('orders'); if (($this->virtuemart_order_id = $orderModel->createOrderFromCart($this)) === false) { $mainframe = JFactory::getApplication(); JError::raiseWarning(500, 'No order created ' . $orderModel->getError()); $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE)); } $orderDetails = $orderModel->getMyOrderDetails($this->virtuemart_order_id); if (!$orderDetails or empty($orderDetails['details'])) { echo JText::_('COM_VIRTUEMART_CART_ORDER_NOTFOUND'); return; } $orderModel->notifyCustomer($this->virtuemart_order_id, $orderDetails); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('vmcalculation'); JPluginHelper::importPlugin('vmcustom'); JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $returnValues = $dispatcher->trigger('plgVmConfirmedOrder', array($this, $orderDetails)); $lifetime = 24 * 60 * 60 * 180; //180 days if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } foreach ($orderDetails['items'] as $product) { //We set a cookie for guests to allow that they can rate/review a product without logging in. $app = JFactory::getApplication(); $key = 'productBought' . $product->virtuemart_product_id; $v = vmCrypt::encrypt($key); $app->input->cookie->set($key, $v, time() + $lifetime, '/'); } // may be redirect is done by the payment plugin (eg: paypal) // if payment plugin echos a form, false = nothing happen, true= echo form , // 1 = cart should be emptied, 0 cart should not be emptied $this->_inConfirm = false; $this->setCartIntoSession(); session_write_close(); session_start(); return $this->virtuemart_order_id; } return NULL; }
/** * 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); }
/** * Checks if user is admin or has vendorId=1, * if superadmin, but not a vendor it gives back vendorId=1 (single vendor, but multiuser administrated) * * @author Mattheo Vicini * @author Max Milbers */ public static function isSuperVendor($adminId = null) { if (!isset(self::$_virtuemart_vendor_id[$adminId])) { self::$_virtuemart_vendor_id[$adminId] = 0; if (empty($adminId)) { $adminId = JFactory::getSession()->get('vmAdminID', null); if ($adminId) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $adminId = vmCrypt::decrypt($adminId); } $user = JFactory::getUser($adminId); } else { $user = JFactory::getUser($adminId); } if (!empty($user->id)) { $q = 'SELECT `virtuemart_vendor_id` FROM `#__virtuemart_vmusers` `au` WHERE `au`.`virtuemart_user_id`="' . $user->id . '" AND `au`.`user_is_vendor` = "1" '; $db = JFactory::getDbo(); $db->setQuery($q); $virtuemart_vendor_id = $db->loadResult(); if ($virtuemart_vendor_id) { self::$_virtuemart_vendor_id[$adminId] = $virtuemart_vendor_id; } else { if ($user->authorise('core.admin', 'com_virtuemart') or self::get('multix', 'none') == 'none' and $user->authorise('core.manage', 'com_virtuemart')) { self::$_virtuemart_vendor_id[$adminId] = 1; } } } if (empty(self::$_virtuemart_vendor_id[$adminId])) { vmdebug('Not a vendor'); } } return self::$_virtuemart_vendor_id[$adminId]; }
function getMd($cryptedMd) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $decryptedMd = vmCrypt::decrypt($cryptedMd); $md = json_decode($decryptedMd, true); return $md; }
public static function isFEmanager($task = null) { $adminId = JFactory::getSession()->get('vmAdminID', null); if ($adminId) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $adminId = vmCrypt::decrypt($adminId); } $user = JFactory::getUser($adminId); if ($user->authorise('vm.manage', 'com_virtuemart') or $user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart')) { if (isset($task)) { if ($user->authorise($task, 'com_virtuemart')) { return $user->id; } } else { return $user->id; } } return false; }
public function save() { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $session = JFactory::getSession(); $sessionData = new stdClass(); $sessionData->selected_method = $this->_selected_method; // card information $sessionData->cc_type = $this->_cc_type; $sessionData->cc_number = vmCrypt::encrypt($this->_cc_number); $sessionData->cc_cvv = vmCrypt::encrypt($this->_cc_cvv); $sessionData->cc_expire_month = $this->_cc_expire_month; $sessionData->cc_expire_year = $this->_cc_expire_year; $sessionData->cc_valid = $this->_cc_valid; //Customer settings $sessionData->autobilling_max_amount = $this->_autobilling_max_amount; //PayPal Express $sessionData->token = $this->_token; $sessionData->payer_id = $this->_payer_id; $sessionData->first_name = $this->_first_name; $sessionData->last_name = $this->_last_name; $sessionData->payer_email = $this->_payer_email; // $sessionData->txn_id = $this->_txn_id; // $sessionData->txn_type = $this->_txn_type; // $sessionData->payment_status = $this->_payment_status; // $sessionData->pending_reason = $this->_pending_reason; $session->set('paypal', json_encode($sessionData), 'vm'); }
function check() { if (empty($this->order_number)) { if (!class_exists('VirtueMartModelOrders')) { require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php'; } $this->order_number = VirtueMartModelOrders::generateOrderNumber((string) time()); } if (empty($this->order_pass)) { $this->order_pass = '******' . substr(md5((string) time() . $this->order_number), 0, 5); } $adminID = JFactory::getSession()->get('vmAdminID', false); if ($adminID) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $adminID = vmCrypt::decrypt($adminID); $this->created_by = $adminID; } return parent::check(); }
private function getRetourParams($cryptedParams) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $cryptedParams = base64_decode($cryptedParams); $params = vmCrypt::decrypt($cryptedParams); $paramsArray = explode(":", $params); $retourParams['virtuemart_paymentmethod_id'] = $paramsArray[0]; $retourParams['order_number'] = $paramsArray[1]; $retourParams['context'] = $paramsArray[2]; return $retourParams; }
public function manager($view = 0) { if (empty($view)) { $view = $this->_name; } if (!isset(self::$_manager[$view])) { if (JFactory::getApplication()->isSite()) { $adminId = JFactory::getSession()->get('vmAdminID', null); if ($adminId) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $adminId = vmCrypt::decrypt($adminId); } $user = JFactory::getUser($adminId); $vendorIdUser = VmConfig::isSuperVendor($user->id); } else { $user = JFactory::getUser(); } if ($user->authorise('core.admin') or $user->authorise('core.admin', 'com_virtuemart') or ($user->authorise('core.manage', 'com_virtuemart') or $user->authorise('vm.manage', 'com_virtuemart')) and $user->authorise('vm.' . $view, 'com_virtuemart')) { self::$_manager[$view] = true; } else { self::$_manager[$view] = false; } } return self::$_manager[$view]; }
/** * Retrieve the detail record for the current $id if the data has not already been loaded. * * @author RickG */ function getShipment($id = 0) { if (!empty($id)) { $this->_id = (int) $id; } if (empty($this->_cache[$this->_id])) { $this->_cache[$this->_id] = $this->getTable('shipmentmethods'); $this->_cache[$this->_id]->load((int) $this->_id); if (empty($this->_cache[$this->_id]->virtuemart_vendor_id)) { if (!class_exists('VirtueMartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->_cache[$this->_id]->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor(); } if ($this->_cache[$this->_id]->shipment_jplugin_id) { JPluginHelper::importPlugin('vmshipment'); $dispatcher = JDispatcher::getInstance(); $blind = 0; $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsShipmentVM3', array(&$this->_cache[$this->_id])); } if (!empty($this->_cache[$this->_id]->_varsToPushParam)) { VmTable::bindParameterable($this->_cache[$this->_id], 'shipment_params', $this->_cache[$this->_id]->_varsToPushParam); } //We still need this, because the table is already loaded, but the keys are set later if ($this->_cache[$this->_id]->getCryptedFields()) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } if (isset($this->_cache[$this->_id]->modified_on)) { $date = JFactory::getDate($this->_cache[$this->_id]->modified_on); $date = $date->toUnix(); } else { $date = 0; } foreach ($this->_cache[$this->_id]->getCryptedFields() as $field) { if (isset($this->_cache[$this->_id]->{$field})) { $this->_cache[$this->_id]->{$field} = vmCrypt::decrypt($this->_cache[$this->_id]->{$field}, $date); } } } /* Add the shipmentcarreir shoppergroups */ $q = 'SELECT `virtuemart_shoppergroup_id` FROM #__virtuemart_shipmentmethod_shoppergroups WHERE `virtuemart_shipmentmethod_id` = "' . $this->_id . '"'; $this->_db->setQuery($q); $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = $this->_db->loadColumn(); if (empty($this->_cache[$this->_id]->virtuemart_shoppergroup_ids)) { $this->_cache[$this->_id]->virtuemart_shoppergroup_ids = 0; } } return $this->_cache[$this->_id]; }
/** * Decides if the rating/review should be shown on the FE * @author Max Milbers */ private function show($product_id, $show) { //dont show if ($show == 'none') { return false; } else { if ($show == 'all') { return true; } else { if ($show == 'registered') { $user = JFactory::getUser(); return !empty($user->id); } else { if ($show == 'bought') { if (empty($product_id)) { return false; } if (isset($this->_productBought[$product_id])) { return $this->_productBought[$product_id]; } if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $key = vmCrypt::encrypt('productBought' . $product_id); $count = JFactory::getApplication()->input->cookie->getString($key, false); if ($count) { //check, somehow broken, atm $v = vmCrypt::encrypt($key); if ($v != $count) { $count = false; } } if (!$count) { $user = JFactory::getUser(); $rr_os = VmConfig::get('rr_os', array('C')); if (!is_array($rr_os)) { $rr_os = array($rr_os); } $db = JFactory::getDBO(); $q = 'SELECT COUNT(*) as total FROM `#__virtuemart_orders` AS o LEFT JOIN `#__virtuemart_order_items` AS oi '; $q .= 'ON `o`.`virtuemart_order_id` = `oi`.`virtuemart_order_id` '; $q .= 'WHERE o.virtuemart_user_id > 0 AND o.virtuemart_user_id = "' . $user->id . '" AND oi.virtuemart_product_id = "' . $product_id . '" '; $q .= 'AND o.order_status IN (\'' . implode("','", $rr_os) . '\') '; $db->setQuery($q); $count = $db->loadResult(); } if ($count) { $this->_productBought[$product_id] = true; return true; } else { $this->_productBought[$product_id] = false; return false; } } } } } }
public static function getBgManagerId() { if (!isset(self::$_cuId)) { $cuId = JFactory::getSession()->get('vmAdminID', null); //echo $cuId; if ($cuId) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $cuId = vmCrypt::decrypt($cuId); if (empty($cuId)) { $cuId = null; } } self::$_cuId = $cuId; } return self::$_cuId; }
function createInvoiceNumber($orderDetails, &$invoiceNumber) { $orderDetails = (array) $orderDetails; $db = JFactory::getDBO(); if (!isset($orderDetails['virtuemart_order_id'])) { vmWarn('createInvoiceNumber $orderDetails has no virtuemart_order_id ', $orderDetails); vmdebug('createInvoiceNumber $orderDetails has no virtuemart_order_id ', $orderDetails); } $q = 'SELECT * FROM `#__virtuemart_invoices` WHERE `virtuemart_order_id`= "' . $orderDetails['virtuemart_order_id'] . '" '; // AND `order_status` = "'.$orderDetails->order_status.'" '; $db->setQuery($q); $result = $db->loadAssoc(); if (!class_exists('ShopFunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } if (!$result or empty($result['invoice_number'])) { $data['virtuemart_order_id'] = $orderDetails['virtuemart_order_id']; $data['order_status'] = $orderDetails['order_status']; $data['virtuemart_vendor_id'] = $orderDetails['virtuemart_vendor_id']; JPluginHelper::importPlugin('vmshopper'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); // plugin returns invoice number, 0 if it does not want an invoice number to be created by Vm $plg_datas = $dispatcher->trigger('plgVmOnUserInvoice', array($orderDetails, &$data)); if (!isset($data['invoice_number'])) { // check the default configuration $orderstatusForInvoice = VmConfig::get('inv_os', array('C')); if (!is_array($orderstatusForInvoice)) { $orderstatusForInvoice = array($orderstatusForInvoice); } //for backward compatibility 2.0.8e $pdfInvoice = (int) VmConfig::get('pdf_invoice', 0); // backwards compatible $force_create_invoice = vRequest::getCmd('create_invoice', -1); // florian : added if pdf invoice are enabled if (in_array($orderDetails['order_status'], $orderstatusForInvoice) or $pdfInvoice == 1 or $force_create_invoice == $orderDetails['order_create_invoice_pass']) { $q = 'SELECT COUNT(1) FROM `#__virtuemart_invoices` WHERE `virtuemart_vendor_id`= "' . $orderDetails['virtuemart_vendor_id'] . '" '; // AND `order_status` = "'.$orderDetails->order_status.'" '; $db->setQuery($q); $count = $db->loadResult() + 1; if (empty($data['invoice_number'])) { $date = date("Y-m-d"); if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $data['invoice_number'] = str_replace('-', '', substr($date, 2, 8)) . vmCrypt::getHumanToken(4) . '0' . $count; } } else { return false; } } $table = $this->getTable('invoices'); $table->bindChecknStore($data); $invoiceNumber = array($table->invoice_number, $table->created_on); } elseif (ShopFunctions::InvoiceNumberReserved($result['invoice_number'])) { $invoiceNumber = array($result['invoice_number'], $result['created_on']); return true; } else { $invoiceNumber = array($result['invoice_number'], $result['created_on']); } return true; }
/** * Technic to inject params as table attributes * @author Max Milbers */ function store($updateNulls = false) { $this->setLoggableFieldsForStore(); if ($this->_cryptedFields) { if (!class_exists('vmCrypt')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmcrypt.php'; } vmdebug('my crytped fields in store ' . get_class($this), $this->_cryptedFields); foreach ($this->_cryptedFields as $field) { if (isset($this->{$field})) { $this->{$field} = vmCrypt::encrypt($this->{$field}); } else { vmdebug('Store vmtable empty property for ' . $field); } } } $this->storeParams(); return parent::store($updateNulls); }
public static function isFEmanager($task = FALSE) { static $c = array(); if (!isset($c[$task])) { $c[$task] = false; $adminId = JFactory::getSession()->get('vmAdminID', null); if ($adminId) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $adminId = vmCrypt::decrypt($adminId); } $user = JFactory::getUser($adminId); if ($user->authorise('vm.manage', 'com_virtuemart') or $user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart')) { if (!empty($task)) { if ($user->authorise($task, 'com_virtuemart')) { $c[$task] = $user->id; } } else { $c[$task] = $user->id; } } } vmdebug('isFEmanager return ' . $c[$task], $c); return $c[$task]; }