Location: PHPKode > projects > HikaShop > back/extensions/plg_user_hikashop/hikashop.php
<?php
/**
 * @package		HikaShop for Joomla!
 * @version		1.4.3
 * @author		hikashop.com
 * @copyright	(C) 2010 HIKARI SOFTWARE. All rights reserved.
 * @license		GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
<?php
jimport('joomla.plugin.plugin');
class plgUserHikashop extends JPlugin{
	function plgUserHikashop(&$subject, $config){
		parent::__construct($subject, $config);
		if(!isset($this->params)){
			$plugin =& JPluginHelper::getPlugin('user', 'hikashop');
			jimport('joomla.html.parameter');
			$this->params = new JParameter( $plugin->params );
		}
		$app =& JFactory::getApplication();
		$this->cart = $app->getUserState('com_hikashop.cart_id',0);
    }
    function onUserBeforeSave($user, $isnew, $new){
    	return $this->onBeforeStoreUser($user, $isnew);
	}
	function onUserAfterSave($user, $isnew, $success, $msg){
		return $this->onAfterStoreUser($user, $isnew, $success, $msg);
	}
	function onUserAfterDelete($user, $success, $msg){
		return $this->onAfterDeleteUser($user, $success, $msg);
	}
	function onUserLogin($user, $options){
		return $this->onLoginUser($user, $options);
	}
	function onBeforeStoreUser($user, $isnew){
		$this->oldUser = $user;
		return true;
	}
	function onAfterStoreUser($user, $isnew, $success, $msg){
		if($success===false) return false;
		if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
		$userClass = hikashop::get('class.user');
		$hikaUser = null;
		$hikaUser->user_email = trim(strip_tags($user['email']));
		$hikaUser->user_cms_id = (int)$user['id'];
		if(!empty($hikaUser->user_cms_id)){
			$hikaUser->user_id = $userClass->getID($hikaUser->user_cms_id,'cms');
		}
		if(empty($hikaUser->user_id) && !empty($hikaUser->user_email)){
			$hikaUser->user_id = $userClass->getID($hikaUser->user_email,'email');
		}
		if(!empty($hikaUser->user_id)){
			$userClass->save($hikaUser,true);
		}
		return true;
	}
	function onAfterDeleteUser($user, $success, $msg){
		if($success===false) return false;
		if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
		$userClass = hikashop::get('class.user');
		$user_id = $userClass->getID($user['email'],'email');
		if(!empty($user_id)){
			$userClass->delete($user_id);
		}
		return true;
	}
	function onLoginUser($user, $options){
		$app =& JFactory::getApplication();
		$cart = $app->getUserState('com_hikashop.cart_id',0);
		if(empty($cart) && !empty($this->cart)){
			$app->setUserState('com_hikashop.cart_id',$this->cart);
		}
	}
}
Return current item: HikaShop