示例#1
0
	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;
		}
	}
示例#2
0
 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;
 }
示例#3
0
	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;
	}
示例#4
0
 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;
 }
示例#5
0
	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;
	}