Example #1
0
 function quit($id, $entry_type = 'msc', $entry_option = null)
 {
     oseAppConfig::load('mscv5');
     $msc_id = $id;
     $user_id = $this->user_id;
     $order_id = $this->order_id;
     $order_item_id = $this->order_item_id;
     $params = oseCall('member')->getAddonParams($msc_id, $user_id, $order_id, array('order_item_id' => $order_item_id));
     $member = oseCall('member');
     $member->instance($user_id);
     $msc = oseCall('msc');
     $ext = $msc->getExtInfo($msc_id, 'msc', 'obj');
     $updated = oseMscAddon::runAction('member.msc.cancelMsc', $params, true, false);
     return $updated;
 }
Example #2
0
 public static function load($app, $config = array())
 {
     oseRegistry::register('registry', 'oseregistry');
     oseRegistry::call('registry');
     switch ($app) {
         case 'msc':
         case 'mscv5':
         case 'msc1v5':
             oseRegistry::register('remote', 'remote');
             oseRegistry::register('email', 'email');
             oseRegistry::register('msc', 'membership');
             oseRegistry::register('user', 'user');
             oseRegistry::quickRequire('user');
             oseRegistry::register('member', 'member');
             // default
             oseRegistry::register('payment', 'payment');
             oseRegistry::quickRequire('payment');
             oseRegistry::register('content', 'content');
             break;
         case 'mscv6':
             oseRegistry::register('form', 'form');
             oseAppConfig::load('payment');
             oseRegistry::quickRequire('payment2');
             oseRegistry::register('payment2', 'paymentMsc');
             oseRegistry::register('msc', 'msc');
             oseRegistry::register('content', 'content');
             break;
         case 'credit':
             oseAppConfig::load('payment');
             oseRegistry::register('form', 'form');
             oseRegistry::quickRequire('payment2');
             oseRegistry::register('payment2', 'paymentCredit');
             oseRegistry::register('credit', 'credit');
             oseRegistry::register('content2', 'content2');
             break;
         case 'ecash':
             oseAppConfig::load('payment');
             oseRegistry::quickRequire('payment2');
             oseRegistry::register('payment2', 'paymentEcash');
             break;
         case 'contract':
             oseRegistry::register('form', 'form');
             oseRegistry::register('contract', 'contract');
             oseRegistry::register('payment2', 'paymentContract');
             break;
         case 'ftable':
             oseRegistry::register('ftable', 'ftable');
             break;
         case 'mart':
             self::load('mscv6');
             self::load('contract');
             self::load('lic');
             oseRegistry::register('form', 'form');
             oseRegistry::register('mart', 'mart');
             oseRegistry::register('payment2', 'paymentMart');
             break;
         case 'commerce':
         case 'payment':
             oseRegistry::register('remote', 'remote');
             oseRegistry::register('email', 'email');
             oseRegistry::register('user2', 'user2');
             oseRegistry::quickRequire('user2');
             oseRegistry::register('locale', 'locale');
             oseRegistry::register('form', 'form');
             oseRegistry::register('event', 'event');
             oseRegistry::register('payment2', 'payment2');
             oseRegistry::quickRequire('payment2');
             break;
         case 'lic':
         case 'license':
             oseAppConfig::load('payment');
             oseRegistry::quickRequire('payment2');
             oseRegistry::register('payment2', 'paymentLic');
             oseRegistry::register('lic', 'lic');
             oseRegistry::register('form', 'form');
             break;
         case 'migration':
             oseRegistry::register('user2', 'user2');
             oseRegistry::quickRequire('user2');
             self::load('mscv6');
             break;
         default:
             oseRegistry::register('user', 'user');
             break;
     }
 }
Example #3
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;

	}
Example #4
0
    /**

     * This method should handle any login logic and report back to the subject

     *

     * @access	public

     * @param   array   holds the user data

     * @param 	array   array holding options (remember, autoregister, group)

     * @return	boolean	True on success

     * @since	1.5

     */
    function onUserLogin($user, $options = array())
    {
    	require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php');
        $mainframe = JFactory::getApplication();
        $db = JFactory::getDBO();
        $option=JRequest::getVar("option");
        jimport('joomla.user.helper');
        if ($mainframe->isAdmin() )
        {
            return; // Dont run in admin
        }

        $pluginParams = $this->params;
        //$loginRedirection = $pluginParams->get('loginRedirection');  // Move to OSE Router;
        $singleLogin = $pluginParams->get('singleLogin');
		$loginRedirect= $pluginParams->get('loginRedirect');
		$autoUpdate = $pluginParams->get('autoUpdateOnLogin');
		$autoUpdateGroup = $pluginParams->get('autoUpdateGroup');
		$user = self::getUser($user);

		// Update BillingInfo names;
		$query = " SELECT user_id, firstname FROM #__osemsc_billinginfo WHERE user_id = ".(int)$user->id;
		$db->setQuery($query);
		$objects = $db->loadObject();
		if (!empty($objects->user_id) && empty($objects->firstname))
		{
			$thisUser = JFactory::getUser($objects->user_id);
			$names = explode(' ',$thisUser->name);
			$firstname =  $db->Quote($names[0]);
			$lastname = count($names)>1?$names[1]:'null';
			$lastname =  $db->Quote($lastname);
			$query = "UPDATE `#__osemsc_billinginfo` SET `firstname` = {$firstname},`lastname` = {$lastname}  WHERE `user_id` = ".(int)$user->id;
			$db->setQuery($query);
			$db->Query();
		}

		$query = " SELECT user_id, lastname FROM #__osemsc_billinginfo WHERE user_id = ".(int)$user->id;
		$db->setQuery($query);
		$objects = $db->loadObject();
		if (!empty($objects->user_id) && empty($objects->lastname))
		{
			$query = "UPDATE `#__osemsc_billinginfo` SET `lastname` = (SELECT lastname FROM #__osemsc_userinfo WHERE user_id = ".(int)$user->id.") WHERE `user_id` =".(int)$user->id;
			$db->setQuery($query);
			$db->Query();
		}
		// BillingInfo names;
		$enableVMUser = $pluginParams->get('enableVMUser');
		if ($enableVMUser==true)
			{
				$oseUser['user_id'] = oseObject::getValue($user,'id');
				$query= "SELECT * FROM `#__virtuemart_userinfos` WHERE `address_type` = 'BT' AND `virtuemart_user_id` = ". (int)$user->id;
				$db->setQuery($query);
				$result= $db->loadObject();
				if(!empty($result)) {
					$query = "SELECT `country_3_code` FROM `#__virtuemart_countries` WHERE  `virtuemart_country_id` = ". $db->Quote($result->virtuemart_country_id);
					$db->setQuery($query);
					$country_3_code=$db->loadResult();
					if (!empty($country_3_code))
					{
						$result->country = $country_3_code;
					}
					else
					{
						$result->country = substr($result->country, 0,3);
					}

					$query = "SELECT `state_2_code` FROM `#__virtuemart_states` WHERE  `virtuemart_state_id` = ". $db->Quote($result->virtuemart_state_id);
					$db->setQuery($query);
					$state_2_code=$db->loadResult();
					if (!empty($state_2_code))
					{
						$result->state = $state_2_code;
					}
					else
					{
						$result->state = substr($result->state, 0,2);
					}
					
					$query= "SELECT count(*) FROM `#__osemsc_billinginfo` WHERE `user_id` = ". (int)$user->id;
					$db->setQuery($query);
					$result2= $db->loadResult();
					if (empty($result2))
					{
						$query= "INSERT INTO `#__osemsc_billinginfo` (`user_id`, `firstname`, `lastname`, `company`, `addr1`, `addr2`, `city`, `state`, `country`, `postcode`, `telephone`) VALUES
						(".(int)$user->id.", '{$result->first_name}', '{$result->last_name}', '{$result->company}', '{$result->address_1}', '{$result->address_2}', '{$result->city}', '{$result->state}', '{$result->country}', '{$result->zip}', '{$result->phone_1}');";
					}
					else
					{
						$query = " UPDATE `#__osemsc_billinginfo` " .
								 " SET `firstname` = '{$result->first_name}', " .
								 " `lastname` = '{$result->last_name}', " .
								 " `company` = '{$result->company}', " .
								 " `addr1` = '{$result->address_1}', " .
								 " `addr2` = '{$result->address_2}', " .
								 " `city` = '{$result->city}', " .
								 " `state` = '{$result->state}', " .
								 " `country` = '{$result->country}', " .
								 " `postcode` = '{$result->zip}', " .
								 " `telephone` = '{$result->phone_1}' " .
								 " WHERE `user_id` =".(int)$user->id;
					}
					$db->setQuery($query);
					$db->query();

				}
			}
		if ($autoUpdate==true && !empty($autoUpdateGroup))
		{
			if (!class_exists("oseMscPublic"))
			{
				require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'helpers'.DS.'oseMscPublic.php');
			}
			oseAppConfig::load('msc');
            $cart = oseMscPublic::getCart();
            $items = $cart->get('items');
			$update = true;
            if(count($items) >0)
            {
             	foreach($items as $item)
            	{
            		if($item['entry_id'] == $autoUpdateGroup)
            		{
            			$update = false;
            		}
            	}
            }

            $query = " SELECT count(*) FROM #__osemsc_member WHERE msc_id = ".(int)$autoUpdateGroup." AND member_id=".(int)$user->id;
			$db->setQuery($query);
			$exists = $db->loadResult();
        	if ($update && empty($exists))
        	{
				// join msc
				if($mainframe->isSite())
            	{
            		$cart = oseMscPublic::getCart();
            		// get current item
            		$cCart = $cart->cart;
            		$cart->init();
            		$cart->__construct();
            		$cart->updateParams('payment_mode','m');
	            	$paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($autoUpdateGroup,$cart->get('currency'),0);
					$nItem = array('entry_id'=>$autoUpdateGroup,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option'));
					$cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem);

					$cart->update();

            		//$orderPaymentInfo = array();//$cart->output();
            		oseMscAddon::runAction('register.payment.save',array('member_id'=>$user->id,'payment_method'=>'none'), true, false);
            		$order_id = JRequest::getInt('order_id',0);
					oseRegistry::call('payment')->getInstance('Order')->confirmOrder($order_id, array());

            		$cart->init();
            		$cart->__construct();


            		$cart1 = oseMscPublic::getCart();$cart1->__construct();
            		$cart1->cart = $cCart;
            		$cart1->update();

            	}
            	else
            	{
            		$cart = oseMscPublic::getCart();
            		// get current item
            		//$cItems = $cart->output();
            		//$cart->init();
            		$cart->updateParams('payment_mode','m');
	            	$paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($autoUpdateGroup,$cart->get('currency'),0);
					$nItem = array('entry_id'=>$autoUpdateGroup,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option'));
					$cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem);

					$cart->update();

            		$orderPaymentInfo = array();//$cart->output();
            		$orderResult = oseMscAddon::runAction('register.payment.save',array('member_id'=>$user->id,'payment_method'=>'none'), true, false);
            		$order_id = JRequest::getInt('order_id',0);
					oseRegistry::call('payment')->getInstance('Order')->confirmOrder($order_id, array());
            		$cart->init();
            		/*$orderPaymentInfo = $cart->output();
            		oseMscPublic::generateOrder($user['id'],'none',$orderPaymentInfo);
            		$order_id = JRequest::getInt('order_id',0);oseExit($order_id);
					oseRegistry::call('payment')->getInstance('Order')->confirmOrder($order_id, array());*/
            	}
        	}
		}
    	$member = oseRegistry::call('member');
		$member->instance($user->id);
		$mscs = $member->getAllOwnedMsc(true,null,'obj');
		$date = oseHTML::getDateTime();
		$date = strtotime($date);
		$updateStatus = false;
		if(!empty($mscs))
		{
			foreach($mscs as $msc)
			{
				$startdate = strtotime($msc->start_date);
				$expdate = strtotime($msc->expired_date);
				$params = oseJson::decode($msc->params);
				
				if($msc->status && ($startdate>$date) && (($date<$expdate) || $msc->eternal == 1 || $msc->expired_date == '0000-00-00 00:00:00'))
				{
					$updateStatus = true;
					$status = 0;
				}elseif(empty($msc->status) && ($startdate < $date) && (($date<$expdate) || $msc->eternal == 1 || $msc->expired_date == '0000-00-00 00:00:00'))
				{
					$updateStatus = true;
					$status = 1;
				}
				
				if($updateStatus)
				{
					$query = "SELECT * FROM `#__osemsc_order_item` WHERE `order_id` = ".$params->order_id;
					$db->setQuery($query);
					$orderItem = $db->loadObject();
					$orderItemParams = oseJson::decode($orderItem->params);
					if($orderItemParams->recurrence_mode == 'fixed')
					{
						$query = "UPDATE `#__osemsc_member` SET `status` = '{$status}' WHERE `id` = ".$msc->id;
						$db->setQuery($query);
						$db->query();
					}
				}
				
			}
		}
 	    if ($singleLogin>0)
	    {
		  self::singleLogin($singleLogin, $db, $user, $mainframe);
	    }
        if ($loginRedirect == true)
        {
        	if (!empty($user))
        	{
				self::loginRedirect($user->id);
        	}
        }

       return true;
    }