/** * 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); }
function save($data = 0) { if($data===0)$data = vRequest::getPost(); $data['custom_desc'] = vRequest::getHtml('custom_desc'); $data['custom_value'] = vRequest::getHtml('custom_value'); $data['layout_pos'] = vRequest::getCmd('layout_pos'); if(isset($data['params'])){ $data['params'] = vRequest::getHtml('params',''); } // onSaveCustom plugin; parent::save($data); }
/** * 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); }
function save($data = 0) { $data = vRequest::getPost(); if (vmAccess::manager('raw')) { $data['payment_name'] = vRequest::get('payment_name', ''); $data['payment_desc'] = vRequest::get('payment_desc', ''); if (isset($data['params'])) { $data['params'] = vRequest::get('params', ''); } } else { $data['payment_name'] = vRequest::getHtml('payment_name', ''); $data['payment_desc'] = vRequest::getHtml('payment_desc', ''); if (isset($data['params'])) { $data['params'] = vRequest::getHtml('params', ''); } } parent::save($data); }
function save($data = 0) { $data = vRequest::getPost(); $user = JFactory::getUser(); if ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart')) { $data['payment_name'] = vRequest::get('payment_name', ''); $data['payment_desc'] = vRequest::get('payment_desc', ''); if (isset($data['params'])) { $data['params'] = vRequest::get('params', ''); } } else { $data['payment_name'] = vRequest::getHtml('payment_name', ''); $data['payment_desc'] = vRequest::getHtml('payment_desc', ''); if (isset($data['params'])) { $data['params'] = vRequest::getHtml('params', ''); } } parent::save($data); }
function save($data = 0) { if ($data === 0) { $data = vRequest::getPost(); } if (vmAccess::manager('raw')) { $data['description'] = vRequest::get('description', ''); if (isset($data['params'])) { $data['params'] = vRequest::get('params', ''); } } else { $data['description'] = vRequest::getHtml('description', ''); if (isset($data['params'])) { $data['params'] = vRequest::getHtml('params', ''); } } $data['name'] = vRequest::getCmd('name'); // onSaveCustom plugin; parent::save($data); }
function save($data = 0) { if($data===0) $data = vRequest::getPost(); $user = JFactory::getUser(); if($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart')){ $data['description'] = vRequest::get('description',''); if(isset($data['params'])){ $data['params'] = vRequest::get('params',''); } } else { $data['description'] = vRequest::getHtml('description',''); if(isset($data['params'])){ $data['params'] = vRequest::getHtml('params',''); } } $data['name'] = vRequest::getCmd('name'); // onSaveCustom plugin; parent::save($data); }
/** * 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); }
private function handleRedirect() { $realex_data = vRequest::getPost(); $this->debugLog('plgVmOnPaymentNotification :' . var_export($realex_data, true), 'debug'); if (!isset($realex_data['ORDER_ID'])) { return false; } $order_number = $realex_data['ORDER_ID']; if (empty($order_number)) { return FALSE; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) { return FALSE; } if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) { return FALSE; } $orderModel = VmModel::getModel('orders'); $order = $orderModel->getOrder($virtuemart_order_id); $this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id); if (!$this->selectedThisElement($this->_currentMethod->payment_element)) { //echo "selectedThisElement PB"; return FALSE; } $realexInterface = $this->_loadRealexInterface(); if (!$realexInterface->validateResponseHash($realex_data)) { $this->returnToVm($realex_data, false, $order['details']['BT']->virtuemart_paymentmethod_id); return FALSE; } $result = $realex_data['RESULT']; $realexInterface->setOrder($order); //$cart = VirtueMartCart::getCart(); //$realexInterface->setCart($cart, false); $order_history = array(); $success = $result == $realexInterface::RESPONSE_CODE_SUCCESS; if ($success) { $status = $this->_currentMethod->status_success; $amountInCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $order['details']['BT']->order_currency); //$currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency); $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CONFIRMED', $amountInCurrency['display'], $order_number); if (isset($realex_data['DCCCHOICE']) and $realex_data['DCCCHOICE'] == $realexInterface::RESPONSE_DCC_CHOICE_YES) { $order_history['comments'] .= "<br />"; $order_history['comments'] .= vmText::sprintf('VMPAYMENT_REALEX_HPP_API_DCC_PAY_OWN_CURRENCY_CHARGED', $this->getCardHolderAmount($realex_data['DCCMERCHANTAMOUNT']), $realex_data['DCCMERCHANTCURRENCY'], $this->getCardHolderAmount($realex_data['DCCCARDHOLDERAMOUNT']), $realex_data['DCCCARDHOLDERCURRENCY']); } $userfield = $realexInterface->cardStorageResponse($realex_data); $realexInterface->storeNewPayment($userfield); if (isset($realex_data['REALWALLET_CHOSEN']) and $realex_data['REALWALLET_CHOSEN'] == 1) { if ($userfield) { $cardStorageResponseText = vmText::_('VMPAYMENT_REALEX_HPP_API_CARD_STORAGE_SUCCESS'); } else { $cardStorageResponseText = vmText::_('VMPAYMENT_REALEX_HPP_API_CARD_STORAGE_FAILED'); } $order_history['comments'] .= "<br />"; $order_history['comments'] .= $cardStorageResponseText; } } else { /** * Note: If a transaction is processed through your account that triggers one of the scenarios that you have set up to reject, * HPP will send a post back to your response script with a Result Code of 110 and a relevant error message. The transaction will not be processed. */ $order_history['comments'] = vmText::_('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CANCELLED'); // here we check if wee need to add the message /* if ($realex_data['RESULT'] == (int)$realexInterface::RESPONSE_CODE_NOT_VALIDATED) { $order_history['comments'] .= "<br />"; $order_history['comments'] .= $realex_data['MESSAGE']; } */ $status = $this->_currentMethod->status_canceled; } $order_history['customer_notified'] = true; $order_history['order_status'] = $status; $db_values['payment_name'] = $this->renderPluginName($this->_currentMethod, 'order'); $db_values['virtuemart_order_id'] = $virtuemart_order_id; $db_values['order_number'] = $order_number; $db_values['virtuemart_paymentmethod_id'] = $this->_currentMethod->virtuemart_paymentmethod_id; $db_values['realex_hpp_api_response_result'] = $realex_data['RESULT']; $db_values['realex_hpp_api_request_type_response'] = $realexInterface::REQUEST_TYPE_AUTH; $db_values['realex_hpp_api_response_pasref'] = isset($realex_data['PASREF']) ? $realex_data['PASREF'] : ""; $db_values['realex_hpp_api_response_authcode'] = isset($realex_data['AUTHCODE']) ? $realex_data['AUTHCODE'] : ""; $db_values['realex_hpp_api_fullresponse'] = json_encode($realex_data); $db_values['realex_hpp_api_fullresponse_format'] = 'json'; $this->storePSPluginInternalData($db_values); $modelOrder = VmModel::getModel('orders'); $modelOrder->updateStatusForOneOrder($virtuemart_order_id, $order_history, TRUE); if ($result == $realexInterface::RESPONSE_CODE_SUCCESS) { if (isset($payments[0]->realex_hpp_api_custom)) { $this->emptyCart($payments[0]->realex_hpp_api_custom, $order_number); } } //$this->displayMessageToRealex($realexInterface, $realex_data, $success, $order_history['comments'], $payments[0]->virtuemart_paymentmethod_id); $this->returnToVm($realex_data, $success, $order['details']['BT']->virtuemart_paymentmethod_id); }
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); }
/** * Check the Joomla ReCaptcha Plg * * @author Maik Künnemann */ function checkCaptcha($retUrl) { if (JFactory::getUser()->guest == 1 and VmConfig::get('reg_captcha')) { $recaptcha = vRequest::getVar('recaptcha_response_field'); JPluginHelper::importPlugin('captcha'); $dispatcher = JDispatcher::getInstance(); $res = $dispatcher->trigger('onCheckAnswer', $recaptcha); if (!$res[0]) { $data = vRequest::getPost(); $data['address_type'] = vRequest::getVar('addrtype', 'BT'); 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_'; } $cart->saveAddressInCart($data, $data['address_type'], true, $prefix); $errmsg = vmText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL'); $this->setRedirect(JRoute::_($retUrl . '&captcha=1', FALSE), $errmsg); return FALSE; } else { return TRUE; } } else { return TRUE; } }
/** * Notify customer * * @author Seyi Awofadeju */ public function notifycustomer() { $data = vRequest::getPost(); $model = VmModel::getModel('waitinglist'); if (!$model->adduser($data)) { $errors = $model->getErrors(); foreach ($errors as $error) { $msg = $error . '<br />'; } $this->setRedirect(JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $data['virtuemart_product_id'], FALSE), $msg); } else { $msg = vmText::sprintf('COM_VIRTUEMART_STRING_SAVED', vmText::_('COM_VIRTUEMART_CART_NOTIFY')); $this->setRedirect(JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $data['virtuemart_product_id'], FALSE), $msg); } }
/** * Save a rating * @author Max Milbers */ public function saveRating($data = 0) { //Check user_rating $maxrating = VmConfig::get('vm_maximum_rating_scale', 5); $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', 0); $app = JFactory::getApplication(); if ($app->isSite()) { $user = JFactory::getUser(); $userId = $user->id; $allowReview = $this->allowReview($virtuemart_product_id); $allowRating = $this->allowRating($virtuemart_product_id); } else { $userId = $data['created_by']; $allowReview = true; $allowRating = true; } if (!empty($virtuemart_product_id)) { //if ( !empty($data['virtuemart_product_id']) && !empty($userId)){ if (empty($data)) { $data = vRequest::getPost(); } if ($allowRating) { //normalize the rating if ($data['vote'] < 0) { $data['vote'] = 0; } if ($data['vote'] > $maxrating + 1) { $data['vote'] = $maxrating; } $data['lastip'] = $_SERVER['REMOTE_ADDR']; $data['vote'] = (int) $data['vote']; $rating = $this->getRatingByProduct($data['virtuemart_product_id']); vmdebug('$rating', $rating); $vote = $this->getVoteByProduct($data['virtuemart_product_id'], $userId); vmdebug('$vote', $vote); $data['virtuemart_rating_vote_id'] = empty($vote->virtuemart_rating_vote_id) ? 0 : $vote->virtuemart_rating_vote_id; if (isset($data['vote'])) { $votesTable = $this->getTable('rating_votes'); $votesTable->bindChecknStore($data, TRUE); $errors = $votesTable->getErrors(); foreach ($errors as $error) { vmError(get_class($this) . '::Error store votes ' . $error); } } if (!empty($rating->rates) && empty($vote)) { $data['rates'] = $rating->rates + $data['vote']; $data['ratingcount'] = $rating->ratingcount + 1; } else { if (!empty($rating->rates) && !empty($vote->vote)) { $data['rates'] = $rating->rates - $vote->vote + $data['vote']; $data['ratingcount'] = $rating->ratingcount; } else { $data['rates'] = $data['vote']; $data['ratingcount'] = 1; } } if (empty($data['rates']) || empty($data['ratingcount'])) { $data['rating'] = 0; } else { $data['rating'] = $data['rates'] / $data['ratingcount']; } $data['virtuemart_rating_id'] = empty($rating->virtuemart_rating_id) ? 0 : $rating->virtuemart_rating_id; vmdebug('saveRating $data', $data); $rating = $this->getTable('ratings'); $rating->bindChecknStore($data, TRUE); $errors = $rating->getErrors(); foreach ($errors as $error) { vmError(get_class($this) . '::Error store rating ' . $error); } } if ($allowReview and !empty($data['comment'])) { //if(!empty($data['comment'])){ $data['comment'] = substr($data['comment'], 0, VmConfig::get('vm_reviews_maximum_comment_length', 2000)); // no HTML TAGS but permit all alphabet $value = preg_replace('@<[\\/\\!]*?[^<>]*?>@si', '', $data['comment']); //remove all html tags $value = (string) preg_replace('#on[a-z](.+?)\\)#si', '', $value); //replace start of script onclick() onload()... $value = trim(str_replace('"', ' ', $value), "'"); $data['comment'] = (string) preg_replace('#^\'#si', '', $value); //replace ' at start $data['comment'] = nl2br($data['comment']); // keep returns //set to defaut value not used (prevent hack) $data['review_ok'] = 0; $data['review_rating'] = 0; $data['review_editable'] = 0; // Check if ratings are auto-published (set to 0 prevent injected by user) // $app = JFactory::getApplication(); if ($app->isSite()) { if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } if (!Permissions::getInstance()->check('admin')) { if (VmConfig::get('reviews_autopublish', 1)) { $data['published'] = 1; } } } $review = $this->getReviewByProduct($data['virtuemart_product_id'], $userId); if (!empty($review->review_rates)) { $data['review_rates'] = $review->review_rates + $data['vote']; } else { $data['review_rates'] = $data['vote']; } if (!empty($review->review_ratingcount)) { $data['review_ratingcount'] = $review->review_ratingcount + 1; } else { $data['review_ratingcount'] = 1; } $data['review_rating'] = $data['review_rates'] / $data['review_ratingcount']; $data['virtuemart_rating_review_id'] = empty($review->virtuemart_rating_review_id) ? 0 : $review->virtuemart_rating_review_id; $reviewTable = $this->getTable('rating_reviews'); $reviewTable->bindChecknStore($data, TRUE); $errors = $reviewTable->getErrors(); foreach ($errors as $error) { vmError(get_class($this) . '::Error store review ' . $error); } } return $data['virtuemart_rating_review_id']; } else { vmError('Cant save rating/review/vote without vote/product_id'); return FALSE; } }
function plgVmOnPaymentNotification() { if (!class_exists('VirtueMartModelOrders')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'; } $mb_data = vRequest::getPost(); if (!isset($mb_data['transaction_id'])) { return; } $order_number = $mb_data['transaction_id']; if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($mb_data['transaction_id']))) { return; } if (!($payment = $this->getDataByOrderId($virtuemart_order_id))) { return; } $method = $this->getVmPluginMethod($payment->virtuemart_paymentmethod_id); if (!$this->selectedThisElement($method->payment_element)) { return FALSE; } if (!$payment) { $this->logInfo('getDataByOrderId payment not found: exit ', 'ERROR'); return NULL; } $this->_storeInternalData($method, $mb_data, $virtuemart_order_id); $modelOrder = VmModel::getModel('orders'); $vmorder = $modelOrder->getOrder($virtuemart_order_id); $order = array(); $error_msg = $this->_processStatus($mb_data, $vmorder, $method); if ($error_msg) { $order['customer_notified'] = 0; $order['order_status'] = $method->status_canceled; $order['comments'] = 'process IPN ' . $error_msg; $modelOrder->updateStatusForOneOrder($virtuemart_order_id, $order, TRUE); $this->logInfo('process IPN ' . $error_msg, 'ERROR'); } else { $this->logInfo('process IPN OK', 'message'); } if (empty($mb_data['payment_status']) || $mb_data['payment_status'] != 'Completed' && $mb_data['payment_status'] != 'Pending') { // can't get status or payment failed //return false; } $order['customer_notified'] = 1; if (strcmp($mb_data['payment_status'], 'Completed') == 0) { $order['order_status'] = $method->status_success; $order['comments'] = vmText::sprintf('VMPAYMENT_MONEYBOOKERS_PAYMENT_STATUS_CONFIRMED', $order_number); } elseif (strcmp($mb_data['payment_status'], 'Pending') == 0) { $order['comments'] = vmText::sprintf('VMPAYMENT_MONEYBOOKERS_PAYMENT_STATUS_PENDING', $order_number); $order['order_status'] = $method->status_pending; } else { $order['order_status'] = $method->status_canceled; } $this->logInfo('plgVmOnPaymentNotification return new_status:' . $order['order_status'], 'message'); $modelOrder->updateStatusForOneOrder($virtuemart_order_id, $order, TRUE); //// remove vmcart $this->emptyCart($payment->user_session, $mb_data['transaction_id']); }
/** * Add or edit a review */ public function review() { $msg = ""; $model = VmModel::getModel('ratings'); $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', 0); $allowReview = $model->allowReview($virtuemart_product_id); $allowRating = $model->allowRating($virtuemart_product_id); if ($allowReview || $allowRating) { $return = $model->saveRating(); if ($return !== FALSE) { $errors = $model->getErrors(); if (empty($errors)) { $msg = JText::sprintf('COM_VIRTUEMART_STRING_SAVED', JText::_('COM_VIRTUEMART_REVIEW')); } foreach ($errors as $error) { $msg = $error . '<br />'; } if (!class_exists('ShopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $data = vRequest::getPost(); if ($allowReview) { } shopFunctionsF::sendRatingEmailToVendor($data); } } $this->setRedirect(JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id, FALSE), $msg); }
function plgVmOnPaymentResponseReceived(&$html) { if (!class_exists('VirtueMartCart')) { require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php'; } if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (!class_exists('VirtueMartModelOrders')) { require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php'; } VmConfig::loadJLang('com_virtuemart_orders', TRUE); $mb_data = vRequest::getPost(); // the payment itself should send the parameter needed. $virtuemart_paymentmethod_id = vRequest::getInt('pm', 0); $order_number = vRequest::getString('on', 0); if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; } // Another method was selected, do nothing if (!$this->selectedThisElement($method->payment_element)) { return NULL; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) { return NULL; } if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) { // JError::raiseWarning(500, $db->getErrorMsg()); return ''; } VmConfig::loadJLang('com_virtuemart'); $orderModel = VmModel::getModel('orders'); $order = $orderModel->getOrder($virtuemart_order_id); vmdebug('KAZNACHEY plgVmOnPaymentResponseReceived', $mb_data); $payment_name = $this->renderPluginName($method); $html = $this->_getPaymentResponseHtml($paymentTable, $payment_name); $link = JRoute::_("index.php?option=com_virtuemart&view=orders&layout=details&order_number=" . $order['details']['BT']->order_number . "&order_pass="******"vm-button-correct" href="' . $link . '">' . vmText::_('COM_VIRTUEMART_ORDER_VIEW_ORDER') . '</a>'; $cart = VirtueMartCart::getCart(); $cart->emptyCart(); return TRUE; }