Пример #1
0
 function output()
 {
     $extend = $this->get('_extend');
     if (!empty($extend)) {
         $info = $extend->output();
     }
     $msc = oseCall('msc');
     $tMsc = JTable::getInstance('Membership', 'oseMscTable');
     if ($this->get('parent_id') != $tMsc->getRootId()) {
         $cartItem = $msc->instance('plan', array('id' => $this->get('parent_id')));
         $info['main_title'] = $cartItem->get('title');
         $info['title'] = $this->get('title');
     } else {
         $info['main_title'] = $this->get('title');
         $info['title'] = '';
     }
     $info['image'] = $this->get('image');
     return $info;
 }
Пример #2
0
	function processPayment($order_id, $post) {
		$payment = oseRegistry::call('payment');
		$orderInfo = $payment->getOrder(array("order_id = {$order_id}"), 'obj');
		$config = oseRegistry::call('msc')->getConfig('payment', 'obj');
		$msc_id = $orderInfo->entry_id;
		$member_id = $orderInfo->user_id;
		$payment_method = $orderInfo->payment_method;
		$orderInfo->payment_price = floatval($orderInfo->payment_price);
		if ($orderInfo->payment_price != '0.00' && $orderInfo->payment_price > 0) {
			if ($orderInfo->payment_mode == 'm') {
				$msc = oseCall('msc');
				$mscExt = $msc->getExtInfo($post['msc_id'], 'msc', 'obj');
				$msc_id = $post['msc_id'];
				if (oseObject::getValue($mscExt, 'renew_disable', false)) {
					$member = oseRegistry::call('member');
					$member->instance($member_id);
					$isRenewMember = $member->isMember($msc_id);
					if (!empty($isRenewMember)) {
						$return['success'] = false;
						$return['payment'] = $payment_method;
						$return['payment_method'] = $payment_method;
						$return['title'] = JText::_('RESTRICTED');
						$return['content'] = JText::_('MEMBERSHIP_RENEW_NOT_ALLOW');
						return $return;
					}
				}
			}
			return oseMscPublic::processPayment($payment_method, $orderInfo, $post);
		} elseif ($orderInfo->payment_price <= 0 && $orderInfo->payment_mode == 'a') {
			return oseMscPublic::processPayment($payment_method, $orderInfo, $post);
		} else {
			if ($payment_method != 'poffline') {
				$payment_method = 'none';
			}
			$db = JFactory::getDBO();
			$query = "SELECT entry_id FROM `#__osemsc_order_item` WHERE `order_id` = " . $order_id;
			$db->setQuery($query);
			$msc_id = $db->loadResult();
			$member = oseRegistry::call('member');
			$member->instance($member_id);
			$isFreeMember = $member->isMember($msc_id);
			$memConfig = oseMscConfig::getConfig('register', 'obj');
			if (!empty($isFreeMember) && $memConfig->allow_freerenewal == false) {
				$result['success'] = false;
				$result['title'] = JText::_('RESTRICTED');
				$result['content'] = JText::_('FREE_MEMBERSHIP_RENEW_NOT_ALLOW');
			} else {
				$result = $payment->getInstance('Order')->confirmOrder($order_id, array());
				$result['payment_method'] = $payment_method;
			}
			return $result;
		}
	}
Пример #3
0
 function authorize($type, $name, $backend = false)
 {
     $db = oseDB::instance();
     if ('member' == substr($type, 0, 6)) {
         $nType = 'member';
     } else {
         $nType = $type;
     }
     // user or member
     if ($this->user_id <= 0) {
         return false;
     } else {
         $my = oseCall('user2')->instance();
         // addons only run in backend, need specific group. e.g. super admin
         if (!$backend && in_array($type, array('panel', 'bridge', 'content'))) {
             return false;
         } elseif ($backend && in_array($type, array('panel', 'bridge', 'content'))) {
             if (!$my->isUserAdmin()) {
                 return false;
             }
         }
         if ($nType == 'member') {
             if ($backend) {
                 if (!$my->isUserAdmin()) {
                     return false;
                 }
             } else {
                 $user = oseCall('user2')->instance($this->user_id, 'msc');
                 if (in_array($name, array('juser', 'billinginfo', 'profile'))) {
                 } elseif (count($user->get('active_membership')) < 1) {
                     return false;
                 }
             }
         }
     }
     // run addon validate if func existed
     $fileOld = "{$nType}.{$name}.php";
     $fileNew = "{$name}.php";
     $filepath = $backend == false ? JPATH_SITE : JPATH_ADMINISTRATOR;
     $filepath .= DS . 'components' . DS . 'com_osemsc' . DS . 'addons' . DS . 'action' . DS . $nType;
     if (JFile::exists($filepath . DS . $fileOld)) {
         require_once $filepath . DS . $fileOld;
     } elseif (JFile::exists($filepath . DS . $fileNew)) {
         require_once $filepath . DS . $fileNew;
     } else {
         return true;
     }
     $className = 'oseMscAddonAction' . ucfirst($nType) . ucfirst($name);
     if ($nType == 'member') {
         $class = new $className($this->get('p'));
     } else {
         $class = new $className($this->get('p'));
     }
     if (method_exists($class, 'validateAccess')) {
         return call_user_func(array($class, 'validateAccess'));
     }
     return true;
 }
Пример #4
0
 function cancel($id, $entry_type = 'msc', $entry_option = null)
 {
     oseRegistry::register('email', 'email');
     oseRegistry::register('msc', 'membership');
     oseRegistry::register('user', 'user');
     oseRegistry::quickRequire('user');
     oseRegistry::register('member', 'member');
     $msc_id = $id;
     $user_id = $this->user_id;
     $db = oseDB::instance();
     $query = " SELECT * FROM `#__osemsc_member` WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$user_id}'";
     $db->setQuery($query);
     $memInfo = oseDB::loadItem('obj');
     $memParams = oseJson::decode($memInfo->params);
     $order_id = oseGetValue($memParams, 'order_id');
     $order_item_id = oseGetValue($memParams, 'order_item_id');
     $params = oseCall('member')->getAddonParams($msc_id, $user_id, $order_id, array('order_item_id' => $order_item_id));
     $msc = oseCall('msc');
     $app = JFactory::getApplication('SITE');
     $controller = JRequest::getCmd('controller');
     if ($app->isSite()) {
         $updated = oseMscAddon::runAction('member.msc.cancelMsc', $params, true, false);
     } elseif ($controller == 'orders') {
         $updated = oseMscAddon::runAction('member.msc.cancelMsc', $params, true, false);
     } else {
         $updated = oseMscAddon::runAction('member.msc.cancelMsc', $params, true, true);
     }
     return $updated;
 }
Пример #5
0
	public static function cancel($params)
	{
		$result = array();
		$result['success'] = true;

		if(empty($params['allow_work']))
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_("Error");
			return $result;
		}
		unset($params['allow_work']);
		$member_id = $params['member_id'];
		$msc_id = $params['msc_id'];
		$user = JFactory::getUser($member_id);
		
		$db = oseDB::instance();
		
		$query = "SELECT * FROM `#__osemsc_member`"
				." WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$member_id}'"
				;
		$db->setQuery($query);
		$memInfo = oseDB::loadItem('obj');
		$memParams = oseJson::decode($memInfo->params,true);

		$order_id = $memParams['order_id'];
		$order_item_id = $memParams['order_item_id'];
		$query = " SELECT * FROM `#__osemsc_order`"
		." WHERE `order_id` = '{$order_id}'"
		;
		$db->setQuery($query);
		$order = oseDB::loadItem('obj');
		$oParams = oseJson::decode($order->params);
		//$msc_option = oseObject::getValue($oParams,'msc_option');
		
		$query = " SELECT * FROM `#__osemsc_order_item`"
				." WHERE `order_id` = '{$order_id}'"
				;
		$db->setQuery($query);
		$order_item = oseDB::loadItem('obj');
		$iParams = oseJson::decode($order_item->params);
		$msc_option = $iParams->msc_option;
		
		if(oseGetValue($oParams,'isLicensee',0))
		{
			$result['success'] = true;
			$result['title'] = JText::_('Done');
			$result['content'] = JText::_("Done");
				
			return $result;
		}

		$query = " SELECT * FROM `#__osemsc_ext`"
				." WHERE `id` = '{$msc_id}' AND `type` = 'oselic'"
				;
		$db->setQuery($query);
		$data = oseDB::loadItem('obj');
		$data = oseJson::decode($data->params);
		$data = oseObject::getValue($data,$msc_option,array());
		
		if( oseObject::getValue($data,'enable_license') )
		{
			oseRegistry :: register('user2', 'user2');
			oseRegistry :: register('lic', 'lic');
			oseRegistry :: register('email', 'email');
			oseRegistry :: register('locale', 'locale');
			$user = oseCall('user2')->instance( $member_id,'lic');
			
			$query = " SELECT * FROM `#__oselic_type_license_key`"
			." WHERE `license_id` = '{$oParams->license_id}' AND `licensee_id` > 0"
			;
			$db->setQuery($query);
			$licenseKeys = oseDB::loadList('obj');
			
			foreach($licenseKeys as $licenseKey)
			{
				if(!empty($licenseKey->licensee_id))
				{
					switch($licenseKey->app)
					{
						case('msc'):
							//version
							oseAppConfig::load( 'mscv6' );
							break;
						default:
							oseAppConfig::load($licenseKey->app);
						break;
					}
					$user = oseCall('user2')->instance($licenseKey->licensee_id,$licenseKey->app);
					$user->cancel($licenseKey->entry_id,$licenseKey->app);
				}
				else
				{
					continue;
				}
			}
				
			// delete license info
			oseDB::delete('#__oselic_type_license_key',array('license_id'=>$oParams->license_id));
			$updated = oseDB::delete('#__oselic_type_license',array('id'=>$oParams->license_id));
		}
		
		

		$result['success'] = true;
		$result['title'] = JText::_('Done');
		$result['content'] = JText::_("Done");

		return $result;

	}
Пример #6
0
 function expire($id, $entry_type = 'msc', $entry_option = null)
 {
     $db = oseDB::instance();
     $query = " SELECT * FROM `{$this->_table}`" . " WHERE `msc_id`='{$id}' AND `member_id`='{$this->user_id}'";
     $db->setQuery($query);
     $item = oseDB::loadItem('obj');
     $mscInfo = $this->find($id);
     if (empty($info) || !in_array($info->get('status'), array(1, 3))) {
         // no need to quit if empty
         $result = array();
         $result['success'] = false;
         $result['title'] = JText::_('ERROR');
         $result['content'] = JText::_('NO_MEMBERSHIP_TO_CANCEL');
         return $result;
     }
     $info->set('status', 'expired');
     $updated = $info->update();
     // cancel addon
     if ($updated) {
         $addon = oseCall('msc')->instance('addon', array('user_id' => $this->user_id, 'mm_id' => $item->id));
         $jResult = $addon->runActionGroup('join', 'expire', false);
         $updated = $jResult['success'];
         if ($updated) {
             return $jResult;
         }
     }
     if ($updated) {
         $addon = oseCall('msc')->instance('addon', array('user_id' => $this->user_id, 'mm_id' => $item->id));
         $jResult = $addon->runActionGroup('join', 'cancel', false);
         $updated = $jResult['success'];
         if ($updated) {
             // cancel email
             $msc = oseCall('msc')->instance('plan', array('id' => $id));
             $mscExtmsc = $msc->getExt('msc');
             $exp_email = oseGetValue($mscExtmsc, 'exp_email');
             if (empty($exp_email)) {
                 $config = oseConfig::load($entry_type, 'email', 'obj');
                 $exp_email = oseGetValue($config, 'default_exp_email', 0);
             }
             if ($exp_email) {
                 $email = oseCall('email');
                 $eObj = $email->getEmail($exp_email);
                 $content = array();
                 $user = oseCall('user2')->instance($this->user_id);
                 $content['user'] = (object) $user->outputPayment($entry_type);
                 $mem = new stdClass();
                 $content['member'] = $mem;
                 $eObj->setEmailVariables($content);
                 $eObj->transEmail();
                 $eTemp = $eObj->output();
                 $email->sendEmail($eTemp, $this->get('email'));
                 //
                 if (oseGetValue($config, 'sendExp2Admin', false)) {
                     //$group = oseConfig::getAdminGroup('contract');
                     $group = explode(',', oseGetValue($config, 'email_admin_group'));
                     if (empty($group)) {
                         $group = oseConfig::getAdminGroup($entry_type);
                     }
                     $email->sendToGroup($eTemp, $group);
                 }
             }
             $result['success'] = true;
             $result['title'] = JText::_('SUCCESS');
             $result['content'] = JText::_('MEMBERSHIP_CANCEL_SUCCESS');
         }
         $result['success'] = true;
         $result['title'] = JText::_('SUCCESS');
         $result['content'] = JText::_('MEMBERSHIP_JOIN_SUCCEED');
     } else {
         $result['success'] = false;
         $result['title'] = JText::_('ERROR');
         $result['content'] = JText::_('MEMBERSHIP_JOIN_FAILED');
     }
     return $result;
 }
Пример #7
0
	public static function renew($params)
	{
		$result = array();

	$result = array();
		$result['success'] = true;
		
		if(empty($params['allow_work']))
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_("Error");
			return $result;
		}
		unset($params['allow_work']);
		
		//oseExit($params);
		$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'];
		
		if(empty($msc_id))
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_("Renew Msc: No Msc ID");
			return $result;
		}
		
		$query = " SELECT * FROM `#__osemsc_order`"
				." WHERE `order_id` = '{$order_id}'"
				;
		$db->setQuery($query);
		$order = oseDB::loadItem('obj');
		$oParams = oseJson::decode($order->params);
		//$msc_option = oseObject::getValue($oParams,'msc_option');
		
		$query = " SELECT * FROM `#__osemsc_order_item`"
				." WHERE `order_id` = '{$order_id}'"
				;
		$db->setQuery($query);
		$order_item = oseDB::loadItem('obj');
		$iParams = oseJson::decode($order_item->params);
		$msc_option = $iParams->msc_option;
		
		if(oseGetValue($oParams,'isLicensee',0))
		{
			$result['success'] = true;
			$result['title'] = JText::_('Done');
			$result['content'] = JText::_("Done");
			
			return $result;
		}
		
		$query = " SELECT * FROM `#__osemsc_ext`"
				." WHERE `id` = '{$msc_id}' AND `type` = 'oselic'"
				;
		$db->setQuery($query);
		$data = oseDB::loadItem('obj');
		$data = oseJson::decode($data->params);
		$data = oseObject::getValue($data,$msc_option,array());
		
		if( oseObject::getValue($data,'enable_license') )
		{
			oseRegistry :: register('user2', 'user2');
			
			oseRegistry :: register('lic', 'lic');
			oseRegistry :: register('email', 'email');
			oseRegistry :: register('locale', 'locale');
			$user = oseCall('user2')->instance( $member_id,'lic');
			$user->join( $data->license_id );
			
			$query = " SELECT * FROM `#__oselic_type_license`"
			." WHERE `user_id` = '{$member_id}'"
			." ORDER BY `id` DESC"
			." LIMIT 1"
			;
			$db->setQuery($query);
			$license = oseDB::loadItem('obj');
			$oParams->license_id = $license->id;

			$vals = array();
			$vals['order_id'] = $order_id;
			$vals['params'] = oseJson::encode($oParams);
			oseDB::update('#__osemsc_order','order_id',$vals);
			
			if( oseObject::getValue($data,'member_expiry_mode') == 1 )
			{
				$query = " SELECT * FROM `#__osemsc_member`"
				." WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$member_id}'"
				;
				$db->setQuery($query);
				$memInfo = oseDB::loadItem('obj');
					
				$vals = array();
				$vals['id'] = $license->id;
				$vals['expiry_date'] = $memInfo->expired_date;
				oseDB::update('#__oselic_type_license','id',$vals);
			}
			elseif( oseObject::getValue($data,'member_expiry_mode') == 2 )
			{
				$vals = array();
				$vals['id'] = $license->id;
				$vals['expiry_date'] = oseObject::getValue($data,'expiry_date');
				oseDB::update('#__oselic_type_license','id',$vals);
			}
		}
		

		$result['success'] = true;
		$result['title'] = JText::_('Done');
		$result['content'] = JText::_("Done");

		return $result;

	}