protected function activateMsc($params = array()) { if (empty($params)) { return array('success' => false); } $member_id = $params['member_id']; if (empty($member_id)) { return false; } $db = oseDB::instance(); $msc = oseRegistry::call('msc'); $member_id = $params['member_id']; $msc_id = $params['msc_id']; $order_id = $params['order_id']; $result = array(); $member = oseRegistry::call('member'); $member->instance($member_id); $updated = $member->joinMsc($msc_id); if ($updated) { $list = oseMscAddon::getAddonList('renew', false, 1, 'obj'); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'activate', 'renew'); $result = oseMscAddon::runAction($action_name, $params, true, false); if (!$result['success']) { self::cancelMsc($params); return $result; } } $userInfo = $member->getBasicInfo('obj'); $ext = $msc->getExtInfo($msc_id, 'msc', 'obj'); if ($ext->wel_email && !$this->isLicensee) { $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($ext->wel_email, 'obj'); $variables = $email->getEmailVariablesWelcome($order_id, $msc_id); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if ($emailConfig->sendWel2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } $result = array(); $result['success'] = true; $result['title'] = $result['status'] = 'Done'; $result['content'] = $result['result'] = JText::_('MEMBERSHIP_JOIN_SUCCEED'); } else { $result['success'] = false; $result['title'] = $result['status'] = 'Error'; $result['content'] = $result['result'] = JText::_('MEMBERSHIP_JOIN_FAILED'); } return $result; }
function cancelMsc($member_ids, $msc_id) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'Fail removing'; $member = oseRegistry::call('member'); foreach ($member_ids as $member_id) { $member->instance($member_id); if (!$member->cancelMsc($msc_id)) { return $result; } else { $params = array(); $params['msc_id'] = $msc_id; $params['member_id'] = $member_id; $params['join_from'] = 'payment'; $params['allow_work'] = true; $params['master'] = true; $list = oseMscAddon::getAddonList('join', true, 1, 'obj'); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'cancel', 'join'); $result = oseMscAddon::runAction($action_name, $params); if (!$result['success']) { $result['content'] = 'Member ID:' . $member_id . ' ' . $action_name . ' ' . $result['content']; return $result; } } //Cancel Emial $userInfo = $member->getUserInfo('obj'); $msc = oseRegistry::call('msc'); $ext = $msc->getExtInfo($msc_id, 'msc', 'obj'); if ($ext->cancel_email) { $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($ext->cancel_email, 'obj'); $variables = $email->getEmailVariablesCancel($member_id, $msc_id); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if ($emailConfig->sendCancel2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } } } $result['success'] = true; $result['title'] = 'Done'; $result['content'] = 'Removed successfully!'; return $result; }
protected function generateAddonsJs() { header('Content-Type: text/javascript'); $type = JRequest::GetCmd('addontype'); $db = oseDB::instance(); $user = JFactory::getUser(); $array = array(); $output = ''; if ($type == 'registerOS') { $headerObjs = oseMscAddon::getAddonList('registerOS_header', false, null, 'obj'); $bodyObjs = oseMscAddon::getAddonList('registerOS_body', false, null, 'obj'); $footerObjs = oseMscAddon::getAddonList('registerOS_footer', false, null, 'obj'); if ($user->guest) { $headerObjs = $this->filter($headerObjs, array('welcome', 'login'), false); } else { $headerObjs = $this->filter($headerObjs, array('login'), false); $bodyObjs = $this->filter($bodyObjs, array('juser', 'juser_e', 'mailing', 'jomsocial'), false); } $array['header'] = $headerObjs; $array['body'] = $bodyObjs; $array['footer'] = $footerObjs; $formItems = array(); foreach ($array as $a) { foreach ($a as $obj) { if (!empty($obj->addon_name)) { $formItems[] = array('xtype' => $obj->name); } } } $output .= "var getFormItems = function() {return " . oseJson::encode($formItems) . "};"; $output .= "\r\n"; } elseif ($type == 'member') { $user = JFactory::getUser(); $member = oseRegistry::call('member'); $view = $member->getInstance('PanelView'); $member->instance($user->id); $result = $member->getMemberPanelView('Member', 'member_user'); $columns = array(); $columns[] = array('type' => 'user', 'title' => JText::_('MEMBER_USER_ACCOUNT')); if (oseObject::getValue($result, 'tpl', false)) { switch ($result['tpl']) { case ('master'): case ('expired'): $columns[] = array('type' => 'billing', 'title' => JText::_('BILLING_INFORMATION')); ; $columns[] = array('type' => 'msc', 'title' => JText::_('MY_MEMBERSHIP')); ; break; default: $columns[] = 'billing'; break; } } $output .= "var getMemTypes = function() {return " . oseJson::encode($columns) . "};"; $output .= "\r\n"; foreach ($columns as $column) { $result = $member->getMemberPanelView('Member', 'member_' . $column['type']); $array[$column['type']] = array_values($result['addons']); } } $output .= "var getAddons = function() {return " . oseJson::encode($array) . "};"; return $output; }
private static function saveOS($params) { $result = array(); $member_id = $params['member_id']; $payment_method = $params['payment_method']; JRequest::setVar('member_id', $member_id); if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error1'); return $result; } $params = array(); $paymentCart = $cart = oseRegistry::call('payment')->getInstance('Cart'); $paymentCart->refreshCartItems($paymentCart->get('items'), $paymentCart->get('currency')); $osePaymentCurrency = $paymentCart->get('currency'); $payment_mode = $paymentCart->getParams('payment_mode'); $subtotal = $paymentCart->getSubtotal(); if (empty($payment_mode)) { $payment_mode = oseMscPublic::savePaymentMode(); } $items = $paymentCart->get('items'); $oneItem = $items[0]; $payment = oseRegistry::call('payment'); $keys = array_keys($items); $order_number = $payment->generateOrderNumber($member_id); $params['entry_type'] = 'msc_list'; $params['payment_price'] = $paymentCart->get('total'); $params['payment_currency'] = $osePaymentCurrency; $params['order_number'] = $order_number; $params['create_date'] = oseHTML::getDateTime(); $params['payment_serial_number'] = substr($order_number, 0, 20); $params['payment_method'] = $payment_method; $params['payment_mode'] = $payment_mode; $params['payment_from'] = 'system_reg'; $params['params'] = array(); $params['params']['start_date'] = oseObject::getValue($oneItem, 'start_date', null); $params['params']['expired_date'] = oseObject::getValue($oneItem, 'expired_date', null); $params['params']['total'] = $paymentCart->get('total'); $params['params']['next_total'] = $paymentCart->get('next_total'); $params['params']['discount'] = $paymentCart->get('discount'); $params['params']['subtotal'] = $subtotal; $params['params']['coupon_user_id'] = $paymentCart->getParams('coupon_user_id'); $params['params']['gross_tax'] = $paymentCart->getTaxParams('amount'); $params['params']['next_gross_tax'] = $paymentCart->getTaxParams('next_amount'); $params['params']['vat_number'] = $paymentCart->getTaxParams('vat_number'); $params['params']['timestamp'] = uniqid("{$member_id}_", true); $params['params']['returnUrl'] = $paymentCart->getParams('returnUrl'); if ($payment_mode == 'a') { $params['params']['has_trial'] = oseObject::getValue($oneItem, 'has_trial', 0); } else { $params['params']['has_trial'] = 0; } $sisow_issuerid = JRequest::getVar('sisow_issuerid'); if ($sisow_issuerid) { $params['params']['sisow_issuerid'] = $sisow_issuerid; } $sisow_payment = JRequest::getVar('sisow_payment'); if ($sisow_payment) { $params['params']['sisow_payment'] = $sisow_payment; } $params['params']['a1'] = $paymentCart->get('total'); $params['params']['p1'] = oseObject::getValue($oneItem, 'p1', 0); $params['params']['t1'] = oseObject::getValue($oneItem, 't1'); $params['params']['a3'] = $paymentCart->get('next_total'); $params['params']['p3'] = oseObject::getValue($oneItem, 'p3', 0); $params['params']['t3'] = oseObject::getValue($oneItem, 't3'); $params['params'] = oseJSON::encode($params['params']); $list = oseMscAddon::getAddonList('register_order', false, 1, 'obj'); foreach ($list as $addon) { $action_name = 'register_order.' . $addon->name . '.add'; $params = oseMscAddon::runAction($action_name, $params); } $paymentOrder = $payment->getInstance('Order'); $updated = $paymentOrder->generateOrder('', $member_id, $params); if ($updated) { $order_id = $updated; $result['order_id'] = $order_id; JRequest::setVar('order_id', $order_id); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error2'); return $result; } foreach ($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item, 'entry_type'); switch ($entry_type) { case ('license'): $license_id = oseObject::getValue($item, 'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id, 'obj'); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case ('msc'): $msc_id = oseObject::getValue($item, 'entry_id'); break; } $msc_option = oseObject::getValue($item, 'msc_option'); if (oseObject::getValue($item, 'eternal')) { $itemParams['payment_mode'] = 'm'; } else { $itemParams['payment_mode'] = $payment_mode; } $price = oseObject::getValue($item, 'a3'); if ($payment_mode == 'a') { if (oseObject::getValue($item, 'has_trial')) { $price = oseObject::getValue($item, 'a1'); } } $itemParams['entry_type'] = oseObject::getValue($item, 'entry_type'); $itemParams['payment_price'] = oseObject::getValue($item, 'first_raw_price'); $itemParams['payment_currency'] = $osePaymentCurrency; $itemParams['create_date'] = oseHTML::getDateTime(); $price_params = $payment->generateOrderParams($msc_id, $price, $payment_mode, $msc_option); $price_params['start_date'] = oseObject::getValue($item, 'start_date', null); $price_params['expired_date'] = oseObject::getValue($item, 'expired_date', null); $price_params['recurrence_mode'] = oseObject::getValue($item, 'recurrence_mode', 'period'); $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj'); $paymentInfo = oseObject::getValue($paymentInfos, $msc_option); $updated = $paymentOrder->generateOrderItem($order_id, oseObject::getValue($item, 'entry_id'), $itemParams); } if ($updated) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Order Generate Error'); } $emailConfig = oseMscConfig::getConfig('email', 'obj'); if (!empty($emailConfig->order_notification)) { $db = oseDB::instance(); $where = array(); $where[] = '`order_id` = ' . $db->Quote($order_id); $orderInfo = $paymentOrder->getOrder($where, 'obj'); $memEmail = oseRegistry::call('member')->getInstance('Email'); $receipt = $memEmail->getOrderNotification($orderInfo);//print_r($receipt);exit; $memEmail->sendToAdminGroup($receipt, $emailConfig->admin_group); } return $result; }
public static function renewMsc($params = array()) { if (empty($params)) { return array('success' => false); } $member_id = $params['member_id']; if (empty($member_id)) { return array('success' => false); } $db = oseDB::instance(); $msc = oseRegistry::call('msc'); //$licInfo = $msc->getExtInfo($item->msc_id,'lic','obj'); $member_id = $params['member_id']; $msc_id = $params['msc_id']; $order_id = $params['order_id']; $result = array(); $member = oseRegistry::call('member'); $member->instance($member_id); $updated = $member->joinMsc($msc_id); if ($updated) { $list = oseMscAddon::getAddonList('renew', true, 1, 'obj'); foreach ($list as $addon) { $action_name = 'renew.' . $addon->name . '.renew'; //echo $action_name.'<br>'; $result = oseMscAddon::runAction($action_name, $params); if (!$result['success']) { self::cancelMsc($params); return $result; } } $userInfo = $member->getBasicInfo('obj'); $ext = $msc->getExtInfo($msc_id, 'msc', 'obj'); if ($ext->wel_email) { $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($ext->wel_email, 'obj'); $variables = $email->getEmailVariablesWelcome($order_id, $msc_id); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if (!empty($emailConfig->sendWel2Admin)) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } $result = array(); $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('JOINED_MEMBERSHIP'); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('FAIL_JOINING_MEMBERSHIP'); } return $result; }
private static function saveOS( $params ) { $result = array(); //$post = JRequest::get('post'); $member_id = $params['member_id']; $payment_method = $params['payment_method']; //oseExit($params); JRequest::setVar('member_id',$member_id); if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error1'); return $result; } $params = array(); //$paymentCart = oseMscPublic::getCart(); $paymentCart = $cart = oseRegistry::call('payment')->getInstance('Cart'); $paymentCart->refreshCartItems($paymentCart->get('items'),$paymentCart->get('currency')); $osePaymentCurrency = $paymentCart->get('currency'); $payment_mode = $paymentCart->getParams('payment_mode'); $subtotal = $paymentCart->getSubtotal(); if(empty($payment_mode)) { $payment_mode = oseMscPublic::savePaymentMode(); } $items = $paymentCart->get('items'); $oneItem = $items[0]; $payment = oseRegistry::call('payment'); $keys = array_keys($items); //$payment_mode = $paymentCart->getParams('payment_mode'); $order_number = $payment->generateOrderNumber( $member_id ); $params['entry_type'] = 'msc_list'; $params['payment_price'] = $paymentCart->get('total'); $params['payment_currency'] = $osePaymentCurrency; $params['order_number'] = $order_number; $params['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $params['payment_serial_number'] = substr($order_number,0,20); $params['payment_method'] = $payment_method; $params['payment_mode'] = $payment_mode; $params['payment_from'] = 'system_reg'; $params['params'] = array(); $params['params']['start_date'] = oseObject::getValue($oneItem,'start_date',null); $params['params']['expired_date'] = oseObject::getValue($oneItem,'expired_date',null); $params['params']['total'] = $paymentCart->get('total'); if($paymentCart->getParams('coupon_range2') == 'all') { $params['params']['next_total'] = $params['params']['total']; } else { $params['params']['next_total'] = $paymentCart->get('next_total'); // } //$params['params']['next_total'] = $params['params']['total'];//$paymentCart->get('next_total'); $params['params']['discount'] = $paymentCart->get('discount'); $params['params']['subtotal'] = $subtotal; $params['params']['coupon_user_id'] = $paymentCart->getParams('coupon_user_id'); $params['params']['gross_tax'] = $paymentCart->getTaxParams('amount'); $params['params']['next_gross_tax'] = $paymentCart->getTaxParams('next_amount'); $params['params']['vat_number'] = $paymentCart->getTaxParams('vat_number'); $params['params']['timestamp'] = uniqid("{$member_id}_",true); $params['params']['returnUrl'] = $paymentCart->getParams('returnUrl'); if($payment_mode == 'a') { $params['params']['has_trial'] = oseObject::getValue($oneItem,'has_trial',0); } else { $params['params']['has_trial'] = 0; } $params['params']['a1'] = $paymentCart->get('total'); $params['params']['p1'] = oseObject::getValue($oneItem,'p1',0); $params['params']['t1'] = oseObject::getValue($oneItem,'t1'); $params['params']['a3'] = $paymentCart->get('next_total'); $params['params']['p3'] = oseObject::getValue($oneItem,'p3',0); $params['params']['t3'] = oseObject::getValue($oneItem,'t3'); $params['params'] = oseJSON::encode($params['params']); $list = oseMscAddon :: getAddonList('register_order', false, 1, 'obj'); foreach($list as $addon) { $action_name= 'register_order.'.$addon->name.'.add'; //echo $action_name; $params = oseMscAddon :: runAction($action_name, $params); } $paymentOrder = $payment->getInstance('Order'); $updated = $paymentOrder->generateOrder('', $member_id, $params); if($updated) { $order_id = $updated; $result['order_id'] = $order_id; JRequest::setVar('order_id',$order_id); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error2'); return $result; } //$paymentOrder->__construct('#__osemsc_order_item'); foreach($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); //$paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); //$paymentInfo = oseObject::getValue($paymentInfos,$msc_option); if ( oseObject::getValue($item,'eternal')) { $itemParams['payment_mode'] = 'm'; } else { $itemParams['payment_mode'] = $payment_mode; } $price = oseObject::getValue($item,'a3'); if($payment_mode == 'a') { if(oseObject::getValue($item,'has_trial')) { $price = oseObject::getValue($item,'a1'); } } //$price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $itemParams['entry_type'] = oseObject::getValue($item,'entry_type'); $itemParams['payment_price'] = oseObject::getValue($item,'first_raw_price'); $itemParams['payment_currency'] = $osePaymentCurrency; $itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $price_params = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); $price_params['start_date'] = oseObject::getValue($item,'start_date',null); $price_params['expired_date'] = oseObject::getValue($item,'expired_date',null); $price_params['recurrence_mode'] = oseObject::getValue($item,'recurrence_mode','period'); $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $updated = $paymentOrder->generateOrderItem($order_id,oseObject::getValue($item,'entry_id'), $itemParams); } //$paymentOrder->__construct('#__osemsc_order'); if($updated) { /* $vmorder=self::AddVmOrder($msc_id,$params,$order_number,$paymentInfo); if(!$vmorder['success']) { return $vmorder; } */ $result['success'] = true; $result['title'] = JText :: _('Done'); $result['content'] = JText :: _('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Order Generate Error'); } return $result; }
function getAddons() { $result = array(); $type = JRequest::getCmd('addon_type', null); if (empty($type)) { oseExit(); } $items = oseMscAddon::getAddonList($type, true, null); if (count($items) < 1) { $result['total'] = 0; $result['results'] = array(); } else { $result['total'] = count($items); $result['results'] = $items; } $result = oseJson::encode($result); oseExit($result); }
function saveCart($post) { $result = array(); $result['success'] = true; $result['reload'] = false; $result['script'] = false; $result['title'] = JText::_('SUCCESSFUL_ACTIVATION'); $result['content'] = JText::_('MEMBERSHIP_ACTIVATED_CONTINUE'); $juser = oseMscAddon::getPost('juser_', $post); $password1 = JRequest::getString('juser_password1', '', 'post', JREQUEST_ALLOWRAW); $password2 = JRequest::getString('juser_password2', '', 'post', JREQUEST_ALLOWRAW); if (oseObject::getValue($juser, 'firstname', false) && oseObject::getValue($juser, 'lastname', false)) { $juser['name'] = oseObject::getValue($juser, 'firstname', '') . ' ' . oseObject::getValue($juser, 'lastname', ''); } else { $juser['name'] = oseObject::getValue($juser, 'username', false); } $juser['password'] = $juser['password1'] = $password1; $juser['password2'] = $password2; $juser['email1'] = $juser['email']; $juser['email2'] = $juser['email']; // check unique username $list = oseMscAddon::getAddonList('registerOS_body', false, 1, 'obj'); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'formValidate', 'register'); $updated = oseMscAddon::runAction($action_name, array('inner' => true)); if (!$updated['success']) { return $updated; } } if (!$updated['success']) { return $updated; } // check empty password if (empty($juser['password'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('MUST_SUPPLY_PASSWORD'); return $result; } $register = oseMscPublic::juserRegister($juser); if (!oseObject::getValue($register, 'success', false)) { return $register; } else { $memConfig = oseMscConfig::getConfig('register', 'obj'); if ($memConfig->auto_login) { $result['reload'] = true; } $list1 = oseMscAddon::getAddonList('registerOS_header', false, 1, 'obj'); $list2 = oseMscAddon::getAddonList('registerOS_body', false, 1, 'obj'); $list3 = oseMscAddon::getAddonList('registerOS_footer', false, 1, 'obj'); $list = array_merge($list1, $list2, $list3); $user = oseObject::getValue($register, 'user'); $cart = oseMscPublic::getCart(); $items = $cart->get('items'); $item = $items[0]; $params = array(); $params['msc_id'] = oseMscPublic::getEntryMscId($item); $params['msc_option'] = oseObject::getValue($item, 'msc_option'); $params['payment_mode'] = $post['payment_payment_mode']; $params['member_id'] = $user->id; $params['payment_method'] = $post['payment_method']; foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'save', 'register'); $updated = oseMscAddon::runAction($action_name, $params); if (!$updated['success']) { return $updated; } } $emailConfig = oseMscConfig::getConfig('email', 'obj'); if (!empty($emailConfig->default_reg_email)) { $member = oseRegistry::call('member'); $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($emailConfig->default_reg_email, 'obj'); if (!empty($emailTempDetail)) { $variables = $email->getEmailVariablesRegistration($user->id); $variables['user'] = oseObject::setValue($variables['user'], 'password', $juser['password1']); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $user->email); if ($emailConfig->sendReg2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } } if ($memConfig->auto_login) { $isLogin = $this->login($juser['username'], $juser['password']); if (!$isLogin['success']) { $session = JFactory::getSession(); $return = $session->get('oseReturnUrl', base64_encode('index.php?option=com_osemsc&view=login')); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = $isLogin['content']; $result['returnUrl'] = $return; return $result; } } return $result; } }
private static function joinFromPayment($params) { $db = oseDB::instance(); $msc = oseRegistry::call('msc'); $member_id = $params['member_id']; $msc_id = $params['msc_id']; $order_id = $params['order_id']; $result = array(); if (empty($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Please Select A Membership First'); return $result; } $member = oseRegistry::call('member'); $member->instance($member_id); $updated = $member->joinMsc($msc_id); if ($updated) { $list = oseMscAddon::getAddonList('join', false, 1, 'obj'); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'save', 'join'); $result = oseMscAddon::runAction($action_name, $params, true, false); if (!$result['success']) { self::cancelMsc($params); return $result; } } $userInfo = $member->getBasicInfo('obj'); $ext = $msc->getExtInfo($msc_id, 'msc', 'obj'); if (oseObject::GetValue($ext, 'wel_email', false)) { $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($ext->wel_email, 'obj'); $variables = $email->getEmailVariablesWelcome($order_id, $msc_id); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if ($emailConfig->sendWel2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } $result = array(); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Joined Membership.'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Fail Joining Membership.'); } return $result; }
public static function save() { $post = JRequest::get('post'); $user = JFactory::getUser(); $my = JFactory::getUser(); $company = array(); foreach($post as $key => $value) { if(strstr($key,'company_')) { $billKey = preg_replace('/company_/','',$key,1); $company[$billKey] = $value; } } //oseExit($company); $db = oseDB::instance(); $query = " SELECT member_id FROM `#__oselic_cs_keys_view`" ." WHERE user_id = {$user->id}" ; $db->setQuery($query); $member_id = $db->loadResult(); if(empty($member_id)) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } $query = " SELECT company_id FROM `#__oselic_cs_company` WHERE user_id='{$member_id}'"; $db->setQuery($query); $num = $db->loadResult(); if (empty ($num)) { $keys = array_keys($company); $keys = '`'.implode('`,`',$keys).'`'; $fields = $db->getTableFields('#__oselic_cs_company'); if(!isset($fields['#__oselic_cs_company'][$key])) { if($my->get('gid') == 24 || $my->get('gid') == 25) { $query = "ALTER TABLE `#__oselic_cs_company` ADD `{$key}` TEXT NULL DEFAULT NULL"; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } } else { unset($company[$key]); } } foreach($company as $key => $value) { $company[$key] = $db->Quote($value); } $values = implode(',',$company); $query = "INSERT INTO `#__oselic_cs_company` (`user_id`,{$keys}) VALUES ('{$member_id}',{$values});"; } else { $fields = $db->getTableFields('#__oselic_cs_company'); foreach($company as $key => $value) { if(!isset($fields['#__oselic_cs_company'][$key])) { $query = "ALTER TABLE `#__oselic_cs_company` ADD `{$key}` TEXT NULL DEFAULT NULL"; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } } $company[$key] = "`{$key}`=".$db->Quote($value); } $company_id = $num; $values = implode(',',$company); $query = " UPDATE `#__oselic_cs_company` SET {$values}" ." WHERE `company_id` ={$company_id}" ; } //echo $query;exit; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Fail Saving Company Info.'); } else { $list = oseMscAddon::getAddonList('usersync',false,null,'obj'); $params = array(); $params['member_id'] = $member_id; $params['allow_work'] = true; foreach($list as $addon) { $action_name = 'usersync.'.$addon->name.'.companySave'; $result = oseMscAddon::runAction($action_name,$params); if(!$result['success']) { return $result; } } $result = array(); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Saved Company Info.'); } return $result; }
function getAddons($type) { return oseMscAddon::getAddonList($type, false, null, 'obj'); }
private function toPaymentOS() { $model = $this->getModel('register'); $post = JRequest::get('POST'); $post['payment_method'] = $payment_method = oseMscPublic::getPaymentMethod(); $cart = oseMscPublic::getCart(); $items = $cart->get('items'); $item = $items[0]; $payment_mode = $cart->getParams('payment_mode'); $msc_id = oseMscPublic::getEntryMscID($item); $allow_to_join = $this->checkJoiningControl($msc_id); if ($allow_to_join == false) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Permission denied, this membership is for members only!'); $result = oseJson::encode($result); oseExit($result); } $msc_option = JRequest::getCmd('msc_option', null); if (empty($payment_mode)) { $result['success'] = false; $result['title'] = JText::_('Error!'); $result['content'] = JText::_('Fail Paying...'); return $result; } if (empty($msc_id)) { $result['success'] = false; $result['title'] = JText::_('Error!'); $result['content'] = JText::_('Fail Paying...'); return $result; } $list = oseMscAddon::getAddonList('registerOS_body', false, 1, 'obj'); $list = oseMscPublic::filter($list, array('juser'), false); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'formValidate', 'register'); $updated = oseMscAddon::runAction($action_name, array('inner' => true)); if (!$updated['success']) { return $updated; } } $user = oseMscPublic::getUser(); $params['member_id'] = $user->id; $params['payment_method'] = $payment_method; oseRegistry::call('msc')->runAddonAction('member.billinginfo.save'); oseRegistry::call('msc')->runAddonAction('register.profile.save', $params); $order = oseRegistry::call('msc')->runAddonAction('register.payment.save', $params); $order_id = $order['order_id']; if ($order_id) { $updated = $model->processPayment($order_id, $post, $msc_option); $result = $updated; if (is_array($result)) { $result['order_id'] = $order_id; } } else { $result['success'] = false; $result['title'] = JText::_('Error!'); $result['content'] = JText::_('Fail Creating Order...'); } return $result; }
function displayMember($addon_type = 'member') { $db = oseDB::instance(); $com = OSECPU_PATH_JS . '/com_ose_cpu/extjs'; oseHTML::script($com . "/fileupload/field.js", '1.5'); oseHTML::stylesheet($com . '/fileupload/field.css', '1.5'); $result = array(); $result['layout'] = 'member'; $user = JFactory::getUser(); $member = oseRegistry::call('member'); $member->instance($user->id); if ($addon_type == 'member') { $where = array(); $where[] = "type LIKE 'member_%'"; $where[] = '`frontend` = 1'; $where[] = '`frontend_enabled` = 1'; $where[] = '`action` = 1 '; $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `#__osemsc_addon`" . $where . " ORDER BY ordering ASC "; $db->setQuery($query); $objs = oseDB::loadList('obj', 'name'); } else { $objs = oseMscAddon::getAddonList($addon_type, false, null, 'obj', 'name'); } //$objs = oseMscAddon::getAddonList($addon_type,false,null,'obj','name'); $memInfos = $member->getAllOwnedMsc(false, 1, 'obj'); if (count($memInfos) > 0) { $memberships = $member->getMemberOwnedMscInfo(false, 1, 'obj'); $payment = oseRegistry::call('payment'); $order_ids = array(); foreach ($memberships as $membership) { $memParams = oseJson::decode($membership->params); if ($memParams->payment_mode == 'a') { $orderInfo = $payment->getOrder(array("`order_id`=" . $db->Quote($memParams->order_id) . "")); if (oseObject::GetValue($orderInfo, 'order_status') == 'confirmed') { $order_ids[$memParams->order_id] = $db->Quote($memParams->order_id); } } } if (count($order_ids) < 1) { unset($objs['msc_cancel']); unset($objs['creditcardupdate']); } $memAllInfos = $member->getAllOwnedMsc(true, 0, 'obj'); $renew = false; foreach ($memAllInfos as $memAllInfo) { $memParams = oseJson::decode($memAllInfo->params); if ($memParams->payment_mode == 'a') { if ($memAllInfo->status == 0) { $renew = true; } } else { $renew = true; } } if (!$renew) { unset($objs['msc_renew']); } //oseExit($objs['direcotry']); if (isset($objs['directory'])) { oseHTML::script(oseMscConfig::generateGmapScript(), '1.5'); oseHTML::script($com . "/gmap/panel.js", '1.5'); } $result['addons'] = $objs; $result['tpl'] = 'master'; } else { $query = " SELECT * FROM `#__osemsc_member` AS mem" . " WHERE mem.member_id = {$user->id}" . " LIMIT 1"; $db->setQuery($query); $item = oseDB::loadItem(); if (empty($item)) { $result['layout'] = 'default'; if ($addon_type == 'member_user') { $result['addons'] = array('juser' => $objs['juser']); } else { $result['addons'] = array(); } $result['tpl'] = ''; } else { unset($objs['msc']); unset($objs['directory']); unset($objs['company']); unset($objs['licuser']); unset($objs['msc_cancel']); unset($objs['creditcardupdate']); $result['addons'] = $objs; $result['tpl'] = 'expired'; //if($addon_type == 'member_user') oseExit($result); } } return $result; }
function generateOrder($member_id, $payment_method, $orderPaymentInfo) { return oseRegistry::call('msc')->runAddonAction('register.payment.save', array('member_id' => $member_id, 'payment_method' => $payment_method), true, false); $result = array(); if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } $paymentOrder = oseRegistry::call('payment')->getInstance('Order'); $params = array(); $items = $orderPaymentInfo['items']; unset($orderPaymentInfo['items']); $order_number = $paymentOrder->generateOrderNumber($member_id); $orderPaymentInfo['order_number'] = $order_number; $orderPaymentInfo['entry_type'] = 'msc_list'; $orderPaymentInfo['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $orderPaymentInfo['payment_serial_number'] = substr($orderPaymentInfo['order_number'], 0, 20); $orderPaymentInfo['payment_method'] = 'system'; $orderPaymentInfo['payment_from'] = 'system_admin'; $orderPaymentInfo['payment_mode'] = 'm'; oseObject::setParams($orderPaymentInfo, array('time_stamp' => uniqid("{$member_id}_", true))); // Extra Order Params Updating Function $list = oseMscAddon::getAddonList('register_order', true, 1, 'obj'); foreach ($list as $addon) { $action_name = 'register_order.' . $addon->name . '.add'; //echo $action_name; $params = oseMscAddon::runAction($action_name, $orderPaymentInfo['params'], true, false); } // generate Order $updated = $paymentOrder->generateOrder('', $member_id, $orderPaymentInfo); if (!$updated) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } // generate orer item // in the backend, only manual payment $order_id = $result['order_id'] = $updated; $payment_mode = 'm'; foreach ($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item, 'entry_type'); switch ($entry_type) { case ('license'): $license_id = oseObject::getValue($item, 'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id, 'obj'); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case ('msc'): $msc_id = oseObject::getValue($item, 'entry_id'); break; } $msc_option = oseObject::getValue($item, 'msc_option'); if (oseObject::getValue($item, 'eternal')) { $itemParams['payment_mode'] = 'm'; } else { $itemParams['payment_mode'] = 'm'; } $price = oseObject::getValue($item, 'a3'); if ($payment_mode == 'a') { if (oseObject::getValue($item, 'has_trial')) { $price = oseObject::getValue($item, 'a1'); } } $itemParams['entry_type'] = oseObject::getValue($item, 'entry_type'); $itemParams['payment_price'] = 0;//oseObject::getValue($item,'first_raw_price'); $itemParams['payment_currency'] = $orderPaymentInfo['payment_currency']; $itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $price_params = $paymentOrder->generateOrderParams($msc_id, $price, $payment_mode, $msc_option); $price_params['start_date'] = oseObject::getValue($item, 'start_date', null); $price_params['expired_date'] = oseObject::getValue($item, 'expired_date', null); $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj'); $paymentInfo = oseObject::getValue($paymentInfos, $msc_option); $updated = $paymentOrder->generateOrderItem($order_id, oseObject::getValue($item, 'entry_id'), $itemParams); } if ($updated) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Order Generate Error'); } return $result; }
* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * @Copyright Copyright (C) 2010- Open Source Excellence (R) */ defined('_JEXEC') or die("Direct Access Not Allowed"); $headerObjs= oseMscAddon :: getAddonList('paymentOS', false, null, 'obj'); oseMscAddon::loadAddons($headerObjs); oseHTML::script(OSEMSCFOLDER."/views/payment/js/js.payment.js",'1.6'); ?> <script type="text/javascript"> Ext.onReady(function(){ var headerObjs = <?php echo oseJson::encode($headerObjs);?>; var oseViewPaymentfp = oseMsc.payment.buildForm(); oseMsc.payment.fp = new oseMsc.payment.form(oseViewPaymentfp); //alert(oseMsc.payment.fp.fp.toSource(0)) oseMsc.payment.fp.onLoadAddons(headerObjs,'payment',false); oseMsc.payment.fp.setClickBtnAction('submitBtnOk'); oseMsc.payment.fp.render('ose-payment'); oseMsc.payment.fp.loadRegInfo();
public static function save() { $post = JRequest :: get('post'); $result = array (); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText :: _('Member Information Updated'); $user = JFactory :: getUser(); $member_id = $user->id; $array = array (); $array['username'] = $post['username']; $array['name'] = $post['firstname'] . ' ' . $post['lastname']; $array['password'] = $post['password']; $array['password2'] = $post['password2']; $array['email'] = $post['email']; if ($user->guest) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('You are not a member!'); $isNew = true; return $result; } else { $isNew = false; $member_id = $user->id; } $exists = $this->checkEmail($array['email'], $member_id); if ($exists == true) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Email already exists.'); $isNew = true; return $result; } $user_id = $member_id; $username = $post['username']; $updated = oseMscPublic :: uniqueUserName($username, $user_id); oseRegistry :: call('msc')->runAddonAction('member.billinginfo.save'); if (!$updated['success']) { return $updated; } $uid = self :: jvsave($member_id, $array); if ($isNew) { $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText :: _('Member Information Updated'); $result['member_id'] = $uid; return $result; } else { $member = oseRegistry :: call('member'); $member->instance($member_id); $updated = $member->updateUserInfo($post); if (!$updated) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Failed Updating Member Information'); $result['member_id'] = ''; } else { $list = oseMscAddon :: getAddonList('usersync', false, null, 'obj'); $params = array (); $params['member_id'] = $member_id; $params['allow_work'] = true; foreach ($list as $addon) { $action_name = 'usersync.' . $addon->name . '.juserSave'; $result = oseMscAddon :: runAction($action_name, $params); if (!$result['success']) { return $result; } } } return $result; } }
JRequest::setVar('tmpl', 'component'); } $list = $this->get('Items'); $this->assignRef('list', $list);
function getAddons() { return oseMscAddon::getAddonList('config', true, null, 'obj'); }
function getAddons() { $register_form = oseRegistry::call('msc')->getConfig('register', 'obj')->register_form; if (empty($register_form) || $register_form == 'default') { } else { switch ($register_form) { case ('onestep'): $type = 'paymentOS'; $items = oseMscAddon::getAddonList($type, false, null, 'obj'); $items = oseJson::encode($items); oseExit($items); break; } } }