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);
		}
	}
Example #2
0
	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;
	}
Example #3
0
 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);
 }
Example #4
0
 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];
 }
Example #5
0
	protected function isInner($params)
	{
		if(oseObject::getValue($params,'inner',false))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
Example #6
0
 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);
	}
Example #9
0
	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 __construct()
 {
     $session =& JFactory::getSession();
     $osecart = $session->get('osecart', array());
     if (empty($osecart)) {
         $this->cart['currency'] = $this->getSelectedCurrency();
         $this->cart['items'] = array();
         $this->cart['total'] = '0.00';
         $this->cart['next_total'] = '0.00';
         $this->cart['subtotal'] = '0.00';
         $this->cart['discount'] = '0.00';
         $this->cart['params'] = array();
         $this->cart['tax'] = array();
         $this->cart['registerType'] = 'cart';
     } else {
         $this->cart['registerType'] = oseObject::getValue($osecart, 'registerType');
         if ($this->cart['registerType'] != 'cart') {
             $this->cart['currency'] = $this->getSelectedCurrency();
             $this->cart['items'] = array();
             $this->cart['subtotal'] = '0.00';
             $this->cart['next_total'] = '0.00';
             $this->cart['total'] = '0.00';
             $this->cart['discount'] = '0.00';
             $this->cart['tax'] = array();
             $this->cart['params'] = array();
         } else {
             $this->cart['currency'] = $this->getSelectedCurrency();
             $this->cart['total'] = oseObject::getValue($osecart, 'total');
             $this->cart['next_total'] = oseObject::getValue($osecart, 'next_total');
             $this->cart['subtotal'] = oseObject::getValue($osecart, 'subtotal');
             $this->cart['params'] = oseObject::getValue($osecart, 'params');
             $this->cart['discount'] = oseObject::getValue($osecart, 'discount');
             $this->cart['items'] = oseObject::getValue($osecart, 'items', array());
             $this->cart['items'] = $this->refreshCartItems();
             $this->cart['tax'] = oseObject::getValue($osecart, 'tax');
         }
         $this->cart['registerType'] = 'cart';
     }
     $this->updateParams('payment_mode', 'm');
     $this->update();
 }
 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 =
 }
Example #12
0
 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;
 }
Example #13
0
	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) {

			}
		}
	}
Example #14
0
	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);
	}
Example #15
0
	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;
	}
Example #16
0
 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;
 }
Example #19
0
	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;
	}
Example #20
0
	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;
	}
Example #21
0
	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;
	}
Example #22
0
 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;
 }
Example #23
0
 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);
 }
 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;
 }
Example #25
0
	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;
	}
Example #26
0
	public function getOrdersMobile()
	{
		$db = oseDB::instance();
		$my = JFactory::getUser();

		$start = JRequest::getInt('start',0);
		$limit = JRequest::getInt('limit',999);

		$where = array();

		$where[] = "o.user_id = '{$my->id}'";
		$where[] = "o.entry_type IN ('msc','msc_list')";

		$where = oseDB::implodeWhere($where);

		$query = " SELECT u.username,u.name, o.* "
		." FROM `#__osemsc_order` AS o "
		." INNER JOIN `#__users` AS u ON u.id = o.user_id"
		. $where
		." LIMIT {$start},999 "
		;

		$db->setQuery($query);
		//oseExit($db->_sql);
		//oseExit($db->getQuery());
		$items = oseDB::loadList();

		$gw = oseRegistry::call('payment')->getInstance('GateWay');
		foreach($items as $key => $item)
		{
			$gwInfo = $gw->getGWInfo(oseObject::getValue($item,'payment_method'));
			if(oseObject::getValue($gwInfo,'is_cc',0) == 1)
			{
				$items[$key] = oseObject::setValue($item,'payment_method','Credit Card');
			}
			if ($item['order_status']=='confirmed' || $item['order_status']=='pending')
			{
				$items[$key]=oseObject::setValue($item,'order_status',JText::_(strtoupper($items[$key]['order_status'])));
			}
			if (isset($item['payment_method']))
			{
				$items[$key]=oseObject::setValue($item,'payment_method',JText::_(strtoupper($items[$key]['payment_method'])));
			}

			$globalConfig = oseRegistry::call('msc')->getConfig('global','obj');
			if(!empty($globalConfig->DateFormat))
			{
				$items[$key]= oseObject::setValue($item,'create_date',date($globalConfig->DateFormat,strtotime($item['create_date'])));
			}
		}

		$result = array();
		$result['total'] = $this->getTotal();
		$result['results'] = $items;
		return $result;
	}
Example #27
0
 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);
         }
     }
 }
Example #28
0
 function getMemberRestrictedContent($type = 'joomla', $content_type, $member_id, $rType = 'array')
 {
     $db = oseDB::instance();
     $member = oseRegistry::call('member');
     $member->instance($member_id);
     $mscs = $member->getAllOwnedMsc(false, 1, 'obj');
     // get restricted of status 1; Step 1 get the start date
     $mValues = array();
     $startDate = array();
     foreach ($mscs as $msc) {
         $startDate[$msc->msc_id] = $msc->start_date;
         $mValues[] = $msc->msc_id;
     }
     if (!empty($mValues)) {
         $mValues = '(' . implode(',', $mValues) . ')';
         $cquery = " (child.entry_id IN {$mValues} AND child.entry_type = 'msc') " . " OR " . " (child.entry_id = '{$member_id}' AND child.entry_type = 'member') ";
         $bquery = " (entry_id IN {$mValues} AND entry_type = 'msc') " . " OR " . " (entry_id = '{$member_id}' AND entry_type = 'member') ";
     } else {
         $cquery = " (child.entry_id = '{$member_id}' AND child.entry_type = 'member') ";
         $bquery = " (entry_id = '{$member_id}' AND entry_type = 'member') ";
     }
     $cWhere = array();
     $cWhere[] = $cquery;
     $cWhere[] = "child.type = '{$type}'";
     $cWhere[] = "child.content_type = '{$content_type}'";
     $cWhere[] = "child.status = '1'";
     $cWhere = oseDB::implodeWhere($cWhere);
     $pWhere = array();
     $pWhere[] = "parent.type = '{$type}'";
     $pWhere[] = "parent.content_type = '{$content_type}'";
     $pWhere[] = "parent.status = '1'";
     $pWhere = oseDB::implodeWhere($pWhere);
     $query = " SELECT parent.* FROM `{$this->table}` AS parent" . " WHERE parent.content_id NOT IN (" . " \t\tSELECT DISTINCT child.content_id " . " \t\tFROM `{$this->table}` AS child" . $cWhere . " )" . " AND " . str_replace('WHERE', '', $pWhere);
     $db->setQuery($query);
     //oseExit($db->_sql);
     $objs = oseDB::loadList($rType);
     // get restricted of status -1;
     $bWhere = array();
     $bWhere[] = $bquery;
     $bWhere[] = "type = '{$type}'";
     $bWhere[] = "content_type = '{$content_type}'";
     $bWhere[] = "status = '-1'";
     $bWhere = oseDB::implodeWhere($bWhere);
     $query = " SELECT DISTINCT content_id " . " FROM `{$this->table}` " . $bWhere;
     $db->setQuery($query);
     $banObj = oseDB::loadList($rType);
     if (empty($objs)) {
         $objs = array();
     }
     if (empty($banObj)) {
         $banObj = array();
     }
     // get restricted of sequential, status = 1
     $query = " SELECT DISTINCT child.content_id, child.entry_id, child.params " . " \tFROM `{$this->table}` AS child" . $cWhere;
     $db->setQuery($query);
     $sqeObjs = oseDB::loadList($rType);
     foreach ($sqeObjs as $key => $sqeObj) {
         $params = oseJson::decode(oseObject::getValue($sqeObj, 'params', '{}'));
         $timeLength = oseObject::getValue($params, 'time_length', false);
         if ($timeLength) {
             // provided that entry type is msc
             $total = strtotime("+{$timeLength}  week", strtotime($startDate[oseObject::getValue($sqeObj, 'entry_id')]));
             $cur = strtotime(oseHTML::getDateTime());
             //oseExit($timeLength);
             if ($cur > $total) {
                 unset($sqeObjs[$key]);
             }
         } else {
             unset($sqeObjs[$key]);
         }
     }
     $objs = array_merge($objs, $banObj, $sqeObjs);
     //oseExit(oseDB::loadList($rType));
     return $objs;
 }
Example #29
0
 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;
 }
Example #30
0
 function &getList()
 {
     $db = oseDB::instance();
     //oseRegistry::call('content')->getInstance('Msc')->getMemberRestrictedContent('joomla','menu','63');
     //oseExit($db->_sql);
     $search = JRequest::getString('search', null);
     $search = JString::strtolower($search);
     $msc_id = JRequest::getInt('msc_id', 0);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 20);
     $menutype = JRequest::getString('menutype', 'mainmenu');
     $where = array();
     //$where = array_merge($where,oseJSON::generateQueryWhere());
     // Added in V 4.4, menu access levels
     $where[] = 'm.menutype = ' . $db->Quote($menutype);
     $where[] = 'm.published != -2';
     if ($search) {
         $searchQuery = ' LOWER(m.name) LIKE ' . $db->Quote('%' . $search . '%') . ' OR LOWER(m.alias) LIKE ' . $db->Quote('%' . $search . '%');
         $where[] = $searchQuery;
     }
     //$access = oseMscJaccess::get_msc_aid(25);
     //Added in V 4.4, menu access levels
     // Generate where query
     $where = count($where) ? ' WHERE (' . implode(') AND (', $where) . ')' : '';
     $query = 'SELECT COUNT(*)' . ' FROM `#__menu` AS m' . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     $query = 'SELECT m.*,  com.name AS com_name' . ' FROM `#__menu` AS m' . ' LEFT JOIN `#__extensions` AS com ON com.extension_id = m.component_id' . $where . ' ORDER BY m.lft';
     $db->setQuery($query, $start, $limit);
     //oseExit($db->getQuery());
     $rows = oseDB::loadList('obj');
     /*
     $total = count($rows);
     
     // establish the hierarchy of the menu
     
     $children = array();
     
     // first pass - collect children
     
     
             if (!empty($rows))
             {
     	      	foreach ($rows as $v )
     	{
     		$pt = $v->parent_id;
     		
     		$list = @$children[$pt] ? $children[$pt] : array();
     
     		array_push( $list, $v );
     
     		$children[$pt] = $list;
     	}
     }
     
     // second pass - get an indent list of the items
     
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, max( 0, 99 ) );
     
     // eventually only pick out the searched items
     
     // slice out elements based on limits
     $list = array_slice( $list, $start, $limit );
     */
     $ordering = array();
     $lang = JFactory::getLanguage();
     // Preprocess the list of items to find ordering divisions.
     foreach ($rows as $item) {
         $ordering[$item->parent_id][] = $item->id;
         // item type text
         switch ($item->type) {
             case 'url':
                 $value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
                 break;
             case 'alias':
                 $value = JText::_('COM_MENUS_TYPE_ALIAS');
                 break;
             case 'separator':
                 $value = JText::_('COM_MENUS_TYPE_SEPARATOR');
                 break;
             case 'component':
             default:
                 // load language
                 $lang->load($item->com_name . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($item->com_name . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->com_name, null, false, false) || $lang->load($item->com_name . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($item->com_name . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->com_name, $lang->getDefault(), false, false);
                 if (!empty($item->com_name)) {
                     $value = JText::_($item->com_name);
                     $vars = null;
                     parse_str($item->link, $vars);
                     if (isset($vars['view'])) {
                         // Attempt to load the view xml file.
                         $file = JPATH_SITE . '/components/' . $item->com_name . '/views/' . $vars['view'] . '/metadata.xml';
                         if (JFile::exists($file) && ($xml = simplexml_load_file($file))) {
                             // Look for the first view node off of the root node.
                             if ($view = $xml->xpath('view[1]')) {
                                 if (!empty($view[0]['title'])) {
                                     $vars['layout'] = isset($vars['layout']) ? $vars['layout'] : 'default';
                                     // Attempt to load the layout xml file.
                                     // If Alternative Menu Item, get template folder for layout file
                                     if (strpos($vars['layout'], ':') > 0) {
                                         // Use template folder for layout file
                                         $temp = explode(':', $vars['layout']);
                                         $file = JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $item->com_name . '/' . $vars['view'] . '/' . $temp[1] . '.xml';
                                         // Load template language file
                                         $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE, null, false, false) || $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0], null, false, false) || $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0], $lang->getDefault(), false, false);
                                     } else {
                                         // Get XML file from component folder for standard layouts
                                         $file = JPATH_SITE . '/components/' . $item->com_name . '/views/' . $vars['view'] . '/tmpl/' . $vars['layout'] . '.xml';
                                     }
                                     if (JFile::exists($file) && ($xml = simplexml_load_file($file))) {
                                         // Look for the first view node off of the root node.
                                         if ($layout = $xml->xpath('layout[1]')) {
                                             if (!empty($layout[0]['title'])) {
                                                 $value .= ' » ' . JText::_(trim((string) $layout[0]['title']));
                                             }
                                         }
                                         if (!empty($layout[0]->message[0])) {
                                             $item->item_type_desc = JText::_(trim((string) $layout[0]->message[0]));
                                         }
                                     }
                                 }
                             }
                             unset($xml);
                         } else {
                             // Special case for absent views
                             $value .= ' » ' . JText::_($item->com_name . '_' . $vars['view'] . '_VIEW_DEFAULT_TITLE');
                         }
                     }
                 } else {
                     if (preg_match("/^index.php\\?option=([a-zA-Z\\-0-9_]*)/", $item->link, $result)) {
                         $value = JText::sprintf('COM_MENUS_TYPE_UNEXISTING', $result[1]);
                     } else {
                         $value = JText::_('COM_MENUS_TYPE_UNKNOWN');
                     }
                 }
                 break;
         }
         $item->item_type = $value;
     }
     foreach ($rows as $item) {
         $item->treename = str_repeat('<span class="gtr">|&mdash;</span>', $item->level - 1) . $item->title;
         $obj = oseRegistry::call('content')->getInstance('msc')->getItem('joomla', 'menu', $item->id, 'msc', $msc_id, null, 'obj');
         $controlled = empty($obj) ? 0 : $obj->status;
         if ($controlled == '1') {
             $item->controlled = JText::_('SHOW_TO_MEMBERS');
         } elseif ($controlled == '-1') {
             $item->controlled = JText::_('HIDE_TO_MEMBERS');
         } else {
             $item->controlled = JText::_('SHOW_TO_ALL');
         }
         $params = oseJson::decode(oseObject::getValue($obj, 'params', '{}'));
         if (!empty($params->time_length)) {
             $item->time_length = $params->time_length;
             $item->time_unit = $params->time_unit;
         }
     }
     $items = array_values($rows);
     $result = array();
     $result['total'] = $total;
     $result['results'] = $items;
     return $result;
 }