ECShop $user 对象
有时候我们是需要把ecshop跟我们现有的项目整合,比如典型的会员系统是我们自己的,网店是ECshop的,或者,我们需要在ucenter的用户跟ECSHOP的做关联,ECShop已经替我们很好的规划了这部分.
ecshop的程序中,有个对象:$user,它就是用来处理用户信息的,比如登陆,注册,还有就是用来和第三方管理通讯和共享资源的.
在user.php中,有一条$user->login($username,$password),这里的$user 是来自includes/init.php中的 $user = & init_users();
而inti_user函数又在lib_common.php中,他里面有一段非常经典的代码.
- include_once(ROOT_PATH . 'includes/modules/integrates/' . $GLOBALS['_CFG']['integrate_code'] . '.php');
- $cfg = unserialize($GLOBALS['_CFG']['integrate_config']);
- $cls = new $GLOBALS['_CFG']['integrate_code']($cfg);
默认情况下$GLOBALS['_CFG']['integrate_code'] 的值为:ecshop 这是在 /includes/lib_common.php 文件的 function load_config()函数中定义的:
- if (emptyempty($arr['integrate_code']))
- {
- $arr['integrate_code'] = 'ecshop'; // 默认的会员整合插件为 ecshop
- }//开源软件:phpfensi.com
默认情况下,调用的会员整合插件是ecshop.
那么这包含的文件就是:'includes/modules/integrates/ecshop.php',打开ecshop.php这个文件,你会发现它继承了'includes/modules/integrates/integrate.php'.
integrate.php里面有很多的方法:login()登陆,edit_user()编辑用户资料,add_user()注册用户.
使用各自系统整合时,就需要重写 integrate 基类,然后调用这个重写后的类.

