function getItem() { $result = array(); $post = JRequest::get('post'); $post = oseMscAddon::getPost('licseat_', $post); if (!isset($post['contact_send'])) { $post['contact_send'] = 0; } if (!isset($post['internal_contact_send'])) { $post['internal_contact_send'] = 0; } $db = oseDB::instance(); $msc_id = JRequest::getInt('msc_id', 0); $member_id = JRequest::getInt('member_id', 0); $mscLicInfo = oseRegistry::call('msc')->getExtInfo($msc_id, 'lic', 'obj'); $mscLicInfoParams = oseObject::getParams($mscLicInfo); $where = array(); $where[] = "license_user_id = '{$member_id}'"; if (empty($mscLicInfoParams->id)) { $where[] = "license_id = '{$mscLicInfoParams->id}'"; } $where = oseDB::implodeWhere(); $query = " SELECT * FROM `#__oselic_license_seat`" . $where . " ORDER BY id DESC"; $db->setQuery($query); $item = oseDB::loadItem('obj'); $result['success'] = empty($item) ? false : true; $result['total'] = empty($item) ? 0 : 1; $result['result'] = empty($item) ? array() : $item; //$result = oseJson::encode($result); return $result; }
public static function save($params) { $result = array(); $post = JRequest::get('post'); $member_id = $params['member_id']; JRequest::setVar('member_id', $member_id); if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } $db = oseDB::instance(); $firstname = $db->Quote(oseObject::getValue($post, 'juser_firstname', $post['juser_username'])); $lastname = $db->Quote(oseObject::getValue($post, 'juser_lastname')); $query = " SELECT COUNT(*) FROM `#__osemsc_userinfo` WHERE user_id = ". (int)$member_id; $db->setQuery($query); $exists = ($db->loadResult() > 0) ? true : false; if ($exists) { return array('success' => true); } else { $query = " INSERT INTO `#__osemsc_userinfo` (user_id,firstname,lastname)" . " VALUES" . " ({$member_id},{$firstname},{$lastname})"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Fail Saving OSE User Info.'); return $result; } return array('success' => true); } }
public static function save($params) { $result = array(); $result['success'] = true; if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.1'); return $result; } unset($params['allow_work']); if ($params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } $db = oseDB::instance(); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where, 'obj'); $member = oseRegistry::call('member'); $member->instance($member_id); $memParams = $member->getMemberInfo($msc_id, 'obj')->memParams; if (empty($memParams)) { $memParams = new stdClass(); } else { $memParams = oseJSON::decode($memParams); } $memParams->order_id = $order_id; $memParams->payment_mode = $curOrder->payment_mode; $memParams->order_item_id = $order_item_id; // Order problem for system add $memParams = oseJSON::encode($memParams); $query = " UPDATE `#__osemsc_member`" . " SET `params` = " . $db->Quote($memParams) . " WHERE msc_id = {$msc_id} AND member_id = {$member_id}"; $memConfig = oseMscConfig::getConfig('register', 'obj'); $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.2'); } // User activation function; $params = JComponentHelper::getParams('com_users'); $useractivation = $params->get('useractivation'); if (oseObject::getValue($memConfig, 'disabled_non_paid', false) == true) { if ($useractivation == 0) { $query = " UPDATE `#__users` SET `block` = 0 where `id` = " . $member_id; $db->setQuery($query); $db->query(); } } return $result; }
function getItems() { // Get a storage key. $store = $this->getStoreId('getItems'); // Try to load the data from internal storage. if (!empty($this->cache[$store])) { return $this->cache[$store]; } $search = $this->getState('filter.search'); $searchid = $this->getState('filter.searchid'); $searchpe = $this->getState('filter.searchpe'); // Load the list items. $items = parent::getItems(); // If emtpy or an error, just return. if (empty($items)) { return array(); } //oseExit($items); $db = oseDB::instance(); // Inject the values back into the array. foreach ($items as $k => $item) { $order_id = null; if ($item->msc_id > 0) { $params = oseJson::decode($item->params); $order_id = oseGetValue($params, 'order_id', 0); $query = " SELECT `title` FROM `#__osemsc_acl`" . " WHERE `id` = '{$item->msc_id}'"; $db->setQuery($query); $item->membership = $db->loadResult(); $query = " SELECT *" . " FROM `#__osemsc_order_fix`" . " WHERE `member_id` = '{$item->id}'"; $db->setQuery($query); $ofItem = oseDB::loadItem('obj'); $item->paypal_email = oseObject::getValue($ofItem, 'email', $item->email); } else { $item->expired_date = null; $item->status = ''; } if (empty($search) && empty($searchid) && empty($searchpe)) { //return array(); } else { //$item->order_number = null; if (!empty($order_id)) { $query = " SELECT `order_id`,`order_number`,`payment_serial_number`,`order_status`" . " FROM `#__osemsc_order`" . " WHERE `order_id` = '{$order_id}'"; $db->setQuery($query); $oItem = oseDB::loadItem('obj'); $item->order_number = $oItem->order_number; $item->order_id = $oItem->order_id; $item->payment_serial_number = $oItem->payment_serial_number; $item->order_status = $oItem->order_status; } else { } } $items[$k] = $item; } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }
public static function getGroups($params = array()) { $msc_id = JRequest::getInt('msc_id', 0); $msc = oseRegistry::call('msc'); $item = $msc->getExtInfo($msc_id, 'jgroup', 'obj'); $jgroup_id = oseObject::getValue($item, 'jgroup_id', null); $gid = JHtml::_('access.usergroups', 'jgroup_jgroup_id', $jgroup_id, true); oseExit($gid); }
protected function isInner($params) { if(oseObject::getValue($params,'inner',false)) { return true; } else { return false; } }
function __construct($p) { parent::__construct($p); $db = oseDB::instance(); $query = " SELECT * FROM `{$this->_table}`" . " WHERE `plan_id` = '" . $this->get('plan_id') . "'"; $db->setQuery($query); $item = oseDB::loadItem(); if (empty($item)) { $this->create(); } else { $this->setProperties($item); } }
function getDefMsgtoNonmembers($content_type, $content_id, $com_type = null) { $db = oseDB::instance(); $controllingMSC = self::getControllingMsc($content_type, $content_id, $com_type); if (!empty($controllingMSC)) { $controllingMSC = $controllingMSC[0]; $query = " SELECT `params` FROM `#__osemsc_ext` WHERE `type` = 'msc' AND `id` = " . (int) $controllingMSC->id; $db->setQuery($query); $result = $db->loadResult(); $result = oseJSON::decode($result); return oseObject::getValue($result, 'restrict'); } else { return false; } }
public static function save() { $result = array(); $post = JRequest::get('post'); $post['primary_contact'] = oseObject::getValue($post, 'primary_contact', 1); $member_id = JRequest::getInt('user_id', 0); JRequest::setVar('member_id', $member_id); $array = array(); $array['username'] = $post['username']; $array['name'] = $post['firstname'] . ' ' . $post['lastname']; $array['password'] = $array['password1'] = $post['password']; $array['password2'] = $post['password2']; $array['email'] = $post['email']; if (empty($member_id)) { $isNew = true; } else { $isNew = false; } $user_id = $member_id; $username = $array['username']; $updated = oseMscPublic::uniqueUserName($username, $user_id); if (!$updated['success']) { return $updated; } //$array['id'] = $user_id; $uid = self::jvsave($member_id, $array); $member = oseRegistry::call('member'); $member->instance($member_id); $updated = $member->updateUserInfo($post); oseRegistry::call('msc')->runAddonAction('member.billinginfo.save'); if (!$updated) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('FAIL_SAVING_OSEMSC_USER_INFO'); $result['member_id'] = ''; } else { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SAVED_JOOMLA_USER_INFO'); } return $result; }
function onAfterDispatch() { $app = JFactory::getApplication('SITE'); if ($app->isAdmin()) { return; } $document = JFactory::getDocument(); if (!JFile::exists(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php')) { return false; } else { require_once(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php'); require_once(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'helpers' . DS . 'oseMscPublic.php'); } $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $order_id = JRequest::getCmd('orderID', null); $code = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $document->addScriptDeclaration($code); }
function display($tpl = null) { $tpl = null; $this->set('_layout', 'default'); oseHTML::initCss(); $com = OSECPU_PATH_JS . '/com_ose_cpu/extjs'; oseHTML::initScript(); oseHTML::script($com . '/ose/app.msg.js', '1.5'); oseHTML::script($com . '/grid/expander.js', '1.5'); oseHTML::script(OSEMSC_F_URL . '/libraries/init.js', '1.5'); $config = oseMscConfig::getConfig('global', 'obj'); oseHTML::stylesheet(OSEMSC_F_URL . '/assets/css/' . $config->frontend_style . '.css', (JOOMLA16) ? '1.6' : '1.5'); $user = JFactory::getUser(); $app = JFactory::getApplication('SITE'); $session = JFactory::getSession(); $db = oseDB::instance(); $order_id = JRequest::getInt('order_id'); $payment = oseRegistry::call('payment'); $where = array(); $where[] = "`order_id` = " . $db->quote($order_id); $order = $payment->getOrder($where, 'obj'); $orderInfoParams = oseJson::decode($order->params); $redirectUrl = urldecode($orderInfoParams->returnUrl); $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $htmlTrack = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $code = oseMscPublic::ajaxOrderTrack($account, $order_id); if (empty($code)) { $code = false; } else { $code = implode("", $code); } $document = JFactory::getDocument(); $document->addScriptDeclaration('var redirectUrl = "' . $redirectUrl . '";'); $document->addScriptDeclaration($htmlTrack); $document->addScriptDeclaration($code); $this->assignRef('orderInfo', $order); $this->prepareDocument(); parent::display($tpl); }
function pricing($price, $currency, $msc_id, $msc_option, $renew = false) { $price = $this->exchangeCurrency($price, $currency); // discount start if ($renew) { $paymentAdvs = oseRegistry::call('msc')->getExtInfo($msc_id, 'paymentAdv'); if (!empty($paymentAdvs)) { $paymentAdv = oseObject::getValue($paymentAdvs, $msc_option); if (!empty($paymentAdv)) { $discount_num = oseObject::getValue($paymentAdv, 'renew_discount'); $discount_type = oseObject::getValue($paymentAdv, 'renew_discount_type'); $price = $this->discount($price, $discount_num, $discount_type); } } } //$price = $price; // discount end $price = number_format($price, 2, '.', ''); return $price; //$price = }
function getFullTree($start, $limit) { $msc = oseRegistry::call('msc'); $return = array(); $items = array(); $items = $msc->retrieveTree(); $return['total'] = count($items); $list = array_slice($items, $start, $limit); foreach ($list as $key => $item) { $members = $msc->getMembers(oseObject::getValue($item, 'id'), 0, 0, 0, 'obj'); $totalExp = oseObject::getValue($members, 'total', 0); $members = $msc->getMembers(oseObject::getValue($item, 'id'), 1, 0, 0, 'obj'); $totalAct = oseObject::getValue($members, 'total', 0); $total = $totalAct + $totalExp; $item = oseObject::setValue($item, 'total', $total); $item = oseObject::setValue($item, 'totalExp', $totalExp); $item = oseObject::setValue($item, 'totalAct', $totalAct); $list[$key] = $item; } $return['results'] = $list; return $return; }
static function getConfig($config_type = null, $type = 'array') { $db = oseDB::instance(); $where = array(); if (!empty($config_type)) { if (is_array($config_type)) { $values = array(); foreach ($config_type as $configType) { $values[] = $db->Quote($configType); } $where[] = 'type IN (' . implode(',', $values) . ')'; } else { $where[] = 'type=' . $db->Quote($config_type); } } $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `#__osemsc_configuration` " . $where; $db->setQuery($query); $objs = oseDB::loadList('obj'); if ($type == 'array') { $config = array(); foreach ($objs as $obj) { $config[$obj->key] = $obj->value; //oseObject::setValue($config,$obj->key,$obj->value); } } else { $config = new stdClass(); foreach ($objs as $obj) { $config->{$obj->key} = $obj->value; //oseObject::setValue($config,$obj->key,$obj->value); } } /*foreach($objs as $obj) { $config = oseObject::setValue($config,$obj->key,$obj->value); }*/ $config = oseObject::setValue($config, 'id', 1); return $config; }
function onAfterInitialise() { $params = $this->params; $app = JFactory::getApplication(); if($app->isAdmin()) { return true; } if (file_exists(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php') && file_exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_ose_cpu'.DS.'define.php') && !file_exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_osemsc'.DS.'installer.dummy.ini')) { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); } else { return false; } if($params->get('pap4_click_track_api')) { require_once(OSEMSC_B_LIB.DS.'PapApi.class.php'); $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); // init session for PAP $session = new Gpf_Api_Session($oseMscConfig->pap_url."/scripts/server.php"); // register click $clickTracker = new Pap_Api_ClickTracker($session); $clickTracker->setAccountId(oseObject::getValue($oseMscConfig,'pap_account_id','default1')); try { $clickTracker->track(); $clickTracker->saveCookies();//oseExit($_COOKIE); } catch (Exception $e) { } } }
public static function getJoinHistory() { $db= oseDB :: instance(); $my = JFactory::getUser(); $member_id = $my->id; $msc_id = JRequest :: getInt('msc_id', '0'); $start = JRequest::getInt('start',0); $limit = JRequest::getInt('limit',20); $query = " SELECT COUNT(*) FROM `#__osemsc_member_history` " ." WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$member_id}'" ; $db->setQuery($query); $total = $db->loadResult(); $query = " SELECT * FROM `#__osemsc_member_history` " ." WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$member_id}'" ." ORDER BY id DESC" ; $db->setQuery($query,$start,$limit); $items = oseDB :: loadList(); foreach($items as $key => $item) { $globalConfig = oseRegistry::call('msc')->getConfig('global','obj'); if(!empty($globalConfig->DateFormat)) { $items[$key]= oseObject::setValue($item,'date',date($globalConfig->DateFormat,strtotime($item['date']))); } } $result = array(); $result['total'] = $total; $result['results'] = $items; $result = oseJson :: encode($result); oseExit($result); }
function display($tpl = null) { $model = $this->getModel('memberships'); $items = $model->getMemberships(); $session = JFactory::getSession(); $osePaymentCurrency = $session->get('osePaymentCurrency', oseRegistry::call('msc')->getConfig('currency', 'obj')->primary_currency); $cards = array(); $com = OSECPU_PATH_JS . '/com_ose_cpu/extjs'; oseHTML::initScript(); oseHTML::script($com . '/ose/app.msg.js', '1.5'); oseHTML::script(OSEMSC_F_URL . '/libraries/init.js', '1.5'); $register_form = oseRegistry::call('msc')->getConfig('register', 'obj')->register_form; $layout = JRequest::getCmd("layout"); if (empty($register_form) || $register_form == 'default') { $layout = (!empty($layout) && ($layout == 'detail' || $layout == 'cartdetail')) ? "cartdetail" : 'cart'; $this->setLayout($layout); $type = 'cart'; } else { $layout = (!empty($layout) && ($layout == 'detail')) ? $layout : 'default'; $this->setLayout($layout); $user = JFactory::getUser(); $tpl = null; $type = 'os'; } if ($layout == 'default' || $layout == 'cart') { $cards = $model->drawMscList($osePaymentCurrency, $items, $type); } else { foreach ($items as $item) { $msc_id = JRequest::getInt('msc_id', oseObject::getValue($item, 'id')); $cards = $model->getMembershipCard($msc_id); break; } } $config = oseMscConfig::getConfig('global', 'obj'); oseHTML::stylesheet(OSEMSC_F_URL . '/assets/css/' . $config->frontend_style . '.css', (JOOMLA16) ? '1.6' : '1.5'); $this->assignRef('cards', $cards); $this->prepareDocument(); parent::display($tpl); }
function sendWelcomeEmail($params) { $orderItem = oseObject::getValue($params, 'orderItem'); $user_id = oseObject::getValue($params, 'user_id'); $member = oseRegistry::call('member'); $member->instance($user_id); $userInfo = $member->getBasicInfo('obj'); $msc_id = $orderItem->entry_id; $emailConfig = oseRegistry::call('msc')->getConfig('email', 'obj'); if ($emailConfig->cancelorder_email) { $emailTempDetail = $this->getDoc($ext->cancel_email, 'obj'); $variables = $this->getEmailVariablesCancel($user_id, $msc_id); $emailParams = $this->buildEmailParams($emailTempDetail->type); $emailDetail = $this->transEmail($emailTempDetail, $variables, $emailParams); $this->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if ($emailConfig->sendCancel2Admin) { $this->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } }
function save() { $model = $this->getModel('coupons'); $id = JRequest::getInt('id', 0); $post = JRequest::get('post'); $result = array(); $result['success'] = true; if (empty($id)) { $title = $post['title']; if (empty($title)) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('TITLE_CAN_NOT_BE_EMPTY'); } else { $updated = $model->add($title); if ($updated) { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('ADDED_SUCCESSFULLY'); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('FAILING_ADDING'); } } } else { $params = array(); $params['amount'] = oseObject::getValue($post, 'amount', 0); $params['title'] = $post['title']; $params['code'] = $post['code']; $params['type'] = oseObject::getValue($post, 'type', null); $params['amount_infinity'] = oseObject::getValue($post, 'amount_infinity', 0); $params['discount'] = oseObject::getValue($post, 'discount', 0); $params['discount_type'] = $post['discount_type']; $params['params'] = oseJson::encode(array('range' => $post['range'], 'range2' => oseObject::getValue($post, 'range2', 'first'), 'amount_left' => oseObject::getValue($post, 'amount_left', 0), 'msc_ids' => oseObject::getValue($post, 'msc_ids', 'all'), 'currencies' => oseObject::getValue($post, 'currencies', 'all'))); $updated = $model->update($id, $params); if ($updated) { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('ADDED_SUCCESSFULLY'); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('FAILING_ADDING'); } } $result = oseJSON::encode($result); oseExit($result); }
private static function activateInAutomaticMode($msc_id,$member_id,$orderInfo,$ext) { $db = oseDB::instance(); $result = array(); $result['success'] = true; $orderParams = oseJSON::decode($orderInfo->params); $start_date = oseHTML::getDateTime(); $start_date = $db->Quote($start_date); $recurrence_num = $orderParams->p3; $recurrence_unit = $orderParams->t3; $expired_date = " DATE_ADD({$start_date},INTERVAL {$recurrence_num} {$recurrence_unit}) "; $query = " UPDATE `#__osemsc_member` " ." SET expired_date = {$expired_date}" ." WHERE member_id = {$member_id} AND msc_id = {$msc_id} " ; $db->setQuery($query); //oseExit($db->_sql); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(' Fail Updated Member\'s Recurrence '); return $result; } $query = " SELECT expired_date FROM `#__osemsc_member` " ." WHERE member_id = {$member_id} AND msc_id = {$msc_id} " ; $db->setQuery($query); $end_date = $db->loadResult(); $end_date = $db->Quote($end_date); $expired_date = " DATE_ADD({$end_date},INTERVAL 1 DAY) "; if(oseObject::getValue($orderParams,'recurrence_times',0) > 1) { } else { $query = " UPDATE `#__osemsc_member` " ." SET expired_date = {$expired_date}" ." WHERE member_id = {$member_id} AND msc_id = {$msc_id} " ; $db->setQuery($query); //oseExit($db->_sql); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(' Fail Updated Member\'s Recurrence '); return $result; } } return $result; }
function updateOrderParams($orderInfo, $params) { $orderInfoParams = oseObject::getValue($orderInfo, 'params'); $orderInfoParams = oseJson::decode($orderInfoParams); if (!is_Array($params)) { $params = (array) $params; } foreach ($params as $key => $value) { $orderInfoParams = oseObject::setValue($orderInfoParams, $key, $value); } $orderInfoParams = oseJson::encode($orderInfoParams); $orderInfo = oseObject::setValue($orderInfo, 'params', $orderInfoParams); return $orderInfo; }
function getBillingInfo() { $user = oseMscPublic::getUser(); $item = array(); $cart = oseMscPublic::getCart(); $cartItems = $cart->get('items'); if (!$user->guest) { $member = oseRegistry::call('member'); $member->instance($user->id); $item = $member->getBillingInfo(); } else { $item['id'] = 1; $item['city'] = ''; } if (oseMscPublic::getRegisterForm() == 'onestep') { $cartItem = empty($cartItems[0]) ? array() : $cartItems[0]; $item['msc_id'] = oseObject::getValue($cartItem, 'entry_id', 0); $item['ose_currency'] = $cart->get('currency'); if (!empty($item['msc_id'])) { $item['msc_option'] = $cartItem['msc_option']; } else { $options = $this->getAllOptions(); if (!empty($options)) { $item['msc_id'] = $options[0]['msc_id']; $item['msc_option'] = $options[0]['id']; } } } else { $item['ose_currency'] = $cart->get('currency'); if ($cart->get('total') <= 0) { $item['total'] = 'free'; } else { $item['total'] = 'nonfree'; } } return $item; }
function getExtSpecificPayment($node, $msc_id, $type, $osePaymentCurrency, $option) { $payment = oseRegistry::call('msc')->getExtInfo($msc_id, 'payment', 'array'); //$payment = oseJson::decode($payment->params,true); if (empty($payment)) { return false; } if (empty($option)) { $options = array_keys($payment); $option = $options[0]; } else { $options = array_keys($payment); //print_r($options); oseExit($option); if (count($options) > 0) { if (!in_array($option, $options)) { $option = $options[0]; } } else { return false; } } if (!isset($payment[$option])) { return false; } $payment = $payment[$option]; $node = oseObject::setValue($node, 'msc_option', $option); if (oseObject::getValue($payment, 'payment_mode') != $type && oseObject::getValue($payment, 'payment_mode') != 'b') { $type = oseObject::getValue($payment, 'payment_mode'); } $node = oseObject::setValue($node, 'has_trial', oseObject::getValue($payment, 'has_trial')); $node = oseObject::setValue($node, 'recurrence_mode', oseObject::getValue($payment, 'recurrence_mode')); $node = $this->getPriceStandard($node, $payment, $osePaymentCurrency); if (oseObject::getValue($payment, 'recurrence_mode') == 'fixed') { //$period = oseHtml::date( oseObject::getValue($payment,'start_date')).' - '. oseHtml::date( oseObject::getValue($payment,'expired_date')); $start_date = date("l,d F Y", strtotime(oseObject::getValue($payment, 'start_date'))); $expired_date = date("l,d F Y", strtotime(oseObject::getValue($payment, 'expired_date'))); if ($start_date == $expired_date) { $period = $start_date; } else { $period = $start_date . ' - ' . $expired_date; } $node = oseObject::setValue($node, 'standard_recurrence', $period); $node = oseObject::setValue($node, 'first_raw_price', oseObject::getValue($node, 'standard_raw_price')); $node = oseObject::setValue($node, 'second_raw_price', oseObject::getValue($node, 'standard_raw_price')); $node = oseObject::setValue($node, 'first_price', oseObject::getValue($node, 'standard_price')); $node = oseObject::setValue($node, 'second_price', $osePaymentCurrency . ' ' . oseObject::getValue($node, 'standard_raw_price')); $node = oseObject::setValue($node, 'p3', 0); $node = oseObject::setValue($node, 't3', 'week'); $node = oseObject::setValue($node, 'eternal', 0); $node = oseObject::setValue($node, 'start_date', oseObject::getValue($payment, 'start_date')); $node = oseObject::setValue($node, 'expired_date', oseObject::getValue($payment, 'expired_date')); } else { if (oseObject::getValue($payment, 'has_trial')) { $node = $this->getPriceTrial($node, $payment, $osePaymentCurrency); $node = oseObject::setValue($node, 'first_raw_price', oseObject::getValue($node, 'trial_raw_price')); $node = oseObject::setValue($node, 'second_raw_price', oseObject::getValue($node, 'standard_raw_price')); $node = oseObject::setValue($node, 'first_price', oseObject::getValue($node, 'trial_price')); $node = oseObject::setValue($node, 'second_price', oseObject::getValue($node, 'standard_price')); $node = oseObject::setValue($node, 'p1', oseObject::getValue($payment, 'p1')); $node = oseObject::setValue($node, 't1', oseObject::getValue($payment, 't1')); } else { $node = oseObject::setValue($node, 'first_raw_price', oseObject::getValue($node, 'standard_raw_price')); $node = oseObject::setValue($node, 'second_raw_price', oseObject::getValue($node, 'standard_raw_price')); $node = oseObject::setValue($node, 'first_price', oseObject::getValue($node, 'standard_price')); $node = oseObject::setValue($node, 'second_price', $osePaymentCurrency . ' ' . oseObject::getValue($node, 'standard_raw_price')); } $node = oseObject::setValue($node, 'p3', oseObject::getValue($payment, 'p3')); $node = oseObject::setValue($node, 't3', oseObject::getValue($payment, 't3')); $node = oseObject::setValue($node, 'eternal', oseObject::getValue($payment, 'eternal', 0)); } return $node; }
public static function renew($params) { if(!class_exists('oseMscPublic')) { require_once(OSEMSC_F_HELPER.DS.'oseMscPublic.php'); } $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Renew.Order'); return $result; } //unset($params['allow_work']); $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where,'obj'); $curOrderParams = oseJson::decode($curOrder->params); $recurrence_times = ($curOrderParams->has_trial)?oseObject::getValue($curOrderParams,'recurrence_times',0)+1:oseObject::getValue($curOrderParams,'recurrence_times',0); if(oseObject::GetValue($config, 'oseaffiliate_enabled',true)) { if(empty($curOrderParams->oseaffiliateID) || empty($curOrderParams->osebannerID)) { return true; } else { //$memParams->oseaffiliateID = $curOrderParams->oseaffiliateID; //$memParams->osebannerID = $curOrderParams->osebannerID; } $file = JPATH_ADMINISTRATOR.DS.'com_ose_affiliates'.DS.'helpers'.DS.'oseaffiliates_helper.php'; if ( JFile::exists($file) ) { require_once($file); } else { return false; } $msc = oseRegistry::call('msc'); $where = array(); $where[] = "`order_item_id` = '{$order_item_id}'"; $curOrderItem = $payment->getInstance('Order')->getOrderItem($where,'obj'); $curOrderItemParams = oseJson::decode($curOrderItem->params); $node = $msc->getInfo($msc_id,'obj'); $paymentInfos = $msc->getExtInfo($msc_id,'payment'); foreach($paymentInfos as $key => $paymentInfo) { if($key != $curOrderItemParams->msc_option) { unset($paymentInfos[$key]); } } $osePaymentCurrency = $curOrder->payment_currency; $options = oseMscPublic::generatePriceOption($node,$paymentInfos,$osePaymentCurrency); $product = "{$node->title}-{$options[0]['title']}"; $helper = new oseAffiliatesHelper(); $helper->setTotalCost($curOrder->payment_price); $helper->setOrderId($order_id); $helper->setProduct($product); $helper->setCurrency($osePaymentCurrency); $helper->setAffiliateId($curOrderParams->oseaffiliateID); $helper->setBannerId($curOrderParams->osebannerID); if(!$helper->createSale()) { return false; } } return $result; }
function getPrice($node) { //oseExit($node); $payment_mode = strtolower(oseObject::getValue($node, 'payment_mode')); $mPrice = oseObject::getValue($node, 'm_price'); $aPrice = oseObject::getValue($node, 'a_price'); if ($payment_mode == 'm') { $price = parent::drawPrice($mPrice, 'm'); } elseif ($payment_mode == 'a') { $price = parent::drawPrice($aPrice, 'a'); } else { $has_trial = oseObject::getValue($node, 'has_trial'); if ($has_trial) { $price = parent::drawPrice($aPrice, 'a'); } else { $price = parent::drawPrice($aPrice, 'a'); } } return $price; }
function combo($config) { $config->width = oseObject::getValue($config, 'width', 100); $config->editable = oseObject::getValue($config, 'editable', false); $config->forceSelection = oseObject::getValue($config, 'forceSelection', true); $config->allowBlank = oseObject::getValue($config, 'allowBlank', false); $config->typeAhead = true; $config->triggerAction = 'all'; $config->mode = 'local'; $c = oseJson::encode($config); $html = "new Ext.form.ComboBox({$c})"; return $html; }
public static function cancel($params) { $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Error Join.PAP'); return $result; } unset($params['allow_work']); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); if(empty($oseMscConfig->pap_enable)) { return $result; } require_once(OSEMSC_B_LIB.DS.'PapApi.class.php'); $session = new Gpf_Api_Session($oseMscConfig->pap_url.'/scripts/server.php'); if(empty($oseMscConfig->pap_username) || empty($oseMscConfig->pap_password)) { return $result; } if(!$session->login(oseObject::getValue($oseMscConfig,'pap_username'), oseObject::getValue($oseMscConfig,'pap_password'))) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = $session->getMessage(); return $result; } //loading transaction by orderid $transaction = new Pap_Api_Transaction($session); $transaction->setOrderId($order_id); $transaction->setType('S'); //$transaction->setAccountId(oseObject::getValue($oseMscConfig,'pap_account_id','default1')); try { if(!$transaction->load()) { echo 'Cannot load transaction, error: '.$transaction->getMessage(); } else { $response = $transaction->refund('note for affiliate'); // or $transaction->chargeBack('note for affiliate'); if ($response->isError()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_("PAP.cancel.error1"); } else { //echo 'chargeback OK'; $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); } } } catch (Exception $e) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_("PAP.cancel.error2"); } return $result; }
function pointedRedirection($sefroutemethod, $menu) { if ((isset($menu->type)) && $menu->type == 'url') { $return = $menu->link; } elseif ((isset($menu->type)) && $menu->type == 'alias') { $menuParams = oseJson::decode($menu->params); $aMenuId = $menuParams->aliasoptions; //$aMenu = JSite::getMenu(true)->getItem($aMenuId); $db = JFactory::getDBO(); $query = "SELECT * FROM `#__menu` WHERE `id` = " . (int) $aMenuId; $db->setQuery($query); $aMenu = $db->loadObject(); return self::pointedRedirection($sefroutemethod, $aMenu); } else { switch ($sefroutemethod) { default: case 0: $redURL = $menu->link . "&Itemid=" . $menu->id; break; case 1: $return = $redURL = ($menu->link == 'index.php?option=com_content&view=featured') ? JRoute::_(JURI::root() . 'index.php') : JRoute::_($menu->link . "&Itemid=" . $menu->id); break; case 2: $jConfig = JFactory::getConfig(); if (JOOMLA16 || JOOMLA17) { if ($jConfig->get('sef_rewrite')) { $redURL = JRoute::_($menu->path); } else { $redURL = "index.php/" . JRoute::_($menu->path); } } else { static $menuPath; $parent_id = oseObject::getValue($menu, 'parent'); if (empty($menuPath)) { $menuPath = array(); array_unshift($menuPath, $menu->alias); } if ($parent_id != 0) { $aMenu = JSite::getMenu(true)->getItem($parent_id); array_unshift($menuPath, $aMenu->alias); $redURL = self::pointedRedirection($sefroutemethod, $aMenu); return $redURL; } else { $menuPath = implode('/', $menuPath); if ($jConfig->get('sef_rewrite')) { $redURL = JRoute::_($menuPath); } else { $redURL = "index.php/" . JRoute::_($menuPath); } } } break; } } if (strpos($redURL, 'http') === false && $sefroutemethod != 1) { $return = JURI::root() . $redURL; } return $return; }
protected function generateMscIdOption() { $list = oseMscPublic::getList(); $result = array(); if (!empty($list)) { $cart = oseMscPublic::getCart(); $options = array(); $msc = oseRegistry::call('msc'); foreach ($list as $key => $entry) { $msc_id = oseObject::getValue($entry, 'id'); $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); $osePaymentCurrency = $cart->get('currency'); $option = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $options = array_merge($options, $option); } $mscList = array('total' => count($list), 'results' => $list); $mscOptions = array('total' => count($options), 'results' => $options); $result = array(); $result['mscList'] = $mscList; $result['mscOptions'] = $mscOptions; } else { $result['mscList'] = array(); $result['mscOptions'] = array(); } return $result; }
function checkAuto($orderInfo) { // get all ingredient $orderInfoParams= oseJson :: decode($orderInfo->params); if(oseObject :: getValue($orderInfo, 'order_status') == 'fraud') { return false; } if($this->currency_code != $orderInfo->payment_currency) { return false; } if(oseObject :: getValue($orderInfoParams, 'has_trial')) { if(oseObject :: getValue($orderInfoParams, 'recurrence_times') > 0) { if($this->mc_gross != $orderInfoParams->next_total) { return false; } } else { if($this->mc_gross != $orderInfoParams->total) { return false; } } } else { if(oseObject :: getValue($orderInfoParams, 'recurrence_times') > 1) { if($this->mc_gross != $orderInfoParams->next_total) { return false; } } else { if($this->mc_gross != $orderInfoParams->total) { return false; } } } return true; }